- Posts: 3
- Joined: Wed Jan 16, 2019 2:05 pm
Without any luck, I'm trying to understand the vertex animation code in the example shaders Tree.fx and Leaf.fx.
Does anyone have a clue how all those wind parameters work?
Why does it have to be that complex?
Does anyone have a clue how all those wind parameters work?
Why does it have to be that complex?
- Code: Select all
// aplication time scaled with factors (0.1, 1, 2, 20) and divided by 57.3 (degrees to radians?)
float4 TreeWindTimer;
float4 TreeWindSize={500, 250, 75, 0.5f};
float3 TreeWindPower={3, 3, 1.5};
float3 TreeGlobalWind=(mul(IN.Pos,World).xyz/TreeWindSize.x)+TreeWindTimer.x;
TreeGlobalWind.x=1+abs(dot(cos(TreeGlobalWind),sin(TreeGlobalWind)));
float3 TreeWindForce=normalize(IN.Pos.xyz)+TreeWindTimer.y;
TreeWindForce.x=sin(TreeWindForce.x);
TreeWindForce.y=0;
TreeWindForce.z=cos(TreeWindForce.z);
float3 WindAnimate=(TreeWindForce*TreeWindPower.x)*(IN.Pos.y/TreeWindSize.y);
float3 TreeWindVariant=normalize(float3(IN.Pos.x,IN.Pos.y/TreeWindSize.z,IN.Pos.z))+TreeWindTimer.z+(IN.Color.y*10);
WindAnimate +=(cos(TreeWindVariant)*TreeWindPower.y)*pow(IN.Color.z,2);
float4 NewPos=float4(IN.Pos.xyz+WindAnimate*TreeGlobalWind.x,1);