unity-game-engineshadercg

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"
}

Solution

  • 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);