Opengl & glsl (vec4 * vec4) redundant

Hi, unfortunately I’m not sure this is about glsl. 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).

Thank you.

Good point. That looks like some test code someone forgot to remove. Should be a no-op that a good compiler will just discard.

I was going to ask you where in the 9th edition you saw that, but I found it:

  • p. 248, Example 5.11: Vertex Shader Used in Geometry Pass of Particle System Simulator
1 Like

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.