Yeah, it does seem a little faster then before...
Gimme a few minutes and I'll have another version for you.
I think I have thouht of a wat to 'blend' the different maps
at the changeover points to give a smoother transition...
Let see how we go...
[EDIT] Not as smooth as I wanted, but take a look and see what you think.
Im gunna continue and TRY to make it actually SMOOTH, cause I need
a rest from MY movement code. Im at the 'tidy and optimize' stage.
And there is one particulat chunk of code Ive TRIED to optimize like 10 times,
But it keeps going wrong and I need to backtrack the optimise.
But theres my current shader, let me know what you think.
//Application fed data
const float4x4 matWorldViewProj;
texture Sand_BM_bmap, Grass_BM_bmap, Rock_BM_bmap, Snow_BM_bmap;
// ColorMap Samplers
sampler SandSampler = sampler_state { Texture = <Sand_BM_bmap>; };
sampler GrassSampler = sampler_state { Texture = <Grass_BM_bmap>; };
sampler RockSampler = sampler_state { Texture = <Rock_BM_bmap>; };
sampler SnowSampler = sampler_state { Texture = <Snow_BM_bmap>; };
// Vertex Shader:
void TerrPaintVS( in float4 InPos: POSITION, in float2 InTex: TEXCOORD0,
out float4 OutPos: POSITION, out float2 OutTex: TEXCOORD0,
out float Height: TEXCOORD1 )
{
// Transform the vertex from object space to projected world space:
OutPos = mul(InPos, matWorldViewProj);
// Pass the texture coordinate to the pixel shader:
OutTex = InTex;
// Capture the Height of this vertex from object space... SEEMINGLY
Height = abs(1-(InPos.y/InPos.w));
}
// Pixel Shader:
float4 TerrPaintPS( in float4 InPos: POSITION, in float2 InTex: TEXCOORD0,
in float Height:TEXCOORD1 ): COLOR
{
float4 Color;
if(Height < 16) Color = tex2D(SandSampler, InTex);
else if(Height < 26) Color = lerp(tex2D(SandSampler,InTex), tex2D(GrassSampler,InTex), 0.5);
else if(Height < 50) Color = tex2D(GrassSampler, InTex);
else if(Height < 55) Color = lerp(tex2D(GrassSampler,InTex), tex2D(RockSampler,InTex), 0.5);
else if(Height < 75) Color = tex2D(RockSampler, InTex);
else if(Height < 85) Color = lerp(tex2D(RockSampler,InTex), tex2D(SnowSampler,InTex), 0.5);
else Color = tex2D(SnowSampler, InTex);
return Color;
}
// Technique:
technique AmbientTechnique
{
pass P0
{
VertexShader = compile vs_2_0 TerrPaintVS();
PixelShader = compile ps_2_0 TerrPaintPS();
}
}