Here is a short video of the grass( now windy, but still not per-pixel lit ). As you can see I am having problems with some of the things being screen-space and post( like the shadows ). It overlays the shadows of objects covered by grass on top of the grass, ugh, it kind of spoils the visuals. But well, you can see in the vid. It's all running on an 8500GT, so please ignore the slight jolts etc etc. It should perform much better on a gaming card instead of this office crap.
Video:
http://uk.youtube.com/watch?v=SN7IwC7HJfsHere is the current version of the shader, of course, the final version will have normal mapping also.
float4x3 World[52] : MINIMESH_WORLD;
float4x4 ViewProj : VIEWPROJECTION;
float4 Colour[52]: MINIMESH_COLOR;
float Time : TIME;
texture Diffuse : TEXTURE0;
float WindSpeed = 2.0f;
float2 WindDir = float2(1, 0.4f);
sampler2D DiffuseSample = sampler_state
{
Texture = (Diffuse);
MINFILTER = LINEAR;
MAGFILTER = LINEAR;
MIPFILTER = LINEAR;
};
struct VertexIN
{
float4 Position: POSITION;
float3 Normal : NORMAL;
float2 UV : TEXCOORD0;
float2 Index : TEXCOORD3; //This is ALWAYS on 3.
};
struct FragmentIN
{
float4 Position: POSITION;
float2 UV : TEXCOORD0;
float4 Colour : COLOR0;
};
void VertexProgram(in VertexIN IN, out FragmentIN OUT)
{
float Sine = sin(Time * WindSpeed);
float4x3 WorldMatrix = World[IN.Index.x];
float3 WorldPos = mul(IN.Position, WorldMatrix);
WorldPos.xz += Sine * (IN.Position.y * 0.5f) * WindDir;
OUT.Position = mul(float4(WorldPos, 1), ViewProj);
OUT.UV = IN.UV;
OUT.Colour = Colour[IN.Index.x];
}
float4 FragmentProgram(in FragmentIN IN): COLOR0
{
float4 Pixel = IN.Colour * tex2D(DiffuseSample, IN.UV);
Pixel.a = tex2D(DiffuseSample, IN.UV).a;
return Pixel;
}
technique render
{
pass pass0
{
VertexShader = compile vs_2_0 VertexProgram();
PixelShader = compile ps_1_1 FragmentProgram();
}
}