Search Issue Tracker
By Design
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
- Crash on RaiseException when terrain detail instancing is excessive
- Prefab variant reference is lost when assigned by click-and-drag in Prefab Editor mode
- Opening any dropdown in Shader Graph stops the Nodes preview but it still plays in the background
- GPU utilization increases when a GameObject is selected
- Motion Blur has sharp edges when object is moving in the foreground of another object
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