Search Issue Tracker
By Design
By Design in 2023.2.X
Votes
0
Found in
2023.1.7f1
2023.2.0b3
Issue ID
UUM-45337
Regression
No
Shader error when using Metal Graphics API and shaders use native 16-bit precision
How to reproduce:
1. Open the attached “Shader16Bug.zip“ project
2. Open the “SampleScene“
Expected result: No errors in the Console
Actual result: “SV_Position must be a 4-component 32-bit float vector or a composite which recursively contains only such a vector at line 44“ error in the Console
Reproducible with: 2023.1.7f1, 2023.2.0b3
Can’t test with: 2021.3.29f1, 2022.3.6f1 (Unrelated to issue errors in the Console)
Reproducible on: macOS 13.4.1 (Intel)
Not 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
- Out-of-bounds memory access with multiple CanvasRenderers under a Canvas when using Mesh API
- Inspector tries to access file after it was deleted when the file was locked in Inspector window
- Changing Transform values in Search window Inspector loses focus while dragging and stopping mouse without releasing dragging action
- Saving changes on the dirty VFX Graph during the Play mode throws "The referenced script (Unknown) on this Behaviour is missing!" warnings
- VFX Graph Debug Info overlaps the "Initialize" block debug info by default
Resolution Note:
The project contains a shader "Custom/HalfTextureColor" that contains the following:
```
struct Varyings
{
min16float4 positionCS : SV_POSITION;
min16float2 uv : TEXCOORD0;
};
```
According to the HLSL documentation, `SV_POSITION` must be declared as `float4`. Also, according to Metal Shading Language documentation, section 5.2.3.3, the vertex shader ouput position must also be `float4`. The Metal shader compiler will output errors otherwise. Therefore, Unity displays the mentioned warning "SV_Position must be a 4-component 32-bit float vector or a composite which recursively contains only such a vector at line 44".
In addition, if the shader accesses high resolution textures (with either width or height bigger than 2048), it might be worth considering changing the type of `uv` to `float4`, as 16-bit floats start to have precision problems with values higher than 2048. For example, 16-bit floats don't have enough precision to represent the number 2049.
Resolution Note (2023.2.X):
The project contains a shader "Custom/HalfTextureColor" that contains the following:
```
struct Varyings
{
min16float4 positionCS : SV_POSITION;
min16float2 uv : TEXCOORD0;
};
```
According to the HLSL documentation, `SV_POSITION` must be declared as `float4`. Also, according to Metal Shading Language documentation, section 5.2.3.3, the vertex shader ouput position must also be `float4`. The Metal shader compiler will output errors otherwise. Therefore, Unity displays the mentioned warning "SV_Position must be a 4-component 32-bit float vector or a composite which recursively contains only such a vector at line 44".
In addition, if the shader accesses high resolution textures (with either width or height bigger than 2048), it might be worth considering changing the type of `uv` to `float4`, as 16-bit floats start to have precision problems with values higher than 2048. For example, 16-bit floats don't have enough precision to represent the number 2049.