Don’t know what I’m doing wrong, but every shader I create with shader graph (in any version). I always get this error:
Then I hit “save asset” a couple of times and it goes away. When I re-open Unity it’s back again.
Here’s a simple shader that just repeats a texture based on a grid size:
It looks fine to me, but no matter what, “Output value ‘vert’ is not completely initialized” warning keeps popping up.
Just want to weight and say this is also a regular occurrence for me in 2019.3. Fortunately it’s not a pressing issue, but evidently something is wrong.
Yep. That is indeed something they could add to the generated shader code to fix the problem.
As an aside, while I know the above line is common in a lot of built-in Unity shaders, I’m strongly against its use in my own shaders. That warning is useful information and means there’s either a bug in your shader or an optimization you could be making. If the vertex output isn’t completely initialized it means you either forgot to set a value that should be set which might explain some visual issue you might see, or it means you’re passing extra unused data to the fragment shader which could be removed to make the shader faster.
No where. This isn’t something for you to fix. Reporting the bug using the in editor “Report a Bug…” dialog is how you get it fixed.
The “fix” @ioesten posted would be for hand written vertex fragment shaders, not for Shader Graph shaders. Infact the existing shaders already do something very similar. The macro referenced in his example code does this:
#define UNITY_INITIALIZE_OUTPUT(type,name) name = (type)0;
That initializes all values of a struct to be zero. If you look at the code in PBRForwardBase.hlsl where the error is being reported, it’s already doing the same thing.
PackedVaryings vert(Attributes input)
{
Varyings output = (Varyings)0; // here
output = BuildVaryings(input);
PackedVaryings packedOutput = (PackedVaryings)0; // and here
packedOutput = PackVaryings(output);
return packedOutput;
}
The problem is those BuildVaryings and PackVaryings functions are overriding the struct, and those functions (which are generated by the shader graph and are unique to each shader) don’t properly initialize all values. Since the functions are just overriding and not modifying the existing struct, the fact it was originally zeroed out doesn’t matter. Really, the bug is there are values being included in the struct that shouldn’t be there, not that it’s not being initialized to zero, so it’s a deeper bug they should fix.
So, what can you do?
Have you reported the bug with an example project using the in-editor Report Bug dialog? If not, no. No one is working on it. This forum is a community forum. There are real devs who sometimes come by to help out, or sometimes to try and find more information about bugs that have been reported, but they are not supposed to work on issues not in the tracker and vetted by their test team.
If you want a bug fixed, report it, then post here.
Technically if you want to fix the issue locally you can take every Shader Graph you make that has the problem, right click on the master node and select “Show Generated Code”, save that to a new .shader file, and find this line:
PackedVaryings output;
And replace it with:
PackedVaryings output = (PackedVaryings)0;
Then delete your Shader Graph shaders and hand modify the shader code when you want to make changes.
Or you can report the bug and ignore the warnings for now.
Hi, if you have an issue that is an actual bug, please check if it exists on the issue tracker or file a bug yourself. Like Ben said, it really helps us to have a formally filed and tracked bug with our test team to resolve issues. c:
Hi, the fix for this has already landed for 7.2.0. There’s a hotfix to ensure all values are zero initialized, and there’s a larger fix in the works to ensure that only necessary data is generated in the structs.
Unfortunately even after this fix you may still see this error on older graphs due an unrelated bug where the warnings on the shader/material do not clear from cache correctly. This warning shouldn’t be breaking your graphs, and you haven’t done anything in your graph wrong. It’s more of a visual nuisance than anything.
You don’t download the Shader Graph package directly, but rather it’s updated along with whatever SRP you’re using. So you need to update your URP or HDRP to 7.2.0 or better (URP doesn’t have a “7.2.0” release, only 7.2.1, but that’ll work too). You can do so through the Package Manager window in the editor. Note the fixed version of the URP may not be available for the version of the editor you’re using. For example, URP 7.2.1 requires Unity 2020.1.