Digital Art Zone

 
     
Help making backface culling shader when using partially transparent textures
Posted: 14 May 2013 02:48 AM   [ Ignore ]
Member
Rank
Total Posts:  59
Joined  2013-05-11

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?

Image Attachments
backface_shader.jpg
Profile
 
 
Posted: 14 May 2013 02:51 AM   [ Ignore ]   [ # 1 ]
Member
Rank
Total Posts:  59
Joined  2013-05-11

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

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

Profile
 
 
Posted: 14 May 2013 05:49 AM   [ Ignore ]   [ # 2 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  14256
Joined  2003-10-09

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.

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile