Search Issue Tracker
By Design
Votes
2
Found in
2021.3.44f1
2022.3.48f1
6000.0.21f1
6000.1.0a7
6000.2.0a1
Issue ID
UUM-82660
Regression
No
Surface Shader lighting displayed incorrectly when Point Light is intersecting a Particle System inside Camera Frustum
How to reproduce:
1. Open the attached "IN-84355" project
2. Open the "Default" Scene and enter Play mode
3. Observe the grass lighting on the “Terrain” GameObject in Game view
Expected result: Grass prefabs have consistent shading regardless of the position of the camera and the particle system in the project
Actual result: Grass prefabs have their surface shader lighting computed incorrectly when a point light is visible and intersecting with a particle system inside the Camera Frustum
Reproducible in: 2021.3.44f1, 2022.3.48f1, 6000.0.21f1
Reproducible on: Windows 11
Not reproducible on: No other environments tested
Notes:
* Behavior only occurs when using deferred rendering and per-pixel lighting with a point light or spot light
* When the point light is moved so that it does not intersect with the particle system, the grass elements render as expected
* When downgrading the Project to 2021.3.x the grass Prefabs might need to be placed in the Project manually, but the issue still reproduces.
* Reproducible using Direct3D 11/12, Vulkan and OpenGL Graphics APIs
* In Unity Editor versions 6000.0.x, issue only reproduces when using Direct3D11 and OpenGLES3
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Memory leak when a lot of UI elements are spawned and despawned
- Warnings are not logged in the Console window when using external code analyzers
- Errors “TLS Allocator ALLOC_TEMP_TLS, underlying allocator ALLOC_TEMP_MAIN has unfreed allocations, size 288“ appear constantly when Prefab is open
- Crash on PPtr<Shader>::operator or NullException errors spammed in console when calling Dispose() on null GraphicsBuffer with baked Reflection Probes
- “EndRenderPass: Not inside a Renderpass” and other Render Graph errors in the Player when Render Graph is enabled and Overlay UI is used
Resolution Note:
The issue appears to be related to how the grass shader reacts to the main light.
The point light in the scene has a high intensity (25), but a low range (10). While anything affected by the point light is visible to the camera, it becomes the main light as it is the brightest light in the scene (the directional light has an intensity of 1.5).
The grass shader picks up the `_LightColor0` color from the main light, but at no point calculates the attenuation due to distance. This results in the shader reacting to the point light when it should be too far away to be affected by it.
As the camera dips down, and the last bit of particle affected by the point light slips out of view, the main light changes, because the point light can no longer affect anything on screen, so the dimmer directional light is used as the main light, which is what results in the sudden change.
This is an issue with the shader used on the grass - Unity is behaving as expected.
The suggested solution would be to take the attenuation of the main light in to account, and perhaps also combine it with the light from first of the 'non-important' lights so that no change between the point light going on and off screen is visible.