Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Qt3D - wrong material blending with clearColor

Qt3D - wrong material blending with clearColor

Scheduled Pinned Locked Moved Unsolved Game Development
qt3dblendingframegraphmaterialalpha
1 Posts 1 Posters 457 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.
  • A Offline
    A Offline
    ABarreiro
    wrote on last edited by ABarreiro
    #1

    Hi,

    I have the following application:

    • main.cpp with a QGuiApplication and a QQmlApplicationEngine that loads the main.qml
    • main.qml with a Window{w:500, h:500, color:"limegreen"} as root component
    • A Scene3D{w:400, h:500} centered in the Window

    The scene3d has the following tree in pseudocode

    • RootEntity
      • Camera
      • RenderSettings
        • ForwardRenderer
      • DiffuseSpecularMaterial (id:planeMaterial; color:0.745, 0.745, 0.745, 1)
      • PlaneMesh: (id:planeMesh; width:7; height:7)
      • Transform: (id:planeTransform; translation:-2.5, 2.5, -14)
      • Entity: (id: planeEntity) // PLANE
      • DiffuseSpecularMaterial (id:sphere1Material; color:1, 0, 0, 0.2; alphaBlending:true)
      • SphereMesh: (id:sphere1Mesh; radius:2.5)
      • Transform: (id:sphere1Transform; translation:-2.5, 2.5, -14)
      • Entity: (id: sphere1Entity) // SPHERE TOP-LEFT
      • PhongAlphaMaterial (id:sphere2Material; color:1, 0, 0; alpha:0.2; sourceAlphaArg:Zero; destinationAlphaArg:One)
      • SphereMesh: (id:sphere2Mesh; radius:2.5)
      • Transform: (id:sphere2Transform; translation:2.5, -2.5, -14)
      • Entity: (id: sphere2Entity) // SPHERE BOTTOM-RIGHT

    Important info:

    • The Sphere 1 is composed with the DiffuseSpecularMaterial which aparently supports alpha values and alpha blending, but the resulting color/alha are wrong. Looks like it is blending just with the Window color (limegreen) instead of the Plane (white)
    • In order to fix this, I followed the recomendation of using PhongAlphaMaterial(deprecated btw) and set the sourceAlphaArg: BlendEquationArguments.Zero and destinationAlphaArg: BlendEquationArguments.One. This is done in Sphere 2, that is working fine:

    step1.png

    The problem now is when I set the clear color transparent clearColor: Qt.rgba(1, 1, 1, 0). As none of the materials is working fine. This is the result:
    step2.png

    My machine has Ubuntu 20.04 and Qt5.14.2

    The objective is to have a scene with a transparent ClearColor in order to see what is "behind" the Scene3D in the QtQuickWindow, but also have opaque/non-opaque objects in my Scene3D... so.... I'm a bit confused, I dont know if this is a expected behaviour of if i'm doing something wrong...

    I would appreciate any help or hint about whats happening

    (If necessary I can share the code to reproduce this)

    Thanks.

    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