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

huangapple go评论56阅读模式
英文:

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

问题

我在学习有关Minecraft着色器时看到了ftransform()函数。

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

这是在顶点着色器中的一个示例用法(.vsh文件)。GLSL 1.20的文档没有提供关于它的实现细节。

上面的代码是否与以下代码执行相同的操作:

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

英文:

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;

答案1

得分: 0

查看规范OpenGL® Shading Language,版本4.60 - 8.5. 几何函数

> 仅在使用兼容性配置文件时可用。对于核心OpenGL,请使用不变量。
仅适用于顶点着色器。此函数将确保传入的顶点值以一种方式转换,以产生与OpenGL的固定功能转换产生的完全相同的结果。它旨在用于计算gl_Position

因此,ftransform()与以下内容相同:

gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
英文:

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;

huangapple
  • 本文由 发表于 2023年6月19日 09:09:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76503102.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定