Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Is it possible to have an occlusion material that also receives shadows in ARFoundation (URP)

Discussion in 'AR' started by Michele_P_LF, Oct 25, 2022.

  1. Michele_P_LF

    Michele_P_LF

    Joined:
    Oct 18, 2021
    Posts:
    9
    Hello!

    Is it possible to add shadows to the 'PlaneOcclusionShader' shader supplied with ARFoundation? I don't think it receives shadows at present.

    I cannot use the AROcclusionManager as the objects I want to use as occluding objects in my AR scene are too far away from the user.

    Is there a better way of doing this?

    Essentially I need occluding transparent objects that also receive realtime shadows when other objects get near them.

    I am working in URP on Unity 2021.3.8f.

    Many thanks!
     
  2. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    793
    newguy123 likes this.
  3. Michele_P_LF

    Michele_P_LF

    Joined:
    Oct 18, 2021
    Posts:
    9
    Thanks @andyb-unity!

    I knew that repo and I love it! In fact, those two shader graphs for the shadows are my go-to anytime I need shadows in URP AR. However although they are transparent they don't have occlusion.

    I guess I could add occlusion to those shader graphs if adding shadows to the occlusion shader doesn't work? I am not sure how to do it though, do you think you could point me in the right direction?

    Many thanks

    M
     
  4. davidmo_unity

    davidmo_unity

    Unity Technologies

    Joined:
    Jun 18, 2019
    Posts:
    99
    An idea I had that may work was creating a quad with WxH vertices where W is the width of the occlusion texture and H is the height. Then develop an index buffer that triangulates the vertices in question into triangles into the quad form. Then place that quad as the far plane in clip space and scale the Z component by the occlusion depth in the shader. Then the mesh could possibly work shadow mapping barring some use-cases such as lights being within the volume defined by the mesh.

    Not a fully fleshed out idea but a thought.
     
    monoganog likes this.
  5. Dennisrudolph

    Dennisrudolph

    Joined:
    Aug 24, 2017
    Posts:
    6
    Any news on this? I can not figure it out. Isn't this an essential feature for AR? I would appreciate any help. Thanks!
     
    monoganog likes this.