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.

This entry was posted in XNA. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s