Search Unity

Vertext program 'vert': Struct variable 'o' is ignored. error in 2017.3

Discussion in 'Shaders' started by omerelfassy, Dec 24, 2017.

  1. omerelfassy

    omerelfassy

    Joined:
    Nov 9, 2015
    Posts:
    20
    Hi,
    I've just upgraded my Unity from 2017.2.0f3 to 2017.3.0f3 and now I'm having an error on one of my shaders.

    Error:
    Vertex program 'vert': Struct variable 'o' is ignored. Only instancing constant buffers can have struct variables. IMG_24122017_224924_0.png


    Code (CSharp):
    1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
    2.  
    3. Shader "Custom FX/Glow FX" {
    4.     Properties
    5.     {
    6.         _MainTex ("Base (RGB), Alpha (A)", 2D) = "black" {}
    7.         _MaskIntensity ("MaskIntensity", Float) = 1
    8.         _CloudsTex ("Clouds", 2D) = "black" {}
    9.         _CloudsScale ("Cloud Scale", Vector) = (1,1,0,0)
    10.         _GradientTex ("Gradient Tex", 2D) = "black" {}
    11.     }
    12.    
    13.     SubShader
    14.     {
    15.         LOD 200
    16.  
    17.         Tags
    18.         {
    19.             "Queue" = "Transparent"
    20.             "IgnoreProjector" = "True"
    21.             "RenderType" = "Transparent"
    22.         }
    23.        
    24.         Pass
    25.         {
    26.             Cull Off
    27.             Lighting Off
    28.             ZWrite Off
    29.             Blend One One
    30.  
    31.             CGPROGRAM
    32.             #pragma vertex vert
    33.             #pragma fragment frag
    34.             #include "UnityCG.cginc"
    35.  
    36.             sampler2D _MainTex;
    37.             sampler2D _GradientTex;
    38.             sampler2D _CloudsTex;
    39.             float4 _MainTex_ST;
    40.             float4 _CloudsTex_ST;
    41.             half2 _CloudsScale;
    42.             fixed _MaskIntensity;
    43.    
    44.             struct appdata_t
    45.             {
    46.                 float4 vertex : POSITION;
    47.                 float2 texcoord : TEXCOORD0;
    48.                 fixed4 color : COLOR;
    49.             };
    50.    
    51.             struct v2f
    52.             {
    53.                 float4 vertex : SV_POSITION;
    54.                 half2 texcoord : TEXCOORD0;
    55.                 half2 texcoord1 : TEXCOORD1;
    56.                 half2 texcoord2 : TEXCOORD2;
    57.                 float4 texcoord_clouds : TEXCOORD3;
    58.             };
    59.    
    60.             v2f o;
    61.  
    62.             v2f vert (appdata_t v)
    63.             {
    64.                 o.vertex = UnityObjectToClipPos(v.vertex);
    65.                 o.texcoord = v.texcoord;
    66.                 o.texcoord_clouds.xy = v.texcoord * _CloudsScale.x + frac(_CloudsTex_ST.xy*_Time.y);
    67.                 return o;
    68.             }
    69.                
    70.             fixed4 frag (v2f IN) : COLOR
    71.             {
    72.                 fixed mask = tex2D(_MainTex, IN.texcoord).r;
    73.                 fixed clouds = tex2D(_CloudsTex,IN.texcoord_clouds.xy);
    74.                 fixed disValue = saturate(mask*_MaskIntensity + ((clouds) * mask));
    75.                 fixed4 color = tex2D(_GradientTex, fixed2(disValue,0.5));
    76.                 return color;
    77.             }
    78.             ENDCG
    79.         }
    80.     }
    81. }
    82.  
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,620
    You probably need to move "v2f o;" inside "v2f vert (appdata_t v)".
     
  3. omerelfassy

    omerelfassy

    Joined:
    Nov 9, 2015
    Posts:
    20
    Thanks! It worked and now the shader is working!

    However, it now shows a different warning.

    upload_2017-12-25_8-4-9.png
     
  4. omerelfassy

    omerelfassy

    Joined:
    Nov 9, 2015
    Posts:
    20
    I solved it when I replaced "v2f o;" with "v2f o = (v2f)0;"
    Thank you for your help :)
     
  5. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,797
    The warning that vert is not completely initialized is because you're not initializing your
    half2 texcoord1 : TEXCOORD1;
    half2 texcoord2 : TEXCOORD2;

    (and if you're not doing anything with those two texcoords, you might as well delete them from your struct)