# Shader that is only visible when the face normal points up

I'd like to create a shader that is completely transparent except for top faces that are parallel to the floor (face normals being parallel to the global Z axis). Used on a cube, only the top face would be visible. I don't intend to rotate the object, so local and global Z are identical. But the shader should not care for the camera position.

After Brenticus' great answer I came up with this solution: it shows only faces that are reasonably parallel to the floor and face towards the camera:

While Suzie is truncated above and below, only the upper plane is visible. Switching the southern math node to 'greater than' would show only the bottom plane.

• I wouldn't be surprised if there wasn't a duplicate lying around somewhere, I just didn't find the right search words. Jan 10 '18 at 2:12
• Small thing: top and bottom faces both have normals parallel to z axis. Top face is same direction as z axis. Related Jan 10 '18 at 2:27
• Might be able to do this with geometry node to separate xyz to color ramp with constant interpolation off the top of my head. Jan 10 '18 at 2:39
• @batfinger from the same geometry node, the Backfacing output can be used to distinguish between upper and lower parts. Jan 12 '18 at 17:40

## 1 Answer

As mentioned in the comments on your question, this can be achieved using the Geometry Node and the Separate XYZ Node. Using the Z output will give you a range of black and white values based on how much the normal of the face is pointing along the Z axis. A ColorRamp node could be used to isolate the parts of the mesh that are pointing straight up (completely white) but the math node works a bit better in this case. I used the Greater Than operation and connected the Z output to the top, and put a number just below 1 in the bottom input. Note that a number like 0.99999 will be displayed as 1, but not treated as such. This will then isolate the parts of the mesh that are pointing straight up or down, and the output can be used as the factor for a mix node.

Here's a quick scene showing my setup on an object:

• While I want the opposite effect ( everything transparent but the level surfaces) it's the perfect answer. Thanks Jan 10 '18 at 3:44
• I will read the question more carefully next time :) Jan 10 '18 at 4:04