Search Unity

DrawProceduralIndirect not casting shadows

Discussion in 'Shaders' started by zombience, Mar 2, 2022.

  1. zombience

    zombience

    Joined:
    Mar 29, 2012
    Posts:
    57
    Hi all,
    Is it possible to cast shadows from meshes created via DrawProceduralIndirect?

    I found this forum post for Unity v2019 in which user bgolus suggested that the vertex.w component must be set to 1 instead of 0. That seemed to fix the issue for the poster in that thread, but this is not working for me.

    Looking elsewhere on the web this question seems to come up occasionally, with mixed answers tending towards no. However the thread above suggests that it can in fact work.

    I have set up my compute shader to surface shader workflow in both:
    Unity 2020.3.24f1 URP
    and
    Unity 2021.2.13f1 HDRP

    and it does not work in either situation.

    In 2020 URP the PBR shader vertex struct defines
    float4 vertex: POSITION
    , and so I did what the above suggested and set the .w component to 1., but this does not work for me.

    In 2021 HDRP the LIT vertex struct in use defines
    float3 positionOS : POSITION;
    , and shadows still do not work.

    In both cases I am calling DrawProceduralIndirect with ShadowCasting mode ON and receive shadows = true.

    In both cases RECEIVING shadows works just fine (unlike in the forum post I linked above), but CASTING shadows does not work.


    Also, I'm happy to post the shader for reference, however I'm using Amplify Shader Editor so the generated shaders are quite large to look through.

    Thanks in advance.