Flickering shadow artefacts on Android deferred pipeline
Deferred pipeline sun shadows look broken on Android
Device: Samsung Galaxy s10 SM-G9730
Steps to Reproduce:
- Enable deferred pipeline on android beta version
- Observe sun shadows
Observed Results:
Shadows have visible flickering artefacts (see attached video)
Expected Results:
Shadows will look normal
Notes:
The frame captured with graphics debugger looks completely normal, artefacts only occur during gameplay on the device itself.
I tried fixing it by editing shader code, and this is the minimum set of edits that resolved the issue on my device (both edits are necessary for it to function properly, removing either causes artefacts to appear)
bool areCascadedShadowsEnabled(float mode) { return round(mode) == 1.0; // Instead of int(mode) == 1 } float GetShadowAmount(ShadowParameters params, DirectionalLightParams light, vec3 worldPos, float NdL, float viewDepth) { vec4 projPos; float amt = 1.0; float cloudAmt = 1.0; bool isSun = light.isSun > 0; // This has to be computed before GetShadowCascade() is called, otherwise artefacts occur. Storing just light.isSun and comparing it with 0 after GetShadowCascade() didn't fix the issue. int cascade = GetShadowCascade(light, worldPos, projPos); if (cascade != -1) { float bias = params.shadowBias[light.index] + params.shadowSlopeBias[light.index] * clamp(tan(acos(NdL)), 0.0, 1.0); projPos.z -= bias / projPos.w; vec2 uv = vec2(projPos.x, projPos.y) * 0.5f + 0.5f; amt = GetFilteredShadow(params, light.index, projPos.z, cascade, uv); if (isSun && params.cloudshadowsEnabled > 0) { // Here use computed previously variable instead of direct light.isSun > 0 comparison. cloudAmt = GetFilteredCloudShadow(params, worldPos, NdL); if (cloudAmt < 1.0) { cloudAmt = max(cloudAmt, 1.0 - params.cloudshadowContribution); amt = min(amt, cloudAmt); } } float shadowRange = params.shadowParams.y; float shadowFade = smoothstep(max(0.0, shadowRange - 8.0), shadowRange, -viewDepth); amt = mix(amt, 1.0, shadowFade); } return amt; }
2023-08-04, 04:29 AM
2024-08-07, 03:55 PM
2024-08-07, 03:55 PM
30
6
1093262
1.20.30.22 Preview, 1.20.30.21 Preview, 1.20.30.20 Preview, 1.20.40.21 Preview