Congratulations to our 2022 Qt Champions!

Qt 3D Studio - VS modfication for materials

  • Hi,

    I want to modify the Vertex Shader in Qt 3D Studio scene.
    The effects modification looks simple - we have to implement own vert() function.
    Unfortunately I have to change the material - all of them have the empty


    section. The Fragment Shaders have a lot of functions calledy by... I don't know what (no main or frag function shown) so it doesn't look clear for me.

    I tried to add the vert() function (using variables from effect.glsllib) but looks like it's not called. I can add the main() but in this case the shader is not working.

    So - is possible to modify the VS for the material?

  • I checked the generated source by NV Nsight - looks like we have different approaches for the materials and effects.
    In the effects:

    void vert();
    void main()
        gl_Position = Transform( ModelViewProjectionMatrix, DestSize, vec4(attr_pos, 1.0) );
        TexCoord = attr_uv;
    void frag();
    void main() 

    and we have possibility to create own implementation.
    The material code (FS):

    void main()
      normal = normalize( computeNormal() );
      float alpha = clamp( evalCutout(), 0.0, 1.0 );
    //another generated section
      fragColor = rgba;

    Looks like we don't have single method like earlier. Maybe it's better, maybe not - but we have some possibilities. Unfortunately the VS looks like:

    void main()
        gl_Position = model_view_projection * vec4(attr_pos, 1.0);
        vec3 texCoord0 = vec3( attr_uv0, 0.0 );
        varTexCoord0 = texCoord0;
        varNormal = normalize( normal_matrix * attr_norm );
        varTangent = normal_matrix * attr_textan;
        varBinormal = normal_matrix * attr_binormal;
        varObjTangent = attr_textan;
        varObjBinormal = attr_binormal;
        varObjPos = attr_pos;
        vec4 worldPos = (model_matrix * vec4(attr_pos, 1.0));
        varWorldPos =;

    In this case I see no possibility to perform the custom calculations by modifying the material file - that's the 1st problem. The 2nd - the uniforms list:

    uniform mat4 view_projection_matrix;
    uniform mat4 view_matrix;
    uniform vec2 camera_properties; //near clip x, far clip y
    uniform vec3 camera_position; //position in world space of the camera
    uniform mat4 model_view_projection;
    uniform mat4 model_matrix;
    uniform mat3 normal_matrix;

    We have the MVP matrix but no separete projection matrix.
    Will be the approach changed in future release? Or maybe I'm wrong and is possible to get the access to the VS (unfortunately I didn't found more details about it)?

Log in to reply