9
$\begingroup$

I'm working on a cycles shader that requires thickness information, and by that I mean interaction between the mesh with the shader itself and other objects inside it, in a way that as closer a diffuse surface is to the mesh with the shader, the more transparent it is. This is an example of the wanted behaviour: enter image description here Ignoring the normal map on the surface, as you can see, the closer the white ball is to the blue pillar, the black it is. This image is using Lightwave's thickness node. If one could input it in a Blender Mix Shader factor, it could control transparent/diffuse values on the surface.

Blender apparently doesn't have a proper thickness node, but it has Light Paths... I took a look at light absorption shaders, but those use a B&W MixRGB directly into the color of a Glass shader, I couldn't make it work using as a factor for a Mix shader. Also the fact that we're using transparency instead of glass can be a problem.

Basically this is the situation visualized:

enter image description here The ray from the camera hits the MixShader Transparent/Diffuse surface, it then travels a certain Depth(D) before it hits another Diffuse Surface, then bounces back through the Mix surface and to the light source. If the Depth travelled is equal or greater than D, the surface is 100% diffuse, otherwise it is a blend until D=0 where transparency is 100%.

Fortunately we have a Transparent Depth Light Path node that can be used, but I'm not knowledgeable enough to understand the math behind it. If you feed Transparency Depth directly into a Mix Shader, the result is almost good, except it is inverted (greater distance = more transparent), and it doesn't work if you flip the shaders on the Mix Shader, or if you multiply it by -1: enter image description here The left object kinda works (but inverted), the right object doesn't but firstly I'd be glad if even the left worked rightly.

So, is there someone with any idea how to make a thickness node on blender? This is the file if anyone is interested:

Regards

$\endgroup$
7
  • 2
    $\begingroup$ I wish I had an answer for you, but just do you know, I'm pretty sure the Transparent Depth input is an integer. It counts the number of transparent shaders the light passes through. The apparent success that was obtained though the nodes is an illusion based on lighting. docs.blender.org/manual/en/dev/render/cycles/nodes/types/input/… $\endgroup$
    – bertmoog
    Commented Jul 13, 2017 at 4:00
  • $\begingroup$ All the light paths are booleans? Anyway, if you look at the absorption node setup, it appears to be possible to have gradients using outputs from the light path node... $\endgroup$
    – Arkhangels
    Commented Jul 13, 2017 at 19:06
  • $\begingroup$ Did you look at the manual? The reason for the gradients that you're seeing is caused by the lighting setup. Once a light ray passes through the transparency, the factor is set to 1 so the next time it strikes the material, it's reflected as diffuse. Anything beyond the first pass through the transparency get the diffuse shader. $\endgroup$
    – bertmoog
    Commented Jul 13, 2017 at 19:15
  • $\begingroup$ Thanks for the explanation! Now it makes sense the results on that last image, why we see the back of the "Blob" as diffuse... And yes I did look at the manual some time ago... Ray Lenght apparently can output floats, and some of the other ones can output integers greater than 1.... maybe that's why those Absorption nodes gives gradients, as they use Ray Length along with Is Camera Ray. $\endgroup$
    – Arkhangels
    Commented Jul 13, 2017 at 21:00
  • 1
    $\begingroup$ Unfortunately I don't think this is possible with pure material nodes at the moment. The ray between the diffuse object and the surface is calculated after the ray between the camera and the surface. If we use its length to adjust the opacity of the surface, it will only affect the surface that the diffuse object "sees". There might be a way to accomplish this with OSL or some compositing tricks, however. $\endgroup$
    – gandalf3
    Commented Jul 14, 2017 at 1:34

3 Answers 3

3
$\begingroup$

Volume shaders should provide the desired result.

enter image description here


1) Create a solid geometry for the volume. Make sure the volume does not touch anything on the interior. In this case, the blob on the cylinder had a Boolean added to remove the interior, then the original cylinder was hidden. A slight smaller copy of the cylinder was used in the rendering.

enter image description here enter image description here

2) Use a combination of the surface shaders and volume shaders for the material. The surface shaders should be mostly transparent so the volume effects are apparent.

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ Cool! But this is kind of a problem, because even though it gives transparency at the edges, you lose definition at the opaque areas with the surface shader right... like you said, you have to have the entire thing almost 100% transparent to see the effect, therefore the opaque areas also lose definition. Would be cool to be able to output the density as factor at a mix shader. $\endgroup$
    – Arkhangels
    Commented Jul 13, 2017 at 19:09
  • $\begingroup$ I have a question that I feel is a bit relevant to the discussions here. I wonder could you please take a look at my question here? I basically want to render depth maps or surface Normals by somehow ignoring the transparent materials. Do you think that's possible? $\endgroup$
    – Amir
    Commented Feb 25, 2018 at 0:47
2
$\begingroup$

Well, after looking at this question for a related issue: Weight Paint in Cycles Nodes

It gave me the idea of using the Proximity value of Dynamic Paint to emulate thickness and since it outputs to Vertex Paint colors, one can use it in an Attribute node as factor for a Mix Shader. The object inside must be a brush, the object with the shader must be a canvas, and this is the result: enter image description here Pros and cons:

-Pro: Easy to set up and use... independent from nodes, but can be integrated by multiplying/adding textures to the Col Attribute before feeding it into the Mix Shader.

-Pro: You can easily control the "thickness" intensity using the Point Distance factor of the Brush object.

-Pro/Con: All objects that you want to be factored into the thickness must be Brushes... but this gives you control over what you want to have influence without having to mess with nodes or Cycles Visibility options for the objects.

-Con: You need dense geometry for better results.. Even simple flat faces need subdivisions for fine thickness control.

-Con: Unfortunately you can't use this method for SELF-thickness evaluation, only for relative distance/thickness of secondary objects in relation to the surface of the primary object.

Using as a factor for Mix Transparent/Diffuse Shader, we get the expected result:

enter image description here

But I'm not going to select my own answer as the correct because it doesn't use nodes and light path nodes to calculate true thickness of the mesh, therefore someone may some day find a proper answer and post here. Regards!

$\endgroup$
2
  • 1
    $\begingroup$ I prefer this answer to the other one even though it has faults. This actually addresses the fundamentals of the original question. $\endgroup$
    – bertmoog
    Commented Jul 17, 2017 at 23:16
  • $\begingroup$ @Arkhangels I have a question that I feel is a bit relevant to the discussions here. I wonder could you please take a look at my question here? I basically want to render depth maps or surface Normals by somehow ignoring the transparent materials. Do you think that's possible? $\endgroup$
    – Amir
    Commented Feb 25, 2018 at 0:48
2
$\begingroup$

You can use OSL for this. For example this - https://github.com/IPv6/kristallum/blob/master/blender/osl/osl_detRaycast_v07.osl

It will give you distance to next face in the direction you set in inputs, with different options. This will limit you to CPU rendering, but will do the job

$\endgroup$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .