aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual/volumetric/main.qml
blob: 9df723baa8dcaa1791204c59aba793864888ae55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

import QtQuick
import QtQuick3D
import QtQuick3D.Helpers
import QtQuick.Controls
import Volume

Window {
    id: window
    width: 640
    height: 640
    visible: true
    color: "black"

    WasdController {
        controlledObject: camera
    }

    View3D {
        id: view
        anchors.fill: parent

        environment: SceneEnvironment {
            clearColor: window.color
            backgroundMode: SceneEnvironment.SkyBox
            lightProbe: Texture {
                source: "qrc:///OpenfootageNET_garage-1024.hdr"
            }
            probeOrientation: Qt.vector3d(0, -90, 0)
        }

        PerspectiveCamera {
            id: camera
            position: Qt.vector3d(0, 0, 400)
        }

        DirectionalLight {
            eulerRotation.x: -60
            castsShadow: true
        }

        Model {
            source: "#Cube"
            materials: CustomMaterial {
                shadingMode: CustomMaterial.Unshaded
                vertexShader: "custom.vert"
                fragmentShader: "custom.frag"
                property TextureInput volume: TextureInput {
                    enabled: true
                    texture: Texture {
                        textureData: VolumeTextureData {}
                    }
                }
                property TextureInput colormap: TextureInput {
                    enabled: true
                    texture: Texture { source: "colormap.png" }
                }
                sourceBlend: CustomMaterial.SrcAlpha
                destinationBlend: CustomMaterial.OneMinusSrcAlpha
            }
        }
    }

    DebugView {
        anchors.right: parent.right
        source: view
    }
}