Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Ayumi, 1 invisible), 584 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Texture Scaling #434060
12/11/13 14:56
12/11/13 14:56
Joined: Mar 2010
Posts: 120
Switzerland
T
TehV Offline OP
Member
TehV  Offline OP
Member
T

Joined: Mar 2010
Posts: 120
Switzerland
Hi,
I have a bumpmap shader running on a few entities. This works fine, but there's one problem with it that I can't seem to solve.
My project requires that the entities are near-infinitely scaleable. The problem is that the entity texture (and therefore the bumpmapping effect) scales along with the model, resulting in the textures being distorted due to the scaling. Is there some way I can prevent this?
Ideally I would like the texture to continuously repeat (tile) up to the edge of my object.

Thanks in advance!

Last edited by TehV; 12/11/13 15:09.
Re: Texture Scaling [Re: TehV] #434072
12/11/13 18:16
12/11/13 18:16
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
you could use triplanar texture mapping. this is a texture mapping technique that uses world coordinates to map the texture onto the model. so the textures are independant from model scale


Visit my site: www.masterq32.de
Re: Texture Scaling [Re: MasterQ32] #434179
12/16/13 12:16
12/16/13 12:16
Joined: Mar 2010
Posts: 120
Switzerland
T
TehV Offline OP
Member
TehV  Offline OP
Member
T

Joined: Mar 2010
Posts: 120
Switzerland
That would work great. How would I implement this in a shader? I'm currently using the pre-made bumpmapping shader, so ideally I'd like to modify that to do what I want rather than creating it from scratch.
It appears that I need to change the vertex shader to retrieve the texture coordinates. In the prefab shader I don't have access to that though, since the actual .fx file only contains the pixel shader and the vertex shader is '#include'd into it. I've tried finding the included file but was unable to find it.
Could I use a new pass to change the texture coordinates before the currently existing pass?
I'm absolutely new to shaders, so code examples with comments would be much appreciated.

Re: Texture Scaling [Re: TehV] #434216
12/16/13 19:14
12/16/13 19:14
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
http://http.developer.nvidia.com/GPUGems3/gpugems3_ch01.html

Here is the theory to this technique.
You should try to understand and modify your shader or even better, create a new one.
But start with some easy shader (write your own vertex and pixel shaders and so on)


Visit my site: www.masterq32.de
Re: Texture Scaling [Re: MasterQ32] #434229
12/17/13 08:07
12/17/13 08:07
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
A very simple way would be to multiply the tex2D coordinate input with the entity scaling:

vec_fill(my.scale_x,...);
my.skill41 = floatv(my.scale_x);

Then in the shader:

InTex = InTex*my.skill41;
float4 color = tex2D(..., InTex); // same for bump


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends

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