anonymous-dev
anonymous-dev

Reputation: 3499

Output value vert is not completly initialized

I am getting the warning

Shader warning in 'Custom/NoobShader_02': Output value 'vert' is not completely initialized at line 30 (on d3d11)

with the following code can anyone explain me why it is doing this?

Shader "Custom/NoobShader_02" {
    Properties {
        twisting ("Twist", Range(-10,10)) = 1
    }
    SubShader {
        Pass{
        CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag

        float twisting;

        struct VertexOutput
        {
            float4 pos : SV_POSITION;
            float3 nor : NORMAL;
        };

        struct VertexInput
        {
            float4 vertex : POSITION;
            float3 normal : NORMAL;
        };

        struct FragmentOutput
        {
            float4 color : COLOR;
        };

        VertexOutput vert (VertexInput i)
        {
            VertexOutput VOUT;
            VOUT.pos = mul(UNITY_MATRIX_MVP, i.vertex);

            return VOUT;
        }

        FragmentOutput frag() 
        {
            FragmentOutput FOUT;
            float4 tempCol = {abs(_SinTime.z),0,0,1};
            FOUT.color = tempCol;
            return FOUT;
        }
        ENDCG
        }
    } 
    FallBack "Diffuse"
}

Upvotes: 3

Views: 8903

Answers (2)

ChrisQ
ChrisQ

Reputation: 1

Same issue right now, all this time later.

Simply adding ZERO_INITIALIZE(Varyings, OUT); beneath Varyings OUT; fixed it.

What's interesting to me is, the offending code that triggered this error in my project... is identical to the example UNITY gives:

https://docs.unity3d.com/Packages/[email protected]/manual/writing-shaders-urp-basic-unlit-structure.html

I guess UNITY themselves aren't bothered by the errors their own code generates? Dunno.

Upvotes: 0

ForceMagic
ForceMagic

Reputation: 6378

It says pretty much what happens, VertexOutput VOUT; is only the declaration of your variable. It's like defining MyObject o; and then trying to use o.ToString(); when o would be still null.

You have to use:

VertexOutput VOUT;
UNITY_INITIALIZE_OUTPUT(VertexOutput, VOUT);

Upvotes: 4

Related Questions