- Home /
Render inside of mesh as black
Hello! I'm garbage with shader coding, but I want to make it so that, for all objects in the scene, whenever the camera renders the insides of them (ergo, clips into them), it fills that empty space with black. How would I achieve this effect? Changing the backfaces to just render black does not work, because if any object is passing through that object, it will still be rendered inside of it (ie: The long box passing through the image on the left).
Answer by Dray · Jan 18, 2018 at 08:51 AM
You could render an inverted version of the mesh completely black and unlit or disable backface culling and use a custom shader to make every face black that is viewed from the back, with the help of its normals most likely. It's possible that your performance suffers a bit from that
This'd have to be applied to every object being rendered, and I also have no idea how to do literally anything you just said.
Only to every object you are able to look into in your game to be precise but yes, that's true. If it differs from the default, you have to implement it.
Now I can't write that full shader for you but I can tell you, you can probably achieve what you want with a single custom shader. Look for some HLSL tutorials, you'll need to spend some time with it but it's doable and worth the little effort.
Within the shader I imagine you'll have to turn Backface Culling off (Backface culling makes polygons only be rendered if you are looking at the front of them) and then, whenever you look at the back of a polygon, just output straight black, without considering lightning or anything.
The Shader Resource in the unity docs is probably a good point to start at ;)
I think you misunderstand, I do not want to render the literal inward-sides of the mesh, I want all the "empty space" in the object to be rendered as solid black.
Your answer
Follow this Question
Related Questions
How to acheive wireframe effect with dots? 0 Answers
Fill in mesh? 2 Answers
Get distance to camera from CameraDepthTexture 1 Answer
Rendering different shader when camera get near object 1 Answer