In the previous code I posted the textures would move around when the camera moved. I was using matWorldViewProj instead of matWorld, lol.

I currently have the horizontal surfaces (top and bottom) working like I wanted, but I am messing up the calculations for the vertical surfaces (walls).



Code:
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,matWorld);
	Out.Tex0.x = Out.Pos.x + (Out.Pos.y*inNormal.z);
	Out.Tex0.y = Out.Pos.z + (Out.Pos.y*inNormal.x);
	
	Out.Pos = mul(inPos,matWorldViewProj);
	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();			
	}		
}


Any ideas to fix the verticals?

EDIT: Nevermind, I fixed it. The main idea was correct but there was just a dumb mistake I made with the normals.


Code:
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,matWorld);
	Out.Tex0.x = Out.Pos.x + (Out.Pos.y*inNormal.x);
	Out.Tex0.y = Out.Pos.z + (Out.Pos.y*inNormal.z);
	
	Out.Pos = mul(inPos,matWorldViewProj);
	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();			
	}		
}


I also leave the fixed code available for anyone interested in somthing like this. (free to use, free to modify, free to re-distribute, no credits needed, no need for permissions, bla bla bla)

Last edited by Carlos3DGS; 04/19/12 14:40. Reason: fixed

"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