Search Issue Tracker
Postponed means that the issue was either a feature request or something that requires major refactoring on our side. Since that makes the issue not actionable in the close future we choose to close it as Postponed and add it on our internal roadmaps and technical debt pages instead.
Postponed
Votes
1
Found in
2018.4
2019.4
2020.3
2020.3.2f1
2021.1
2021.2
Issue ID
1332472
Regression
No
unity_LightColor[1] returns black color when the Point Light's color is white
How to reproduce:
1. Open the user's attached "PointLightAuto.zip" project
2. Open the "SampleScene" Scene
3. Open the "TestPointAutoLightColor.shader" Shader in External Editor
4. Uncomment the line "return unity_LightColor[1];"
5. Comment out the line "return unity_LightColor[0];"
6. Observe the "Capsule" GameObject's color in the Game view
Expected result: "Capsule" GameObject's color is white
Actual result: "Capsule" GameObject's color is black
Reproducible with: 2018.4.34f1, 2019.4.24f1, 2020.3.7f1, 2021.1.5f1, 2021.2.0a15
Note:
- The issue is not reproducible when returning unity_LightColor[0]
- The issue is not reproducible if the Point Light's color is anything but white
Comments (1)
-
nsaxena_unity
Apr 29, 2021 14:56
- The issue is not reproducible if the Point Light's Render Mode is anything but "Auto"
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
- Different text alignment in the column header in Entities "System" window
- Objects with Universal Render Pipeline/Particles/Lit shader are always lit up when changing their Rendering Layer Mask
- PolySpatial “Trying to set shader on a Material Variant.” error is printed in the console when entering Play Mode
- Error “Shader error in 'YSCloudCover': call to 'tex3D' is ambiguous at Assets/YSCloudCoverText.shader(606) (on d3d11)“ is present when compiling tex3D shader with DXC
- Placeholder asset is not loaded with Advertisement Legacy sample when using the latest version of the package
Resolution Note (2021.2.X):
This issue is by design. With no ForwardAdd pass in the shader, lights set to "Not Important" and "Auto" Render Mode (pixel lights) will be treated as Vertex lights instead. The lights in the repro project are set to Auto, so the unity_LightColor array, which contains colors of 4 vertex lights, will contain colors of the 4 first of these.
The last light in this array (unity_LightColor[1] in this case) will be blended with SH in order to prevent pop-in, which is explained here https://docs.unity3d.com/Manual/RenderTech-ForwardRendering.html, and is what causes the observed gray color. Note that this behavior only occurs when a directional light is present in the scene.
In a scene with many lights, the best solution is to handle additional pixel lights in a ForwardAdd pass. The ForwardBase pass only handles the main directional light and 4 vertex lights. Please see the following link for more information on how to make a shader use all lights properly https://en.wikibooks.org/wiki/Cg_Programming/Unity/Multiple_Lights.
This information will make it into the manual soon.