Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Shader Issues

Discussion in 'Scripting' started by Camronas, Mar 12, 2018.

  1. Camronas

    Camronas

    Joined:
    Apr 20, 2012
    Posts:
    154
    Hey everyone,

    A friend of mine made this Shader for me years ago and I wanted to use it again in one of my projects. Well it would appear Unity has updated or something because it no longer works and throws me errors instead.

    I have never worked in Shaders before and have literally no idea where to even start.

    Here is the code in full:
    Code (CSharp):
    1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
    2.  
    3. /************************************************************************************************************************/
    4.  
    5. Shader "Kybernetik/Transparent Dual Scrolling Textures"
    6. {
    7.     /************************************************************************************************************************/
    8.  
    9.     Properties
    10.     {
    11.         _Colour("Colour", Color) = (1,1,1,1)
    12.         _Diffuse1("Diffuse 1", 2D) = "white" {}
    13.         _Movement1("Movement 1", Vector) = (0,0,0,0)
    14.         _Diffuse2("Diffuse 2", 2D) = "white" {}
    15.         _Movement2("Movement 2", Vector) = (0,0,0,0)
    16.     }
    17.    
    18.     /************************************************************************************************************************/
    19.    
    20.     Category
    21.     {
    22.         /************************************************************************************************************************/
    23.  
    24.         Tags
    25.         {
    26.             "Queue" = "Transparent"
    27.             "IgnoreProjector" = "True"
    28.             "RenderType" = "Transparent"
    29.         }
    30.  
    31.         LOD 200
    32.  
    33.         Blend SrcAlpha OneMinusSrcAlpha
    34.         ZWrite Off
    35.         Lighting Off
    36.  
    37.         /************************************************************************************************************************/
    38.  
    39.         SubShader
    40.         {
    41.             /************************************************************************************************************************/
    42.        
    43.             Pass
    44.             {
    45.  
    46.                 /************************************************************************************************************************/
    47.  
    48.                 LOD 200
    49.                
    50.                 CGPROGRAM
    51.        
    52.                 #include "UnityCG.cginc"
    53.                 #pragma vertex VertexProgram
    54.                 #pragma fragment FragmentProgram
    55.  
    56.                 fixed4 _Colour;
    57.                 sampler2D _Diffuse1;
    58.                 fixed4 _Movement1;
    59.                 sampler2D _Diffuse2;
    60.                 fixed4 _Movement2;
    61.        
    62.                 /************************************************************************************************************************/
    63.  
    64.                 struct VertexOutput
    65.                 {
    66.                     float4 position : SV_POSITION;
    67.                     float2 texcoord1;
    68.                     float2 texcoord2;
    69.                 };
    70.            
    71.                 VertexOutput VertexProgram(appdata_full v)
    72.                 {
    73.                     VertexOutput output;
    74.                     output.position = UnityObjectToClipPos(v.vertex);
    75.                     output.texcoord1 = v.texcoord.xy + _Movement1 * _Time.y;
    76.                     output.texcoord2 = v.texcoord.xy + _Movement2 * _Time.y;
    77.                     return output;
    78.                 }
    79.  
    80.                 half4 FragmentProgram(VertexOutput input) : COLOR
    81.                 {
    82.                     float4 colour = (tex2D(_Diffuse1, input.texcoord1) + tex2D(_Diffuse2, input.texcoord2)) * 0.5f * _Colour;
    83.                     return colour;
    84.                 }
    85.            
    86.                 /************************************************************************************************************************/
    87.  
    88.                 ENDCG
    89.             }
    90.         }
    91.     }
    92.  
    93.     /************************************************************************************************************************/
    94.  
    95.     FallBack "Diffuse"
    96.        
    97.     /************************************************************************************************************************/
    98. }
    What it is meant to do is have 2 textures with transparency scrolling in specified directions and speeds.

    The errors I am getting are:
    and:
    Thanks in advance for any and all help!
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
    try
    Code (CSharp):
    1.                     struct VertexOutput
    2.                     {
    3.                         float4 position : SV_POSITION;
    4.                         float2 texcoord1 : TEXCOORD0;
    5.                         float2 texcoord2 : TEXCOORD1;
    6.                     };

    https://docs.unity3d.com/Manual/SL-ShaderSemantics.html
     
  3. Camronas

    Camronas

    Joined:
    Apr 20, 2012
    Posts:
    154
    You are amazing! Thank you so much!
     
  4. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350