Is the second approach “better” in some way? It prevents the warning, but it adds more cruft to the graph. I also don’t know whether it has any performance impact one way or the other.
Implicit truncation warnings serve to, well, warn you that the truncation is happening so that you’re not surprised when the alpha channel of your RGBA output is suddenly missing from your variable later in the graph because you passed it through a node that takes in a three-component vector.
If I recall correctly, it’s about as computationally expensive as a swizzle operation. You probably shouldn’t worry about it.
I’m interested in that as well because I get spammed in the Console by those warnings and it’s pretty annoying.
Are we supposed to get rid of those warnings by editing the Shader Graphs the way @dgoyette showed in the screenshot and is it expensive in a way or another or another method exists to remove/hide that kind of warnings?
This problem affects me as well; especially since it says it’s an “error” and not a “warning”; if it’s an actual error what am I supposed to do? If its a warning, how do I turn it off? Having to swizzle manually just for peace of mind seems inoptimal.
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 V4 to V3). In a script, 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.
That’s just a semantics issue in the Unity inspector for shaders. Instead of the header for that textbox being “Errors (#):” it should be “Output (#):”
It’s only an actual error if the message is accompanied by a red !-agon. If it’s a yellow yield triangle, then it’s just a warning. If you are getting an actual error because of this (the shader doesn’t compile or doesn’t function), you may be truncating a value type that absolutely cannot be truncated, but I haven’t seen this myself.
I’m getting a ginormous amount of “implicit truncation” warning messages in my console even after I did check more than a handful of times in my shaders that there isn’t any implicit truncation.
It always pointing me to a sub graph I made that a few more shader graphs uses and there is 0 truncation there.
So I picked into the generated code and discovered the culprit! it’s the “normal from texture” node! yea this one:
The generated code is:
IMO
It’s probably fine to ignore. you would do a truncation anyway either manually or automatically when you need\have to… the warning is just to let you know an automatic truncation occurred and it’s not obvious if it is intended or not.