[Interest] Qt3D problems

Helmut Mülner helmut.muelner at gmail.com
Wed Apr 3 17:27:22 CEST 2019


Hello,

QDiffuseSpecularMapMaterial should have a setDiffuse/setSpecular which
expects a Qt3DRender::QAbstractTexture * so you would need to create
Qt3DRender::QTexture2D instances and set your painted images on these.

I have been experimented a bit and discovered:

-       Although I get the shader error message the resulting 3D scene looks
reasonable (the texture and some dump-mapping effect are visible).

-       The problem seems to be specific to my
computer/configuration/hardware. My office neighbor (with a newer computer
and a better graphics card) has no problems.

-       QDiffuseSpecularMapMaterial is obsolete, so I tried to replace it
with  QDiffuseSpecularMaterial.

There's a manual test in the qt3d sources which should be doing that:
<https://code.qt.io/cgit/qt/qt3d.git/tree/tests/manual/paintedtexture-cpp/sc
ene.cpp>
https://code.qt.io/cgit/qt/qt3d.git/tree/tests/manual/paintedtexture-cpp/sce
ne.cpp

With QDiffuseSpecularMaterial of course one has to use e.g.
material->setNormal(QVariant::fromValue(normalTexture)).

But the resulting scene did now fulfill my expectations – with large
rectangular pixels on the surfaces and no siginifact bump mapping.

What I really would like to achieve: I get the model data (a profile that is
extended in z direction) and a surface texture from a database.

I would like to display this model with directional light from the camera
viewpoint with the surface texture (with optional color table modification)
and with some dump-mapping effect (derived from the surface texture and/or
from random noise).

This worked reasonable well with Qt-5.9.4 using QNormalDiffuseMapMaterial.
But I am sure there can be a better, more efficient solution that also looks
better. Only problem: I am not yet experienced enough with OpenGL and Qt3D.
:)

QNormalDiffuseMapMaterial should still be usable though. What has changed
however is that before we would provide shader versions for each GL version.
Now instead we generate a graph that gets converted to (in theory) correct
shader code at runtime based on the GL version we find at runtime. I suspect
we may not be handling the ES2 case properly. What is odd though is that
Qt3D seems to detect GL3 support but you say your driver's glsl compiler
only supports ES2. If that's the case, in your main.cpp I'd suggest setting
the QSurfaceFormat::defaultFormat() to OpenGL ES2.0 so that Qt3D only uses
ES2 compatible GL functions.

Please feel free to file a bug report about that and assign it to me please.

I will try to further isolate the problem and report then and would be
thankful for hints where to look.

BTW: The “Qt 3D: PBR Materials QML Example” crashes on my computer but the
GL 4.x and GL 3.x demos of the Geeks3d GUP Caps Viewer work.

Helmut

 

On 4/2/19 1:13 PM, Helmut Mülner wrote:

Hi,

 

I have a Windows 10 (Qt-5.9.6, msvc2017_64) desktop application with a big
C++ backend and the frontend in QML.

I recently tried to upgrade to Qt-5.12.2, but now the
QNormalDiffuseMapMaterial does not work anymore.

 

I display a 3D-model that is generated from database data.

The front-end is simple:

Scene3D {

    id: scene3d

    width: 4

    focus: true

    aspects: ["input", "logic"]

    cameraAspectRatioMode: Scene3D.AutomaticAspectRatio

    enabled: visible

    visible: false

    entity: controller.myCustomEntity

}

 

myCustomEntity is derived from Qt3DCore:QEntity.

Setting up the material is done this way:

auto material = new Qt3DExtras::QNormalDiffuseMapMaterial();
        material->setShininess(10.0f);
        material->setAmbient(QColor(colorString));
        material->setSpecular(QColor(20, 20, 20));
        auto width = some_width();
        auto height = some_height();
        auto heightMap = createSomeHeightMap (width, height, 
);
        auto img = heightMap.convertToFormat(QImage::Format_Indexed8);
        // img.setColorCount(colortable.size());
        // img.setColorTable(colortable); // use a specific color table
 
        auto textureImage = img.convertToFormat(QImage::Format_ARGB32);
        auto* diffuseImage = new MyTextureImage(textureImage);
        material->diffuse()->addTextureImage(diffuseImage);
        auto normalMap =
RailEntityPrivate::makeNormalMapFromHeightMap(heightMap);
        auto* normalImage = new MyTextureImage(normalMap);
        material->normal()->addTextureImage(normalImage);
         


 

Using:

class MyTextureImage : public Qt3DRender::QPaintedTextureImage
{
public:
    explicit MyTextureImage(QImage image)
        : image(image)
    {
        setSize(image.size());
    }
 
protected:
    void paint(QPainter *painter) override
    {
        painter->drawImage(0, 0, image);
    }
 
private:
    QImage image;
};
 

 

After upgrading to Qt 5.12.2 and enabling some trace categories I get:

 

qt.scenegraph.general: Using sg animation driver

qt.scenegraph.general: Animation Driver: using vsync: 16.67 ms

qt.scenegraph.general: texture atlas dimensions: 1024x1024

qt.scenegraph.general: R/G/B/A Buffers:   8 8 8 8

qt.scenegraph.general: Depth Buffer:      24

qt.scenegraph.general: Stencil Buffer:    8

qt.scenegraph.general: Samples:           0

qt.scenegraph.general: GL_VENDOR:         Intel

qt.scenegraph.general: GL_RENDERER:       Intel(R) HD Graphics 4000

qt.scenegraph.general: GL_VERSION:        4.0.0 - Build 10.18.10.5059

qt.scenegraph.general: GL_EXTENSIONS:     GL_ARB_shading_language_packing
GL_ARB_color_buffer_float GL_ARB_fragment_program_shadow
GL_ARB_seamless_cube_map GL_EXT_texture_swizzle GL_NV_texgen_reflection
GL_ARB_get_program_binary GL_EXT_texture_shared_exponent
GL_ARB_vertex_array_bgra GL_EXT_framebuffer_multisample
WGL_ARB_create_context_profile WGL_ARB_pixel_format
GL_ARB_draw_elements_base_vertex GL_ARB_texture_compression_bptc
GL_ARB_draw_instanced GL_ARB_blend_func_extended GL_ARB_transform_feedback3
WGL_ARB_buffer_region GL_SGIS_generate_mipmap GL_ATI_separate_stencil
GL_ARB_fragment_program GL_EXT_texture_sRGB GL_EXT_texture_storage
GL_ARB_map_buffer_range GL_EXT_texture_rectangle GL_ARB_texture_swizzle
GL_WIN_swap_hint GL_EXT_compiled_vertex_array GL_EXT_texture_snorm
GL_EXT_geometry_shader4 GL_ARB_texture_env_dot3
GL_ARB_texture_cube_map_array GL_EXT_draw_buffers2
GL_ARB_texture_border_clamp GL_ARB_pixel_buffer_object
GL_ARB_texture_non_power_of_two GL_ARB_multi_draw_indirect
GL_ARB_vertex_type_2_10_10_

10_rev GL_INTEL_performance_queries GL_ARB_buffer_storage
GL_EXT_framebuffer_blit GL_ARB_map_buffer_alignment
GL_ARB_transform_feedback_instanced GL_EXT_texture_lod_bias
GL_ARB_texture_cube_map GL_KHR_debug GL_EXT_clip_volume_hint
GL_ARB_point_sprite GL_EXT_blend_func_separate GL_ARB_texture_rectangle
GL_ARB_sampler_objects GL_ARB_texture_storage GL_SUN_multi_draw_arrays
WGL_EXT_extensions_string GL_SGIS_texture_edge_clamp
GL_EXT_shader_integer_mix GL_ARB_timer_query GL_ARB_base_instance
WGL_EXT_swap_control_tear GL_EXT_texture3D GL_ARB_texture_rg
GL_ARB_debug_output GL_EXT_stencil_wrap GL_ARB_framebuffer_sRGB
GL_ARB_provoking_vertex GL_ARB_shader_subroutine GL_SGIS_texture_lod
GL_EXT_texture_array GL_ARB_window_pos GL_EXT_packed_depth_stencil
GL_ARB_program_interface_query GL_IBM_texture_mirrored_repeat
WGL_ARB_pixel_format_float WGL_ARB_create_context GL_EXT_stencil_two_side
GL_ARB_sync GL_EXT_separate_specular_color GL_ARB_shading_language_100
GL_ARB_vertex_array_object GL_ARB_occlusion_query2 GL_ARB_textur

e_env_crossbar GL_ARB_texture_buffer_range GL_EXT_texture_integer
GL_EXT_gpu_program_parameters WGL_EXT_depth_float
GL_ARB_texture_storage_multisample GL_ARB_framebuffer_no_attachments
GL_NV_conditional_render GL_ARB_tessellation_shader GL_ARB_robustness
GL_ARB_stencil_texturing GL_ARB_texture_rgb10_a2ui
GL_ARB_texture_env_combine GL_ARB_fragment_shader GL_ARB_texture_float
GL_EXT_abgr GL_ARB_sample_shading GL_ARB_explicit_attrib_location
GL_INTEL_performance_query GL_EXT_framebuffer_object
WGL_ARB_framebuffer_sRGB GL_EXT_secondary_color GL_ARB_texture_compression
GL_EXT_blend_minmax GL_EXT_blend_color GL_EXT_rescale_normal
WGL_NV_DX_interop GL_ARB_depth_clamp GL_ARB_transpose_matrix
GL_ARB_transform_feedback2 GL_ARB_vertex_shader GL_ARB_instanced_arrays
WGL_ARB_make_current_read GL_ARB_gpu_shader5
WGL_EXT_create_context_es2_profile GL_ARB_geometry_shader4
GL_EXT_blend_equation_separate GL_ARB_conservative_depth
GL_ARB_texture_buffer_object_rgb32 GL_ARB_copy_buffer GL_ARB_shadow
GL_KHR_blend_equation_advanced 

GL_ARB_internalformat_query GL_EXT_texture_filter_anisotropic
GL_ARB_occlusion_query GL_ARB_uniform_buffer_object
WGL_ARB_extensions_string GL_EXT_fog_coord GL_ARB_separate_shader_objects
GL_ARB_shader_atomic_counters GL_ARB_draw_buffers GL_EXT_texture_edge_clamp
GL_EXT_texture_env_add GL_ARB_shader_precision GL_ARB_compatibility
GL_ARB_vertex_buffer_object GL_ARB_arrays_of_arrays
GL_ARB_vertex_attrib_binding GL_ARB_shader_bit_encoding
GL_ARB_shader_objects GL_EXT_multi_draw_arrays GL_ARB_texture_env_add
GL_ARB_framebuffer_object GL_EXT_texture_env_combine GL_ARB_draw_indirect
WGL_EXT_create_context_es_profile WGL_EXT_swap_control GL_ARB_texture_gather
GL_NV_blend_square GL_EXT_packed_pixels GL_EXT_texture_compression_s3tc
GL_NV_primitive_restart GL_EXT_shadow_funcs GL_ARB_ES3_compatibility
GL_ARB_internalformat_query2 GL_EXT_gpu_shader4 GL_ARB_ES2_compatibility
GL_INTEL_map_texture GL_ARB_depth_texture GL_EXT_bgra
GL_ARB_vertex_attrib_64bit GL_ARB_texture_multisample
GL_ARB_fragment_coord_conventions GL_ARB_m

ultitexture GL_ARB_draw_buffers_blend GL_ARB_gpu_shader_fp64
WGL_ARB_multisample GL_EXT_texture_buffer GL_ARB_half_float_vertex
GL_EXT_transform_feedback GL_EXT_draw_range_elements
WGL_EXT_pixel_format_packed_float GL_ARB_half_float_pixel WGL_ARB_pbuffer
WGL_ARB_create_context_robustness GL_ARB_vertex_program
GL_ARB_texture_query_lod GL_ARB_depth_buffer_float
GL_ARB_shading_language_420pack GL_EXT_texture_sRGB_decode
GL_EXT_blend_subtract GL_3DFX_texture_compression_FXT1
GL_ARB_point_parameters GL_ARB_compressed_texture_pixel_storage
GL_ARB_multisample GL_ARB_viewport_array GL_ARB_texture_compression_rgtc
GL_EXT_packed_float

qt.scenegraph.general: Max Texture Size: 16384

qt.scenegraph.general: Debug context:    false




qt.scenegraph.general: animation driver switched to timer mode

Qt3D.Renderer.Backend: class Qt3DRender::Render::GraphicsHelperInterface
*__cdecl
Qt3DRender::Render::GraphicsContext::resolveHighestOpenGLFunctions(void)
Building OpenGL 3.3

Qt3D.Renderer.Backend: context supports 16 texture units

Qt3D.Renderer.Backend: VAO support =  true

Qt3D.Renderer.Backend: class Qt3DRender::Render::GraphicsHelperInterface
*__cdecl
Qt3DRender::Render::GraphicsContext::resolveHighestOpenGLFunctions(void)
Building OpenGL 3.3




Qt3D.Renderer.Backend: class Qt3DRender::Render::GraphicsHelperInterface
*__cdecl
Qt3DRender::Render::GraphicsContext::resolveHighestOpenGLFunctions(void)
Building OpenGL 3.3

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "texCoordScale" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "modelMatrix" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "modelNormalMatrix"
-1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"modelViewProjection" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "envLightCount" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "lightCount" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "lights[0].type" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "lights[1].type" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "lights[2].type" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "lights[3].type" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "lights[4].type" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "lights[5].type" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "lights[6].type" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "lights[7].type" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "lights[0].position"
-1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "lights[1].position"
-1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "lights[2].position"
-1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "lights[3].position"
-1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "lights[4].position"
-1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "lights[5].position"
-1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "lights[6].position"
-1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "lights[7].position"
-1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "lights[0].color" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "lights[1].color" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "lights[2].color" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "lights[3].color" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "lights[4].color" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "lights[5].color" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "lights[6].color" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "lights[7].color" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[0].intensity" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[1].intensity" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[2].intensity" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[3].intensity" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[4].intensity" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[5].intensity" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[6].intensity" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[7].intensity" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[0].direction" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[1].direction" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[2].direction" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[3].direction" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[4].direction" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[5].direction" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[6].direction" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[7].direction" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[0].constantAttenuation" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[1].constantAttenuation" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[2].constantAttenuation" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[3].constantAttenuation" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[4].constantAttenuation" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[5].constantAttenuation" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[6].constantAttenuation" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[7].constantAttenuation" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[0].linearAttenuation" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[1].linearAttenuation" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[2].linearAttenuation" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[3].linearAttenuation" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[4].linearAttenuation" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[5].linearAttenuation" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[6].linearAttenuation" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[7].linearAttenuation" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[0].quadraticAttenuation" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[1].quadraticAttenuation" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[2].quadraticAttenuation" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[3].quadraticAttenuation" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[4].quadraticAttenuation" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[5].quadraticAttenuation" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[6].quadraticAttenuation" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[7].quadraticAttenuation" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[0].cutOffAngle" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[1].cutOffAngle" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[2].cutOffAngle" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[3].cutOffAngle" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[4].cutOffAngle" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[5].cutOffAngle" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[6].cutOffAngle" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block
"lights[7].cutOffAngle" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "normalTexture" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "eyePosition" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "shininess" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "ks" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "diffuseTexture" -1

Qt3D.Renderer.Shaders: Active Uniform in Default Block  "ka" -1

Qt3D.Renderer.Shaders: Active Attribute  "vertexTexCoord"

Qt3D.Renderer.Shaders: Active Attribute  "vertexPosition"

Qt3D.Renderer.Shaders: Active Attribute  "vertexNormal"

Qt3D.Renderer.Shaders: Active Attribute  "vertexTangent"

QOpenGLShader::compile(Fragment): ERROR: 4:63: 'const' : overloaded
functions must have the same parameter qualifiers 

ERROR: 4:63: 'lightCount' : undeclared identifier 

ERROR: 4:63: 'assign' : implicit conversion between types not allowed in ES
2.0 

ERROR: 4:63: 'assign' : implicit conversion between types not allowed in ES
2.0 

ERROR: 4:63: '<' :  wrong operand types  no operation '<' exists that takes
a left-hand operand of type 'int' and a right operand of type 'float' (or
there is no acceptable conversion)

ERROR: 4:65: 'light' : undeclared identifier 

ERROR: 4:65: 'assign' :  cannot convert from 'uniform structure' to 'float'

ERROR: 4:67: 'assign' :  cannot convert from 'uniform structure' to 'float'

ERROR: 4:69: 'assign' :  cannot convert from 'uniform structure' to 'float'

ERROR: 4:71: 'assign' :  cannot convert from 'uniform structure' to 'float'

ERROR: 4:73: 'assign' :  cannot convert from 'uniform structure' to 'float'

ERROR: 4:75: 'assign' :  cannot convert from 'uniform structure' to 'float'

ERROR: 4:77: 'assign' :  cannot convert from 'uniform structure' to 'float'

ERROR: 4:79: 'assign' :  cannot convert from 'uniform structure' to 'float'

ERROR: 4:82: 'type' :  field selection requires structure, vector, or matrix
on left hand side 

ERROR: 4:82: 'assign' : implicit conversion between types not allowed in ES
2.0 

ERROR: 4:82: 'assign' : implicit conversion between types not allowed in ES
2.0 

ERROR: 4:82: '!=' :  wrong operand types  no operation '!=' exists that
takes a left-hand operand of type 'float' and a right operand of type 'const
int' (or there is no acceptable conversion)

ERROR: 4:83: 's' : undeclared identifier 

ERROR: 4:83: 'position' :  field selection requires structure, vector, or
matrix on left hand side 

ERROR: 4:83: 'assign' :  cannot convert from '3-component vector of float'
to 'float'

ERROR: 4:84: 'attenuation' :  field selection requires structure, vector, or
matrix on left hand side 

ERROR: 4:86: 'attenuation' :  field selection requires structure, vector, or
matrix on left hand side 

ERROR: 4:86: 'x' :  field selection requires structure, vector, or matrix on
left hand side 

ERROR: 4:86: 'attenuation' :  field selection requires structure, vector, or
matrix on left hand side 

ERROR: 4:86: 'y' :  field selection requires structure, vector, or matrix on
left hand side 

ERROR: 4:86: 'attenuation' :  field selection requires structure, vector, or
matrix on left hand side 

ERROR: 4:86: 'z' :  field selection requires structure, vector, or matrix on
left hand side 

ERROR: 4:89: 'type' :  field selection requires structure, vector, or matrix
on left hand side 

ERROR: 4:89: 'assign' : implicit conversion between types not allowed in ES
2.0 

ERROR: 4:89: 'assign' : implicit conversion between types not allowed in ES
2.0 

ERROR: 4:89: '==' :  wrong operand types  no operation '==' exists that
takes a left-hand operand of type 'float' and a right operand of type 'const
int' (or there is no acceptable conversion)

ERROR: 4:90: 'direction' :  field selection requires structure, vector, or
matrix on left hand side 

ERROR: 4:90: 'cutOffAngle' :  field selection requires structure, vector, or
matrix on left hand side 

ERROR: 4:94: 's' : undeclared identifier 

ERROR: 4:94: 'direction' :  field selection requires structure, vector, or
matrix on left hand side 

ERROR: 4:97: 's' : undeclared identifier 

ERROR: 4:97: 'dot' : no matching overloaded function found - implicit
conversion not allowed 

ERROR: 4:101: 'reflect' : no matching overloaded function found - implicit
conversion not allowed 

ERROR: 4:101: '=' :  cannot convert from 'const float' to '3-component
vector of float'

ERROR: 4:106: 'intensity' :  field selection requires structure, vector, or
matrix on left hand side 

ERROR: 4:106: 'color' :  field selection requires structure, vector, or
matrix on left hand side 

ERROR: 4:107: 'intensity' :  field selection requires structure, vector, or
matrix on left hand side 

ERROR: 4:107: 'color' :  field selection requires structure, vector, or
matrix on left hand side 

ERROR: 4:121: 'diffuseColor' : undeclared identifier 

ERROR: 4:121: 'specularColor' : undeclared identifier 

ERROR: 4:121: 'adsModel' : no matching overloaded function found - implicit
conversion not allowed 

ERROR: 4:20: 'normalTexture' : undeclared identifier 

ERROR: 4:20: 'texture2D' : no matching overloaded function found - implicit
conversion not allowed 

ERROR: 4:20: '=' :  cannot convert from 'const float' to '4-component vector
of float'

 

 

*** Problematic Fragment shader source code ***

#version 110

#ifdef GL_KHR_blend_equation_advanced

#extension GL_ARB_fragment_coord_conventions : enable

#extension GL_KHR_blend_equation_advanced : enable

#endif

#define lowp

#define mediump

#define highp

#line 1

 

varying highp vec3 worldPosition;

uniform highp vec3 eyePosition;

varying highp vec3 worldNormal;

varying highp vec4 worldTangent;

varying highp vec2 texCoord;

uniform highp vec4 ka;

uniform sampler2D diffuseTexture;

uniform highp vec4 ks;

uniform highp float shininess;

/***************************************************************************
*

**

** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).

** Contact: https://www.qt.io/licensing/

**

** This file is part of the Qt3D module of the Qt Toolkit.

**

** $QT_BEGIN_LICENSE:BSD$

** Commercial License Usage

** Licensees holding valid commercial Qt licenses may use this file in

** accordance with the commercial license agreement provided with the

** Software or, alternatively, in accordance with the terms contained in

** a written agreement between you and The Qt Company. For licensing terms

** and conditions see https://www.qt.io/terms-conditions. For further

** information use the contact form at https://www.qt.io/contact-us.

**

** BSD License Usage

** Alternatively, you may use this file under the terms of the BSD license

** as follows:

**

** "Redistribution and use in source and binary forms, with or without

** modification, are permitted provided that the following conditions are

** met:

**   * Redistributions of source code must retain the above copyright

**     notice, this list of conditions and the following disclaimer.

**   * Redistributions in binary form must reproduce the above copyright

**     notice, this list of conditions and the following disclaimer in

**     the documentation and/or other materials provided with the

**     distribution.

**   * Neither the name of The Qt Company Ltd nor the names of its

**     contributors may be used to endorse or promote products derived

**     from this software without specific prior written permission.

**

**

** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS

** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT

** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR

** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT

** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,

** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT

** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,

** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY

** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT

** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE

** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."

**

** $QT_END_LICENSE$

**

****************************************************************************
/

 

#define FP highp

 

FP mat3 transpose(const in FP mat3 inputMatrix)

{

    FP vec3 i0 = inputMatrix[0];

    FP vec3 i1 = inputMatrix[1];

    FP vec3 i2 = inputMatrix[2];

 

    FP mat3 outputMatrix = mat3(

        vec3(i0.x, i1.x, i2.x),

        vec3(i0.y, i1.y, i2.y),

        vec3(i0.z, i1.z, i2.z)

    );

 

    return outputMatrix;

}

 

FP mat3 calcWorldSpaceToTangentSpaceMatrix(const in FP vec3 wNormal, const
in FP vec4 wTangent)

{

    // Make the tangent truly orthogonal to the normal by using
Gram-Schmidt.

    // This allows to build the tangentMatrix below by simply transposing
the

    // tangent -> eyespace matrix (which would now be orthogonal)

    FP vec3 wFixedTangent = normalize(wTangent.xyz - dot(wTangent.xyz,
wNormal) * wNormal);

 

    // Calculate binormal vector. No "real" need to renormalize it,

    // as built by crossing two normal vectors.

    // To orient the binormal correctly, use the fourth coordinate of the
tangent,

    // which is +1 for a right hand system, and -1 for a left hand system.

    FP vec3 wBinormal = cross(wNormal, wFixedTangent.xyz) * wTangent.w;

 

    // Construct matrix to transform from world space to tangent space

    // This is the transpose of the tangentToWorld transformation matrix

    FP mat3 tangentToWorldMatrix = mat3(wFixedTangent, wBinormal, wNormal);

    FP mat3 worldToTangentMatrix = transpose(tangentToWorldMatrix);

    return worldToTangentMatrix;

}

 

 

#line 13

uniform sampler2D normalTexture;

/***************************************************************************
*

**

** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).

** Contact: https://www.qt.io/licensing/

**

** This file is part of the Qt3D module of the Qt Toolkit.

**

** $QT_BEGIN_LICENSE:BSD$

** Commercial License Usage

** Licensees holding valid commercial Qt licenses may use this file in

** accordance with the commercial license agreement provided with the

** Software or, alternatively, in accordance with the terms contained in

** a written agreement between you and The Qt Company. For licensing terms

** and conditions see https://www.qt.io/terms-conditions. For further

** information use the contact form at https://www.qt.io/contact-us.

**

** BSD License Usage

** Alternatively, you may use this file under the terms of the BSD license

** as follows:

**

** "Redistribution and use in source and binary forms, with or without

** modification, are permitted provided that the following conditions are

** met:

**   * Redistributions of source code must retain the above copyright

**     notice, this list of conditions and the following disclaimer.

**   * Redistributions in binary form must reproduce the above copyright

**     notice, this list of conditions and the following disclaimer in

**     the documentation and/or other materials provided with the

**     distribution.

**   * Neither the name of The Qt Company Ltd nor the names of its

**     contributors may be used to endorse or promote products derived

**     from this software without specific prior written permission.

**

**

** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS

** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT

** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR

** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT

** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,

** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT

** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,

** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY

** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT

** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE

** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."

**

** $QT_END_LICENSE$

**

****************************************************************************
/

 

#define FP highp

 

const int MAX_LIGHTS = 8;

const int TYPE_POINT = 0;

const int TYPE_DIRECTIONAL = 1;

const int TYPE_SPOT = 2;

struct Light {

    int type;

    FP vec3 position;

    FP vec3 color;

    FP float intensity;

    FP vec3 direction;

    FP vec3 attenuation;

    FP float cutOffAngle;

};

uniform Light lights[MAX_LIGHTS];

uniform int lightCount;

 

#line 52

 

void adsModel(const in FP vec3 vpos, const in FP vec3 vnormal, const in FP
vec3 vview, const in FP float shininess,

              out FP vec3 diffuseColor, out FP vec3 specularColor)

{

    diffuseColor = vec3(0.0);

    specularColor = vec3(0.0);

 

    FP vec3 n = normalize( vnormal );

 

    FP vec3 s;

    Light light;

    for (int i = 0; i < lightCount; ++i) {

        if (i == 0)

            light = lights[0];

        else if (i == 1)

            light = lights[1];

        else if (i == 2)

            light = lights[2];

        else if (i == 3)

            light = lights[3];

        else if (i == 4)

            light = lights[4];

        else if (i == 5)

            light = lights[5];

        else if (i == 6)

            light = lights[6];

        else if (i == 7)

            light = lights[7];

 

        FP float att = 1.0;

        if ( light.type != TYPE_DIRECTIONAL ) {

            s = light.position - vpos;

            if (length( light.attenuation ) != 0.0) {

                FP float dist = length(s);

                att = 1.0 / (light.attenuation.x + light.attenuation.y *
dist + light.attenuation.z * dist * dist);

            }

            s = normalize( s );

            if ( light.type == TYPE_SPOT ) {

                if ( degrees(acos(dot(-s, normalize(light.direction))) ) >
light.cutOffAngle)

                    att = 0.0;

            }

        } else {

            s = normalize( -light.direction );

        }

 

        FP float diffuse = max( dot( s, n ), 0.0 );

 

        FP float specular = 0.0;

        if (diffuse > 0.0 && shininess > 0.0 && att > 0.0) {

            FP vec3 r = reflect( -s, n );

            FP float normFactor = ( shininess + 2.0 ) / 2.0;

            specular = normFactor * pow( max( dot( r, vview ), 0.0 ),
shininess );

        }

 

        diffuseColor += att * light.intensity * diffuse * light.color;

        specularColor += att * light.intensity * specular * light.color;

    }

}

 

FP vec4 phongFunction(const in FP vec4 ambient,

                      const in FP vec4 diffuse,

                      const in FP vec4 specular,

                      const in FP float shininess,

                      const in FP vec3 worldPosition,

                      const in FP vec3 worldView,

                      const in FP vec3 worldNormal)

{

    // Calculate the lighting model, keeping the specular component separate

    FP vec3 diffuseColor, specularColor;

    adsModel(worldPosition, worldNormal, worldView, shininess, diffuseColor,
specularColor);

 

    // Combine spec with ambient+diffuse for final fragment color

    FP vec3 color = (ambient.rgb + diffuseColor) * diffuse.rgb

                  + specularColor * specular.rgb;

 

    return vec4(color, diffuse.a);

}

 

#line 16

 

void main()

{

    highp vec2 v4 = texCoord;

    highp vec4 v14 = texture2D(normalTexture, v4);

    highp float v16 = float(2.0);

    highp vec3 v15 = v14.rgb;

    highp vec4 v3 = worldTangent;

    highp vec3 v2 = worldNormal;

    highp vec3 v18 = vec3(1.0);

    highp vec3 v17 = v15 * v16;

    highp mat3 v12 = calcWorldSpaceToTangentSpaceMatrix(v2, v3);

    highp vec3 v19 = v17 - v18;

    highp mat3 v13 = transpose(v12);

    highp vec3 v1 = eyePosition;

    highp vec3 v0 = worldPosition;

    highp vec3 v20 = v13 * v19;

    highp vec3 v9 = v1 - v0;

    highp float v8 = shininess;

    highp vec4 v7 = ks;

    highp vec4 v6 = texture2D(diffuseTexture, v4);

    highp vec4 v5 = ka;

    highp vec3 v11 = normalize(v20);

    highp vec3 v10 = normalize(v9);

    highp vec4 v21 = phongFunction(v5, v6, v7, v8, v0, v10, v11);

    gl_FragColor = v21;

}

 

***

 

My theory: First the program “thinks” it should use OPENGL 3.3 and selects a
corresponding shader, but the shader compiler only support ES 2.0.

I also could not find the shader code that is used here. And yes, I found
the qtshadercache and deleted all files.

 

Any idea?

 

The documentation says that QNormalDiffuseMapMaterial is deprecated,
therefore I tried to replace it with QDiffuseSpecularMaterial, but I was
unable to find any documentation or example or test that shows how to
generate a QVariant with a texture from a QImage to use in setDiffuse and
setNormal.

 

Best regards and hopefully

Helmut M.

 





_______________________________________________
Interest mailing list
Interest at qt-project.org <mailto:Interest at qt-project.org> 
https://lists.qt-project.org/listinfo/interest

-- 
Paul Lemire | paul.lemire at kdab.com <mailto:paul.lemire at kdab.com>  | Senior
Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel: France +33 (0)4 90 84 08 53, http://www.kdab.fr
KDAB - The Qt, C++ and OpenGL Experts
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190403/4d62a8ab/attachment.html>


More information about the Interest mailing list