+2
Completed

Backface Normals

William Lau 9 years ago updated by Freya Holmér (Developer) 9 years ago 7
Is there any easy way to get backface normals?

I was trying to do a Normal dot View Direction to detect backface for shading, but right now it seems double sided shader normal node gives the flipped normal for backfaces, hence impossible to detect backface using this method.

The only alternative I have right now, is to Cross Product the Tangent and Binomial to get the correct frontface normal vector.

Answer

Answer
Completed
This has now been fixed in 1.18. No more artifacts + this node :)

+1
The problem with using Tangent Cross Binomial is that it is less accurate and it doesn't work for spheres or rounded objects.
Thank you very much for this wonderful asset Mr. Holmér, this makes it so easy to create beautiful shaders. This is a problem I've been experiencing too though. I'm making a lit atmosphere shader to add realism to my procedural planets, and it would really reduce rendering costs to use one mesh, with the backfaced polys lit the same way as the front facing ones. I figured it would be simple with normalizing the vertex/pixel offset from the center, but I can't seam to get this working either. A node that outputs 1 if front, and 0 if backfacing would be perfect, or if you could suggest another way to do this.
I managed to solve this by taking the standard dot of the view and the normal * Vector3(0,0,1). It would still be a useful feature to have a common node to detect backfacing.
Under review
Glad you find it useful, and glad you found a solution for now! And yes, there really should be a face-sign node, but right now I'm a bit swamped in other work I'm afraid
I would find this useful too.
Making a shader to cull walls in front of a player and can't detect the backface even with the above workaround.

Rad work btw, keep it up
Thanks!
And it might be possible to get the desired effect using two shaders rather than one :)
Answer
Completed
This has now been fixed in 1.18. No more artifacts + this node :)