Search Issue Tracker
Fixed in 4.5.5
Votes
16
Found in
4.0.1f2
Issue ID
522223
Regression
Yes
Lighting is incorrect when a custom projection matrix is set on the camera
See attached image.
Regression from 3.5
Steps to reproduce.
1. Open scene (camera_repro)
2.Press Play: 2 views of the same scene, one using a normal ortho camera (green background), and the second using a custom projection matrix. (to see camera (with green background) choose "Camera 2 (Normal ortho)" in the Hierarchy and check and uncheck camera check box)(also please see in Scene tab)
3. Lighting is incorrect with the custom projection matrix (on the camera with blue background you can't see red light. To see it - try to move light to the right)
Comments (2)
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
- The Scrollbar becomes unusable when adding Elements to the List
- "One or more data file missing for baking set NewScene Baking Set. Cannot load shared data." error in Player when a specific project is built
- Choosing new HDR Colour using RGB values breaks colour on Intensity Selectors
- Rendering/Decal Layer Mask options are different inside Prefab Mode and outside Prefab Mode when the project is upgraded to Unity 6
- Incorrect Realtime GI Light Probes baking when more than one Light Probe Group is used and "Baked Global Illumination" is enabled
vrdaveb
Aug 06, 2014 02:59
We found the lighting behaves a lot better if you divide _ProjectionParams.z by 2. If you grab the 4.5.2 shader source ZIP and look at the code in Internal-PrePassLighting.shader's CalculateLight(..) function:
half4 CalculateLight (v2f i)
{
i.ray = i.ray * (_ProjectionParams.z / i.ray.z);
float2 uv = i.uv.xy / i.uv.w;
...
should be
half4 CalculateLight (v2f i)
{
i.ray = i.ray * (_ProjectionParams.z / (2.0 * i.ray.z));
float2 uv = i.uv.xy / i.uv.w;
...
CalculateLight may need more changes to support custom projection matrices.
vrdaveb
Jul 29, 2014 20:35
This also breaks lighting and shadows in deferred rendering if you have an asymmetric frustum, which is very common in stereoscopic rendering.