Backface culling
Hello, I need to render my model with backface culling enabled. Do you think it's doable using a camera shader? I tried but I'm a newbie and I failed.
Firstly, I don't know how to get an "eye" vector, so that I can compare it's angle with the surface normal. I guess it should be one of the values of the "variable" block? Are the values of the block documented somewhere? I tried connecting the V value to the shader, but once I do that I'm not able to connect the imager block anymore.
Secondly, I'm not sure how to actually form the output. Am I supposed to bend the opacity input of the imager block somehow, to hide the pixel? The opacity input is a color and I don't really know what color am I supposed to send there. I tried sending random color values to the input and it didn't seem to have any effect on the rendered image. Same with the alpha input.
Any hints would be greatly appreciated.
Comments
what are you trying to render? I'm asking because you may not need to use this technique in Studio for the desired result.
Basically I need to render separate body parts and then assemble the resulting images. For that I need to render just the visible part of each of the body parts.
But since DAZ Studio renders the backfaces, if I render for example just the right arm, I will get a black hollow part at the end - see the attachment.
There was a thread on getting a different set of properties on front and back of a surface that covered this. V and I, as I recall, are the camera vectors though one goes one way and the other the other. N gives you the normal. So take the cross product with a Binary Operation brick and test it for > 0 to switch between properties.
Thanks. I think I understand the principle, but I'm clueless when it comes to the actual shader blocks. Should I use the Imager block or the Surface block for the camera shader? According to documentation, when the Surface block is used in the camera shader, "the values are applied in a “global” context, that is to say that it is applied to any surface that does not specify its own shade". That sounds like what I need. However, whenever I use the Surface block in a camera shader, I get "Error during rendering!" while rendering and I need to restart DS.
Also I'm not sure I understand the difference between "Variable [fixed]" and "Variable [root context]". Ideally, I suppose, I should use the Surface root and Variable [root context] to get the fresh camera vector/surface normal. But I'm hitting the "error during rendering" problem, which I don't quite understand.
EDIT: Found the thread! Awesome, thanks a lot. Now, if only I was able to do this globally, without changing individual materials.