Skip to content

gl_Vertex

gl_Vertex

Valid Programs: *.vsh


The vertex position attribute in model space (which varies for different geometry). It can be converted to view space using gl_ModelViewMatrix

vec3 model_pos = gl_Vertex.xyz;
vec4 view_pos = gl_ModelViewMatrix * vec4(model_pos, 1.0);
vec4 clip_pos = gl_ProjectionMatrix * view_pos;
gl_Position = clip_pos;

in vec3 vaPosition;

For terrain this is relative to the chunk and you must add chunkOffset as shown below. For all other geometry, vaPosition directly stores the model space position. It can be converted to view space using modelViewMatrix

vec3 model_pos = vaPosition + chunkOffset;
vec4 view_pos = modelViewMatrix * vec4(model_pos, 1.0);
vec4 clip_pos = projectionMatrix * view_pos;
gl_Position = clip_pos;