Absolutly great!!



code:
Code:
#define SHADOWMAP

#include <define>
#include <transform>
#include <sun>
#include <lights>
#include <fog>
#include <normal>

Texture entSkin1; // Red/green/blue for blending
Texture entSkin2; // MultiTexture 
Texture entSkin3; // ShadowMap
//Texture entSkin4; // NormalMap

float4 vecSkill41;
float fAmbient;

sampler sMaskTex   = sampler_state { Texture = <entSkin1>; MipFilter = Linear; };
sampler sQuadTex   = sampler_state { Texture = <entSkin2>; MipFilter = Linear; };
sampler sShadowTex = sampler_state { Texture = <entSkin3>; MipFilter = Linear; };
//sampler sNormalTex = sampler_state { Texture = <entSkin4>; MipFilter = Linear; }; 

//////////////////////////////////////////////////////////////////////
struct out_QuadTex // Output to the pixelshader fragment
{
	float4 Pos			: POSITION;
	float4 Color		: COLOR0;
	float  Fog	   	: FOG;
	float2 MaskCoord	: TEXCOORD0;
	float2 NWCoord		: TEXCOORD1;
	float2 NECoord 	: TEXCOORD2;
	float2 SWCoord		: TEXCOORD3;
	float2 SECoord		: TEXCOORD4;
	float2 ShadowCoord: TEXCOORD5;
};

out_QuadTex vs_QuadTex (
	float4 inPos : POSITION,
	float3 inNormal : NORMAL,
	float2 inTexCoord0 : TEXCOORD0 )
{
	out_QuadTex Out;

	Out.Pos = DoTransform(inPos); // transform to screen coordinates

// rotate and normalize the normal
	float3 N = DoNormal(inNormal);
	float3 P = mul(inPos,matWorld);

	Out.Color = fAmbient; // Add ambient and sun light
	for (int i=0; i<8; i++)  // Add 8 dynamic lights
		Out.Color += DoLight(P,N,i);
	Out.Fog = DoFog(inPos); // Add fog

	Out.MaskCoord = inTexCoord0.xy;
	Out.ShadowCoord = inTexCoord0.xy;
	
// scale the texture coordinates for the masked textures
	Out.NWCoord = inTexCoord0.xy * vecSkill41.w;
	Out.NECoord = inTexCoord0.xy * vecSkill41.w;
	Out.SWCoord = inTexCoord0.xy * vecSkill41.w;
	Out.SECoord = inTexCoord0.xy * vecSkill41.w;
	
	return Out;
}

float4 ps_QuadTex(out_QuadTex In): COLOR
{
	float HalfSize = 0.5; 
	In.NWCoord = fmod(In.NWCoord, HalfSize);
	In.NECoord.x = fmod(In.NECoord.x, HalfSize)+0.5;
	In.NECoord.y = fmod(In.NECoord.y, HalfSize);
	In.SWCoord.x = fmod(In.SWCoord.x, HalfSize);
	In.SWCoord.y = fmod(In.SWCoord.y, HalfSize)+0.5;
	In.SECoord = fmod(In.SECoord, HalfSize);
	
// retrieve the pixels for the textures and the masks
	float4 MaskColor 		= tex2D(sMaskTex,In.MaskCoord);
	float4 NWColor 		= tex2D(sQuadTex,In.NWCoord);
	float4 NEColor 		= tex2D(sQuadTex,In.NECoord);
	float4 SWColor 		= tex2D(sQuadTex,In.SWCoord);
	float4 SEColor 		= tex2D(sQuadTex,In.SECoord);
	float4 ShadowColor 	= tex2D(sShadowTex,In.ShadowCoord);

// blend the blue, red and green textures over the base texture
	float4 NEMixed 	= lerp(NWColor,NEColor,MaskColor.b);
	float4 SWMixed 	= lerp(NEMixed,SWColor,MaskColor.r);
	float4 FinalColor = lerp(SWMixed,SEColor,MaskColor.g);
   
// Add the vertex light and shadow map
#ifdef SHADOWMAP
	FinalColor *= ShadowColor;
#else
	FinalColor *= In.Color;
#endif
	FinalColor.a = 1.0f;	// prevent transparency
	return FinalColor;
}


technique QuadTex_13
{
	pass one
	{
		sampler[0] = (sMaskTex);
		sampler[1] = (sQuadTex);
		sampler[2] = (sShadowTex);

		VertexShader = compile vs_2_0 vs_QuadTex();
		PixelShader = compile ps_2_0 ps_QuadTex();
	}
}

// fallback if nothing works
technique fallback { pass one { } }



@ChrisB
How many times can I thank you without sounding like a bore?
Sincerelly, thank you very much!

@EvilSOB
I will take good care of that! With my indispensable Collins. Uploaded to my webspace. Maybe i translate it for the spanish community. Thank you!