Friday, April 6, 2007

Scamped shader for Terrain

This scamped shader doesn't work well for a terrain having steep grades. But, because the shader works in only shader, it's possible to use for a model which XNA doesn't allow to access vertex buffers. (It's impossible to access buffers with the GetData method, because buffers of auto managed models are readonly)

1) Prepares your terrain model having no steep grades.

2) Prepares the shade which takes POSITION.xz for TEXCOORD0.uv. The most simply example;

VS_OUTPUT Transform(
  float4 vPos : POSITION,
  float2 vTexCoord0 : TEXCOORD0 )
    VS_OUTPUT Output; 
    Output.Position = mul(vPos, WorldViewProj);
    Output.TextureUV = vPos.xz * TexScale;
    return Output;

You may add your effects to this.

You may change a effect of a model on your program directy, if you don't want to make the special custom pipe-line.

This shader is helpful for prototype. Download sample.

No comments: