Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QtDesign studio has some trouble when using shaderprogram
Forum Updated to NodeBB v4.3 + New Features

QtDesign studio has some trouble when using shaderprogram

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 167 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    ForeverLoki
    wrote on last edited by ForeverLoki
    #1

    Here is my code in QtDesign studio 4.0

    CustomMaterial {
                id: customMaterial1
                property color ambient:  Qt.rgba(0.15, 0.35, 0.50, 1.0)
                property color ka: Qt.rgba(0.15, 0.35, 0.50, 1.0)//ambient
                property color specularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0)
                property real shininess: 150.0
                property real textureScale: 1.0
                property real offsetx: 0.0
                property real offsety: 0.0
                property real wavescale: 0.0
                property real specularity: 1.0
                property real waveheight: 0.1
                property real waveStrenght: 0.1
                property real normalAmount: 2.0
                property real waveRandom: 1.0
    
                property real texCoordScale: 1.0
                property real vertYpos: 0.0
    
                property TextureInput foamTexture: TextureInput {
                    enabled: true
                    texture:Texture{
                        id: foamTexture
                        source:"../../../textures/foam.jpg"}
                }
                property TextureInput skyTexture: TextureInput {
                    enabled: true
                    texture: Texture{
                        id: skyTexture
                        source:"../../../textures/sky.jpg"
                    }
                }
                property TextureInput waveTexture: TextureInput {
                    enabled: true
                    texture: Texture{
                        id: waveTexture
                        source:"../../../textures/Waterwave.jpg"
                    }
                }
                property TextureInput specularTexture: TextureInput {
                    enabled: true
                    texture: Texture{
                        id: specularTexture
                        source:"../../../textures/WaterSpecular.jpg"
                    }
    
                }
                property TextureInput diffuseTexture: TextureInput {
                    enabled: true
                    texture:Texture{
                        id: diffuseTexture
                        source:"../../../textures/WaterDiffuse.jpg"
                    }
                }
                property TextureInput normalTexture: TextureInput {
                    enabled: true
                    texture:Texture{
                        id: normalTexture
                        source:"../../../textures/WaterNormal.jpg"
                    }
                }
                shadingMode: CustomMaterial.Unshaded
                vertexShader: "../../../shaders/test/water.vert"
                fragmentShader: "../../../shaders/test/water.frag"
            }
    

    I got two error in QtCreator when I am changing projection from QtDesign Studio to QtCreator
    QSpirvCompiler: Failed to parse shader
    Failed to compile vertex shader:

    "custom material -->water.vert>water.frag:a46ea2d3d2c9243dfc30960db194be3a87c3dd21;hasLighting=true;lightCount=5;specularModel=Default;;diffuseMap={;;;;};emissiveMap={;;;;};specularMap={;;;;};baseColorMap={;;;;};bumpMap={;;;;};specularAmountMap={;;;;};normalMap={;;;;};clearcoatNormalMap={;;;;};opacityMap={;;;;};roughnessMap={;;;;};metalnessMap={;;;;};occlusionMap={;;;;};translucencyMap={;;;;};heightMap={;;;;};clearcoatMap={;;;;};clearcoatRoughnessMap={;;;;};transmissionMap={;;;;};thicknessMap={;;;;};opacityMap_channel=R;roughnessMap_channel=R;metalnessMap_channel=R;occlusionMap_channel=R;translucencyMap_channel=R;heightMap_channel=R;clearcoatMap_channel=R;clearcoatRoughnessMap_channel=R;transmissionMap_channel=R;thicknessMap_channel=R;boneCount=0;overridesPosition=true;alphaMode=Default;;vertexAttributes={position=true;normal=true;texcoord0=true;;tangent=true;binormal=true;;}};morphTargetCount=0;morphTarget0Attributes={;;;;;;;}};morphTarget1Attributes={;;;;;;;}};morphTarget2Attributes={;;;;;;;}};morphTarget3Attributes={;;;;;;;}};morphTarget4Attributes={;;;;;;;}};morphTarget5Attributes={;;;;;;;}};morphTarget6Attributes={;;;;;;;}};morphTarget7Attributes={;;;;;;;}}"
    "ERROR: :65: 'location' : overlapping use of location 16\nERROR: 1 compilation errors. No code generated."
    QSpirvCompiler: Failed to parse shader
    Failed to compile vertex shader:

    "custom material -->water.vert>water.frag:a46ea2d3d2c9243dfc30960db194be3a87c3dd21;hasLighting=true;lightCount=5; ... same as above"
    "ERROR: :63: 'location' : overlapping use of location 16\nERROR: 1 compilation errors. No code generated."

    There is my shader.vert:

    #version 330 core

    VARYING vec3 vertexPosition;
    VARYING vec3 vertexNormal;
    VARYING vec2 vertexTexCoord;
    VARYING vec4 vertexTangent;

    VARYING vec3 worldPosition;
    VARYING vec3 worldNormal;
    VARYING vec4 worldTangent;
    VARYING vec2 texCoord;
    VARYING vec2 movtexCoord;
    VARYING vec2 multexCoord;
    VARYING vec2 waveTexCoord;
    VARYING vec2 skyTexCoord;
    VARYING vec3 vpos;

    VARYING mat4 modelMatrix;
    VARYING mat3 modelNormalMatrix;
    VARYING mat4 mvp;

    VARYING vec3 eyePosition;

    void MAIN()
    {
    modelMatrix = MODEL_MATRIX
    modelNormalMatrix = NORMAL_MATRIX
    mvp = MODELVIEWPROJECTION_MATRIX

    vertexPosition = VERTEX
    vertexNormal = NORMAL
    vertexTexCoord = UV0
    vertexTangent =  TANGENT
    
    eyePosition = CAMERA_POSITION
    
    // Scale texture coordinates for for fragment shader
    texCoord = vertexTexCoord * texCoordScale;
    movtexCoord = vertexTexCoord * texCoordScale;
    multexCoord = vertexTexCoord * (texCoordScale*0.5);
    waveTexCoord = vertexTexCoord * (texCoordScale * 6);
    skyTexCoord = vertexTexCoord * (texCoordScale * 0.2);
    
    // Add Animated x and y Offset to SKY, MOV and MUL texCoords
    movtexCoord = vec2(texCoord.x+offsetx,texCoord.y+offsety);
    multexCoord = vec2(texCoord.x-offsetx,texCoord.y+offsety);
    skyTexCoord = vec2(texCoord.x-(offsetx/2),texCoord.y-(offsety/2));
    
    // Transform position, normal, and tangent to world coords
    worldPosition = vec3(modelMatrix * vec4(vertexPosition, 1.0));
    worldNormal = normalize(modelNormalMatrix * vertexNormal);
    worldTangent.xyz = normalize(vec3(modelMatrix * vec4(vertexTangent.xyz, 0.0)));
    worldTangent.w = vertexTangent.w;
    
    // Calculate animated vertex positions
    
    float sinPos = (vertexPosition.z)+(vertexPosition.x);
    float sinPos2 = (vertexPosition.y/2)+(vertexPosition.z);
    vec3 vertMod = vec3(vertexPosition.x,vertexPosition.y,vertexPosition.z);
    
    vertMod = vec3(vertMod.x+=sin(vertYpos*2.2-sinPos2)*waveheight,
                   vertMod.y=sin(vertYpos*2.2+sinPos)*waveheight,
                   vertMod.z-=sin(vertYpos*2.2-cos(sinPos2))*waveheight);
    
    vec3 vertModCom = vec3(vertMod.x+=cos(vertYpos*2.2-cos(sinPos2))*waveheight,
                           vertMod.y=sin(vertYpos*2.2+cos(sinPos))*waveheight,
                           vertMod.z-=cos(vertYpos*2.2-cos(sinPos))*waveheight);
    
    
    // Add wave animation only to vertices above world pos.y zero
    if(vertexPosition.y < 0.0){vertModCom = vertexPosition;}
    else{vertModCom = vertModCom;}
    
    vpos = vertModCom;
    
    // Calculate vertex position in clip coordinates
    POSITION = mvp * vec4(vertModCom, 1.0);
    

    }

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved