| 1 |
// Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB). |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
|
| 4 |
import Qt3D.Core 2.0 |
| 5 |
import Qt3D.Render 2.0 |
| 6 |
import Qt3D.Extras 2.0 |
| 7 |
import Qt3D.Input 2.0 |
| 8 |
import QtQuick 2.0 as QQ2 |
| 9 |
import QtQuick 2.12 |
| 10 |
|
| 11 |
|
| 12 |
Entity { |
| 13 |
id: sceneRoot |
| 14 |
|
| 15 |
Camera { |
| 16 |
id: camera |
| 17 |
projectionType: CameraLens.OrthographicProjection |
| 18 |
left: -2 |
| 19 |
right: 2 |
| 20 |
top: 2 |
| 21 |
bottom: -2 |
| 22 |
nearPlane: 0.1 |
| 23 |
farPlane: 1000.0 |
| 24 |
position: Qt.vector3d(0.0, 0.0, 1.0) |
| 25 |
upVector: Qt.vector3d(0.0, 1.0, 0.0) |
| 26 |
viewCenter: Qt.vector3d(0.0, 0.0, 0.0) |
| 27 |
} |
| 28 |
|
| 29 |
RenderTarget { |
| 30 |
id: renderTargetFBO |
| 31 |
attachments : [ |
| 32 |
RenderTargetOutput { |
| 33 |
attachmentPoint : RenderTargetOutput.Color0 |
| 34 |
texture : Texture2DMultisample { |
| 35 |
id : colorAttachment |
| 36 |
width : scene3d.width |
| 37 |
height : scene3d.height |
| 38 |
format : Texture.RGBA8_UNorm |
| 39 |
generateMipMaps : false |
| 40 |
samples: 1 |
| 41 |
} |
| 42 |
}, |
| 43 |
RenderTargetOutput { |
| 44 |
attachmentPoint : RenderTargetOutput.Depth |
| 45 |
texture : Texture2DMultisample { |
| 46 |
width : scene3d.width |
| 47 |
height : scene3d.height |
| 48 |
format : Texture.D32F |
| 49 |
generateMipMaps : false |
| 50 |
samples: 1 |
| 51 |
} |
| 52 |
} |
| 53 |
] |
| 54 |
} |
| 55 |
|
| 56 |
components: [ |
| 57 |
RenderSettings { |
| 58 |
activeFrameGraph: FrameGraph { |
| 59 |
id: framegraph |
| 60 |
camera: camera |
| 61 |
fbo: renderTargetFBO |
| 62 |
} |
| 63 |
renderPolicy: RenderSettings.Always |
| 64 |
} |
| 65 |
] |
| 66 |
|
| 67 |
Entity { |
| 68 |
id: firstPassEntities |
| 69 |
|
| 70 |
Entity { |
| 71 |
components: [ |
| 72 |
Transform { |
| 73 |
translation: Qt.vector3d(0,0,-2) |
| 74 |
}, |
| 75 |
Material1 { |
| 76 |
color: "red" |
| 77 |
}, |
| 78 |
SphereMesh { } |
| 79 |
] |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
Entity { |
| 84 |
components: [ |
| 85 |
Transform { |
| 86 |
translation: Qt.vector3d(1,0,-1) |
| 87 |
}, |
| 88 |
Material2 { |
| 89 |
color: "green" |
| 90 |
}, |
| 91 |
SphereMesh { } |
| 92 |
] |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
Entity { |
| 97 |
id: secondPassEntities |
| 98 |
components: [framegraph.layer] |
| 99 |
|
| 100 |
Entity { |
| 101 |
components: [ |
| 102 |
Transform { |
| 103 |
translation: Qt.vector3d(0,0,-4) |
| 104 |
scale: 0.5 |
| 105 |
}, |
| 106 |
Material1 { |
| 107 |
ColorAnimation on color { |
| 108 |
from: "black" |
| 109 |
to: "purple" |
| 110 |
duration: 2000 |
| 111 |
loops: Animation.Infinite |
| 112 |
} |
| 113 |
}, |
| 114 |
SphereMesh { } |
| 115 |
] |
| 116 |
} |
| 117 |
|
| 118 |
|
| 119 |
Entity { |
| 120 |
components: [ |
| 121 |
Transform { |
| 122 |
translation: Qt.vector3d(1,0,-3) |
| 123 |
scale: 0.5 |
| 124 |
}, |
| 125 |
Material2 { |
| 126 |
color: "orange" |
| 127 |
}, |
| 128 |
SphereMesh { } |
| 129 |
] |
| 130 |
} |
| 131 |
} |
| 132 |
|
| 133 |
PostProcess { |
| 134 |
colorTexture: colorAttachment |
| 135 |
} |
| 136 |
} |