How to do this shdow

Your feedback is very important to us. We are listening.

How to do this shdow

Postby fishead » Wed Jan 16, 2019 3:42 pm

hey gus, I am a effect worker from china . but i dont a programmer, so i cant understand this code.
But this shadow shader is very nice. it dont need light .
Can some one help me to do this shader in amplify shader editor ? please !
Code: Select all
Shader "Custom/NewShadow" {
   Properties{
   _MainTex("Base (RGB)", 2D) = "white" {}
   //*********************绘制阴影的参数****************************
   _ShadowPlane("Shadow Plane", Vector) = (0,1,0,0.02)
   _ShadowColor("Shadow Color",Color) = (0.2, 0.2, 0.2, 1)
   _ShadowPara("Shadow Param",Vector) = (-0.006,60,3,0.02)
   _lightDirection("LightDir",Vector) = (0,-1,0)
      //*************************************************
   }
      SubShader{
         Tags { "RenderType" = "Opaque" }
         LOD 200

         CGPROGRAM
         #pragma surface surf Lambert

         sampler2D _MainTex;

         struct Input {
            float2 uv_MainTex;
         };

         void surf(Input IN, inout SurfaceOutput o) {
            half4 c = tex2D(_MainTex, IN.uv_MainTex);
            o.Albedo = c.rgb;
            o.Alpha = c.a;
         }
         ENDCG
            Pass{
      CGPROGRAM
         #pragma vertex vert
         #pragma fragment frag
         #pragma target 2.0
         #pragma multi_compile_fog

         #include "UnityCG.cginc"

         struct appdata_t {
            float4 vertex : POSITION;
            float2 texcoord : TEXCOORD0;
            UNITY_VERTEX_INPUT_INSTANCE_ID
         };

         struct v2f {
            float4 vertex : SV_POSITION;
            float2 texcoord : TEXCOORD0;
            UNITY_FOG_COORDS(1)
            UNITY_VERTEX_OUTPUT_STEREO
         };

         sampler2D _MainTex;
         float4 _MainTex_ST;

         v2f vert(appdata_t v)
         {
            v2f o;
            UNITY_SETUP_INSTANCE_ID(v);
            UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
            o.vertex = UnityObjectToClipPos(v.vertex);
            o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
            UNITY_TRANSFER_FOG(o,o.vertex);
            return o;
         }

         fixed4 frag(v2f i) : SV_Target
         {
            fixed4 col = tex2D(_MainTex, i.texcoord);
            UNITY_APPLY_FOG(i.fogCoord, col);
            UNITY_OPAQUE_ALPHA(col.a);
            return col;
         }
            ENDCG
         }
            //*******************绘制阴影的参数pass 只需要在你原来的shader里面加入这个pass就可以绘制出实时阴影了******************************
            pass {
               Tags { "QUEUE" = "Transparent" "RenderType" = "Transparent" }
               ZWrite Off
               Fog { Mode Off }
               Blend SrcAlpha OneMinusSrcAlpha
               CGPROGRAM
               #pragma vertex vert
               #pragma fragment frag
               #include "UnityCG.cginc"
               struct v2f {
                  float4 pos : SV_POSITION;
                  half3 texcord0 : TEXCOORD0;
                  half3 texcord1 : TEXCOORD1;
               };
               uniform fixed4 _ShadowPlane;
               uniform fixed4 _ShadowPara;
               uniform fixed3 _lightDirection;
               uniform fixed4 _ShadowColor;
               v2f vert(appdata_tan v)
               {
                    v2f o;
                    fixed3 vt;
                    vt = mul(unity_ObjectToWorld , v.vertex).xyz;
                    fixed3 tmpvar_3;
                    tmpvar_3 = (vt - (((dot(_ShadowPlane.xyz, vt) - _ShadowPlane.w) / dot(_ShadowPlane.xyz, _lightDirection)) * _lightDirection));
                    fixed4 tmpvar_4;
                    tmpvar_4.w = 1.0;
                    tmpvar_4.xyz = tmpvar_3;
                    o.pos = mul(UNITY_MATRIX_VP , tmpvar_4);
                    o.texcord0 = mul(unity_ObjectToWorld,float4(0, 0, 0, 1));
                    o.texcord1 = tmpvar_3;
                    return o;
               }

               float4 frag(v2f inData) : COLOR
               {
                  fixed3 posToPlane = inData.texcord0 - inData.texcord1;
                  fixed4 f = _ShadowColor;
                  fixed v = pow(1.0 - clamp(((sqrt(dot(posToPlane,posToPlane)) * _ShadowPara.w) - _ShadowPara.x),0,1),_ShadowPara.y) * _ShadowPara.z;
                  f.w = v * _ShadowColor.a;
                  return f;
               }
               ENDCG
            }
         //*************************************************

   }
      FallBack "Diffuse"
}

ANY ONE can help me ????
sry ,my english is very poor~
fishead
 
Posts: 1
Joined: Wed Jan 16, 2019 3:33 pm

Re: How to do this shdow

Postby Amplify_Borba » Wed Jan 16, 2019 4:07 pm

Hello, thank you for getting in touch and for your support!

Our forum is mostly aimed at technical support, shader conversion is outside of the scope of our support as we don't have the resources to assist users in this manner, and I don't think you'll get many answers here from other users.

As such, I recommend posting on the official shader section of the unity forum, apologies for the inconvenience.
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests

cron