#line 1 "complex-ogre-grass1-in.txt" void main(float4 position : POSITION, float3 normal : NORMAL, float2 uv : TEXCOORD0, out float4 oPosition : POSITION, out float2 oUv : TEXCOORD0, out float4 oColour : COLOR, uniform float4x4 worldViewProj, //uniform float4 camObjPos, uniform float4 ambient, uniform float4 objSpaceLight, uniform float4 lightColour, uniform float4 offset) { float4 mypos = position; //offset = float4(0.5, 0, 0, 0); float4 factor = float4(1,1,1,1) - uv.yyyy; mypos = mypos + offset * factor; oPosition = mul(worldViewProj, mypos); oUv = uv; // Color // get vertex light direction (support directional and point) float3 light = normalize(objSpaceLight.xyz - (mypos.xyz * objSpaceLight.w)); // grass is just 2D quads, so if light passes underneath we need to invert the normal // abs() will have the same effect float diffuseFactor = abs(dot(normal.xyz, light)); oColour = ambient + diffuseFactor * lightColour; }