Search Unity

Question Need some help with one tricky effect

Discussion in 'Shaders' started by DuvE, Mar 20, 2024.

  1. DuvE

    DuvE

    Joined:
    May 22, 2016
    Posts:
    169
    Hi,

    I want to make a Local Depth-based effects. Imagine something like a mini rocket barrage using a Spot Light Depth Buffer (The one used for Shadow rendering). In the Visual Effects Graph, the spawned particle will pick a random UV position, get the World Space of that point from the Local Depth Map, and just lerp the position from the VFX center to that location.

    The problem is I'm not very experienced with advanced stuff like this, so I have some questions:

    - What is the best and fastest approach to render a local depth map, just like a shadow depth map from a spotlight?

    - In the VFX Graph I will need to reconstruct World Pos from Depth, so I need to pass some matrices, right? Like inverse-projection and inverse-view ones. I'm planning to use 3 different projections, Orthographic, Perspective, and Spherical.

    - Will it be more expensive to use a zero-intensity spotlight and its matrices and depth info, instead of recreating the whole thing?