Care to give us two pair of eyes? Haha.
GrassVertOut GrassVS( GrassVertIn IN ) {GrassVertOut OUT;OUT.texcoords = IN.texcoords;//Animate grassfloat4 worldpos = mul(IN.pos, world);//distance to grass for rangefloat gdist = length(worldpos.xyz - EyePos.xyz);float height = clamp(IN.pos.z, 0, 100) / 100;float2 wind = WindVec * 2.5 + 0.25;float2 pos_ticks1 = worldpos.xy / 1000 + ticks;float2 pos_ticks2 = worldpos.xy / 750 + ticks * 2;float2 pos_ticks3 = worldpos.xy / 500 + ticks * 3;float2 pos_ticks4 = worldpos.xy / 200 + ticks * 4;//grass offset for bendingfloat2 bend_ticks1 = (worldpos.xy - EyePos.xy)/1000 * 1/gdist;//interactive grassif ( gdist < 100 ) { //bend worldpos.xy += (cos(bend_ticks1)) * height * (1/gdist) * 3500;} else { worldpos.xy += ( sin(pos_ticks1) + cos(pos_ticks2) + sin(pos_ticks3) + cos(pos_ticks4) ) * height * wind * 10;}
GrassVertOut GrassVS (GrassVertIn IN) { GrassVertOut OUT; OUT.texcoords = IN.texcoords; // Animate grass float4 worldpos = mul (IN.pos, world); //distance to grass for range float gdist = length(worldpos.xy - PlayerPos.xy); float height = clamp (IN.pos.z, 0, 100) / 100; float2 wind = WindVec * 2.5 + 0.25; float2 pos_ticks1 = worldpos.xy / 1000 + ticks; float2 pos_ticks2 = worldpos.xy / 750 + ticks * 2; float2 pos_ticks3 = worldpos.xy / 500 + ticks * 3; float2 pos_ticks4 = worldpos.xy / 200 + ticks * 4; //grass offset for bending float2 bend_ticks1 = (worldpos.xy - PlayerPos.xy)/1000 * 1/gdist; //interactive grassif ( gdist < 100 ) { //bend worldpos.xy += (bend_ticks1)/abs(bend_ticks1)*(cos(bend_ticks1)) * height * 1/(25+gdist) * 3500;} else { worldpos.xy += ( sin(pos_ticks1) + cos(pos_ticks2) + sin(pos_ticks3) + cos(pos_ticks4) ) * height * wind * 10;}
GrassVertOut GrassVS (GrassVertIn IN) { GrassVertOut OUT; OUT.texcoords = IN.texcoords;now look at his code, add only his changes into that section of code.
//Animate grass
float4 worldpos = mul (IN.pos, world);
//Animate grass float height = clamp(IN.pos.z, 0, 100) / 100; float2 wind = WindVec * 2.5 + 0.25; float2 pos_ticks1 = worldpos.xy / 1000 + ticks; float2 pos_ticks2 = worldpos.xy / 750 + ticks * 2; float2 pos_ticks3 = worldpos.xy / 500 + ticks * 3; float2 pos_ticks4 = worldpos.xy / 200 + ticks * 4; worldpos.xy += ( sin(pos_ticks1) + cos(pos_ticks2) + sin(pos_ticks3) + cos(pos_ticks4) ) * height * wind * 10;
// Animate grass //distance to grass for range float gdist = length(worldpos.xy - PlayerPos.xy); float height = clamp (IN.pos.z, 0, 100) / 100; float2 wind = WindVec * 2.5 + 0.25; float2 pos_ticks1 = worldpos.xy / 1000 + ticks; float2 pos_ticks2 = worldpos.xy / 750 + ticks * 2; float2 pos_ticks3 = worldpos.xy / 500 + ticks * 3; float2 pos_ticks4 = worldpos.xy / 200 + ticks * 4; //grass offset for bending float2 bend_ticks1 = (worldpos.xy - PlayerPos.xy)/1000 * 1/gdist; //interactive grassif ( gdist < 100 ) { //bend worldpos.xy += (bend_ticks1)/abs(bend_ticks1)*(cos(bend_ticks1)) * height * 1/(25+gdist) * 3500;} else { worldpos.xy += ( sin(pos_ticks1) + cos(pos_ticks2) + sin(pos_ticks3) + cos(pos_ticks4) ) * height * wind * 10;}