Output value 'vert' is not completely initialized

Don’t know what I’m doing wrong, but every shader I create with shader graph (in any version). I always get this error:

5083775--500318--grid.png

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.

What am I doing wrong?

Same here in 2019.3. Just multiply 2 colors and plug it into the emission, presto, error. Pressing Save Asset a few times gets rid of it again.

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.

same here 2019.3.0b12

1 Like

You’re not doing anything wrong, and there’s nothing you can do to fix it. This is Unity’s bug.

5 Likes

This fixes it:

v2f vert(appdata_base v)
{
//initialize ‘o’…
v2f o;
UNITY_INITIALIZE_OUTPUT(v2f, o);

1 Like

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.

4 Likes

where do I put this?

1 Like

Are there actually any Unity devs on this shader graph forum?

Would be great to know this is a known issue and is being worked on.

1 Like

can you please tell me where to put this. I am having the same issue

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.

2 Likes

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:

I am also getting the same error in 2019.3.0f3. I couldn’t find a bug logged for it so I logged one.

1 Like

Unity has acknowledged the issue and sent it to their dev team:

From: Gytis Zasciurinskas bugs@unity3d.com
Date: Mon, 20 Jan 2020 12:54:01 +01:00

Hi,

We successfully reproduced this issue and have sent it for resolution with our developers.

We highly appreciate your contribution. If you have further questions, feel free to contact us.

Thanks,
Gytis
Customer QA Team

1 Like

Any news about this? I just upgraded to 2019.3.1f1 and the “Output value ‘vert’ is not completely initialized” is still a problem…

I have the same exact problem, I also reportedd, but just seen that it is in progress. so I guess I’ll wait

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.

What is 7.2.0?

Shader Graph version 7.2.0

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.

2 Likes

URP 7.2.1 is now available in 2019.3.2.f1