Help making backface culling shader when using partially transparent textures

edited May 2013 in New Users

Here's a simple shader I'm trying to use to make it so you can use a texture that has some parts transparent but which doesn't render the polygons on the other side of the model. This way the transparency in the front doesn't show anything on the back.

I think I'm pretty close but it's not quite giving the result I need. The way I have it:

1 - "calculate normal" is dotted with itself

2 - if it's positive, output 1. otherwise output 0. this makes backface polygons have 0 values and forward facing polygons have 1 values

3 - this is multiplied with the opacity of the texture

The attached screenshot shows what I have. The problem is it's not culling anything in the render. This is confusing because it seems like it should work since if I flip the function of the compare brick from greater than to less than, the preview for that brick turns from white to black, so I'm not sure what the problem is.

Is there something obvious I'm doing wrong? Is 'calculate normal' the right place to start with this?

backface_shader.jpg
1925 x 1050 - 205K
Post edited by whitefrozenturkey on

Comments

  • edited December 1969

    Here's the daz file I'm using for this

    http://lucidology.com/upload/backface.daz

  • Richard HaseltineRichard Haseltine Posts: 101,010
    edited May 2013

    A unit vector dotted with itself will always be one - to check the facing of a polygon you need to get the vector to or from the camera (I or V from a Variable brick as I recall), normalise that to make it into a unit vector, and take the dot product of that and the surface normal. Note, however, that this will only go part way to what you want - if there's internal geometry, such as the mouth on a human, that faces the camera that will still show.

    Post edited by Richard Haseltine on
Sign In or Register to comment.