Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-100572

Quick 3D: Shadow maps aren't working correctly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 6.3.0 Beta3, 6.4.0 Beta1
    • 6.2.3, 6.4.0 FF
    • Quick: 3D
    • None
    • 62a2a1cf75 (qt/qtquick3d/dev) 56af61b930 (qt/qtquick3d/6.3) 56af61b930 (qt/qtquick3d/6.3.0) 56af61b930 (qt/tqtc-qtquick3d/6.3.0)
    • Qt Quick 3D: Week 7 - 8

    Description

      The shadow map of a light gets gradually lighter the closer it is to the object or light (unsure which it is).

      import QtQuick
      import QtQuick.Window
      import QtQuick3D
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          View3D {
              id: view
              anchors.fill: parent
      
              PerspectiveCamera {
                  position: Qt.vector3d(0, 200, 300)
                  eulerRotation.x: -30
              }
      
              DirectionalLight {
                  eulerRotation: Qt.vector3d(-30, -30, -30)
                  castsShadow: true
              }
      
              Model {
                  id: cube
                  source: "#Cube"
      
                  materials: PrincipledMaterial {
                      baseColor: "red"
                  }
                  scale: Qt.vector3d(10, 1, 10)
              }
      
              Model {
                  id: cube2
                  source: "#Cube"
                  materials: PrincipledMaterial {
                      baseColor: "green"
                  }
                  position: Qt.vector3d(-100, 150, 0)
              }
      
              Model {
                  id: cube3
                  source: "#Cube"
                  materials: PrincipledMaterial {
                      baseColor: "yellow"
                  }
                  position: Qt.vector3d(-100, 250, 0)
              }
          }
      }
      

      This example shows a green and yellow (out of camera bounds) cube hovering over a red cube and lit by a directional light. The shadow map fades out towards the cubes.

      With Qt 6.2 branch:

      With dev branch, a new bug has snuck in. The shadow map of the yellow and green cube are now added together so that the shadows become darker in the area where both appear.

      With dev branch:

      With a point light, you see some of the same things. Since the point light is the only light in the scene, you would expect the cube's shadow to be completely black (just like the cube sides that are facing away from the light). Instead it is a gradient from red to a bit darker red.

      With 6.2 branch (same with dev):

      Interestingly, pixels that are outside attenuation range of the point light are actually darker than the darkest pixels inside the shadow, where the light does not reach at all.

      Example with point light:

      import QtQuick
      import QtQuick.Window
      import QtQuick3D
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          View3D {
              id: view
              anchors.fill: parent
      
              PerspectiveCamera {
                  position: Qt.vector3d(0, 200, 300)
                  eulerRotation.x: -30
              }
      
              PointLight {
                  position: Qt.vector3d(-300, 300, 0)
                  castsShadow: true
              }
      
              Model {
                  id: cube
                  source: "#Cube"
      
                  materials: PrincipledMaterial {
                      baseColor: "red"
                  }
                  scale: Qt.vector3d(10, 1, 10)
              }
      
              Model {
                  id: cube2
                  source: "#Cube"
                  materials: PrincipledMaterial {
                      baseColor: "green"
                  }
                  position: Qt.vector3d(-100, 150, 0)
              }
      
              Model {
                  id: cube3
                  source: "#Cube"
                  materials: PrincipledMaterial {
                      baseColor: "yellow"
                  }
                  position: Qt.vector3d(-100, 250, 0)
              }
      
          }
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            janichol Andy Nichols
            esabraha Eskil Abrahamsen Blomfeldt
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes