3

In Qt's Qt 3D Wireframe QML example, the vertex shader code looks as follows:

#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 );
}

None of the uniform variables above are initialized in the example's source code, so they must receive default values as explained in the doc for ShaderProgram, which states:

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

The list of "default uniforms" is given as well.

I tried to find the part in the Qt source code where these uniforms are assigned their default values (which I guess are identity matrices), but couldn't somehow. Any ideas?

  • 3
    Have a look into functions `setShaderAndUniforms` and `initializeStandardUniformSetters` under Qt\5.13.0\Src\qt3d\src\render\renderers\opengl\renderer\renderview.cpp – vre Jun 07 '19 at 11:27
  • @vre Thank you for taking the time! I feel a bit silly for not finding this info myself though. Cheers! –  Jun 09 '19 at 11:16
  • 1
    @vre Add it as an answer. – karlphillip Jan 08 '22 at 01:47

1 Answers1

0

The initialization of the uniforms can be found e.g. for Qt 5.13.0 in the functions setShaderAndUniforms and initializeStandardUniformSetters in the Qt3d module under ./Src/qt3d/src/render/renderers/opengl/renderer/renderview.cpp.

vre
  • 6,041
  • 1
  • 25
  • 39