用ASE制作地表积水效果

unity引擎制作实时刷下雨地面效果

  大家好,我是阿赵。
  之前在Unity引擎做了几种不同的效果,比如视差偏移、下雨效果、顶点颜色工具等。这一篇文章,将会把这几个效果合并在一起,做出一个混合积水地表的效果。这个几个shader的基础写法在之前都已经给过,这里换一下方式,使用ASE编辑器来做这个Shader。

一、效果介绍

  这个例子的效果大概是这样的:
  首先有一个凹凸感比较明显的地表:
在这里插入图片描述

  然后打开之前做的刷顶点颜色的攻击。为了能让笔刷刷下去之后,地表立刻改变,所以我这里加了一个是否绘制完立刻保存的选项。
  先刷了R通道,可以看到地表出现了湿润的感觉。
在这里插入图片描述

  再刷G通道,可以看到,地表出现了积水,然后积水的地方还有雨滴效果
在这里插入图片描述

  放大看,是这种效果:
在这里插入图片描述

二、ASE节点编辑

  如果不用PBR材质,水的质感不会那么好,所以我这里的光照模型是用过了PBR的。之前没有怎么介绍过ASE(AmplifyShaderEditor)的用法,我这里直接用了ASE工具来编辑这个Shader。

1、世界顶点坐标的计算

在这里插入图片描述

  这个连线很简单,把WorldPosition的xz值保存起来,起名叫做worldPosXZ

2、高度图采样

在这里插入图片描述

  由于后面有多个地方需要用到高度图,所以先保存一个结果

3、视差偏移的计算

在这里插入图片描述

  这里是效果的重点,地面的凹凸这么明显,其实是依赖了这个ParallaxOcclusionMapping技术,中文叫做视差遮挡偏移。里面用到几个参数,包括了刚才计算的worldPosXZ,还有高度图。最后输出了一个新的采样UV,我命名为worldUV。

4、地表法线计算

在这里插入图片描述

用worldUV采样地表的法线贴图,得到一个地表法线值。

5、下雨法线计算

在这里插入图片描述

  下雨的法线,之前已经介绍过了,用worldPosXZ乘以平铺次数,再Fract,得到的uv,再加上行列数,播放速度,传入Flipbook UV Animation节点里面,得到的UV坐标采样雨点的法线序列图。

6、顶点颜色定义

在这里插入图片描述

  由于需要混合多种效果,我打算利用顶点色的R通道和G通道。所以这里需要到顶点色。但单纯是顶点色会感觉没那么好看,所以先用worldUV采样高度图,然后通过HeightLerp节点混合顶点色和高度图,得到了R通道值和G通道值。

7、基础颜色混合

在这里插入图片描述

  用worldUV采样地表砖块的基础颜色贴图,然后和一个黑色做Lerp插值,然后再通过刚才计算的R通道顶点色值再做一次Lerp插值。得到的效果就是,如果R通道的值越大,地表的颜色就显得越深,好像是湿了一样。

8、法线混合

在这里插入图片描述

  把刚才计算的地表法线和雨点法线,通过G通道顶点色做Lerp插值,得到了一个不同位置凹凸感不一样的效果,G通道的值越大,就越接近雨滴效果。

9、光滑度混合

在这里插入图片描述

  这一步其实不是很必要,我自己按照自己喜好加的,默认的光滑度变低,然后让光滑度随着之前的地表湿润程度R通道增大而增大。

10、最终输出

在这里插入图片描述

  把刚才算好的结果,输入到各自的通道就行了。
  最终整个Shader编辑完成
在这里插入图片描述

三、源码

  这里贴出的是ASE生成的Shader代码,有安装ASE的朋友可以复制过去,应该就可以在ASE里面打开了。

// Made with Amplify Shader Editor
// Available at the Unity Asset Store - http://u3d.as/y3X 
Shader "ASEWaterGround"
{
	Properties
	{
		_groundTiling("groundTiling", Vector) = (1,1,0,0)
		_heightTex("heightTex", 2D) = "white" {}
		_scale("scale", Float) = 1
		_ref("ref", Float) = 1
		_baseTex("baseTex", 2D) = "white" {}
		_groundNormalTex("groundNormalTex", 2D) = "bump" {}
		_blend("blend", Range( 0 , 1)) = 0
		_roughnessTex("roughnessTex", 2D) = "white" {}
		_pColor("pColor", Color) = (0,0,0,0)
		_depth("depth", Range( 0 , 1)) = 0
		_col("col", Float) = 1
		_speed("speed", Float) = 25
		_row("row", Float) = 1
		_rainNormalTex("rainNormalTex", 2D) = "white" {}
		_rainTiling("rainTiling", Float) = 1
		_roughVal("roughVal", Float) = 0.2
		_groundNormalScale("groundNormalScale", Float) = 1
		_rainNormalScale("rainNormalScale", Float) = 1
		[HideInInspector] _texcoord( "", 2D ) = "white" {}
		[HideInInspector] __dirty( "", Int ) = 1
	}

	SubShader
	{
		Tags{ "RenderType" = "Opaque"  "Queue" = "Geometry+0" "IsEmissive" = "true"  }
		Cull Back
		CGINCLUDE
		#include "UnityStandardUtils.cginc"
		#include "UnityPBSLighting.cginc"
		#include "Lighting.cginc"
		#pragma target 3.0
		#ifdef UNITY_PASS_SHADOWCASTER
			#undef INTERNAL_DATA
			#undef WorldReflectionVector
			#undef WorldNormalVector
			#define INTERNAL_DATA half3 internalSurfaceTtoW0; half3 internalSurfaceTtoW1; half3 internalSurfaceTtoW2;
			#define WorldReflectionVector(data,normal) reflect (data.worldRefl, half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal)))
			#define WorldNormalVector(data,normal) half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal))
		#endif
		struct Input
		{
			float3 worldPos;
			float3 viewDir;
			INTERNAL_DATA
			float3 worldNormal;
			float4 vertexColor : COLOR;
			float2 uv_texcoord;
		};

		uniform sampler2D _groundNormalTex;
		uniform float2 _groundTiling;
		uniform sampler2D _heightTex;
		uniform float _scale;
		uniform float _ref;
		uniform float4 _heightTex_ST;
		uniform float _groundNormalScale;
		uniform sampler2D _rainNormalTex;
		uniform float _rainTiling;
		uniform float _col;
		uniform float _row;
		uniform float _speed;
		uniform float _rainNormalScale;
		uniform float _blend;
		uniform sampler2D _baseTex;
		uniform float4 _pColor;
		uniform float _depth;
		uniform sampler2D _roughnessTex;
		SamplerState sampler_roughnessTex;
		uniform float4 _roughnessTex_ST;
		uniform float _roughVal;


		inline float2 POM( sampler2D heightMap, float2 uvs, float2 dx, float2 dy, float3 normalWorld, float3 viewWorld, float3 viewDirTan, int minSamples, int maxSamples, float parallax, float refPlane, float2 tilling, float2 curv, int index )
		{
			float3 result = 0;
			int stepIndex = 0;
			int numSteps = ( int )lerp( (float)maxSamples, (float)minSamples, saturate( dot( normalWorld, viewWorld ) ) );
			float layerHeight = 1.0 / numSteps;
			float2 plane = parallax * ( viewDirTan.xy / viewDirTan.z );
			uvs.xy += refPlane * plane;
			float2 deltaTex = -plane * layerHeight;
			float2 prevTexOffset = 0;
			float prevRayZ = 1.0f;
			float prevHeight = 0.0f;
			float2 currTexOffset = deltaTex;
			float currRayZ = 1.0f - layerHeight;
			float currHeight = 0.0f;
			float intersection = 0;
			float2 finalTexOffset = 0;
			while ( stepIndex < numSteps + 1 )
			{
			 	currHeight = tex2Dgrad( heightMap, uvs + currTexOffset, dx, dy ).r;
			 	if ( currHeight > currRayZ )
			 	{
			 	 	stepIndex = numSteps + 1;
			 	}
			 	else
			 	{
			 	 	stepIndex++;
			 	 	prevTexOffset = currTexOffset;
			 	 	prevRayZ = currRayZ;
			 	 	prevHeight = currHeight;
			 	 	currTexOffset += deltaTex;
			 	 	currRayZ -= layerHeight;
			 	}
			}
			int sectionSteps = 4;
			int sectionIndex = 0;
			float newZ = 0;
			float newHeight = 0;
			while ( sectionIndex < sectionSteps )
			{
			 	intersection = ( prevHeight - prevRayZ ) / ( prevHeight - currHeight + currRayZ - prevRayZ );
			 	finalTexOffset = prevTexOffset + intersection * deltaTex;
			 	newZ = prevRayZ - intersection * layerHeight;
			 	newHeight = tex2Dgrad( heightMap, uvs + finalTexOffset, dx, dy ).r;
			 	if ( newHeight > newZ )
			 	{
			 	 	currTexOffset = finalTexOffset;
			 	 	currHeight = newHeight;
			 	 	currRayZ = newZ;
			 	 	deltaTex = intersection * deltaTex;
			 	 	layerHeight = intersection * layerHeight;
			 	}
			 	else
			 	{
			 	 	prevTexOffset = finalTexOffset;
			 	 	prevHeight = newHeight;
			 	 	prevRayZ = newZ;
			 	 	deltaTex = ( 1 - intersection ) * deltaTex;
			 	 	layerHeight = ( 1 - intersection ) * layerHeight;
			 	}
			 	sectionIndex++;
			}
			return uvs.xy + finalTexOffset;
		}


		void surf( Input i , inout SurfaceOutputStandard o )
		{
			float3 ase_worldPos = i.worldPos;
			float2 worldPosXZ65 = (ase_worldPos).xz;
			float3 ase_worldNormal = WorldNormalVector( i, float3( 0, 0, 1 ) );
			float3 ase_worldViewDir = normalize( UnityWorldSpaceViewDir( ase_worldPos ) );
			float2 OffsetPOM1 = POM( _heightTex, ( worldPosXZ65 * _groundTiling ), ddx(( worldPosXZ65 * _groundTiling )), ddy(( worldPosXZ65 * _groundTiling )), ase_worldNormal, ase_worldViewDir, i.viewDir, 8, 8, _scale, _ref, _heightTex_ST.xy, float2(0,0), 0 );
			float2 worldUV30 = OffsetPOM1;
			float3 groundNormalVal72 = UnpackScaleNormal( tex2D( _groundNormalTex, worldUV30 ), _groundNormalScale );
			// *** BEGIN Flipbook UV Animation vars ***
			// Total tiles of Flipbook Texture
			float fbtotaltiles41 = _col * _row;
			// Offsets for cols and rows of Flipbook Texture
			float fbcolsoffset41 = 1.0f / _col;
			float fbrowsoffset41 = 1.0f / _row;
			// Speed of animation
			float fbspeed41 = _Time[ 1 ] * _speed;
			// UV Tiling (col and row offset)
			float2 fbtiling41 = float2(fbcolsoffset41, fbrowsoffset41);
			// UV Offset - calculate current tile linear index, and convert it to (X * coloffset, Y * rowoffset)
			// Calculate current tile linear index
			float fbcurrenttileindex41 = round( fmod( fbspeed41 + 0.0, fbtotaltiles41) );
			fbcurrenttileindex41 += ( fbcurrenttileindex41 < 0) ? fbtotaltiles41 : 0;
			// Obtain Offset X coordinate from current tile linear index
			float fblinearindextox41 = round ( fmod ( fbcurrenttileindex41, _col ) );
			// Multiply Offset X by coloffset
			float fboffsetx41 = fblinearindextox41 * fbcolsoffset41;
			// Obtain Offset Y coordinate from current tile linear index
			float fblinearindextoy41 = round( fmod( ( fbcurrenttileindex41 - fblinearindextox41 ) / _col, _row ) );
			// Reverse Y to get tiles from Top to Bottom
			fblinearindextoy41 = (int)(_row-1) - fblinearindextoy41;
			// Multiply Offset Y by rowoffset
			float fboffsety41 = fblinearindextoy41 * fbrowsoffset41;
			// UV Offset
			float2 fboffset41 = float2(fboffsetx41, fboffsety41);
			// Flipbook UV
			half2 fbuv41 = frac( ( worldPosXZ65 * _rainTiling ) ) * fbtiling41 + fboffset41;
			// *** END Flipbook UV Animation vars ***
			float3 rainNormalVal69 = UnpackScaleNormal( tex2D( _rainNormalTex, fbuv41 ), _rainNormalScale );
			float temp_output_10_0_g4 = _blend;
			float4 tex2DNode17 = tex2D( _heightTex, worldUV30 );
			float clampResult8_g4 = clamp( ( ( tex2DNode17.r - 1.0 ) + ( i.vertexColor.g * 2.0 ) ) , 0.0 , 1.0 );
			float lerpResult12_g4 = lerp( ( 0.0 - temp_output_10_0_g4 ) , ( temp_output_10_0_g4 + 1.0 ) , clampResult8_g4);
			float clampResult13_g4 = clamp( lerpResult12_g4 , 0.0 , 1.0 );
			float gVal26 = clampResult13_g4;
			float3 lerpResult48 = lerp( groundNormalVal72 , rainNormalVal69 , gVal26);
			float3 normalBlendVal80 = lerpResult48;
			o.Normal = normalBlendVal80;
			float4 tex2DNode13 = tex2D( _baseTex, worldUV30 );
			float4 lerpResult33 = lerp( tex2DNode13 , _pColor , _depth);
			float temp_output_10_0_g3 = _blend;
			float clampResult8_g3 = clamp( ( ( tex2DNode17.r - 1.0 ) + ( i.vertexColor.r * 2.0 ) ) , 0.0 , 1.0 );
			float lerpResult12_g3 = lerp( ( 0.0 - temp_output_10_0_g3 ) , ( temp_output_10_0_g3 + 1.0 ) , clampResult8_g3);
			float clampResult13_g3 = clamp( lerpResult12_g3 , 0.0 , 1.0 );
			float rVal25 = clampResult13_g3;
			float4 lerpResult35 = lerp( tex2DNode13 , lerpResult33 , rVal25);
			float4 baseColorBlend83 = lerpResult35;
			o.Emission = baseColorBlend83.rgb;
			float2 uv_roughnessTex = i.uv_texcoord * _roughnessTex_ST.xy + _roughnessTex_ST.zw;
			float4 tex2DNode29 = tex2D( _roughnessTex, uv_roughnessTex );
			float lerpResult56 = lerp( ( tex2DNode29.r * _roughVal ) , tex2DNode29.r , rVal25);
			float smoothnessBlend86 = lerpResult56;
			o.Smoothness = smoothnessBlend86;
			o.Alpha = 1;
		}

		ENDCG
		CGPROGRAM
		#pragma surface surf Standard keepalpha fullforwardshadows 

		ENDCG
		Pass
		{
			Name "ShadowCaster"
			Tags{ "LightMode" = "ShadowCaster" }
			ZWrite On
			CGPROGRAM
			#pragma vertex vert
			#pragma fragment frag
			#pragma target 3.0
			#pragma multi_compile_shadowcaster
			#pragma multi_compile UNITY_PASS_SHADOWCASTER
			#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
			#include "HLSLSupport.cginc"
			#if ( SHADER_API_D3D11 || SHADER_API_GLCORE || SHADER_API_GLES || SHADER_API_GLES3 || SHADER_API_METAL || SHADER_API_VULKAN )
				#define CAN_SKIP_VPOS
			#endif
			#include "UnityCG.cginc"
			#include "Lighting.cginc"
			#include "UnityPBSLighting.cginc"
			struct v2f
			{
				V2F_SHADOW_CASTER;
				float2 customPack1 : TEXCOORD1;
				float4 tSpace0 : TEXCOORD2;
				float4 tSpace1 : TEXCOORD3;
				float4 tSpace2 : TEXCOORD4;
				half4 color : COLOR0;
				UNITY_VERTEX_INPUT_INSTANCE_ID
				UNITY_VERTEX_OUTPUT_STEREO
			};
			v2f vert( appdata_full v )
			{
				v2f o;
				UNITY_SETUP_INSTANCE_ID( v );
				UNITY_INITIALIZE_OUTPUT( v2f, o );
				UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o );
				UNITY_TRANSFER_INSTANCE_ID( v, o );
				Input customInputData;
				float3 worldPos = mul( unity_ObjectToWorld, v.vertex ).xyz;
				half3 worldNormal = UnityObjectToWorldNormal( v.normal );
				half3 worldTangent = UnityObjectToWorldDir( v.tangent.xyz );
				half tangentSign = v.tangent.w * unity_WorldTransformParams.w;
				half3 worldBinormal = cross( worldNormal, worldTangent ) * tangentSign;
				o.tSpace0 = float4( worldTangent.x, worldBinormal.x, worldNormal.x, worldPos.x );
				o.tSpace1 = float4( worldTangent.y, worldBinormal.y, worldNormal.y, worldPos.y );
				o.tSpace2 = float4( worldTangent.z, worldBinormal.z, worldNormal.z, worldPos.z );
				o.customPack1.xy = customInputData.uv_texcoord;
				o.customPack1.xy = v.texcoord;
				TRANSFER_SHADOW_CASTER_NORMALOFFSET( o )
				o.color = v.color;
				return o;
			}
			half4 frag( v2f IN
			#if !defined( CAN_SKIP_VPOS )
			, UNITY_VPOS_TYPE vpos : VPOS
			#endif
			) : SV_Target
			{
				UNITY_SETUP_INSTANCE_ID( IN );
				Input surfIN;
				UNITY_INITIALIZE_OUTPUT( Input, surfIN );
				surfIN.uv_texcoord = IN.customPack1.xy;
				float3 worldPos = float3( IN.tSpace0.w, IN.tSpace1.w, IN.tSpace2.w );
				half3 worldViewDir = normalize( UnityWorldSpaceViewDir( worldPos ) );
				surfIN.viewDir = IN.tSpace0.xyz * worldViewDir.x + IN.tSpace1.xyz * worldViewDir.y + IN.tSpace2.xyz * worldViewDir.z;
				surfIN.worldPos = worldPos;
				surfIN.worldNormal = float3( IN.tSpace0.z, IN.tSpace1.z, IN.tSpace2.z );
				surfIN.internalSurfaceTtoW0 = IN.tSpace0.xyz;
				surfIN.internalSurfaceTtoW1 = IN.tSpace1.xyz;
				surfIN.internalSurfaceTtoW2 = IN.tSpace2.xyz;
				surfIN.vertexColor = IN.color;
				SurfaceOutputStandard o;
				UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandard, o )
				surf( surfIN, o );
				#if defined( CAN_SKIP_VPOS )
				float2 vpos = IN.pos;
				#endif
				SHADOW_CASTER_FRAGMENT( IN )
			}
			ENDCG
		}
	}
	Fallback "Diffuse"
	CustomEditor "ASEMaterialInspector"
}
/*ASEBEGIN
Version=18500
0;0;1920;1019;2715.25;1678.37;1;True;True
Node;AmplifyShaderEditor.CommentaryNode;68;-4261.146,-1310.134;Inherit;False;599.3811;233;WorldPosXZ;3;2;3;65;WorldPosXZ;1,1,1,1;0;0
Node;AmplifyShaderEditor.WorldPosInputsNode;2;-4211.146,-1260.134;Inherit;False;0;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3
Node;AmplifyShaderEditor.SwizzleNode;3;-4026.887,-1257.968;Inherit;False;FLOAT2;0;2;2;3;1;0;FLOAT3;0,0,0;False;1;FLOAT2;0
Node;AmplifyShaderEditor.CommentaryNode;77;-4289.755,-861.7321;Inherit;False;579.1816;280;Comment;2;9;59;HeightTex;1,1,1,1;0;0
Node;AmplifyShaderEditor.RegisterLocalVarNode;65;-3885.765,-1256.464;Inherit;False;worldPosXZ;-1;True;1;0;FLOAT2;0,0;False;1;FLOAT2;0
Node;AmplifyShaderEditor.TexturePropertyNode;9;-4239.756,-811.7321;Inherit;True;Property;_heightTex;heightTex;1;0;Create;True;0;0;False;0;False;None;95664866b70aee84ba32b0c9a54451e2;False;white;Auto;Texture2D;-1;0;2;SAMPLER2D;0;SAMPLERSTATE;1
Node;AmplifyShaderEditor.CommentaryNode;78;-4455.765,-268.7075;Inherit;False;976.8647;665.7678;ParallaxOcclusionMapping;9;5;6;1;67;75;11;10;12;30;ParallaxOcclusionMapping;1,1,1,1;0;0
Node;AmplifyShaderEditor.GetLocalVarNode;67;-4405.765,-218.7075;Inherit;False;65;worldPosXZ;1;0;OBJECT;;False;1;FLOAT2;0
Node;AmplifyShaderEditor.RegisterLocalVarNode;59;-3934.578,-774.3611;Inherit;False;heightTexVal;-1;True;1;0;SAMPLER2D;;False;1;SAMPLER2D;0
Node;AmplifyShaderEditor.Vector2Node;5;-4403.4,-132.2613;Inherit;False;Property;_groundTiling;groundTiling;0;0;Create;True;0;0;False;0;False;1,1;2,2;0;3;FLOAT2;0;FLOAT;1;FLOAT;2
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;6;-4206.425,-161.6577;Inherit;False;2;2;0;FLOAT2;0,0;False;1;FLOAT2;0,0;False;1;FLOAT2;0
Node;AmplifyShaderEditor.RangedFloatNode;12;-4057.774,230.061;Inherit;False;Property;_ref;ref;3;0;Create;True;0;0;False;0;False;1;0;0;0;0;1;FLOAT;0
Node;AmplifyShaderEditor.GetLocalVarNode;75;-4217.452,16.21494;Inherit;False;59;heightTexVal;1;0;OBJECT;;False;1;SAMPLER2D;0
Node;AmplifyShaderEditor.CommentaryNode;71;-2970.312,-1359.645;Inherit;False;1750.331;403.1255;RainNormal;11;42;37;40;43;41;64;69;44;46;66;45;RainNormal;1,1,1,1;0;0
Node;AmplifyShaderEditor.ViewDirInputsCoordNode;11;-4315.974,209.0607;Inherit;False;Tangent;False;0;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3
Node;AmplifyShaderEditor.RangedFloatNode;10;-4273.474,112.5602;Inherit;False;Property;_scale;scale;2;0;Create;True;0;0;False;0;False;1;-0.01;0;0;0;1;FLOAT;0
Node;AmplifyShaderEditor.ParallaxOcclusionMappingNode;1;-3924.296,-24.45464;Inherit;False;0;8;False;-1;16;False;-1;4;0.02;0;False;1,1;False;0,0;7;0;FLOAT2;0,0;False;1;SAMPLER2D;;False;2;FLOAT;0.02;False;3;FLOAT3;0,0,0;False;4;FLOAT;0;False;5;FLOAT2;0,0;False;6;FLOAT;0;False;1;FLOAT2;0
Node;AmplifyShaderEditor.GetLocalVarNode;66;-2920.312,-1297.915;Inherit;False;65;worldPosXZ;1;0;OBJECT;;False;1;FLOAT2;0
Node;AmplifyShaderEditor.RangedFloatNode;45;-2830.445,-1212.29;Inherit;False;Property;_rainTiling;rainTiling;14;0;Create;True;0;0;False;0;False;1;5;0;0;0;1;FLOAT;0
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;46;-2638.089,-1296.725;Inherit;False;2;2;0;FLOAT2;0,0;False;1;FLOAT;0;False;1;FLOAT2;0
Node;AmplifyShaderEditor.CommentaryNode;79;-2977.709,-251.7889;Inherit;False;1223.207;650.2081;VertexColor;9;22;18;17;16;21;76;25;23;26;VertexColor;1,1,1,1;0;0
Node;AmplifyShaderEditor.RegisterLocalVarNode;30;-3694.966,-10.05673;Inherit;False;worldUV;-1;True;1;0;FLOAT2;0,0;False;1;FLOAT2;0
Node;AmplifyShaderEditor.RangedFloatNode;40;-2360.534,-1236.611;Inherit;False;Property;_col;col;10;0;Create;True;0;0;False;0;False;1;4;0;0;0;1;FLOAT;0
Node;AmplifyShaderEditor.GetLocalVarNode;21;-2927.709,-114.2687;Inherit;False;30;worldUV;1;0;OBJECT;;False;1;FLOAT2;0
Node;AmplifyShaderEditor.FractNode;37;-2475.998,-1309.645;Inherit;False;1;0;FLOAT2;0,0;False;1;FLOAT2;0
Node;AmplifyShaderEditor.RangedFloatNode;42;-2359.974,-1146.519;Inherit;False;Property;_row;row;12;0;Create;True;0;0;False;0;False;1;4;0;0;0;1;FLOAT;0
Node;AmplifyShaderEditor.CommentaryNode;74;-2984.073,-801.1234;Inherit;False;997.9521;280;GroundNormal;4;72;14;31;63;GroundNormal;1,1,1,1;0;0
Node;AmplifyShaderEditor.RangedFloatNode;43;-2353.974,-1072.519;Inherit;False;Property;_speed;speed;11;0;Create;True;0;0;False;0;False;25;25;0;0;0;1;FLOAT;0
Node;AmplifyShaderEditor.GetLocalVarNode;76;-2917.33,-200.6836;Inherit;False;59;heightTexVal;1;0;OBJECT;;False;1;SAMPLER2D;0
Node;AmplifyShaderEditor.VertexColorNode;18;-2668.394,44.2112;Inherit;False;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
Node;AmplifyShaderEditor.TFHCFlipBookUVAnimation;41;-2085.974,-1301.52;Inherit;False;0;0;6;0;FLOAT2;0,0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;4;FLOAT;0;False;5;FLOAT;0;False;3;FLOAT2;0;FLOAT;1;FLOAT;2
Node;AmplifyShaderEditor.GetLocalVarNode;31;-2934.073,-744.1212;Inherit;False;30;worldUV;1;0;OBJECT;;False;1;FLOAT2;0
Node;AmplifyShaderEditor.RangedFloatNode;22;-2719.71,282.4193;Inherit;False;Property;_blend;blend;6;0;Create;True;0;0;False;0;False;0;0.115;0;1;0;1;FLOAT;0
Node;AmplifyShaderEditor.RangedFloatNode;64;-2013.828,-1086.708;Inherit;False;Property;_rainNormalScale;rainNormalScale;17;0;Create;True;0;0;False;0;False;1;1;0;0;0;1;FLOAT;0
Node;AmplifyShaderEditor.SamplerNode;17;-2689.394,-201.7889;Inherit;True;Property;_TextureSample0;Texture Sample 0;6;0;Create;True;0;0;False;0;False;-1;None;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
Node;AmplifyShaderEditor.CommentaryNode;85;-1524.068,1206.155;Inherit;False;1215.321;564.71;BaseColorBlend;8;33;36;13;35;32;34;28;83;BaseColorBlend;1,1,1,1;0;0
Node;AmplifyShaderEditor.RangedFloatNode;63;-2921.229,-670.2874;Inherit;False;Property;_groundNormalScale;groundNormalScale;16;0;Create;True;0;0;False;0;False;1;1;0;0;0;1;FLOAT;0
Node;AmplifyShaderEditor.SamplerNode;14;-2671.856,-751.1234;Inherit;True;Property;_groundNormalTex;groundNormalTex;5;0;Create;True;0;0;False;0;False;-1;None;0370537a00ad26e4a896f79b2aec4f23;True;0;True;bump;Auto;True;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
Node;AmplifyShaderEditor.SamplerNode;44;-1799.768,-1267.344;Inherit;True;Property;_rainNormalTex;rainNormalTex;13;0;Create;True;0;0;False;0;False;-1;None;b9e603798145b2044a49e582271b0f1b;True;0;False;white;Auto;True;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
Node;AmplifyShaderEditor.GetLocalVarNode;28;-1451.562,1256.155;Inherit;False;30;worldUV;1;0;OBJECT;;False;1;FLOAT2;0
Node;AmplifyShaderEditor.FunctionNode;16;-2287.12,-94.13768;Inherit;False;HeightLerp;-1;;3;bd8e91b1bb22e95439a8890d04c777d9;0;3;1;FLOAT;0;False;5;FLOAT;0;False;10;FLOAT;1;False;1;FLOAT;0
Node;AmplifyShaderEditor.FunctionNode;23;-2303.664,94.44557;Inherit;False;HeightLerp;-1;;4;bd8e91b1bb22e95439a8890d04c777d9;0;3;1;FLOAT;0;False;5;FLOAT;0;False;10;FLOAT;1;False;1;FLOAT;0
Node;AmplifyShaderEditor.CommentaryNode;88;-1616.297,535.2726;Inherit;False;1151.513;485.281;SmoothnessBlend;6;29;53;51;54;56;86;SmoothnessBlend;1,1,1,1;0;0
Node;AmplifyShaderEditor.RegisterLocalVarNode;25;-1978.502,-55.11339;Inherit;False;rVal;-1;True;1;0;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.RegisterLocalVarNode;26;-1982.639,114.9326;Inherit;False;gVal;-1;True;1;0;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.RegisterLocalVarNode;72;-2224.121,-693.5996;Inherit;False;groundNormalVal;-1;True;1;0;FLOAT3;0,0,0;False;1;FLOAT3;0
Node;AmplifyShaderEditor.RegisterLocalVarNode;69;-1443.982,-1247.856;Inherit;False;rainNormalVal;-1;True;1;0;FLOAT3;0,0,0;False;1;FLOAT3;0
Node;AmplifyShaderEditor.RangedFloatNode;53;-1081.148,695.8835;Inherit;False;Property;_roughVal;roughVal;15;0;Create;True;0;0;False;0;False;0.2;0.7;0;0;0;1;FLOAT;0
Node;AmplifyShaderEditor.SamplerNode;29;-1566.297,625.0161;Inherit;True;Property;_roughnessTex;roughnessTex;7;0;Create;True;0;0;False;0;False;-1;None;15ac75118ec027447b8e1654c7251a3f;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
Node;AmplifyShaderEditor.CommentaryNode;82;-1458.872,-377.4322;Inherit;False;798.8788;383.9342;NormalBlendVal;5;48;80;73;70;49;NormalBlendVal;1,1,1,1;0;0
Node;AmplifyShaderEditor.RangedFloatNode;34;-1220.218,1646.01;Inherit;False;Property;_depth;depth;9;0;Create;True;0;0;False;0;False;0;0.381;0;1;0;1;FLOAT;0
Node;AmplifyShaderEditor.ColorNode;32;-1474.068,1504.578;Inherit;False;Property;_pColor;pColor;8;0;Create;True;0;0;False;0;False;0,0,0,0;0,0,0,0;True;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
Node;AmplifyShaderEditor.SamplerNode;13;-1268.437,1279.198;Inherit;True;Property;_baseTex;baseTex;4;0;Create;True;0;0;False;0;False;-1;None;757b27643c0257b499d31aac165b18fc;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
Node;AmplifyShaderEditor.GetLocalVarNode;73;-1400.521,-327.4322;Inherit;False;72;groundNormalVal;1;0;OBJECT;;False;1;FLOAT3;0
Node;AmplifyShaderEditor.GetLocalVarNode;70;-1408.872,-206.3976;Inherit;False;69;rainNormalVal;1;0;OBJECT;;False;1;FLOAT3;0
Node;AmplifyShaderEditor.GetLocalVarNode;49;-1392.448,-109.4981;Inherit;False;26;gVal;1;0;OBJECT;;False;1;FLOAT;0
Node;AmplifyShaderEditor.GetLocalVarNode;36;-911.2296,1654.865;Inherit;False;25;rVal;1;0;OBJECT;;False;1;FLOAT;0
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;54;-935.7402,585.2726;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.LerpOp;33;-905.2296,1499.865;Inherit;False;3;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;2;FLOAT;0;False;1;COLOR;0
Node;AmplifyShaderEditor.GetLocalVarNode;51;-1251.783,904.5536;Inherit;False;25;rVal;1;0;OBJECT;;False;1;FLOAT;0
Node;AmplifyShaderEditor.LerpOp;35;-724.1446,1386.959;Inherit;False;3;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;2;FLOAT;0;False;1;COLOR;0
Node;AmplifyShaderEditor.LerpOp;48;-1137.917,-257.1948;Inherit;False;3;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT;0;False;1;FLOAT3;0
Node;AmplifyShaderEditor.LerpOp;56;-910.9443,771.4702;Inherit;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.RegisterLocalVarNode;80;-888.9934,-227.4163;Inherit;False;normalBlendVal;-1;True;1;0;FLOAT3;0,0,0;False;1;FLOAT3;0
Node;AmplifyShaderEditor.RegisterLocalVarNode;83;-538.7474,1448.889;Inherit;False;baseColorBlend;-1;True;1;0;COLOR;0,0,0,0;False;1;COLOR;0
Node;AmplifyShaderEditor.RegisterLocalVarNode;86;-706.7839,799.3683;Inherit;False;smoothnessBlend;-1;True;1;0;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.GetLocalVarNode;81;59.31812,-44.23235;Inherit;False;80;normalBlendVal;1;0;OBJECT;;False;1;FLOAT3;0
Node;AmplifyShaderEditor.GetLocalVarNode;84;77.09093,73.9717;Inherit;False;83;baseColorBlend;1;0;OBJECT;;False;1;COLOR;0
Node;AmplifyShaderEditor.GetLocalVarNode;87;55.48254,194.7304;Inherit;False;86;smoothnessBlend;1;0;OBJECT;;False;1;FLOAT;0
Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;365.0914,19.1281;Float;False;True;-1;2;ASEMaterialInspector;0;0;Standard;ASEWaterGround;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;Back;0;False;-1;0;False;-1;False;0;False;-1;0;False;-1;False;0;Opaque;0.5;True;True;0;False;Opaque;;Geometry;All;14;all;True;True;True;True;0;False;-1;False;0;False;-1;255;False;-1;255;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;False;2;15;10;25;False;0.5;True;0;0;False;-1;0;False;-1;0;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;0;0,0,0,0;VertexOffset;True;False;Cylindrical;False;Relative;0;;-1;-1;-1;-1;0;False;0;0;False;-1;-1;0;False;-1;0;0;0;False;0.1;False;-1;0;False;-1;False;16;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT;0;False;4;FLOAT;0;False;5;FLOAT;0;False;6;FLOAT3;0,0,0;False;7;FLOAT3;0,0,0;False;8;FLOAT;0;False;9;FLOAT;0;False;10;FLOAT;0;False;13;FLOAT3;0,0,0;False;11;FLOAT3;0,0,0;False;12;FLOAT3;0,0,0;False;14;FLOAT4;0,0,0,0;False;15;FLOAT3;0,0,0;False;0
WireConnection;3;0;2;0
WireConnection;65;0;3;0
WireConnection;59;0;9;0
WireConnection;6;0;67;0
WireConnection;6;1;5;0
WireConnection;1;0;6;0
WireConnection;1;1;75;0
WireConnection;1;2;10;0
WireConnection;1;3;11;0
WireConnection;1;4;12;0
WireConnection;46;0;66;0
WireConnection;46;1;45;0
WireConnection;30;0;1;0
WireConnection;37;0;46;0
WireConnection;41;0;37;0
WireConnection;41;1;40;0
WireConnection;41;2;42;0
WireConnection;41;3;43;0
WireConnection;17;0;76;0
WireConnection;17;1;21;0
WireConnection;14;1;31;0
WireConnection;14;5;63;0
WireConnection;44;1;41;0
WireConnection;44;5;64;0
WireConnection;16;1;17;1
WireConnection;16;5;18;1
WireConnection;16;10;22;0
WireConnection;23;1;17;1
WireConnection;23;5;18;2
WireConnection;23;10;22;0
WireConnection;25;0;16;0
WireConnection;26;0;23;0
WireConnection;72;0;14;0
WireConnection;69;0;44;0
WireConnection;13;1;28;0
WireConnection;54;0;29;1
WireConnection;54;1;53;0
WireConnection;33;0;13;0
WireConnection;33;1;32;0
WireConnection;33;2;34;0
WireConnection;35;0;13;0
WireConnection;35;1;33;0
WireConnection;35;2;36;0
WireConnection;48;0;73;0
WireConnection;48;1;70;0
WireConnection;48;2;49;0
WireConnection;56;0;54;0
WireConnection;56;1;29;1
WireConnection;56;2;51;0
WireConnection;80;0;48;0
WireConnection;83;0;35;0
WireConnection;86;0;56;0
WireConnection;0;1;81;0
WireConnection;0;2;84;0
WireConnection;0;4;87;0
ASEEND*/
//CHKSM=E11325D7EB9C809FDB1090C9406210D19CCE1D9F

经过网友提醒,发现漏了一个自定义节点HeightLerp,补充一下,不好意思,建个空文件,然后重命名为HeightLerp.asset,把这些内容复制到文件里面就行:

%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
  m_ObjectHideFlags: 0
  m_PrefabParentObject: {fileID: 0}
  m_PrefabInternal: {fileID: 0}
  m_GameObject: {fileID: 0}
  m_Enabled: 1
  m_EditorHideFlags: 0
  m_Script: {fileID: 11500000, guid: 78b2425a2284af743826c689403a4924, type: 3}
  m_Name: HeightLerp
  m_EditorClassIdentifier: 
  m_functionInfo: "// Made with Amplify Shader Editor\n// Available at the Unity Asset
    Store - http://u3d.as/y3X \n/*ASEBEGIN\nVersion=18500\n219;110;1906;1004;1286.601;389.1078;1;True;False\nNode;AmplifyShaderEditor.FunctionInput;10;-693,26;Inherit;False;BlendContrast;1;2;False;1;0;FLOAT;1;False;1;FLOAT;0\nNode;AmplifyShaderEditor.SimpleSubtractOpNode;9;-462,-19;Inherit;False;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0\nNode;AmplifyShaderEditor.ClampOpNode;8;-806,145;Inherit;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;1;False;1;FLOAT;0\nNode;AmplifyShaderEditor.SimpleAddOpNode;11;-465,70;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;1;False;1;FLOAT;0\nNode;AmplifyShaderEditor.ClampOpNode;13;-29.08301,7.1912;Inherit;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;1;False;1;FLOAT;0\nNode;AmplifyShaderEditor.LerpOp;12;-225,8;Inherit;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;1;FLOAT;0\nNode;AmplifyShaderEditor.RangedFloatNode;4;-1325,109;Inherit;False;Constant;_Float0;Float
    0;0;0;Create;True;0;0;False;0;False;1;0;0;0;0;1;FLOAT;0\nNode;AmplifyShaderEditor.RangedFloatNode;6;-1319,319;Inherit;False;Constant;_Float1;Float
    1;0;0;Create;True;0;0;False;0;False;2;0;0;0;0;1;FLOAT;0\nNode;AmplifyShaderEditor.SimpleMultiplyOpNode;2;-1146,249;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0\nNode;AmplifyShaderEditor.FunctionInput;5;-1368,241;Inherit;False;TransitionPhase;1;1;False;1;0;FLOAT;0;False;1;FLOAT;0\nNode;AmplifyShaderEditor.SimpleAddOpNode;7;-958,147;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0\nNode;AmplifyShaderEditor.FunctionInput;1;-1316,30;Inherit;False;Height;1;0;False;1;0;FLOAT;0;False;1;FLOAT;0\nNode;AmplifyShaderEditor.SimpleSubtractOpNode;3;-1154,91;Inherit;False;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0\nNode;AmplifyShaderEditor.FunctionOutput;0;212.5811,99.79137;Inherit;False;True;-1;Output;0;False;1;0;FLOAT;0;False;1;FLOAT;0\nWireConnection;9;1;10;0\nWireConnection;8;0;7;0\nWireConnection;11;0;10;0\nWireConnection;13;0;12;0\nWireConnection;12;0;9;0\nWireConnection;12;1;11;0\nWireConnection;12;2;8;0\nWireConnection;2;0;5;0\nWireConnection;2;1;6;0\nWireConnection;7;0;3;0\nWireConnection;7;1;2;0\nWireConnection;3;0;1;0\nWireConnection;3;1;4;0\nWireConnection;0;0;13;0\nASEEND*/\n//CHKSM=2E3E2B366EDC33EBD63D25A458743FB0493FC048"
  m_functionName: 
  m_description: 
  m_additionalIncludes:
    m_additionalIncludes: []
    m_outsideIncludes: []
  m_additionalPragmas:
    m_additionalPragmas: []
    m_outsidePragmas: []
  m_additionalDirectives:
    m_validData: 0
    m_isDirty: 0
    m_moduleName: ' Additional Directives'
    m_independentModule: 1
    m_additionalDirectives: []
    m_shaderFunctionDirectives: []
    m_nativeDirectives: []
    m_nativeDirectivesIndex: -1
    m_nativeDirectivesFoldout: 0
    m_directivesSaveItems: []
  m_nodeCategory: 3
  m_customNodeCategory: 
  m_previewPosition: 0
  m_hidden: 0
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
Unity中的Amplify Shader Editor(ASE)是一个功能强大的着色器编辑器工具,它可以帮助我们创建各种自定义的图形效果。在Unity中实现全屏风沙效果,我们可以使用ASE来构建自定义着色器。 首先,我们需要创建一个新的shader。在ASE中,我们可以使用节点和连接来构建着色器的逻辑。为了实现风沙效果,我们可以使用以下节点: 1. 顶点和片段节点:这些节点将我们的顶点和片段着色器链接在一起。 2. UV节点:用于获取纹理的坐标。 3. 采样节点:用于从纹理中采样颜色。 4. 噪声节点:用于创建风沙的噪声效果。 5. 变换节点:用于控制风沙的移动和扭曲。 6. 颜色和混合节点:用于创建风沙的颜色和混合效果。 一旦我们将这些节点连接在一起,我们就可以得到一个风沙的着色器效果。然而,这只是一个简单的例子。如果我们希望获得更加逼真的风沙效果,我们可以添加更多的节点和自定义参数,以达到我们想要的效果。 最后,我们需要将创建的着色器应用于场景中的相机或对象上。我们可以通过添加一个新的材质,并将这个材质分配给相机或对象的渲染组件来实现。 总结起来,UnityASE工具提供了一种简单而强大的方式来创建全屏风沙效果。通过使用各种节点和连接,我们可以轻松地构建自定义的着色器,并将其应用于场景中的相机或对象上。这样,我们就可以实现逼真的、令人赏心悦目的风沙效果
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值