Shader warning in 'Master': implicit truncation of vector type

Viewed 3167

I get these warnings whenever I save changes in any shader file. It does not seem to relate directly to the shader files, since it works perfectly in a new project. Unfortunately it seems impossible to open this "Master" shader and edit it, double clicking the error message does not open any file.

Master shader error

I'm using Unity 2021.1.0b11.2079 and the Universal Render Pipeline.

Does anyone know why these warnings appear and how I can solve the root issue?

Thanks a lot!

1 Answers

The warning just means that some components of the vector are being ignored as it is converted to another type with less components(for example float3 to float2). In a script(here HLSL), instead of writing

float3 a = float3(1, 2, 3);
float2 b = a;

(which will give your a warning) you can simply write

float3 a = float3(1, 2, 3);
float2 b = a.xy;

The behaviour is the same, but the warning is gone.

Related