0
votes

I’m reading OpenGL Programming Guide, Ninth Edition.

I’m in trouble with this:

#version 420 core
uniform mat4 model_matrix;
…
layout (location = 0) in vec4 position;
…
void main(void)
{
vec4 pos = (model_matrix * (position * vec4(1.0, 1.0, 1.0, 1.0)));
…
};

So, what’s the point in multiplying "position" times vec4(1.0, 1.0, 1.0, 1.0)? The result will be "position" with or without vec4(1.0, 1.0, 1.0, 1.0).

1
IIRC vec4*vec4 is piecewise multiplication so its just scaling. Yes its redundant but maybe it will be latter on (in the tutorial or whatever) used for scaling ...Spektre

1 Answers

0
votes

I checked it in the Red book and there is no specific reason there, then it is just about a scale to the vertices positions in case that vector is different of Vector4.One and you want to do a scale, but if it is just a units vector, there is no need to do it and you can simple remove the redundancy.