I had a nailed thorn and needed take it off.
I found a better way, but the box has to be perfectly aligned to the system planes and all the cube faces has to be detached from each other, otherwise it will not work.
Save box scales into x->skill41, y->skill42 and z->skill43
tiled.fx
float4x4 matWorld;
float4x4 matWorldViewProj;
float4 vecSkill41;
texture entSkin1;
sampler TexSampler = sampler_state
{
Texture = <entSkin1>;
MipFilter = Linear;
AddressU = Wrap;
Addressv = Wrap;
};
struct out_tiling
{
float4 Pos : POSITION;
float2 Tex0 : TEXCOORD0;
};
out_tiling vs_20
(
in float4 inPos : POSITION,
in float3 inNormal : NORMAL,
in float2 inTex0 : TEXCOORD0
)
{
out_tiling Out;
Out.Pos = mul(inPos,matWorldViewProj);
Out.Tex0.x = inTex0.x * ( (vecSkill41.y*inNormal.x) + (vecSkill41.x*inNormal.y) + (vecSkill41.x*inNormal.z) );
Out.Tex0.y = inTex0.y * ( (vecSkill41.z*inNormal.x) + (vecSkill41.y*inNormal.y) + (vecSkill41.z*inNormal.z) );
return Out;
}
float4 ps_20 ( out_tiling In ): COLOR
{
return tex2D ( TexSampler, In.Tex0 );
}
technique TexTile
{
pass one
{
VertexShader = compile vs_2_0 vs_20();
PixelShader = compile ps_2_0 ps_20();
}
}
Salud!