openglglslshaderminecraftvertex-shader

Does ftransform() in GLSL 1.20 do the same thing as mat3(gbufferModelViewInverse) * (gl_NormalMatrix * gl_Normal)?


I saw the ftransform() function while learning about Minecraft shaders.

gl_Position = ftransform(); 
TexCoords = gl_MultiTexCoord0.st;

Here is an example use in a Vertex Shader. (.vsh file) The docs for GLSL 1.20 does not give details at all about its implementation.

Does the above code do the same thing as the following:

gl_Position = mat3(gbufferModelViewInverse) * (gl_NormalMatrix * gl_Normal); 
TexCoords = gl_MultiTexCoord0.st;

Solution

  • See the specification The OpenGL® Shading Language, Version 4.60 - 8.5. Geometric Functions:

    Available only when using the compatibility profile. For core OpenGL, use invariant. For vertex shaders only. This function will ensure that the incoming vertex value will be transformed in a way that produces exactly the same result as would be produced by OpenGL’s fixed functionality transform. It is intended to be used to compute gl_Position

    So ftransform() does the same as:

    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;