- Home /
Can a shader render darkness inside a mesh?
Probably not, but I'm wondering if there is a way to render a solid color (like black) if the camera is looking 'inside' a mesh. I mean, I know that the normals are used to cull and what not. But hang on. Like, if you have a sphere, and you move the camera just inside it, you'll see a 'hole', and if rendering backfaces, or 2-sided triangles, you see the other side of inside the sphere. But can something be done to render a solid color instead? Would a picture help?
Answer by AlkisFortuneFish · Feb 07, 2014 at 12:29 AM
Yes. Basically, you want to add a second rendering pass, rendering the back faces black. Adding this pass to your shader would work:
Pass { Cull Front Color (0,0,0,1) }
Have a look at the Debugging Normals example here.
Answer by nesis · Feb 07, 2014 at 12:17 AM
You can render backfaces, yes. I'm pretty sure I've seen an example of what you're talking about where backfaces were rendered unlit red.