First shader version:

TerrainPainter.fx
Code:
//Application fed data
const float4x4 matWorld; // World matrix
texture Sand_BM, Grass_BM, Rock_BM, Snow_BM;

// ColorMap Samplers
sampler SandSampler = sampler_state 
{ 
	Texture = <Sand_BM>;
	MipFilter = Linear; 
	AddressU  = Wrap; 
	AddressV  = Wrap; 
}; 

sampler GrassSampler = sampler_state 
{ 
	Texture = <Grass_BM>;
	MipFilter = Linear; 
	AddressU  = Wrap; 
	AddressV  = Wrap; 
};  

sampler RockSampler = sampler_state 
{ 
	Texture = <Rock_BM>;
	MipFilter = Linear; 
	AddressU  = Wrap; 
	AddressV  = Wrap; 
};  

sampler SnowSampler = sampler_state 
{ 
	Texture = <Snow_BM>;
	MipFilter = Linear; 
	AddressU  = Wrap; 
	AddressV  = Wrap; 
};  

// Vertex Shader: 
void TerrPaintVS( 
in float4 InPos: POSITION, 
in float2 InTex: TEXCOORD0, 
out float4 OutPos: POSITION, 
out float2 OutTex: TEXCOORD0) 
{ 
	// Transform the vertex from object space to world space: 
	OutPos = mul(InPos, matWorld); 
	// Pass the texture coordinate to the pixel shader: 
	OutTex = InTex; 
}

// Pixel Shader: 
float4 TerrPaintPS(
in float4 InPos: POSITION, 
in float2 InTex: TEXCOORD0): COLOR 
{
	float4 Color;
	if(InPos.y<16)	Color = tex2D(SandSampler, InTex); 
	else if(InPos.y<50)	Color = tex2D(GrassSampler, InTex); 
	else if(InPos.y<75)	Color = tex2D(RockSampler, InTex); 
	else Color = tex2D(SnowSampler, InTex);
	
	return Color; 
} 

// Technique: 
technique AmbientTechnique 
{ 
	pass P0 
	{ 
		VertexShader = compile vs_2_0 TerrPaintVS(); 
		PixelShader  = compile ps_2_0 TerrPaintPS(); 
	} 
}



Material Definition inside my game script:
Code:
MATERIAL* mtlTerrain =
{
   effect = "TerrainPainter.fx";
   flags = AUTORELOAD; // allows to edit the shader at runtime
}



How I assign the material in my game script:
Code:
int x; int y;
for(x=0;x<TERRAIN_COUNT;x++)
{
	for(y=0;y<TERRAIN_COUNT;y++)
	{
		Terrain[x][y]=ent_create("Terrain33.mdl",vector(x*512,y*512,0),NULL);
		ent_clone(Terrain[x][y]);
		Terrain[x][y].material = mtlTerrain;
		//ent_cloneskin(Terrain[x][y]);
	}
}



Does not even compile, I get this error message:
Quote:
Malfunction W1550
Can't compile effect:
TerrainPainter.fx(53,18): error X4502: invalid ps_2_0 input semantic
'POSITION'
D:\TERRAIN TEST\memory(71,18):
ID3DXEffectCompiler::CompileEffect: There was an error compiling expression
ID3DXEffectCompiler: Compilation failed
> in float4 InPos: POSITION, <

any help with this is welcome


@EvilSOB: Seems I am not an opera singer yet, but I am trying... At the moment it feels like I can't even sing in the shower, LOL!

Last edited by Carlos3DGS; 11/06/11 12:16.

"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1