1
\$\begingroup\$

I try to make a curved shader with shadow effect I got a existing curved shader in github and it has no shadow effect i try to modify it but i couldn't find any appropriate solution.

The shaderor helping script link: https://gist.github.com/g0ody/5550039

Curved.shader:

Shader "Platogo/Curved" { Properties { _MainTex ("Base (RGB)", 2D) = "white" {} _QOffset ("Offset", Vector) = (0,0,0,0) _Dist ("Distance", Float) = 100.0 } SubShader { Tags { "RenderType"="Opaque" } Pass { Lighting Off

        CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag
        #include "UnityCG.cginc"

        sampler2D _MainTex;
        float4 _QOffset;
        float _Dist;
        uniform float4 _MainTex_ST;

        struct v2f {
    float4 pos : SV_POSITION;
    float2 uv : TEXCOORD0;
        };

        v2f vert (appdata_base v)
        {
    v2f o;
    float4 vPos = mul (UNITY_MATRIX_MV, v.vertex);
    float zOff = vPos.z/_Dist;
    vPos += _QOffset*zOff*zOff;
    o.pos = mul (UNITY_MATRIX_P, vPos);
    o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
    return o;
        }

        half4 frag (v2f i) : COLOR
        {
          return tex2D(_MainTex, i.uv);
        }
        ENDCG
    }
}
FallBack "Mobil/Unlit"

}

CurvedAlpha.shader

Shader "Platogo/CurvedAlpha" { Properties { _MainTex ("Base (RGB)", 2D) = "white" {} _QOffset ("Offset", Vector) = (0,0,0,0) _Dist ("Distance", Float) = 100.0 _Alpha ("Alpha", Range(0.0,1.0)) = 1.0 } SubShader { Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} LOD 100

    ZWrite On
    Blend SrcAlpha OneMinusSrcAlpha 

    Pass
    {
        Lighting Off

        CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag
        #include "UnityCG.cginc"

        sampler2D _MainTex;
        float4 _QOffset;
        float _Dist;
        float _Alpha;
        uniform float4 _MainTex_ST;

        struct v2f {
            float4 pos : SV_POSITION;
            float2 uv : TEXCOORD0;
        };

        v2f vert (appdata_base v)
        {
            v2f o;
            float4 vPos = mul (UNITY_MATRIX_MV, v.vertex);
            float zOff = vPos.z/_Dist;
            vPos += _QOffset*zOff*zOff;
            o.pos = mul (UNITY_MATRIX_P, vPos);
            o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
            return o;
        }

        half4 frag (v2f i) : COLOR
        {
            return tex2D(_MainTex, i.uv) * float4(1,1,1,_Alpha);
        }
        ENDCG
    }
}

FallBack "Platogo/Unlit Texture Alpha" }

Sample of what i need

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.