Cycles - Invert normals in shader nodes?

Hi

Is there any way to invert the object normals using cycles shader nodes.

I have tried playing with the geometry input node node normal input - played with vector math etc, but nothing seems to work - so i’m not sure it’s possible. Does anyone know?

Thanks

Hi, can you try these options

  • Add a Geometry Node: Use the Normal output.
  • Add a Vector Math Node: Set it to Multiply and input -1 to invert the normals.
  • Connect the result to the Normal input of your shader (e.g., Principled BSDF).

I hope this will help you and resolve your problem…

I already tried that, it doesn’t work - the output just goes black. The object on the right is how I expect it to look (manually inverted normals on the sphere).

The Glass shader has some internal checks about its normals, that don’t work quite as you expect.

The trick part in your setup is not to change the normals, but to change the IOR to its inverse (1/1.5).

4 Likes

Yes I know that trick, I was just looking for other ways of achieving the same thing. Cheers.

What i’m trying to do is use the ray depth node to automatically change the IOR of the material during each penetration of a surface in order to try and achieve pseudo nested dielectric effect.

Not sure if i’m barking up the wrong tree though

I understood what you’re after… And I’ve also looked into other ways to implement nested dielectrics in shaders.
But it’s really very difficult to implement.
I even tried to do it in OSL using messaging between shaders, but unfortunately that only works for shaders in the nodetree, and for each object alone.

This would be easier, if we could store custom information in rays, like: "After a refraction, the new ray now carries ‘my last shift in IOR was from 1.004 to 1.5’, or something.

Without this possibility, we can only wait that nested dielectrics are implemented in source.

I also wrote an OSL script that would trace the incoming rays back, to see where they where originated, but we cannot ‘shade’ a traced ray, so I needed to put the other refractive objects in some kind of list.

1 Like

Hello,
Maybe a way to explore …

I would be interested if you could share the rest of your experience, thank you.

It’s an interesting problem. Could you share more context? So adjusting the IOR based on ray depth doesn’t work?

No. Because the IOR is a relation between the light velocity from outer media to inner media.
And ray depth cannot store that, and it’s meaningless in this case.
You’d need the relative IOR from both media to correctly set the Shader, but one of the variables is missing (and it’s normally assumed its the light speed in vacuum).

Hello,

Unfortunately, my suggestion does not provide a solution.



For some unknown (for me) reason, in this configuration, with the mixing of the “Glass BSDF” nodes, there is indeed a “Color” exchange but a strange combination of “IOR”.

See you

Hi,

Yes, after testing these “Shaders” (Glass, Principled and Refraction), I think you can even say that this warning can be extended to all “Shaders” with refraction/transmission.

Glass BSDF shader looks different than Refraction BSDF mixed with Glossy BSDF with Fresnel so there must be something happening inside the glass with Glass BSDF. I have always suspected that internal reflections are calculated somehow with Glass BSDF but not with Refraction BSDF mixed with Glossy. Maybe that has something to do with this. It would be interesting to understand what really is happening here.

Yeah, I could… but this is just a flaw (not an error) in the render logic, for optimizing other more common situations (rayhit-BVHTree vs shading-SVM). It may be replaced by some other better algorythm, in a near future; but for now, it’s what we got.
The same goes for nested dielectrics… and it’s in the plan list for Cycles. So this flaw may change–be gone in a near future.

I have never found that (at least not for colourless glass - see below). This image has one sphere with the straight glass shader - and the other is a mix of glossy and refraction - with a Fresnel node driving the mix.

As long as you set the IOR value of the Fresnel and refraction nodes to be the same value as the IOR on the glass shader - I can’t see any difference.

Where it does make a difference is in coloured glass - particularly the reflections.

I tend to prefer the refraction/glossy mix since if you use the straight glass shader and give it a strong colour, the reflections are also coloured (like conductive/metallic materials), which is not physically accurate. The refractive element however looks identical.

Your test scene has very little to refract. But I played with it quite a bit a long time ago and noticed a difference. Maybe it has changed since then and I just missed something when quickly testing it now. There is something mysterious about Glass shader… :smiley: Testing now. Maybe I spoke too soon and it is like you say now.

I think I was answering some question on Blender Stack Exchange or here about how to be able to composite glass on top of changing background and change refractions using UV map coordinates of the background turned to color behind it and Map UV node in the compositor and I could not separate reflections just right.

Yeah, you are right. It seems to look the same now even with a more refracting scene:

I was wrong. Am I going crazy? :smiley: Maybe. I must have missed something.

One thing that is easy to miss (I have done it myself) is making the Fresnel node and Refraction node IORs the same. If these are different - you do get some weird results.

Hi,
I agree with @Moony’s answer.

To overcome a distortion of the HDRI, I made both positions (at the top, the “Glass BSDF” is on the right, at the bottom the “Glass BSDF” is on the left).


With “Volume Absorption” :


And in addition to what @Moony said, be careful with the distribution of microfacets you use, “Refraction BSDF” only has “Beckmann” or “GGX” (for my tests I only used GGX for everything).

Hi,
Thanks for your answer.

This is not a criticism, just an observation.
A limitation that can be taken into account, so it is better to use the inversion of normals or the inversion of the IOR in two assigned materials (and not a mixture “inside” the “Glass BSDF”).

Good news, for the upcoming changes !