summaryrefslogtreecommitdiffstats
path: root/examples/demos/FX_Material_Showroom/content/ShockwaveEffect.ui.qml
blob: 17f54e249b6d8129d12a6ddb4d38f87c11d99298 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick3D
import QtQuick3D.Particles3D
import QtQuick3D.Helpers

ParticleSystem3D {
    id: shockwave
    visible: true
    ParticleEmitter3D {
        id: pressurewaveemitter

        enabled: shockwave.visible
        particleScale: 0
        particleEndScaleVariation: 0
        particleEndScale: 30
        emitRate: 0
        lifeSpan: 100
        velocity: burstDirection

        ModelParticle3D {
            id: modelParticle
            sortMode: Particle3D.SortDistance
            fadeOutDuration: 50
            fadeInDuration: 50
        }

        VectorDirection3D {
            id: burstDirection
            direction.y: 0
            directionVariation.x: 0
            directionVariation.z: 0
            directionVariation.y: 0
        }

        Model {
            source: "#Sphere"
            castsReflections: true
            receivesReflections: true
            materials: shockwaveMat
            receivesShadows: true
            scale.y: 1
            castsShadows: true
            instancing: modelParticle.instanceTable
            scale.z: 1
            scale.x: 1
        }

        DynamicBurst3D {
            id: dynamicBurst6
            enabled: true
            duration: 0
            amount: 1
            time: 0
            triggerMode: DynamicBurst3D.TriggerTime
        }

        particle: modelParticle
    }

    Connections {
        target: shockwaveTimer
        onTriggered: shockwave.reset()
    }

    Connections {
        target: shockwaveTimer
        onTriggered: pressurewave1.reset()
    }

    Connections {
        target: shockwaveTimer
        onTriggered: debris.reset()
    }

    Connections {
        target: shockwaveTimer
        onTriggered: debris.startTime = debris.time
    }

    Connections {
        target: shockwaveTimer
        onTriggered: debris1.reset()
    }

    Connections {
        target: shockwaveTimer
        onTriggered: debris1.startTime = debris1.time
    }

    Timer {
        id: shockwaveTimer
        running: shockwave.visible
        repeat: true
        interval: 5000
        triggeredOnStart: true
    }

    ParticleSystem3D {
        id: debris
        visible: true
        ParticleEmitter3D {
            id: pressurewaveemitter1
            emitBursts: dynamicBurst7
            shape: targetShape10
            particleScaleVariation: 0.5
            particleRotationVelocityVariation.z: 0
            particleRotationVelocityVariation.x: 0
            lifeSpanVariation: 0
            system: debris

            enabled: shockwave.visible
            particle: modelParticle7
            particleScale: 0.5
            particleEndScale: 0
            lifeSpan: 3000
            ModelParticle3D {
                id: modelParticle7
                colorVariation.w: 0
                colorVariation.z: 0
                colorVariation.y: 0
                colorVariation.x: 0
                alignMode: Particle3D.AlignTowardsTarget
                sortMode: Particle3D.SortDistance
                maxAmount: 500000
                fadeInDuration: 1500
                fadeOutDuration: 1500
            }

            Model {
                source: "#Sphere"
                castsReflections: true
                receivesReflections: true
                materials: shockwavedebrisMat
                receivesShadows: true
                scale.y: 1
                castsShadows: true
                instancing: modelParticle7.instanceTable
                scale.z: 5
                scale.x: 3
            }

            Attractor3D {
                id: particleAttractor
                y: 0
                useCachedPositions: false
                durationVariation: (debris.time - debris.startTime) * 0.5
                hideAtEnd: false
                shape: targetShape10
                particles: modelParticle7
                system: debris
                duration: (debris.time - debris.startTime) * 0.5
            }

            DynamicBurst3D {
                id: dynamicBurst7
                enabled: true
                duration: 10
                amount: 500
                time: 100
                triggerMode: DynamicBurst3D.TriggerTime
            }

            particleEndScaleVariation: 0
            emitRate: 0
        }

        ParticleModelShape3D {
            id: targetShape10
            fill: true
            delegate: Model {
                source: "#Sphere"
                eulerRotation.z: 0
                scale.y: 0.01
                eulerRotation.y: 0
                eulerRotation.x: 0
                scale.z: (debris.time - debris.startTime) * 0.01
                scale.x: (debris.time - debris.startTime) * 0.01
            }
        }
    }

    ParticleSystem3D {
        id: debris1
        ParticleEmitter3D {
            id: pressurewaveemitter2
            system: debris1

            enabled: shockwave.visible
            particle: modelParticle8
            particleScale: 1
            particleScaleVariation: 0.0
            particleRotationVelocityVariation.x: 0
            particleEndScale: 0
            lifeSpan: 3000
            particleRotationVelocityVariation.z: 0
            emitBursts: dynamicBurst8
            ModelParticle3D {
                id: modelParticle8
                colorVariation.w: 0
                colorVariation.z: 0
                colorVariation.y: 0
                colorVariation.x: 0
                alignTargetPosition.y: 1
                maxAmount: 500000
                fadeInDuration: 1500
                alignMode: Particle3D.AlignTowardsTarget
                sortMode: Particle3D.SortDistance
                fadeOutDuration: 1500
            }

            Model {
                source: "#Sphere"
                castsReflections: true
                receivesReflections: true
                materials: shockwavedebrisMat
                receivesShadows: true
                scale.y: 1
                castsShadows: true
                instancing: modelParticle8.instanceTable
                scale.z: 1
                scale.x: 2
            }

            Attractor3D {
                id: particleAttractor1
                y: 0
                system: debris1
                durationVariation: (debris1.time - debris1.startTime) * 0.5
                hideAtEnd: false
                duration: (debris1.time - debris1.startTime) * 0.5
                useCachedPositions: false
                particles: modelParticle8
                shape: targetShape11
            }

            DynamicBurst3D {
                id: dynamicBurst8
                enabled: true
                duration: 10
                amount: 500
                time: 0
                triggerMode: DynamicBurst3D.TriggerTime
            }
            particleEndScaleVariation: 0
            lifeSpanVariation: 3000
            emitRate: 0
            shape: targetShape11
        }

        ParticleModelShape3D {
            id: targetShape11
            fill: true
            delegate: Model {
                source: "#Sphere"
                eulerRotation.z: 0
                scale.y: 0.01
                eulerRotation.x: 0
                eulerRotation.y: 0
                scale.z: (debris1.time - debris1.startTime) * 0.05
                scale.x: (debris1.time - debris1.startTime) * 0.05
            }
        }
    }

    Node {
        id: __materialLibrary__

        CustomMaterial {
            id: shockwaveMat
            fragmentShader: "shaders/shockwave.frag"
            depthDrawMode: Material.NeverDepthDraw
            shadingMode: CustomMaterial.Shaded
            destinationBlend: CustomMaterial.OneMinusSrcAlpha
            cullMode: Material.BackFaceCulling
            property color baseColor: "#ffffff"
            sourceBlend: CustomMaterial.One
            vertexShader: "shaders/shockwave.vert"
            objectName: "Shockwave Material"
        }

        CustomMaterial {
            id: shockwaveMat2
            fragmentShader: "shaders/shockwave.frag"
            depthDrawMode: Material.NeverDepthDraw
            shadingMode: CustomMaterial.Shaded
            destinationBlend: CustomMaterial.One
            cullMode: Material.BackFaceCulling
            property color baseColor: "#85e1fc"
            sourceBlend: CustomMaterial.One
            vertexShader: "shaders/shockwave.vert"
            objectName: "Shockwave Material"
        }

        CustomMaterial {
            id: shockwavedebrisMat
            fragmentShader: "shaders/debris.frag"
            depthDrawMode: Material.NeverDepthDraw
            property real brightness: 10
            property TextureInput dfMask: debristexinput
            shadingMode: CustomMaterial.Shaded
            destinationBlend: CustomMaterial.One
            cullMode: Material.NoCulling
            property color baseColor: "#3355ff"
            sourceBlend: CustomMaterial.SrcAlpha
            TextureInput {
                id: debristexinput
                enabled: true
                texture: debristex
            }

            Texture {
                id: debristex
                source: "images/debris.png"
                generateMipmaps: true
                mipFilter: Texture.Linear
            }
            vertexShader: "shaders/debris.vert"
            objectName: "Debris Material"
        }
    }

    ParticleSystem3D {
        id: pressurewave1
        y: 9
        ParticleEmitter3D {
            particleRotationVariation.y: 90
            particleRotationVelocityVariation.y: 360
            emitBursts: diskburst
            velocity: flatdiskdir
            emitRate: 0
            enabled: shockwave.visible
            particle: flatshockwave
            ModelParticle3D {
                id: flatshockwave
                maxAmount: 100
                fadeOutDuration: 1500
                fadeInDuration: 0
                sortMode: Particle3D.SortDistance
            }

            VectorDirection3D {
                id: flatdiskdir
                direction.y: 1
                directionVariation.z: 1
            }

            Model {
                source: "#Sphere"
                instancing: flatshockwave.instanceTable
                receivesReflections: true
                castsReflections: true
                receivesShadows: true
                materials: shockwaveMat2
                scale.y: 0.05
                castsShadows: true
            }

            DynamicBurst3D {
                id: diskburst
                time: 0
                duration: 0
                enabled: true
                triggerMode: DynamicBurst3D.TriggerTime
                amount: 2
            }
            particleEndScaleVariation: 10
            particleEndScale: 40
            particleScale: 0
            lifeSpan: 1500
        }
    }
}