Announcement

Collapse
No announcement yet.

Last of Us style indirect shadows

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • started a topic Last of Us style indirect shadows

    Last of Us style indirect shadows

    As an experiment I tried to recreate the awesome indirect shadow system of the Last of Us:



    This is based on this talk.

    Still far from a complete implementation, but the basics are there.

  • replied
    Here is a texture to try that has channel packed light source angle.

    R=5degrees
    G=15degrees
    B=30degrees

    A=60degrees

    Click image for larger version

Name:	rgba_5-15-30-60.jpg
Views:	1
Size:	9.1 KB
ID:	1079427

    Click image for larger version

Name:	rgba_A-60.jpg
Views:	1
Size:	6.8 KB
ID:	1079428

    *edit* fixed curve mapping, it was slightly wrong before.
    Last edited by RyanB; 06-05-2015, 03:59 AM.

    Leave a comment:


  • replied
    Hey guys, if anybody is curious to mess with this I made a material that can be used to render out the soft shadow lookup textures that are similar to the last of us paper (although not exactly).

    The core of the math is in this custom node with inputs d, r0, r1:

    Code:
    float div1=cos(d)-(cos(r0)*cos(r1));
    div1/=sin(r0)*sin(r1);
    
    float div2=((-1)*cos(r1))+(cos(d)*cos(r0));
    div2/=sin(d)*sin(r0);
    
    float div3=((-1)*cos(r0))+(cos(d)*cos(r1));
    div3/=sin(d)*sin(r1);
    
    float term=(2*PI)-(2*PI*cos(r0));
    term-=2*PI*cos(r1);
    term-=2*acos(div1);
    term+=2*cos(r0)*acos(div2);
    term+=2*cos(r1)*acos(div3);
    
    
    
    return term;
    The material graph:

    Click image for larger version

Name:	SoftShadowMap_Mat_01.JPG
Views:	1
Size:	145.4 KB
ID:	1079429

    Click image for larger version

Name:	SoftShadowMap_Mat_02.JPG
Views:	1
Size:	75.1 KB
ID:	1079430


    Notice that the only modifiable variable still hooked up is the light cone angle. So you render multiple textures with various light cone angles and channel pack them and lerp between them to adjust the penumbra in realtime.

    All cosine nodes have a period of 2pi so that they work the same as the custom one ones. Also notice all the starting degrees get converted to radians which makes it easier. And the UVs need to be given sphere like curvature which is why there is cosine on the UVs.

    https://www.cse.ust.hk/~psander/docs/aperture.pdf
    Attached Files
    Last edited by RyanB; 06-05-2015, 04:11 AM.

    Leave a comment:


  • replied
    Properly implementing this got a bit bigger then I initially thought so to be honest I haven't really been able to work on this much further. Additionally I noticed some work on surfel-based shadowing in the main source github, which might solve a similar issue, so I kind of focused on other things.

    I'll see if I can clean up the prototype and post the source here if someone else would like to attempt to create something more useful with it.

    @RyanB: The images posted here used the lookup texture from the Naughty Dog presentation as I wanted to get the basics working first. My plan was to make a simple maxscript to automate the baking. Shouldn't be to hard as you can basically bake a small coverage texture per pixel and store the average.

    Leave a comment:


  • replied
    Yeah, good work!
    Uncharted 4 is using the indirect shadow system from TLOU and I guess also the next AAA games will use it.

    Click image for larger version

Name:	unch.jpg
Views:	1
Size:	21.5 KB
ID:	1079109
    Attached Files
    Last edited by Jhosep_Chevarria; 05-29-2015, 10:45 PM.

    Leave a comment:


  • replied
    I believe The Order used a very similar tech for occlusion and dynamic character reflections for the main character.

    Leave a comment:


  • replied
    Great work!!
    Looks quite nice.

    Skimmed the paper you posted an I am curious.

    So the last of us setup said they mapped a bunch of spheres onto the character and used that. I guess that means each screen pixel needs to trace against every sphere for an intersection?

    *edit* ah it doesnt actually raytrace to hit the spheres but rather knows analytically how much they occlude based on size/distance. that makes sense. very neat trick. And then they eventually skip the analytical step by baking the falloff to a texture. Did you get to the texture baking step yet?
    Last edited by RyanB; 05-29-2015, 05:03 PM.

    Leave a comment:


  • replied
    Wow this is incredible! Are you planning on releasing it commercially or for free? Either way I would totally dig this

    Leave a comment:


  • replied
    It is looking good. Any progress?

    Leave a comment:


  • replied
    Originally posted by Tom Looman View Post
    Cool!!, would you have a side by side comparison of the original + your approach?
    Sure, as the spheres are lit indirectly they basically just float without it:

    Click image for larger version

Name:	Without.jpg
Views:	1
Size:	13.1 KB
ID:	1066643 Click image for larger version

Name:	With.jpg
Views:	1
Size:	12.8 KB
ID:	1066644

    I did hit quite a roadblock though. I build the initial prototype as a material function that is added to the ambient occlusion input of a material. This works great for a quick test scene with few objects and materials, but it does not scale well at all. Instead I wanted to implement the shadows as deferred decals, but it seems like those not only can't write to the AO buffer but the decal material also can't access all the surface properties I need to calculate the shadows.

    Another approach that would probably work is to implement the effect in a separate postprocess pass. This also has the performance benefit of being able to render the pass at a lower resolution with upscaling to provide a nice performance/quality trade-off. (Its strength is in the blurry effect anyway, so a significant lower res would probably not be that noticeable) There is just one slight issue with this approach: I haven't really touched the engine's source at all, so it'll probably take quite a while before I understand the rendering pipeline well enough to actually do that...

    Leave a comment:


  • replied
    Cool!!, would you have a side by side comparison of the original + your approach?

    Leave a comment:


  • replied
    This looks fantastic! Looking forward to seeing more.

    Leave a comment:


  • replied
    This is a side project that I can only work on during my (sadly limited) free time, so don't expect progress to be fast, but your feedback keeps me motivated to continue, so thanks

    The next step is to generalize the system to work with ellipsoids instead of just spheres, which is an important step towards getting it to work with characters.

    Leave a comment:


  • replied
    i want to see more of this in action

    Leave a comment:


  • replied
    If you can get it working with animated meshes + good performance I would gladly pay for your solution.

    Leave a comment:

Working...
X