DESKTOP-FB72PO8\Administrator hai 5 días
pai
achega
87601a9fb5
Modificáronse 1 ficheiros con 14 adicións e 7 borrados
  1. 14 7
      Assets/Art/ParallaxCloud/Shader/ParallaxCloud.shader

+ 14 - 7
Assets/Art/ParallaxCloud/Shader/ParallaxCloud.shader

@@ -3,6 +3,7 @@ Shader "Custom/ParallaxCloud"
     Properties
     {
         _MainTex ("BaseMap:基础贴图", 2D) = "white" {}
+//        _TurbulenceTex ("turbulence:扰动图", 2D) = "white" {}
         _Color ("Color:颜色", Color) = (0.0, 0.0, 0.0, 1.0)
         _ParallaxSize ("ParallaxSize:视差映射强度", Range(0.0, 0.1)) = 0.0
         _ParallaxLayers ("ParallaxLayers:视差映射层数", Range(1.0, 50.0)) = 20
@@ -67,7 +68,10 @@ Shader "Custom/ParallaxCloud"
             SAMPLER(sampler_NormalTex);
             TEXTURE2D(_ParallaxTex);
             SAMPLER(sampler_ParallaxTex);
+
             sampler2D _CameraDepthTexture;
+            // TEXTURE2D(_TurbulenceTex);
+            // SAMPLER(sampler_TurbulenceTex);
 
             Varyings vert(Attributes v)
             {
@@ -78,8 +82,8 @@ Shader "Custom/ParallaxCloud"
                 o.tDirWS = normalize(TransformObjectToWorld(v.tangent.xyz));
                 o.bDirWS = normalize(cross(o.nDirWS, o.tDirWS) * v.tangent.w);
                 // o.uv.xy = TRANSFORM_TEX(v.uv, _MainTex) + float2(frac(_Time.y * _MoveSpeed), 0.0);
-                 o.uv.xy=  o.positionWS.xz*0.06+ float2(frac(_Time.y * _MoveSpeed), 0.0);
-                o.uv.zw = v.uv;
+                o.uv.xy = o.positionWS.xz * 0.06 + float2(frac(_Time.y * _MoveSpeed), 0.0);
+                o.uv.zw =  o.positionWS.xz * 0.02;
                 o.screenPos = ComputeScreenPos(o.positionCS);
                 return o;
             }
@@ -127,17 +131,20 @@ Shader "Custom/ParallaxCloud"
                 dist = dist * 0.2;
                 dist = clamp(dist, 0, 1);
 
-                float ptcpos=length(i.positionWS-_WorldSpaceCameraPos);
-                ptcpos= 1-(ptcpos-100)/50;
-                ptcpos=clamp(ptcpos,0,1);
+                float ptcpos = length(i.positionWS - _WorldSpaceCameraPos);
+                ptcpos = 1 - (ptcpos - 100) / 50;
+                ptcpos = clamp(ptcpos, 0, 1);
                 //Light mylight = GetMainLight();
                 //half3 light = mylight.color;
                 float3x3 TBN = float3x3(i.tDirWS, i.bDirWS, i.nDirWS);
                 float3 vDir = normalize(i.positionWS - _WorldSpaceCameraPos.xyz);
                 float3 vDirTS = mul(TBN, vDir);
-
+                // float2 raoDongUv = SAMPLE_TEXTURE2D(_TurbulenceTex, sampler_TurbulenceTex,i.positionWS.xz * 0.06).r*0.1;
+                // i.uv.xy += raoDongUv;
+                // i.uv.zw += raoDongUv;
                 float3 var_MainTex = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv.zw).rgb;
 
+
                 half2 offset = 0.0;
                 half currentDepth = 0.0;
                 half parallaxDepth = 0.0;
@@ -163,7 +170,7 @@ Shader "Custom/ParallaxCloud"
 
                 half3 finalColor = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv.xy).rgb * var_MainTex.rgb;
                 float alphaTex = max(var_MainTex.r * finalColor.r, 0.0);
-                half alpha = max(pow(abs(lerp(alphaTex, 1.0, _Alpha)), _AlphaExtent), 0.0) * _Alpha * dist*ptcpos;
+                half alpha = max(pow(abs(lerp(alphaTex, 1.0, _Alpha)), _AlphaExtent), 0.0) * _Alpha * dist * ptcpos;
                 return half4(finalColor * _Color.rgb, alpha);
             }
             ENDHLSL