Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Post processing projector shader

Discussion in 'Shaders' started by fujivio, Dec 20, 2020.

  1. fujivio

    fujivio

    Joined:
    Dec 10, 2020
    Posts:
    4
    I need to implement displaying of fog of war. I have a square texture with black and white areas (white represent areas the player sees).
    At first I tried to make the fog of war using projectors, but this method turned out to be too poor in terms of performance, as objects are rendered twice. Then, I got the idea to make a shader, in which the standard textures for each object + fog texture are passed (but uv for fog is calculated based on the value of unity_ObjectToWorld). The method is quite working and fast, but it sounds kind of strange, since you need to use this shader for each game object and pass fog texture to every material.
    Finally, I thought of using a post processing shader for this, but I just can't actually write this shader. I need the texture that is passed to the material that the Blit script (URP) uses to render the post-processing effect to be displayed on top of all objects in the scene.
    Can anyone help with this?

    Also, it would be very cool if someone could tell me how to blur this texture in the shader (so that I don't have to generate a very large fog texture)
     
  2. fujivio

    fujivio

    Joined:
    Dec 10, 2020
    Posts:
    4
    Made it possible to map a texture to all objects in the scene using a shader. The material with this shader is applied to the quad in front of the camera:
    upload_2020-12-23_11-52-56.png
    Works good and mush faster than projector, but I ran into the problem that the texture is also overlaid on the sky. Is it possible to limit the result of the nodes of this graph?
    upload_2020-12-23_11-56-10.png