QmlDesigner: Unify the background of 3D preview images

Added 3D checkerboard floor on all 3D previews.
Since shadows generally look bad for arbitrary 3D scenes, and would
mostly be obscured by the model itself as we want the light mostly
from the front, removed shadows also from the material preview to unify
the previews.

Qt5 had issues rendering the 3D floor texture, so used a static image
there, as Qt5 only generates previews of one size.

Fixes: QDS-7078
Change-Id: I74d094878ed01e6e531ad60df1f8d9d7cf415860
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
Miikka Heikkinen
2022-06-23 14:20:56 +03:00
parent 7aaaccb281
commit 8a8a2f5c55
8 changed files with 51 additions and 55 deletions

View File

@@ -13,7 +13,7 @@
<file>mockfiles/images/directional@2x.png</file>
<file>mockfiles/images/point.png</file>
<file>mockfiles/images/point@2x.png</file>
<file>mockfiles/images/floor_tex.png</file>
<file>mockfiles/images/static_floor.png</file>
<file>mockfiles/images/spot.png</file>
<file>mockfiles/images/spot@2x.png</file>
<file>mockfiles/qt5/AdjustableArrow.qml</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@@ -45,10 +45,6 @@ View3D {
Node {
DirectionalLight {
shadowMapQuality: Light.ShadowMapQualityMedium
shadowFilter: 20
shadowFactor: 21
castsShadow: true
eulerRotation.x: -26
eulerRotation.y: -57
}
@@ -68,25 +64,5 @@ View3D {
source: "#Sphere"
materials: previewMaterial
}
Model {
id: floorModel
source: "#Rectangle"
scale.y: 8
scale.x: 8
eulerRotation.x: -90
materials: floorMaterial
DefaultMaterial {
id: floorMaterial
diffuseMap: floorTex
Texture {
id: floorTex
source: "../images/floor_tex.png"
scaleU: floorModel.scale.x
scaleV: floorModel.scale.y
}
}
}
}
}

View File

@@ -123,14 +123,13 @@ Item {
anchors.fill: parent
}
Rectangle {
// We can use static image in Qt5 as only small previews will be generated
Image {
id: backgroundRect
anchors.fill: parent
z: -1
gradient: Gradient {
GradientStop { position: 1.0; color: "#222222" }
GradientStop { position: 0.0; color: "#999999" }
}
source: "../images/static_floor.png"
fillMode: Image.Stretch
}
}
}

View File

@@ -70,7 +70,7 @@ View3D {
materials: [
DefaultMaterial {
diffuseColor: "#4aee45"
diffuseColor: "#999999"
}
]
}

View File

@@ -45,10 +45,6 @@ View3D {
Node {
DirectionalLight {
shadowMapQuality: Light.ShadowMapQualityMedium
shadowFilter: 20
shadowFactor: 21
castsShadow: true
eulerRotation.x: -26
eulerRotation.y: -57
}
@@ -70,24 +66,5 @@ View3D {
materials: previewMaterial
}
Model {
id: floorModel
source: "#Rectangle"
scale.y: 8
scale.x: 8
eulerRotation.x: -90
materials: floorMaterial
DefaultMaterial {
id: floorMaterial
diffuseMap: floorTex
Texture {
id: floorTex
source: "../images/floor_tex.png"
scaleU: floorModel.scale.x
scaleV: floorModel.scale.y
}
}
}
}
}

View File

@@ -126,6 +126,50 @@ Item {
GradientStop { position: 1.0; color: "#222222" }
GradientStop { position: 0.0; color: "#999999" }
}
// Use View3D instead of static image to make background look good on all resolutions
View3D {
anchors.fill: parent
environment: sceneEnv
SceneEnvironment {
id: sceneEnv
antialiasingMode: SceneEnvironment.MSAA
antialiasingQuality: SceneEnvironment.High
}
DirectionalLight {
eulerRotation.x: -26
eulerRotation.y: -57
}
PerspectiveCamera {
y: 125
z: 120
eulerRotation.x: -31
clipNear: 1
clipFar: 1000
}
Model {
id: floorModel
source: "#Rectangle"
scale.y: 8
scale.x: 8
eulerRotation.x: -90
materials: floorMaterial
DefaultMaterial {
id: floorMaterial
diffuseMap: floorTex
Texture {
id: floorTex
source: "../images/floor_tex.png"
scaleU: floorModel.scale.x
scaleV: floorModel.scale.y
}
}
}
}
}
}
}

View File

@@ -70,7 +70,7 @@ View3D {
materials: [
DefaultMaterial {
diffuseColor: "#4aee45"
diffuseColor: "#999999"
}
]
}