Search Issue Tracker

By Design

Votes

0

Found in

2021.3.36f1

2022.3.21f1

2023.2.14f1

Issue ID

UUM-68000

Regression

No

The depth of shadows alters when the project is built

--

-

How to reproduce:
1. Open the “GS” project
2. Open the “SnowScene_Deffered“ scene
3. Enter the Play Mode
4. Observe the shadows
5. Build and Run the project (File->Build and Run)
6. Observe the shadows

Expected result: The shadows are naturally diffused throughout the scene both in the Editor and the Player
Actual result: The shadows are sharp and too dark in Player

Reproducible in: 2021.3.36f1, 2022.3.21f1, 2023.2.14f1
Couldn’t test with: 2023.3.0b10 (Compilation errors)

Reproduced on: Windows 10
Not reproduced on: No other environments tested

Notes:
- User indicated that they use SampleSH() function in URP shader library to get the Ambient light in their shader. They noticed that values of “ambientLighting” might cause this problem to occur in the “// Ambient” section of code in the GlobalSnowPass.hlsl file (Assets->GlobalSnow->Runtime->Resources->GlobalSnow->Shaders)
- Enabling the Frame Debugger while in the Player resolves the issue in versions 2021.3.36f1 and 2022.3.21f1.
- Shadows are sharp and too dark both in the Editor and the Player in version 2023.2.14f1
- Built project crashes when enabling Frame Debugger in version 2023.2.14f1

  1. Resolution Note:

    The shader which calls the `SampleSH()` function is being rendered onto a fullscreen quad mesh using CommandBuffer.DrawMesh. This doesn't work for a few reasons:
    - The method does not populate any lighting-related uniforms, including those used by `SampleSH()` (these are `unity_SHAr`, `unity_SHAb`, etc.). Attempting to use these will result in undefined results. This is described in our documentation https://docs.unity3d.com/ScriptReference/Rendering.CommandBuffer.DrawMesh.html
    - `SampleSH()` returns the result of evaluating the interpolated light probe associated with the object currently being rendered. In this case, the object is the fullscreen quad mesh. It doesn't really make sense to ask for the interpolated light probe for such a renderer, as it doesn't exist in the scene in meaningful way. For the same reason, you can't access reflection probes, lightmaps, etc. - these are all per-object. That it 'works' in editor is a coincidence.

    If you just want to sample the ambient probe specifically, you can feed it in directly using https://docs.unity3d.com/ScriptReference/MaterialPropertyBlock.CopySHCoefficientArraysFrom.html with https://docs.unity3d.com/ScriptReference/RenderSettings-ambientProbe.html and passing the resulting MaterialPropertyBlock to the DrawMesh call.

    Alternatively, you could use the evaluated lighting already present in the GBuffer - this contains contribution from the ambient probe.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.