#What would be sensitive approach for fading object near camera in Built-in render pipeline.

1 messages · Page 1 of 1 (latest)

light solstice
#

I've some idea of how to proceed, but they all have some issues. At the moment, I'm looking into https://docs.unity3d.com/Manual/SL-ShaderReplacement.html with a two camera setup.

Ideally, I would like to have the materials be renderer as is and then modify the resulting color to add the transparence. Maybe I could draw all near object into a texture (1 per object), then reuse those texture to redraw with an other shader that would sample those texture. However, doing that seem to be really intensive computationally.

warped lion
#

For fading objects when they're close to the camera in Unity, you can refine the shaders and add a camera script, like this:
Modify your object shaders to increase transparency based on how close they are to the camera. This involves calculating the distance in the vertex shader and using it to adjust transparency in the fragment shader.
Attach a script to your camera that detects when objects are near. This script can then use shader keywords to switch materials between transparent and non-transparent states as needed.

Note that trying to render each object to its own texture and then applying transparency can be pretty heavy on performance, especially with lots of objects. Using shader modifications and keywords to toggle transparency should yield better results

light solstice
warped lion
#

If it's just a keyword, you can likely use the same shader just separate the transparency variation with a keyword and set the correct material settings. You could also make all objects support transparency but that will likely have a big performance impact. Another idea that may or may not work depending on your exact case would be to use dithering instead of transparency and that would essentially mitigate the cost of transparency.