Transparent objects cannot receive additional light shadows in deferred rendering

Unity 6000.0.34f1
URP 17.0.3
When using deferred rendering, transparent objects cannot receive additionalLight shadows,I found that the reason is that the order of the attributes “_AdditionalShadowParams” and “_AdditionalLightsWorldToShadow” does not correspond to the index of forwardLight.

Thanks for flagging this. Could you file a bug report?

Thank you!

Sent. Check “AdditionalLightsShadowCasterPass.Setup".

1 Like

A new question, in ”UniversalCameraData.cs“.

public Matrix4x4 GetProjectionMatrix(int viewIndex = 0)
{
#if ENABLE_VR && ENABLE_XR_MODULE
    if (xr.enabled)
        return m_JitterMatrix * xr.GetProjMatrix(viewIndex);
#endif
    return m_JitterMatrix * m_ProjectionMatrix;
}

internal Matrix4x4 GetGPUProjectionMatrix(bool renderIntoTexture, int viewIndex = 0)
{
    return m_JitterMatrix * GL.GetGPUProjectionMatrix(GetProjectionMatrix(viewIndex), renderIntoTexture);
}

Should be ?

internal Matrix4x4 GetGPUProjectionMatrix(bool renderIntoTexture, int viewIndex = 0)
{
    return  GL.GetGPUProjectionMatrix(GetProjectionMatrix(viewIndex), renderIntoTexture);
}

When enable TAA, i construct position world space using unity_MatrixInvVP and the depthTexture I get wrong positionWS,changing this solved the problem.

Thanks for the bug report. I saw it internally (IN-93606).

Do you use a custom ScripableRenderPass? If yes, could you use GetGPUProjectionMatrixNoJitter there instead?

I have tried it, the result is right only when I use “GL.GetGPUProjectionMatrix(GetProjectionMatrix(viewIndex), renderIntoTexture)”.

StencilDeferred.hlsl using _ScreenToWorld to calculate the world space without using unity_MatrixInvVP. When using unity_MatrixInvVP, positionWS will jitter.

Wrong.

UNITY_MATRIX_I_VP = inverseViewMatrix*(m_JitterMatrix * GL.GetGPUProjectionMatrix(GetProjectionMatrix(viewIndex), renderIntoTexture)).Inverse;
float3 positionWS = ComputeWorldSpacePosition(uv, depth, UNITY_MATRIX_I_VP);
UNITY_MATRIX_I_VP = inverseViewMatrix*(GL.GetGPUProjectionMatrix(GetProjectionMatrixNoJitter(viewIndex), renderIntoTexture)).Inverse;
float3 positionWS = ComputeWorldSpacePosition(uv, depth, UNITY_MATRIX_I_VP);

Correct

UNITY_MATRIX_I_VP = inverseViewMatrix*(GL.GetGPUProjectionMatrix(GetProjectionMatrix(viewIndex), renderIntoTexture)).Inverse;
float3 positionWS = ComputeWorldSpacePosition(uv, depth, UNITY_MATRIX_I_VP)