Search Unity

How to make this shader compatible with LWRP ?

Discussion in 'Shaders' started by CraftKontrol, Sep 7, 2019.

  1. CraftKontrol

    CraftKontrol

    Joined:
    Aug 17, 2019
    Posts:
    1
    Hi Guys !

    i'm trying to make this shader compatible with the LWRP, but without succes...
    Is there a solution ? Please give me examples, i'm not a Shader Badass !

    Thank you !

    Code (csharp):
    1. Shader "Custom/Sin Wave" {
    2.     Properties{
    3.         _Tile("Tile", Range(0.0,1.0)) = 0.5
    4.         _Color ("Color", Color) = (1.0,1.0,1.0,0.5)
    5.         _ForegroundColor("Foreground Color", Color) = (1,1,1,0)
    6.         _BackgroundColor("Background Color", Color) = (0,0,0,0)
    7.         _ForegroundMask("Foreground Mask", 2D) = "white" {}
    8.         _ForegroundCutoff("Foreground Cutoff", Range(0,1)) = 0.5
    9.         _BackgroundCutoff("Background Cutoff", Range(0,1)) = 0.5
    10.         _Radius("Radius", Range(0.0,1.0)) = 0.5
    11.     }
    12.         SubShader
    13.         {
    14.             Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
    15.  
    16.             Lighting Off
    17.             LOD 100
    18.             ZWrite Off
    19.             Blend SrcAlpha OneMinusSrcAlpha
    20.             CGPROGRAM
    21.  
    22.             #pragma surface surf Standard alpha:fade
    23.             #pragma target 3.0
    24.  
    25.             sampler2D _ForegroundMask;
    26.             struct Input {
    27.             float2 uv_ForegroundMask;
    28.         };
    29.  
    30.         fixed4 _ForegroundColor;
    31.         fixed4 _BackgroundColor;
    32.         fixed4 _Color;
    33.         half _ForegroundCutoff;
    34.         half _BackgroundCutoff;
    35.         half _Radius;
    36.         half _Tile;
    37.  
    38.         void surf(Input IN, inout SurfaceOutputStandard color:alpha)
    39.         {
    40.  
    41.             fixed x = (-0.5 + IN.uv_ForegroundMask.x) * _Tile;
    42.             fixed y = (-0.5 + IN.uv_ForegroundMask.y) * 2;
    43.             fixed radius = 0.5 + sin(x * 3.1415926535) * _Radius;
    44.             radius -= (0.5 * y + 0.5);
    45.             clip(radius - _BackgroundCutoff);
    46.             clip(_ForegroundCutoff - radius);
    47.             color.Albedo = _Color;
    48.             color.Alpha = _Color.a;
    49.         }
    50.             ENDCG
    51.     }
    52.     FallBack "Unlit/Transparent"
    53.    
    54. }