Search Unity

Accessing light data (including shadow texture) from compute shader?

Discussion in 'Image Effects' started by Alex_curiscope, Jul 23, 2017.

  1. Alex_curiscope

    Alex_curiscope

    Joined:
    Apr 4, 2017
    Posts:
    55
    Hey all.

    I want to implement volumetric lighting and advisories in an image effect and i'm thinking about using compute shaders to help with that (like they did in assassin's creed 4 on current gen).

    I have done a quick search around but nothing jumps out at me. I think I'll need access to each light's shadow depth texture so I can calculate if a point in space is in shadow or not.

    These are my first compute shaders so I'm not familiar with how to pass data around to and from them.

    Also are these light data stored on the gpu? If not, then I guess I can just send them to the compute shader from the cpu provided I can access them from the api...
     
  2. snaildex

    snaildex

    Joined:
    May 24, 2015
    Posts:
    1
    You can sample shadowmaps in regular material shaders, however you can't get shadowmaps from lights in scripts, so you can't assign them to any other shaders. Light data assigned to uniforms. Most organic way to deal with it is to use deferred pipeline and modify standart lighting pass shader with volumetric calculations.