Search Unity

[Shader] MatteShadow + Ambient Occlusion

Discussion in 'High Definition Render Pipeline' started by GeniusKoala, Jul 23, 2021.

  1. GeniusKoala

    GeniusKoala

    Joined:
    Oct 13, 2017
    Posts:
    97
    Hi,

    We need to put 3D characters on live environnement (Streaming Image Sequence). I have a matteshadow shader (Unlit) to have their shadows but I can't have ambient occlusion with the plane on the feet. I would like this ambient occlusion to have more the feeling they are in this environnement. If it is not possible, have you got any idea how to proceed a similar result in HDRP please?

    Thanks for reading,
     
  2. GeniusKoala

    GeniusKoala

    Joined:
    Oct 13, 2017
    Posts:
    97
    @Matjio @SebLagarde It would be really helpful if some technical people would have an idea of how to achieve this. I can send you more information in private since I can't share any visual in public so far.
     
  3. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    766
    Hey, AO should work with any opaque object (shadow matte or not).

    However, I suspect your object is transparent. AO relies on depth buffer to compute occlusion, since transparent are not in the depth buffer, it's expected that if your plane is transparent, it won't be considered as an occluder and no AO will be generated.

    Quick and dirty hack would be to use fake AO transparent plane at the bottom of the feet or maybe your setup is more specific ?
     

    Attached Files:

    GeniusKoala likes this.
  4. GeniusKoala

    GeniusKoala

    Joined:
    Oct 13, 2017
    Posts:
    97
    Hi! Thanks for the reply! We have moving 3D characters in front of a plane. This plane displays a texture of a live environnement so that with our camera the characters look like they stand up on a real barrel in a live room (It is for a children TV shows).

    So far we just used a Lit shader with matte shadow option to cast the shadow of the character on a transparent proxy.

    How would you use the fake AO transparent? Is it baked? Since the characters are moving it has to be dynamic. We can't animate AO depending on if the feet are stick to the ground or not (if the chararcters run for example).
     
  5. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    766
    I made a quick and dirty example, the basic idea is just to modulate the opacity/position/rotation of the "fake AO" depending on your character foot transform.
    The texture is just a stretched blurred black dot on a plane but you can paint something that fit more what AO should look like.

    It's far from ideal, but it's pretty easy to setup. And given your plane surface is unlit (does not support decal) and transparent (won't support SSAO/RTAO), I don't have a better idea :)
     

    Attached Files:

    GeniusKoala likes this.
  6. GeniusKoala

    GeniusKoala

    Joined:
    Oct 13, 2017
    Posts:
    97
    Thank you for your post! That's a good trick but we can't afford so much time for this feature since our deadlines are short. Don't you think the compositor or a render pass could make it?

    EDIT : If I understood correctly, does your solution needs to animate the AO plane or is an automatic solution?
     
    Last edited: Nov 4, 2021