You could use tri-planar texturing, something like the following (untested but should/ could work):
const float4x4 matWorldViewProj;
const float4x4 matWorld;
const float4 vecSunDir;
float4 vecSkill41;
texture entSkin1;
sampler ColorMapSampler = sampler_state
{
Texture = <entSkin1>;
AddressU = Wrap;
AddressV = Wrap;
};
void DiffuseVS(
in float4 InPos: POSITION,
in float3 InNormal: NORMAL,
in float2 InTex: TEXCOORD0,
out float4 OutPos: POSITION,
out float3 OutTex: TEXCOORD0,
out float3 OutNormal: TEXCOORD1,
out float3 OutNormal2: TEXCOORD2)
{
OutPos = mul(InPos, matWorldViewProj);
OutNormal = mul(InNormal, matWorld);
OutNormal2 = InNormal;
OutTex = InPos.xyz*vecSkill41.x+vecSkill41.yzw;
}
float4 DiffusePS(
in float3 InTex: TEXCOORD0,
in float3 InNormal: TEXCOORD1,
in float3 InNormal2: TEXCOORD2): COLOR
{
InNormal = normalize(InNormal);
float Diffuse = saturate(dot(-vecSunDir, InNormal)*2)*0.5+0.5;
float4 Color = tex2D(ColorMapSampler, InTex.xy)*InNormal2.z*InNormal2.z;
Color += tex2D(ColorMapSampler, InTex.xz+0.333)*InNormal2.y*InNormal2.y;
Color += tex2D(ColorMapSampler, InTex.yz+0.667)*InNormal2.x*InNormal2.x;
float4 final = Color*Diffuse;
return final;
}
technique DiffuseTechnique
{
pass P0
{
VertexShader = compile vs_2_0 DiffuseVS();
PixelShader = compile ps_2_0 DiffusePS();
}
}
entity.skill41 is the scaling of the texture, try for example
entity.skill41 = floatd(1.0,16.0); // for a cube with a width of 16 quants
You can add an offset such as
entity.skill42 = floatv(0.5);
entity.skill43 = floatv(0.5);
entity.skill44 = floatv(0.5);
which might result in better tiling/ fitting textures.