- Home /
Layer Dependent Reflections
Hello!
I can't seem to find any answers on this seemingly simple problem.
Briefly, I would like environment reflections (like what a reflection probe does) per layer.
But maybe if I explain what my scene is like a little, you can guide me to perhaps a better solution. I have a room that consists of two meshes: one for the outside and one for the inside. I would like the surrounding area to be reflected on the outside of the room but not the inside. I am using Deferred Shading and screen space reflections as well. Reflection probes are the easiest, but I can't get them to not apply to the inside mesh. It is also possible that I would like a different reflection to be applied to the inside mesh.
The closest I've gotten is to render a camera into a cubemap of the surrounding environment, and use a custom shader to apply the reflections using the normal map to the emission output of the shader; however, the problem I had with that is decreasing the smoothness on the shader didn't blur the reflection like Unity does with environment reflections (as this doesn't register as a reflection and a texture in the end). I can't seem to find a way to blur the texture to make it look like it's "semi-smooth" either.
Answer by Namey5 · Aug 08, 2019 at 09:18 AM
You should be able to use 2 different probes for this exact purpose - have one main probe on the outside of the building that covers a large area, and one on the inside of the building that just covers the interior. Unity should automatically blend between them (if the exterior one is overriding the interior, you can increase the importance of the interior probe).
As for blurred cubemap reflections, you can use the same technique that the probes do. Make sure that your cubemap generates mipmaps, then in your shader;
//Instead of
texCUBE (_Cube, refl);
//Use
texCUBElod (_Cube, float4 (refl, (1.0 - smoothness) * 8.0));
Thank you, this helped a bit, I didn't even think to use two probes. This works exactly as you said it would. I've attached a picture of what I'm working on since it makes this a little more challenging, I think. The exterior is cylinder-shaped so defining the interior is a bit odd using the reflection probes box properties and It won't include all of the interior mesh (which will be round as well). I would prefer the inside to be cylinder-shaped as well, but if it's not possible, it's not possible. I haven't tried the shader code yet, do you think that would be probably the next step to try, to avoid the box inclusion issue of the probes?
Edit: I modified my ASE shader to use the texCUBElod ability, and it worked like a charm. I think I'll use that option as it is less I have to do in the scene (no reflection probes at all) and I can just choose what materials use the reflections of the cube map or not. The result from that looks like this: You can see the reflections of the planet (script on camera rendering to cubemap, set global so any shader can use the reflection if necessary) and the screen space reflections. The cube inside is using the same shader with the reflections turned off and keeps the SSRR. Again, thank you for your help!
Your answer
Follow this Question
Related Questions
Subtractive Rendering? 4 Answers
Skybox reflections stopped working. 0 Answers
Unity iOS Rendering Standard shader issue 0 Answers
Layering Transparent Objects 0 Answers