Search Issue Tracker
By Design
By Design in 2023.1.X
Votes
0
Found in
2020.3.36f1
2021.3.6f1
2022.1.8f1
2022.2.0a18
2023.1.0a3
Issue ID
UUM-9645
Regression
No
[WebGL] Shader covers the whole scene when building on WebGL platform
Steps to reproduce:
1. Open the user’s attached project
2. Open Assets/Scene/SampleScene.unity
3. Enter Play Mode
4. Observe the Game view
5. Navigate to File > Build Settings and switch to WebGL
6. Build the project and observe the build
Expected result: A sphere has a thin green outline
Actual result: The green outline covers the whole scene
Reproducible with: 2020.3.36f1, 2021.3.6f1, 2022.1.8f1, 2022.2.0a18, 2023.1.0a3
Reproducible on: Windows 10
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
- [Tile Palette] Sprites not rendering when brush tool "Paint a filled box with active brush" is used for the first time
- Adding available Nodes with longer names in Fragment Context window overflow Fragment Context window in Shader Graph
- "Layer Palette Profile" Asset is automatically applied to the second Terrain but doesn't load any layers
- "Terrain Tools" shortcut conflicts with the Overlays shortcut by default
- Longer Shader Graph Property Reference names breaks VFX Graph Output Particle Node
Resolution Note:
OpenGL / WebGL has a different projection space than D3D/Metal/Vulkan. The provided outline shader uses o.pos.z assuming D3D projection. On GL, the projected z is in [near, far] range. So you can compensate for GL with something like:
o.pos = UnityObjectToClipPos(v.vertex);
float3 norm = mul((float3x3)UNITY_MATRIX_IT_MV, v.normal);
float2 offset = TransformViewToProjection(norm.xy);
#ifndef UNITY_REVERSED_Z // GL
float z = (o.pos.z - _ProjectionParams.y) / (_ProjectionParams.z - _ProjectionParams.y);
o.pos.xy += offset.xy * z * _OutlineWidth;
#else
o.pos.xy += offset.xy * o.pos.z * _OutlineWidth;
#endif
Resolution Note (2023.1.X):
OpenGL / WebGL has a different projection space than D3D/Metal/Vulkan. The provided outline shader uses o.pos.z assuming D3D projection. On GL, the projected z is in [near, far] range. So you can compensate for GL with something like:
o.pos = UnityObjectToClipPos(v.vertex);
float3 norm = mul((float3x3)UNITY_MATRIX_IT_MV, v.normal);
float2 offset = TransformViewToProjection(norm.xy);
#ifndef UNITY_REVERSED_Z // GL
float z = (o.pos.z - _ProjectionParams.y) / (_ProjectionParams.z - _ProjectionParams.y);
o.pos.xy += offset.xy * z * _OutlineWidth;
#else
o.pos.xy += offset.xy * o.pos.z * _OutlineWidth;
#endif