Gamestudio Links
Zorro Links
Newest Posts
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 905 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Tile-ing Textures [Re: txesmi] #399767
04/19/12 14:19
04/19/12 14:19
Joined: Oct 2008
Posts: 513
Carlos3DGS Offline OP
User
Carlos3DGS  Offline OP
User

Joined: Oct 2008
Posts: 513
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
Re: Tile-ing Textures [Re: Carlos3DGS] #399769
04/19/12 15:13
04/19/12 15:13
Joined: Dec 2000
Posts: 4,608
mk_1 Offline

Expert
mk_1  Offline

Expert

Joined: Dec 2000
Posts: 4,608
You should eventually optimize your level by combining several of the blocks to one mesh to reduce the number of draw calls. In that case you don't even need a special shader because you can set the uv's directly.


Follow me on twitter
Re: Tile-ing Textures [Re: mk_1] #435252
01/04/14 20:18
01/04/14 20:18
Joined: May 2008
Posts: 257
D
djfeeler Offline
Member
djfeeler  Offline
Member
D

Joined: May 2008
Posts: 257
Hello,

I would like to know how to add lighting with sunlight in the first code that was done.

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 float2 inTex0 	: TEXCOORD0
)
{
	out_tiling Out;
	
	Out.Pos = mul(inPos,matWorldViewProj);
	Out.Tex0 = inTex0;

	return Out;
}
	
float4 ps_20 ( out_tiling In ): COLOR
{
	float2 Coord;
	Coord.x = In.Tex0.x * vecSkill41.x;
	Coord.y = In.Tex0.y * vecSkill41.y;
	
	return tex2D ( TexSampler, Coord );
}

technique TexTile
{
	pass one
	{
		VertexShader = compile vs_2_0 vs_20();
		PixelShader = compile ps_2_0 ps_20();	
	}		
}



Thanks in advance.

Page 2 of 2 1 2

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1