- Home /
How can I make backfaces render the skybox through geometry?
I have been trying for a little over 2 hours to figure this out with resources on the internet, but I have not found any solutions, I am trying to make the backs of faces make a hole through geometry to the skybox in a multi-pass surface shader (not using a seperate mesh for the backfaces with a seperate material). I have been using a method similar to the one found here , but that does not work with a surface shader, or makes the front faces still appear through it. I would appreciate any help. If the specific shader is needed, I can provide it.
Answer by kritoa · Jun 09, 2017 at 05:53 AM
There may be a better way to do it, but if I had to do this today, I'd turn off backface culling, make my shader test the surface normal and look vector, and if we're looking at the backside of a piece of geometry, don't run the regular surface shader, but just look up the skybox texture instead...
Here's a shader that does a simple unlit constant shader on the back facing geometry: http://www.alanzucconi.com/2016/10/02/3d-printer-shader-effect-part-2/
and somewhere in here is how to write a shader that looks up the skybox: https://en.m.wikibooks.org/wiki/GLSL_Programming/Unity/Skyboxes
So this wouldn't really be the same as actually cutting holes through geometry, but instead painting skybox on top of far geometry, but it should be indistinguishable.
It doesn't look like the code on the website is compatible with regular shader code, since it is written in glsl. Does anyone know if it's possible to get the skybox color using shaderlab?