MATERIAL* drakanterrianmat =
{ skin1 = rock_bmap;
skin2 = grass_bmap;
effect = "const float4x4 matWorldViewProj;
const float4x4 matWorld;
const float4 vecAmbient;
const float4 vecSunDir;
float4 AmbientColor = float4(1, 1, 1, 1);
float AmbientIntensity = 1.0f;
float DiffuseIntensity = 1.0f;
float4 SunColor = {0.9f,0.9f,0.5f,1.0f};
float Normal_y;
texture entSkin1;
texture mtlSkin1;
texture mtlSkin2;
sampler ColorMapSampler=sampler_state
{ Texture = <entSkin1>;
AddressU = Clamp;
AddressV = Clamp;
};
sampler RockMapSampler=sampler_state
{ Texture = <mtlSkin1>;
AddressU = Wrap;
AddressV = Wrap;
};
sampler GrassMapSampler=sampler_state
{ Texture = <mtlSkin2>;
AddressU = Wrap;
AddressV = Wrap;
};
struct VS_Input
{ float4 InPosition :POSITION;
float3 InNormal :NORMAL;
float2 InTexture :TEXCOORD0;
};
struct VS_Output
{ float4 OutPosition :POSITION;
float2 OutTexture :TEXCOORD0;
float3 OutNormal :TEXCOORD1;
float2 OutBlendTex :TEXCOORD2;
};
struct PS_Input
{ float2 InTexture :TEXCOORD0;
float2 InNormal :TEXCOORD1;
float3 InBlendTex :TEXCOORD2;
};
VS_Output vs(VS_Input Input)
{ VS_Output Output;
Output.OutPosition=mul(Input.InPosition,matWorldViewProj);
Output.OutNormal=normalize(mul(Input.InNormal,matWorld));
Output.OutTexture = Input.InTexture*512;
Output.OutBlendTex = Input.InTexture;
Normal_y = Input.InNormal.y;
return Output;
}
float4 ps(PS_Input Input) : COLOR0
{ float4 Ambient = AmbientIntensity*vecAmbient;
float4 Diffuse = DiffuseIntensity*saturate(dot(vecSunDir,normalize(Input.InNormal)));
float4 Color = tex2D(ColorMapSampler,Input.InBlendTex);
float4 GrassTexture = tex2D(GrassMapSampler, Input.InTexture);
float4 RockTexture = tex2D(RockMapSampler, Input.InTexture);
float4 ReturnTexture = lerp(RockTexture,GrassTexture,Normal_y);
Diffuse *= SunColor;
return (Ambient+Diffuse)*ReturnTexture;
}
technique ApplyTextures
{ pass P0
{ VertexShader = compile vs_2_0 vs();
PixelShader = compile ps_2_0 ps();
}
}";
}