OpenGL: layout qualifier?

You’re right, the vertex shader is executed for each vertex. A vertex is composed by of or several attributes (positions, normals, texture coordinates etc.). On the CPU side when you create your VAO, you describe each attribute by saying “this data in this buffer will be attribute 0, the data next to it will be … Read more

Differences between GLSL and GLSL ES 2

Is GLSL ES 2 a totally separate language, or a special version of GLSL? Every version of GLSL is ultimately a “totally separate language;” some aren’t even backwards compatible with previous versions. However, the ES variation of GLSL is even moreso. Think of it as a fork of desktop GLSL. A fork of GLSL from … Read more

texture vs texture2D in GLSL

Yes, texture2D() is deprecated as of (at least) OpenGL 3.3; see page 99 of the 3.30 GLSL specification. It will continue to be supported in OpenGL compatibility profiles to avoid breaking existing code, but its usage in new code is strongly discouraged. EDIT: The details are slightly different for OpenGL ES, but the end result … Read more

What’s the logic for determining a min/max vector in GLSL?

Quoting from the first source that I could find (PDF), at the top of §8.3 Common Functions, page 132: These all operate component-wise. The description is per component. Nearly all the functions that operator on vectors but really only make sense for a scalar operate component-wise. (This includes abs, sign, floor, trunc, round, roundEven, ceil, … Read more

From RGB to HSV in OpenGL GLSL

I am the author of the second implementation. It has always behaved correctly for me, but you wrote 2.9 / 6.9 instead of 2.0 / 6.0. Since you target GLSL, you should use conversion routines that are written with the GPU in mind: // All components are in the range [0…1], including hue. vec3 rgb2hsv(vec3 … Read more

tech