gpt4 book ai didi

shader - Qt3d 如何/在哪里为着色器制服分配默认值?

转载 作者:行者123 更新时间:2023-12-05 07:22:26 24 4
gpt4 key购买 nike

在 Qt 中 Qt 3D Wireframe QML example , vertex shader code看起来如下:

#version 330 core

in vec3 vertexPosition;
in vec3 vertexNormal;

out EyeSpaceVertex {
vec3 position;
vec3 normal;
} vs_out;

uniform mat4 modelView;
uniform mat3 modelViewNormal;
uniform mat4 mvp;

void main()
{
vs_out.normal = normalize( modelViewNormal * vertexNormal );
vs_out.position = vec3( modelView * vec4( vertexPosition, 1.0 ) );

gl_Position = mvp * vec4( vertexPosition, 1.0 );
}

上面的 uniform 变量都没有在示例的源代码中初始化,因此它们必须接收默认值,如 ShaderProgram 的文档中所述。 ,其中指出:

Qt3D will automatically populate a set of default uniforms if they are encountered during the shader instrospection phase.

还给出了“默认制服”列表。

我试图在 Qt 源代码中找到为这些制服分配默认值(我猜是单位矩阵)的部分,但不知何故找不到。有什么想法吗?

最佳答案

制服的初始化可以在例如对于函数中的 Qt 5.13.0 setShaderAndUniformsinitializeStandardUniformSetters./Src/qt3d/src/render/renderers/opengl/renderer/renderview.cpp 下的 Qt3d 模块中.

关于shader - Qt3d 如何/在哪里为着色器制服分配默认值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56488388/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com