Search Unity

capturing shadow map

Discussion in 'General Graphics' started by jctz, Sep 16, 2015.

  1. jctz

    jctz

    Joined:
    Aug 14, 2013
    Posts:
    47
    Hi guys,

    We would like to reduce the cost of dynamic shadows in our game, in terms of the extra draw calls. Our game has dynamically-generated levels so lightmapping isn't an option for us. We do, however, have the luxury of:

    1) all our shadows are from a single directional light
    2) our shadow-casting d-light never changes intensity or facing
    3) 99% of our props cast shadows all the time. We also have doors that cast shadows. They start out closed but once they're opened, they stay open and we can remove shadow casting from them forever.

    To reduce the # of draw calls needed for dynamic shadows, is there any way we can capture the shadow map during one render, and then use that for the rest of the game?

    For this to work:
    1) render one frame with some sort of replaced shadow-casting shader
    2) save that texture into a global texture that can be referenced in any other shader
    3) shaders for any shadow receiver will sample that map manually

    Does this sound remotely feasible?
     
  2. Zuntatos

    Zuntatos

    Joined:
    Nov 18, 2012
    Posts:
    612
    It is completely feasible. I got exactly this working for point lights @ my thread , but no directional light support yet.
     
  3. jctz

    jctz

    Joined:
    Aug 14, 2013
    Posts:
    47
    Thanks Zuntatos! And here I was, thinking I was SOOOO smart...sigh.
     
  4. jctz

    jctz

    Joined:
    Aug 14, 2013
    Posts:
    47
    Uh-oh, this requires shader model 3.0 doesn't it?
     
  5. Zuntatos

    Zuntatos

    Joined:
    Nov 18, 2012
    Posts:
    612
    It does. Maybe it's able to be changed to shader model 2.0 - didn't try it since nearly all gpu's are SM 3.0+ by now