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
1 registered members (AbrahamR), 717 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
What is what in the Matrix #21391
12/20/03 01:45
12/20/03 01:45
Joined: Aug 2003
Posts: 145
Beorn Offline OP
Member
Beorn  Offline OP
Member

Joined: Aug 2003
Posts: 145
I got the texture sizing working with some tirekicking, but i dont know how the transformation matrix works in detail. I know that 41 and 42 controlls UV position. and i also found out that 21, 22 controlls scaling in some way, but its hard to try and guess those things.

So could anyone tell me/point me to some info on this?




Re: What is what in the Matrix [Re: Beorn] #21392
12/20/03 12:51
12/20/03 12:51
Joined: Aug 2003
Posts: 145
Beorn Offline OP
Member
Beorn  Offline OP
Member

Joined: Aug 2003
Posts: 145
Bumping this since i really would like some input here.
I found out i was quite wrong in my earlier post about what does what.

I have found out how to scale stuff. Can i scale and move a texture using the same matrix or do i havce to use separate?

Is it correct to assume that if i change 11,22,33 i will scale the texture?

What i am trying to achieve is using different parts of a large bitmaps for different entities in the fixed Function pipeline. I have some success but no control;)

Any nuggets of information would be appreciated.

Re: What is what in the Matrix [Re: Beorn] #21393
12/24/03 06:54
12/24/03 06:54
Joined: Sep 2003
Posts: 3,236
San Diego, CA
M
Marco_Grubert Offline
Expert
Marco_Grubert  Offline
Expert
M

Joined: Sep 2003
Posts: 3,236
San Diego, CA
I am not sure which Matrix you are referring to, but at the same time it sounds like general matrix operations that confuse you, so here's a quick intro to linear algebra:
a matrix is an ordered collection of numbers and in computer graphics it's mostly a 2 dimensional grid with 3x3 or 4x4 entries. Matrices can be multiplied in order to yield a new matrix. This is of particular interest since a coordinate/vector can be regarded as a one-dimensional matrix. Here's how the two get multiplied, assuming a 4x4 matrix and a 4x1 vector (4 rows, 1column):
Code:

Matrix * in-vector = output-vector

(e11 e12 e13 e14) (x) (x*e11 + y*e12 + z*e13 + w*e14)
(e21 e22 e23 e24) (y) (x*e21 + y*e22 + z*e23 + w*e24)
(e31 e32 e33 e34) * (z) = (x*e31 + y*e32 + z*e33 + w*e34)
(e41 e42 e43 e44) (w) (x*e41 + y*e42 + z*e43 + w*e44)



If e11,e22,e33 and e44 are all 1 and the rest of the matrix is 0, you have an Identity Matrix and the resulting vector would simply be (x,y,z,w).
Usually you have an x,y,z coordinate (or U,V,0 for texture coordinates) and w is set to 1. With w==1 looking at the last column of the equation you can see that this basically adds the vector (e14,e24,e34,e44) to the original (x,y,z,1). Therefore (e14,e24,e34,e44) is said to be a translation vector which moves the input point around (or shifts the texture around).
If you have an identity matrix (everything zero accepts for the center diagonal from top left to bottom right) and then change the diagonal to something other then 1, e.g. to all 4s, your output vector changes to (4x, 4y, 4z, 4w).

To summarize: the 4th column (or the 4th row- I don't know which standard the shader uses) determines offset/translation. The diagonal (e11,e22,e33,e44) determines scaling.

What about the rest of the elements ? They rotate your input vectors. e12, e13, etc. are sines and cosines of a rotation. If you want to figure out how to set those- do a google search for "rotation matrix".

Re: What is what in the Matrix [Re: Marco_Grubert] #21394
12/24/03 10:11
12/24/03 10:11

A
Anonymous
Unregistered
Anonymous
Unregistered
A



I know this thread is about shaders (and matrix) and don't want to turn this shader/matrix thread into a math/matrix thread but I think I've probably seen the matrix before (probably in 11th grade in high-school) and I do have a question.

In the matrix, is it something like you add or subtract like for example:

(By the way, it seems like you have added a plus sign in between the two of the numbers/letters...)

Code:

{10 15 25} {20 10 15} {30 + 25 + 40}
{ 5 20 10} + (15 5 40} = {20 + 25 + 50}
{30 0 5} {10 20 25} {40 + 20 + 30}



...and...

Code:

{50 25 15} {30 10 10} {20 + 15 + 5}
{45 30 55} - {15 20 45} = {30 + 10 + 10}
{60 20 35} {15 5 20} {45 + 15 + 15}



And is it the same thing as if you multiply or divide?

If no, please correct me if I'm wrong.

The reason I ask is this is pretty fascinating... Gonna have to get my memory refreshed...

Re: What is what in the Matrix [Re: Marco_Grubert] #21395
12/31/03 12:57
12/31/03 12:57
Joined: Aug 2003
Posts: 145
Beorn Offline OP
Member
Beorn  Offline OP
Member

Joined: Aug 2003
Posts: 145
Thanks Marco,
Very good explanation.
I have some knowledge of the concept behind matrices but i havent used it before so theres a stack of books beside my computer all the time;)
Applying this splinter of knowledge is tricky though.

If i understand this correctly the matrices that are listed in the docs are pre-set by the engine (world, view etc) plus the mtlMat that i can set myself.



Re: What is what in the Matrix [Re: Beorn] #21396
02/12/04 20:23
02/12/04 20:23
Joined: Oct 2003
Posts: 1,550
United Kingdom
indiGLOW Offline
Serious User
indiGLOW  Offline
Serious User

Joined: Oct 2003
Posts: 1,550
United Kingdom
all i see is ...blonde......brunette.......redhead.....

In all seriousness this is exactly what I am looking for! A starting point to understanding the syntex of shaders...


The Art of Conversation is dead : Discuss
Re: What is what in the Matrix #21397
02/13/04 05:57
02/13/04 05:57
Joined: Sep 2003
Posts: 3,236
San Diego, CA
M
Marco_Grubert Offline
Expert
Marco_Grubert  Offline
Expert
M

Joined: Sep 2003
Posts: 3,236
San Diego, CA
Quote:

Code:

{10 15 25} {20 10 15} {30 + 25 + 40}
{ 5 20 10} + (15 5 40} = {20 + 25 + 50}
{30 0 5} {10 20 25} {40 + 20 + 30}


And is it the same thing as if you multiply or divide?




The above is wrong. Matrix addition is done element-wise.
Code:

(a11 a12) (b11 b12) (a11+b11 a12+b12)
(a21 a22) + (b21 b22) = (a21+b21 a22+b22)

Same thing for subtraction- just replace the plus with a minus. Matrix multiplication is done by multiplying rows of matrix A with each column of matrix B. The matrix-vector multiplication I wrote about above is only a special case where the second matrix is a vector, i.e. a single-column-matrix.
Matrix division does not exist. But you can (sometimes) do a matrix multiplication with an inverse matrix which is similar to a division.

There is an excellent website covering all fields of mathematics:
http://mathworld.wolfram.com/

I also highly recommend the math program "Derive" which is a bit expensive for hobby users, but there is a 30-day-trial allowing you to play around with matrix and vector equations.


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