top of page

Vertex Wind

Simulating wind using Vertex displacement

///// Vertex Wind /////
half4 _WindDir;
half4 _WindYDisp;
half4 _WindZDisp;

inline void ApplyWind(inout float3 wPos, float3 vtxPos)
{
	float zDisp = _Time.y * _WindZDisp.x; // Distance based Frequency
	zDisp += length(wPos.xz) * _WindZDisp.z; // W Distance Offset
	zDisp += vtxPos.y * _WindZDisp.y; // L Height Offset

	float yDisp = _Time.y * _WindYDisp.x; // Distance based Frequency
	yDisp += length(wPos.xz) * _WindYDisp.z; // W Distance Offset
	yDisp += vtxPos.y * _WindYDisp.y; // L Height Offset
	
	float spreadBias = length(vtxPos.xz) * _WindDir.z;
	float heightBias = vtxPos.y * _WindDir.y;
	
	float3 wDir = 1;
	sincos(_WindDir.x * 3.1415926/180.0, wDir.x, wDir.z);
	wDir.xz *= sin(zDisp) * _WindZDisp.w;
	wDir.y *= sin(yDisp) * _WindYDisp.w;

	float3 wave = wDir * _WindDir.w;
	wave *= spreadBias + heightBias;
	wPos += wave;
}


Recent Posts

See All
Height Map and Parallax Mapping

In this blog, I will explain Adjust UV using HeightMap RayTrace HeightMap to find Occlusions. o.Height = SAMPLE_TEXTURE2D(_PKDMAP,...

 
 
 

Comments


bottom of page