Search Unity

Alpha test is not fully supported on Unity 2017?

Discussion in 'Shaders' started by Coresi7, Aug 6, 2017.

  1. Coresi7

    Coresi7

    Joined:
    Mar 10, 2017
    Posts:
    13
    Hello everyone, recently we have optimize some legacy codes, include legacy shaders which we need to use. However these shaders is failed to functional in Unity 2017, and the error message as followings:

    Shader error in 'test': Parse error: syntax error, unexpected TVAL_ID, expecting TOK_SETTEXTURE or '}' at line 11

    We know that fix function shaders is not recommend since Unity 5.x, but these code should be kept for some reason, what could we do?

    The shader code is as following.
    Code (CSharp):
    1. Shader "Tut/Shader/Common/AlphaTest_alpha_0"
    2. {
    3.     Properties {
    4.         _DstTex ("DstTex", 2D) ="white"{}
    5.         _SrcTex ("SrcTex", 2D) ="white"{}
    6.         _CutOff ("Cut Off", Float) =0.5
    7.     }
    8.     SubShader {
    9.         Pass{
    10.             AlphaTest Off
    11.             SetTexture[_DstTex] { combine texture alpha }
    12.         }
    13.         Pass {
    14.             AlphaTest  Always  [_CutOff]
    15.             SetTexture [_SrcTex] { combine texture  alpha }
    16.         }
    17.     }
    18. }
    19.  
     
  2. ImperativeGames

    ImperativeGames

    Joined:
    Dec 11, 2016
    Posts:
    34
    Yeah, I have a lot of similar errors in UFPS and Hazelwood Loft assets... Don't know what to do with that.
     
  3. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    you can just convert them into vert frag though
     
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Just create a new Unity material, and set it to use standard shader. If you play with the settings it can do alpha test and everything you want.