Tell me about matTexture

Posted By: Error014

Tell me about matTexture - 08/04/12 15:31

Hello, everyone!

The manual is a bit foggy about what exactly matTexture does and holds. They say:

Quote:

u,v
Pixel offsets of sprite and model textures in horizontal and vertical direction. They affect the matTexture texture transformation matrix. By changing these offsets in real time, effects like streaming water can be achieved.


Or this:

Quote:

matTexture
The texture transformation matrix, determined by the entities' uv values.


Which may be the worst description ever.


Alright, so after googling this problem, I saw that apparently, one needs to use DoTexture. Which is really just this:

Quote:

return mul(float4(inTex.x,inTex.y,1,1),matTexture).xy;


Okay, sweet. So apparently, there's something in the first 2x2-block of that 4x4-matrix that gives us the texture, neat.

The problem is, though, it doesn't work. I'm using a slightly adapted version of the fx_mirrorfloor version, and in there (in the vertex shader), I have:

Code:
Out.Tex0 = mul(float4(inTex0.x,inTex0.y,1,1),matTexture).xy;



(I've also defined matTexture, don't worry about that)

And with that, I see no texture shifting. Neither do I see something with that:

Code:
Out.Tex0.x = mul(float4(inTex0.x,inTex0.y,1,1),matTexture).x;
	Out.Tex0.y = inTex0.y;



If I instead use, say, this:

Code:
Out.Tex0.x = inTex0.x + vecTime.w/16;
Out.Tex0.y = inTex0.y;



I see the expected texture shifting.
But I need to have individual u,v-offsets.


It's very possible I just don't understand how matTexture is to be used.

So can anyone help me with this? When exactly is matTexture (re)calculated? How do I use it for shifting a texture?


Thanks!
Posted By: Superku

Re: Tell me about matTexture - 08/04/12 16:20

When I think about it the only senseful approach for (a) matTexture is the following:
1 0 u 0
0 1 0 v
0 0 1 0
0 0 0 1
When you take the vector (Tex.x,Tex.y,1,1) and multiply the matrix above from left, you'd get the result (Tex.x + u, Tex.y + v,1,1). But when I check matTexture[0][2] or matTexture[2][0], I always get 0. So I assume it's a bug, matTexture isn't calculated anymore.
Posted By: Error014

Re: Tell me about matTexture - 08/04/12 18:40

Ah, thank you. Good to know it's not a failure on my part, then. laugh

And yeah, that matrix makes a lot of sense. I should have stared a bit longer at the vector (tex.x,tex.y,1,1) to figure that out.


Have you tried it with the new 8.40-version? Since I'm still rockin' the ol' 8.30.5-version.
I'm just asking so we can provide that bit in a Bug-Hunt-thread. laugh
Posted By: Superku

Re: Tell me about matTexture - 08/04/12 20:16

Yep, it's the 8.40 public beta. wink
Posted By: Error014

Re: Tell me about matTexture - 08/04/12 20:58

Thanks for the help! I've posted a bug report on this issue.
© 2023 lite-C Forums