PDA

View Full Version : Simple question



JohnnyKPL
04-28-2015, 07:22 AM
Why in GLSL language doing this:

// position = vec2;
// trans = mat4;

gl_Position = trans * vec4(position, 0.0, 1.0);

is different from:

gl_Position = vec4(position, 0.0, 1.0) * trans;

IonutCava
04-28-2015, 07:30 AM
Because maths get in the way

reader1
04-28-2015, 08:01 AM
Why in GLSL language doing this:

// position = vec2;
// trans = mat4;

gl_Position = trans * vec4(position, 0.0, 1.0);

is different from:

gl_Position = vec4(position, 0.0, 1.0) * trans;

This is quit basic math algorithm. the first is correct.
vec4 needs 4 elments, but position has only two, thus, you have to add two, 0 and 1. you can also make them 3,6; 2,9 etc. generally the last one makes one.

Cornix
04-28-2015, 10:31 AM
Because multiplication with matrices is not commutative. Do internet research on commutativity and matrices and you may learn more.