Texture Scaling

Posted By: TehV

Texture Scaling - 12/11/13 14:56

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!
Posted By: MasterQ32

Re: Texture Scaling - 12/11/13 18:16

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
Posted By: TehV

Re: Texture Scaling - 12/16/13 12:16

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.
Posted By: MasterQ32

Re: Texture Scaling - 12/16/13 19:14

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)
Posted By: Superku

Re: Texture Scaling - 12/17/13 08:07

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
© 2024 lite-C Forums