Initial commit
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
// Copyright (C) 2022 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
||||
|
||||
import QtQuick
|
||||
import QtQuick3D
|
||||
import QtQuick3D.Helpers.impl
|
||||
|
||||
DepthOfFieldEffect {
|
||||
readonly property TextureInput sourceSampler: TextureInput {
|
||||
texture: Texture {}
|
||||
}
|
||||
property real focusDistance: 600
|
||||
property real focusRange: 100
|
||||
property real blurAmount: 4
|
||||
|
||||
Shader {
|
||||
id: downsampleVert
|
||||
stage: Shader.Vertex
|
||||
shader: "qrc:/qtquick3d_helpers/shaders/downsample.vert"
|
||||
}
|
||||
Shader {
|
||||
id: downsampleFrag
|
||||
stage: Shader.Fragment
|
||||
shader: "qrc:/qtquick3d_helpers/shaders/downsample.frag"
|
||||
}
|
||||
|
||||
Shader {
|
||||
id: blurVert
|
||||
stage: Shader.Vertex
|
||||
shader: "qrc:/qtquick3d_helpers/shaders/depthoffieldblur.vert"
|
||||
}
|
||||
Shader {
|
||||
id: blurFrag
|
||||
stage: Shader.Fragment
|
||||
shader: "qrc:/qtquick3d_helpers/shaders/depthoffieldblur.frag"
|
||||
}
|
||||
|
||||
Buffer {
|
||||
id: downsampleBuffer
|
||||
name: "downsampleBuffer"
|
||||
format: Buffer.RGBA16F
|
||||
textureFilterOperation: Buffer.Linear
|
||||
textureCoordOperation: Buffer.ClampToEdge
|
||||
sizeMultiplier: 0.5
|
||||
}
|
||||
|
||||
passes: [
|
||||
Pass {
|
||||
shaders: [ downsampleVert, downsampleFrag ]
|
||||
output: downsampleBuffer
|
||||
},
|
||||
Pass {
|
||||
shaders: [ blurVert, blurFrag ]
|
||||
commands: [
|
||||
// INPUT is the texture for downsampleBuffer
|
||||
BufferInput {
|
||||
buffer: downsampleBuffer
|
||||
},
|
||||
// the actual input texture is exposed as sourceSampler
|
||||
BufferInput {
|
||||
sampler: "sourceSampler"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,703 @@
|
||||
// Copyright (C) 2022 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
||||
|
||||
import QtQuick
|
||||
import QtQuick3D
|
||||
import QtQuick3D.Helpers.impl
|
||||
|
||||
MainSceneEffect {
|
||||
id: sceneEffect
|
||||
property int tonemapMode: SceneEnvironment.TonemapModeLinear
|
||||
property real exposure: 1.0
|
||||
property real white: 1.0
|
||||
property bool applyFXAA: false
|
||||
property bool ditheringEnabled: false
|
||||
property real sharpnessAmount: 0.0 // 0.0 - 1.0
|
||||
property bool colorAdjustmentsEnabled: false
|
||||
property real adjustmentBrightness: 1.0
|
||||
property real adjustmentContrast: 1.0
|
||||
property real adjustmentSaturation: 1.0
|
||||
|
||||
// Lens Flare
|
||||
property bool lensFlareEnabled: false
|
||||
property real lensFlareBloomScale: 10 // 0 - 20
|
||||
property real lensFlareBloomBias: 0.95 // 0 - x (basically maximum color value)
|
||||
property real lensFlareGhostDispersal: 0.5 // 0 - 1
|
||||
property int lensFlareGhostCount: 4 // 0 - 20
|
||||
property real lensFlareHaloWidth: 0.25 // 0 - 1
|
||||
property real lensFlareStretchToAspect: 0.5 // 0 - 1
|
||||
property real lensFlareDistortion: 5 // 0.0 - 20.0
|
||||
property real lensFlareBlurAmount: 3 // 0.0 - 5.0
|
||||
property bool lensFlareApplyDirtTexture: false
|
||||
property bool lensFlareApplyStarburstTexture: false
|
||||
property vector3d lensFlareCameraDirection: Qt.vector3d(0, 0, -1)
|
||||
property bool lensFlareDebug: false
|
||||
|
||||
property TextureInput lensColorTexture: TextureInput {
|
||||
id: lensColorTextureInput
|
||||
texture: defaultLensColorTexture
|
||||
}
|
||||
property alias lensColorTextureAlias: lensColorTextureInput.texture
|
||||
Texture {
|
||||
id: defaultLensColorTexture
|
||||
source: "qrc:/qtquick3d_helpers/images/gradientTexture.png"
|
||||
tilingModeHorizontal: Texture.ClampToEdge
|
||||
tilingModeVertical: Texture.ClampToEdge
|
||||
}
|
||||
|
||||
property TextureInput lensDirtTexture: TextureInput {
|
||||
id: lensDirtTextureInput
|
||||
texture: defaultLensDirtTexture
|
||||
}
|
||||
property alias lensDirtTextureAlias: lensDirtTextureInput.texture
|
||||
Texture {
|
||||
id: defaultLensDirtTexture
|
||||
source: "qrc:/qtquick3d_helpers/images/lens_dirt_default.jpeg"
|
||||
}
|
||||
|
||||
property TextureInput starburstTexture: TextureInput {
|
||||
id: lensStarburstTextureInput
|
||||
texture: defaultLensStarburstTexture
|
||||
}
|
||||
property alias starburstTextureAlias: lensStarburstTextureInput.texture
|
||||
Texture {
|
||||
id: defaultLensStarburstTexture
|
||||
source: "qrc:/qtquick3d_helpers/images/noiseTexture.png"
|
||||
}
|
||||
|
||||
// Glow data
|
||||
readonly property bool isFirstPass: true
|
||||
property bool isGlowEnabled: false
|
||||
property bool glowQualityHigh: false
|
||||
property bool glowUseBicubicUpscale: false
|
||||
property real glowStrength : 1.0 // 0.0 - 2.0
|
||||
property real glowIntensity : 0.8 // 0.0 - 8.0
|
||||
property real glowBloom : 0.0 // 0.0 - 1.0
|
||||
property int glowBlendMode : 2 // Additive,Screen,Softlight,Replace
|
||||
property real glowHDRMaximumValue: 12.0 // 0.0 - 256.0
|
||||
property real glowHDRScale: 2.0 // 0.0 - 4.0
|
||||
property real glowHDRMinimumValue: 1.0 // 0.0 - 4.0
|
||||
property int glowLevel: 1 // 1 - 7
|
||||
|
||||
// Color Grading (LUT)
|
||||
property bool enableLut: false
|
||||
property alias lutTextureAlias: lutTextureInput.texture
|
||||
property TextureInput lut: TextureInput {
|
||||
id: lutTextureInput
|
||||
texture: defaultLutTexture
|
||||
}
|
||||
property real lutSize: 16.0 // size of texture, textures are 3d in 2d, so width = lutSize * lutSize, height = lutSize
|
||||
property real lutFilterAlpha: 1.0 // 0.0 - 1.0
|
||||
Texture {
|
||||
id: defaultLutTexture
|
||||
source: "qrc:/qtquick3d_helpers/luts/identity.png"
|
||||
}
|
||||
|
||||
// Vignette
|
||||
property bool vignetteEnabled: false
|
||||
property real vignetteStrength: 15 // 0 - 15
|
||||
property color vignetteColor: "gray"
|
||||
property real vignetteRadius: 0.35 // 0 - 5
|
||||
|
||||
readonly property TextureInput glowBuffer1: TextureInput {
|
||||
texture: Texture {}
|
||||
}
|
||||
readonly property TextureInput glowBuffer2: TextureInput {
|
||||
texture: Texture {}
|
||||
}
|
||||
readonly property TextureInput glowBuffer3: TextureInput {
|
||||
texture: Texture {}
|
||||
}
|
||||
readonly property TextureInput glowBuffer4: TextureInput {
|
||||
texture: Texture {}
|
||||
}
|
||||
readonly property TextureInput glowBuffer5: TextureInput {
|
||||
texture: Texture {}
|
||||
}
|
||||
readonly property TextureInput glowBuffer6: TextureInput {
|
||||
texture: Texture {}
|
||||
}
|
||||
readonly property TextureInput glowBuffer7: TextureInput {
|
||||
texture: Texture {}
|
||||
}
|
||||
|
||||
readonly property TextureInput lensFlareDownsampleBuffer: TextureInput {
|
||||
texture: Texture {}
|
||||
}
|
||||
|
||||
readonly property TextureInput lensFlareFeaturesBuffer: TextureInput {
|
||||
texture: Texture {}
|
||||
}
|
||||
|
||||
readonly property TextureInput lensFlareTexture: TextureInput {
|
||||
texture: Texture {}
|
||||
}
|
||||
|
||||
Component.onCompleted: buildPasses()
|
||||
|
||||
onIsGlowEnabledChanged: buildPasses()
|
||||
onLensFlareEnabledChanged: buildPasses()
|
||||
|
||||
function buildPasses() {
|
||||
let passList = [];
|
||||
if (lensFlareEnabled) {
|
||||
passList.push(lensFlareDownsamplePass)
|
||||
passList.push(lensFlareFeaturesPass)
|
||||
passList.push(lensFlareBlurHorizontalPass)
|
||||
passList.push(lensFlareBlurVerticalPass)
|
||||
}
|
||||
|
||||
if (isGlowEnabled) {
|
||||
passList.push(horizontalBlurPass1)
|
||||
passList.push(verticalBlurPass1)
|
||||
passList.push(horizontalBlurPass2)
|
||||
passList.push(verticalBlurPass2)
|
||||
passList.push(horizontalBlurPass3)
|
||||
passList.push(verticalBlurPass3)
|
||||
passList.push(horizontalBlurPass4)
|
||||
passList.push(verticalBlurPass4)
|
||||
passList.push(horizontalBlurPass5)
|
||||
passList.push(verticalBlurPass5)
|
||||
passList.push(horizontalBlurPass6)
|
||||
passList.push(verticalBlurPass6)
|
||||
passList.push(horizontalBlurPass7)
|
||||
passList.push(verticalBlurPass7)
|
||||
}
|
||||
|
||||
passList.push(tonemapPass)
|
||||
tonemapPass.rebuildCommands();
|
||||
|
||||
sceneEffect.passes = passList // qmllint disable read-only-property
|
||||
}
|
||||
|
||||
Shader {
|
||||
id: tonemapperFrag
|
||||
stage: Shader.Fragment
|
||||
shader: "qrc:/qtquick3d_helpers/shaders/tonemapper.frag"
|
||||
}
|
||||
|
||||
Shader {
|
||||
id: glowHorizontalBlur
|
||||
stage: Shader.Fragment
|
||||
shader: "qrc:/qtquick3d_helpers/shaders/glowhorizontalblur.frag"
|
||||
}
|
||||
|
||||
Shader {
|
||||
id: glowVerticalBlur
|
||||
stage: Shader.Fragment
|
||||
shader: "qrc:/qtquick3d_helpers/shaders/glowverticalblur.frag"
|
||||
}
|
||||
|
||||
Shader {
|
||||
id: lensFlareDownsample
|
||||
stage: Shader.Fragment
|
||||
shader: "qrc:/qtquick3d_helpers/shaders/lensflaredownsample.frag"
|
||||
}
|
||||
|
||||
Shader {
|
||||
id: lensFlareFeatures
|
||||
stage: Shader.Fragment
|
||||
shader: "qrc:/qtquick3d_helpers/shaders/lensflarefeatures.frag"
|
||||
}
|
||||
|
||||
Shader {
|
||||
id: lensFlareVerticalBlurVert
|
||||
stage: Shader.Vertex
|
||||
shader: "qrc:/qtquick3d_helpers/shaders/lensflareblurvertical.vert"
|
||||
}
|
||||
Shader {
|
||||
id: lensFlareHorizontalVert
|
||||
stage: Shader.Vertex
|
||||
shader: "qrc:/qtquick3d_helpers/shaders/lensflareblurhorizontal.vert"
|
||||
}
|
||||
Shader {
|
||||
id: lensFlareGaussianBlur
|
||||
stage: Shader.Fragment
|
||||
shader: "qrc:/qtquick3d_helpers/shaders/lensflaregaussianblur.frag"
|
||||
}
|
||||
|
||||
Buffer {
|
||||
id: tempBuffer1
|
||||
name: "tempBuffer1"
|
||||
format: Buffer.RGBA16F
|
||||
textureFilterOperation: Buffer.Linear
|
||||
textureCoordOperation: Buffer.ClampToEdge
|
||||
bufferFlags: Buffer.None
|
||||
sizeMultiplier: 0.5
|
||||
}
|
||||
Buffer {
|
||||
id: tempBuffer2
|
||||
name: "tempBuffer2"
|
||||
format: Buffer.RGBA16F
|
||||
textureFilterOperation: Buffer.Linear
|
||||
textureCoordOperation: Buffer.ClampToEdge
|
||||
bufferFlags: Buffer.None
|
||||
sizeMultiplier: 0.25
|
||||
}
|
||||
Buffer {
|
||||
id: tempBuffer3
|
||||
name: "tempBuffer3"
|
||||
format: Buffer.RGBA16F
|
||||
textureFilterOperation: Buffer.Linear
|
||||
textureCoordOperation: Buffer.ClampToEdge
|
||||
bufferFlags: Buffer.None
|
||||
sizeMultiplier: 0.125
|
||||
}
|
||||
Buffer {
|
||||
id: tempBuffer4
|
||||
name: "tempBuffer4"
|
||||
format: Buffer.RGBA16F
|
||||
textureFilterOperation: Buffer.Linear
|
||||
textureCoordOperation: Buffer.ClampToEdge
|
||||
bufferFlags: Buffer.None
|
||||
sizeMultiplier: 0.0625
|
||||
}
|
||||
Buffer {
|
||||
id: tempBuffer5
|
||||
name: "tempBuffer5"
|
||||
format: Buffer.RGBA16F
|
||||
textureFilterOperation: Buffer.Linear
|
||||
textureCoordOperation: Buffer.ClampToEdge
|
||||
bufferFlags: Buffer.None
|
||||
sizeMultiplier: 0.03125
|
||||
}
|
||||
Buffer {
|
||||
id: tempBuffer6
|
||||
name: "tempBuffer6"
|
||||
format: Buffer.RGBA16F
|
||||
textureFilterOperation: Buffer.Linear
|
||||
textureCoordOperation: Buffer.ClampToEdge
|
||||
bufferFlags: Buffer.None
|
||||
sizeMultiplier: 0.015625
|
||||
}
|
||||
Buffer {
|
||||
id: tempBuffer7
|
||||
name: "tempBuffer7"
|
||||
format: Buffer.RGBA16F
|
||||
textureFilterOperation: Buffer.Linear
|
||||
textureCoordOperation: Buffer.ClampToEdge
|
||||
bufferFlags: Buffer.None
|
||||
sizeMultiplier: 0.0078125
|
||||
}
|
||||
|
||||
Buffer {
|
||||
id: glowBuffer1
|
||||
name: "glowBuffer1"
|
||||
format: Buffer.RGBA16F
|
||||
textureFilterOperation: Buffer.Linear
|
||||
textureCoordOperation: Buffer.ClampToEdge
|
||||
bufferFlags: Buffer.None
|
||||
sizeMultiplier: 0.5
|
||||
}
|
||||
Buffer {
|
||||
id: glowBuffer2
|
||||
name: "glowBuffer2"
|
||||
format: Buffer.RGBA16F
|
||||
textureFilterOperation: Buffer.Linear
|
||||
textureCoordOperation: Buffer.ClampToEdge
|
||||
bufferFlags: Buffer.None
|
||||
sizeMultiplier: 0.25
|
||||
}
|
||||
Buffer {
|
||||
id: glowBuffer3
|
||||
name: "glowBuffer3"
|
||||
format: Buffer.RGBA16F
|
||||
textureFilterOperation: Buffer.Linear
|
||||
textureCoordOperation: Buffer.ClampToEdge
|
||||
bufferFlags: Buffer.None
|
||||
sizeMultiplier: 0.125
|
||||
}
|
||||
Buffer {
|
||||
id: glowBuffer4
|
||||
name: "glowBuffer4"
|
||||
format: Buffer.RGBA16F
|
||||
textureFilterOperation: Buffer.Linear
|
||||
textureCoordOperation: Buffer.ClampToEdge
|
||||
bufferFlags: Buffer.None
|
||||
sizeMultiplier: 0.0625
|
||||
}
|
||||
Buffer {
|
||||
id: glowBuffer5
|
||||
name: "glowBuffer5"
|
||||
format: Buffer.RGBA16F
|
||||
textureFilterOperation: Buffer.Linear
|
||||
textureCoordOperation: Buffer.ClampToEdge
|
||||
bufferFlags: Buffer.None
|
||||
sizeMultiplier: 0.03125
|
||||
}
|
||||
Buffer {
|
||||
id: glowBuffer6
|
||||
name: "glowBuffer6"
|
||||
format: Buffer.RGBA16F
|
||||
textureFilterOperation: Buffer.Linear
|
||||
textureCoordOperation: Buffer.ClampToEdge
|
||||
bufferFlags: Buffer.None
|
||||
sizeMultiplier: 0.015625
|
||||
}
|
||||
Buffer {
|
||||
id: glowBuffer7
|
||||
name: "glowBuffer7"
|
||||
format: Buffer.RGBA16F
|
||||
textureFilterOperation: Buffer.Linear
|
||||
textureCoordOperation: Buffer.ClampToEdge
|
||||
bufferFlags: Buffer.None
|
||||
sizeMultiplier: 0.0078125
|
||||
}
|
||||
|
||||
Buffer {
|
||||
id: lensFlareDownsampleBuffer
|
||||
name: "lensFlareDownsampleBuffer"
|
||||
format: Buffer.RGBA16F
|
||||
textureFilterOperation: Buffer.Linear
|
||||
textureCoordOperation: Buffer.ClampToEdge
|
||||
bufferFlags: Buffer.None
|
||||
sizeMultiplier: 0.5
|
||||
}
|
||||
|
||||
Buffer {
|
||||
id: lensFlareFeaturesBuffer
|
||||
name: "lensFlareFeaturesBuffer"
|
||||
format: Buffer.RGBA16F
|
||||
textureFilterOperation: Buffer.Linear
|
||||
textureCoordOperation: Buffer.ClampToEdge
|
||||
bufferFlags: Buffer.None
|
||||
sizeMultiplier: 0.5
|
||||
}
|
||||
|
||||
Buffer {
|
||||
id: lensFlareBlurTempBuffer
|
||||
name: "lensFlareBlurTempBuffer"
|
||||
format: Buffer.RGBA16F
|
||||
textureFilterOperation: Buffer.Linear
|
||||
textureCoordOperation: Buffer.ClampToEdge
|
||||
bufferFlags: Buffer.None
|
||||
sizeMultiplier: 0.5
|
||||
}
|
||||
|
||||
Buffer {
|
||||
id: lensFlareBlurBuffer
|
||||
name: "lensFlareBlurBuffer"
|
||||
format: Buffer.RGBA16F
|
||||
textureFilterOperation: Buffer.Linear
|
||||
textureCoordOperation: Buffer.ClampToEdge
|
||||
bufferFlags: Buffer.None
|
||||
sizeMultiplier: 0.5
|
||||
}
|
||||
|
||||
Pass {
|
||||
id: horizontalBlurPass1
|
||||
shaders: [glowHorizontalBlur]
|
||||
commands: [
|
||||
SetUniformValue {
|
||||
target: "isFirstPass"
|
||||
value: true
|
||||
}
|
||||
]
|
||||
output: tempBuffer1
|
||||
}
|
||||
|
||||
Pass {
|
||||
id: verticalBlurPass1
|
||||
shaders: [glowVerticalBlur]
|
||||
commands: [
|
||||
SetUniformValue {
|
||||
target: "isFirstPass"
|
||||
value: false
|
||||
},
|
||||
BufferInput {
|
||||
buffer: tempBuffer1
|
||||
}
|
||||
]
|
||||
output: glowBuffer1
|
||||
}
|
||||
|
||||
Pass {
|
||||
id: horizontalBlurPass2
|
||||
shaders: [glowHorizontalBlur]
|
||||
commands: [
|
||||
SetUniformValue {
|
||||
target: "isFirstPass"
|
||||
value: false
|
||||
},
|
||||
BufferInput {
|
||||
buffer: glowBuffer1
|
||||
}
|
||||
]
|
||||
output: tempBuffer2
|
||||
}
|
||||
|
||||
Pass {
|
||||
id: verticalBlurPass2
|
||||
shaders: [glowVerticalBlur]
|
||||
commands: [
|
||||
SetUniformValue {
|
||||
target: "isFirstPass"
|
||||
value: false
|
||||
},
|
||||
BufferInput {
|
||||
buffer: tempBuffer2
|
||||
}
|
||||
]
|
||||
output: glowBuffer2
|
||||
}
|
||||
|
||||
Pass {
|
||||
id: horizontalBlurPass3
|
||||
shaders: [glowHorizontalBlur]
|
||||
commands: [
|
||||
SetUniformValue {
|
||||
target: "isFirstPass"
|
||||
value: false
|
||||
},
|
||||
BufferInput {
|
||||
buffer: glowBuffer2
|
||||
}
|
||||
]
|
||||
output: tempBuffer3
|
||||
}
|
||||
|
||||
Pass {
|
||||
id: verticalBlurPass3
|
||||
shaders: [glowVerticalBlur]
|
||||
commands: [
|
||||
SetUniformValue {
|
||||
target: "isFirstPass"
|
||||
value: false
|
||||
},
|
||||
BufferInput {
|
||||
buffer: tempBuffer3
|
||||
}
|
||||
]
|
||||
output: glowBuffer3
|
||||
}
|
||||
|
||||
Pass {
|
||||
id: horizontalBlurPass4
|
||||
shaders: [glowHorizontalBlur]
|
||||
commands: [
|
||||
SetUniformValue {
|
||||
target: "isFirstPass"
|
||||
value: false
|
||||
},
|
||||
BufferInput {
|
||||
buffer: glowBuffer3
|
||||
}
|
||||
]
|
||||
output: tempBuffer4
|
||||
}
|
||||
|
||||
Pass {
|
||||
id: verticalBlurPass4
|
||||
shaders: [glowVerticalBlur]
|
||||
commands: [
|
||||
SetUniformValue {
|
||||
target: "isFirstPass"
|
||||
value: false
|
||||
},
|
||||
BufferInput {
|
||||
buffer: tempBuffer4
|
||||
}
|
||||
]
|
||||
output: glowBuffer4
|
||||
}
|
||||
|
||||
Pass {
|
||||
id: horizontalBlurPass5
|
||||
shaders: [glowHorizontalBlur]
|
||||
commands: [
|
||||
SetUniformValue {
|
||||
target: "isFirstPass"
|
||||
value: false
|
||||
},
|
||||
BufferInput {
|
||||
buffer: glowBuffer4
|
||||
}
|
||||
]
|
||||
output: tempBuffer5
|
||||
}
|
||||
|
||||
Pass {
|
||||
id: verticalBlurPass5
|
||||
shaders: [glowVerticalBlur]
|
||||
commands: [
|
||||
SetUniformValue {
|
||||
target: "isFirstPass"
|
||||
value: false
|
||||
},
|
||||
BufferInput {
|
||||
buffer: tempBuffer5
|
||||
}
|
||||
]
|
||||
output: glowBuffer5
|
||||
}
|
||||
|
||||
Pass {
|
||||
id: horizontalBlurPass6
|
||||
shaders: [glowHorizontalBlur]
|
||||
commands: [
|
||||
SetUniformValue {
|
||||
target: "isFirstPass"
|
||||
value: false
|
||||
},
|
||||
BufferInput {
|
||||
buffer: glowBuffer5
|
||||
}
|
||||
]
|
||||
output: tempBuffer6
|
||||
}
|
||||
|
||||
Pass {
|
||||
id: verticalBlurPass6
|
||||
shaders: [glowVerticalBlur]
|
||||
commands: [
|
||||
SetUniformValue {
|
||||
target: "isFirstPass"
|
||||
value: false
|
||||
},
|
||||
BufferInput {
|
||||
buffer: tempBuffer6
|
||||
}
|
||||
]
|
||||
output: glowBuffer6
|
||||
}
|
||||
Pass {
|
||||
id: horizontalBlurPass7
|
||||
shaders: [glowHorizontalBlur]
|
||||
commands: [
|
||||
SetUniformValue {
|
||||
target: "isFirstPass"
|
||||
value: false
|
||||
},
|
||||
BufferInput {
|
||||
buffer: glowBuffer6
|
||||
}
|
||||
]
|
||||
output: tempBuffer7
|
||||
}
|
||||
|
||||
Pass {
|
||||
id: verticalBlurPass7
|
||||
shaders: [glowVerticalBlur]
|
||||
commands: [
|
||||
SetUniformValue {
|
||||
target: "isFirstPass"
|
||||
value: false
|
||||
},
|
||||
BufferInput {
|
||||
buffer: tempBuffer7
|
||||
}
|
||||
]
|
||||
output: glowBuffer7
|
||||
}
|
||||
|
||||
Pass {
|
||||
id: lensFlareDownsamplePass
|
||||
shaders: [lensFlareDownsample]
|
||||
output: lensFlareDownsampleBuffer
|
||||
}
|
||||
|
||||
Pass {
|
||||
id: lensFlareFeaturesPass
|
||||
shaders: [lensFlareFeatures]
|
||||
commands: [
|
||||
BufferInput {
|
||||
buffer: lensFlareDownsampleBuffer
|
||||
sampler: "lensFlareDownsampleBuffer"
|
||||
}
|
||||
]
|
||||
output: lensFlareFeaturesBuffer
|
||||
}
|
||||
|
||||
Pass {
|
||||
id: lensFlareBlurHorizontalPass
|
||||
shaders: [lensFlareHorizontalVert, lensFlareGaussianBlur]
|
||||
commands: [
|
||||
BufferInput {
|
||||
buffer: lensFlareFeaturesBuffer
|
||||
sampler: "lensFlareTexture"
|
||||
}
|
||||
]
|
||||
output: lensFlareBlurTempBuffer
|
||||
}
|
||||
Pass {
|
||||
id: lensFlareBlurVerticalPass
|
||||
shaders: [lensFlareVerticalBlurVert, lensFlareGaussianBlur]
|
||||
commands: [
|
||||
BufferInput {
|
||||
buffer: lensFlareBlurTempBuffer
|
||||
sampler: "lensFlareTexture"
|
||||
}
|
||||
|
||||
]
|
||||
output: lensFlareBlurBuffer
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: sceneEffect
|
||||
function onIsGlowEnabledChanged() { tonemapPass.rebuildCommands() }
|
||||
function onLensFlareEnabledChanged() { tonemapPass.rebuildCommands() }
|
||||
}
|
||||
|
||||
BufferInput {
|
||||
id: glowBufferInput1
|
||||
buffer: glowBuffer1
|
||||
sampler: "glowBuffer1"
|
||||
}
|
||||
BufferInput {
|
||||
id: glowBufferInput2
|
||||
buffer: glowBuffer2
|
||||
sampler: "glowBuffer2"
|
||||
}
|
||||
BufferInput {
|
||||
id: glowBufferInput3
|
||||
buffer: glowBuffer3
|
||||
sampler: "glowBuffer3"
|
||||
}
|
||||
BufferInput {
|
||||
id: glowBufferInput4
|
||||
buffer: glowBuffer4
|
||||
sampler: "glowBuffer4"
|
||||
}
|
||||
BufferInput {
|
||||
id: glowBufferInput5
|
||||
buffer: glowBuffer5
|
||||
sampler: "glowBuffer5"
|
||||
}
|
||||
BufferInput {
|
||||
id: glowBufferInput6
|
||||
buffer: glowBuffer6
|
||||
sampler: "glowBuffer6"
|
||||
}
|
||||
BufferInput {
|
||||
id: glowBufferInput7
|
||||
buffer: glowBuffer7
|
||||
sampler: "glowBuffer7"
|
||||
}
|
||||
BufferInput {
|
||||
id: lensFlareBufferInput
|
||||
buffer: lensFlareBlurBuffer
|
||||
sampler: "lensFlareTexture"
|
||||
}
|
||||
|
||||
Pass {
|
||||
id: tonemapPass;
|
||||
shaders: [tonemapperFrag]
|
||||
|
||||
function rebuildCommands() {
|
||||
let dynamicCommands = []
|
||||
if (sceneEffect.isGlowEnabled) {
|
||||
dynamicCommands.push(glowBufferInput1)
|
||||
dynamicCommands.push(glowBufferInput2)
|
||||
dynamicCommands.push(glowBufferInput3)
|
||||
dynamicCommands.push(glowBufferInput4)
|
||||
dynamicCommands.push(glowBufferInput5)
|
||||
dynamicCommands.push(glowBufferInput6)
|
||||
dynamicCommands.push(glowBufferInput7)
|
||||
}
|
||||
if (sceneEffect.lensFlareEnabled) {
|
||||
dynamicCommands.push(lensFlareBufferInput)
|
||||
}
|
||||
tonemapPass.commands = dynamicCommands; // qmllint disable read-only-property
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
// Copyright (C) 2025 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
||||
|
||||
import QtQuick
|
||||
import QtQuick3D
|
||||
import QtQuick3D.Helpers.impl
|
||||
|
||||
SsgiEnvEffect {
|
||||
id: ssgiEffect
|
||||
|
||||
property bool indirectLightEnabled: true
|
||||
property real indirectLightBoost: 4.0 // 1 - 100
|
||||
|
||||
property real bufferSizeFactor: 0.5 // 0 - 1 (leave it at 0.5, generally)
|
||||
|
||||
property bool simulatedBounceEnabled: false
|
||||
property real simulatedBounceFactor: 0.5 // 0 - 1
|
||||
|
||||
property int sampleCount: 4 // 1 - 16
|
||||
property real sampleRadius: 0.1 // 0.001 - 4
|
||||
property int sliceCount: 4 // 1 - 8
|
||||
property real hitThickness: 0.5 // 0.001 - 4
|
||||
|
||||
property int debugMode: 0 // internal; needs uncommenting ENABLE_DEBUG_MODE in all the shaders
|
||||
|
||||
readonly property TextureInput indirectAndAoSampler: TextureInput {
|
||||
texture: Texture {}
|
||||
}
|
||||
|
||||
readonly property TextureInput blurredIndirectAndAoSampler: TextureInput {
|
||||
texture: Texture {}
|
||||
}
|
||||
|
||||
Buffer {
|
||||
id: indirectAndAoBuffer
|
||||
name: "indirectAndAoBuffer"
|
||||
sizeMultiplier: ssgiEffect.bufferSizeFactor
|
||||
format: Buffer.RGBA16F
|
||||
|
||||
}
|
||||
|
||||
Buffer {
|
||||
id: blurredIndirectAndAoBuffer
|
||||
name: "blurredIndirectAndAoBuffer"
|
||||
sizeMultiplier: ssgiEffect.bufferSizeFactor
|
||||
bufferFlags: Buffer.SceneLifetime // for simulatedBounce
|
||||
format: Buffer.RGBA16F
|
||||
}
|
||||
|
||||
Shader {
|
||||
id: ssgiMainShader
|
||||
stage: Shader.Fragment
|
||||
shader: "qrc:/qtquick3d_helpers/shaders/ssgi_ssilvb.frag"
|
||||
}
|
||||
|
||||
Shader {
|
||||
id: ssgiBlurDownShader
|
||||
stage: Shader.Fragment
|
||||
shader: "qrc:/qtquick3d_helpers/shaders/ssgi_dualfilterblur_down.frag"
|
||||
}
|
||||
|
||||
Shader {
|
||||
id: ssgiBlurUpShader
|
||||
stage: Shader.Fragment
|
||||
shader: "qrc:/qtquick3d_helpers/shaders/ssgi_dualfilterblur_up.frag"
|
||||
}
|
||||
|
||||
Shader {
|
||||
id: ssgiComposeShader
|
||||
stage: Shader.Fragment
|
||||
shader: "qrc:/qtquick3d_helpers/shaders/ssgi_compose.frag"
|
||||
}
|
||||
|
||||
Pass {
|
||||
id: ssaoAndIndirectPass
|
||||
output: indirectAndAoBuffer
|
||||
shaders: ssgiMainShader
|
||||
commands: [
|
||||
// for simulatedBounce
|
||||
BufferInput {
|
||||
// because it is SceneLifetime, so here this is the result from the previous frame
|
||||
buffer: blurredIndirectAndAoBuffer
|
||||
sampler: "blurredIndirectAndAoSampler"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
// Kawase / dual filter blur
|
||||
// https://community.arm.com/cfs-file/__key/communityserver-blogs-components-weblogfiles/00-00-00-20-66/siggraph2015_2D00_mmg_2D00_marius_2D00_notes.pdf
|
||||
Buffer {
|
||||
id: tempBuffer1
|
||||
name: "tempBuffer1"
|
||||
sizeMultiplier: ssgiEffect.bufferSizeFactor * 0.5
|
||||
format: Buffer.RGBA16F
|
||||
}
|
||||
|
||||
Buffer {
|
||||
id: tempBuffer2
|
||||
name: "tempBuffer2"
|
||||
sizeMultiplier: ssgiEffect.bufferSizeFactor * 0.5 * 0.5
|
||||
format: Buffer.RGBA16F
|
||||
}
|
||||
|
||||
Pass {
|
||||
id: indirectLightBufferBlurDownInputTo1
|
||||
output: tempBuffer1
|
||||
shaders: ssgiBlurDownShader
|
||||
commands: [
|
||||
BufferInput {
|
||||
buffer: indirectAndAoBuffer
|
||||
}
|
||||
]
|
||||
}
|
||||
Pass {
|
||||
id: indirectLightBufferBlurDown1To2
|
||||
output: tempBuffer2
|
||||
shaders: ssgiBlurDownShader
|
||||
commands: [
|
||||
BufferInput {
|
||||
buffer: tempBuffer1
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Pass {
|
||||
id: indirectLightBufferBlurUp2To1
|
||||
output: tempBuffer1
|
||||
shaders: ssgiBlurUpShader
|
||||
commands: [
|
||||
BufferInput {
|
||||
buffer: tempBuffer2
|
||||
}
|
||||
]
|
||||
}
|
||||
Pass {
|
||||
id: indirectLightBufferBlurUp1ToOutput
|
||||
output: blurredIndirectAndAoBuffer
|
||||
shaders: ssgiBlurUpShader
|
||||
commands: [
|
||||
BufferInput {
|
||||
buffer: tempBuffer1
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Pass {
|
||||
id: ssgiCompositionPass
|
||||
shaders: ssgiComposeShader
|
||||
commands: [
|
||||
BufferInput {
|
||||
buffer: blurredIndirectAndAoBuffer
|
||||
sampler: "blurredIndirectAndAoSampler"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
passes:
|
||||
[ ssaoAndIndirectPass,
|
||||
indirectLightBufferBlurDownInputTo1, indirectLightBufferBlurDown1To2,
|
||||
indirectLightBufferBlurUp2To1, indirectLightBufferBlurUp1ToOutput,
|
||||
ssgiCompositionPass
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
// Copyright (C) 2025 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
||||
|
||||
import QtQuick
|
||||
import QtQuick3D
|
||||
import QtQuick3D.Helpers.impl
|
||||
|
||||
SsrEnvEffect {
|
||||
id: ssrEffect
|
||||
|
||||
// Global
|
||||
property real roughnessCut: 0.65
|
||||
|
||||
// Main pass
|
||||
property real stepSize: 0.01
|
||||
property real minRayStep: 0.01
|
||||
property int binarySteps: 8
|
||||
property int maxSteps: 512
|
||||
property real baseThickness: 20
|
||||
|
||||
readonly property TextureInput ssrSampler: TextureInput { texture: Texture {} }
|
||||
readonly property TextureInput ssrMaskSampler: TextureInput { texture: Texture {} }
|
||||
readonly property TextureInput ssrReflConfSampler: TextureInput { texture: Texture {} }
|
||||
|
||||
Buffer {
|
||||
id: ssrBufferMask
|
||||
name: "ssrBufferMask"
|
||||
sizeMultiplier: 1.0
|
||||
format: Buffer.RGBA32F
|
||||
}
|
||||
|
||||
Buffer {
|
||||
id: ssrBufferMainReflColorConf
|
||||
name: "ssrBufferMainReflColorConf"
|
||||
sizeMultiplier: 1.0
|
||||
format: Buffer.RGBA32F
|
||||
}
|
||||
|
||||
Pass {
|
||||
id: ssrMaskPass
|
||||
output: ssrBufferMask
|
||||
shaders: Shader { stage: Shader.Fragment; shader: "qrc:/qtquick3d_helpers/shaders/ssr_mask.frag" }
|
||||
}
|
||||
|
||||
Pass {
|
||||
id: ssrMainPass
|
||||
output: ssrBufferMainReflColorConf
|
||||
shaders: [
|
||||
Shader {
|
||||
stage: Shader.Fragment
|
||||
shader: "qrc:/qtquick3d_helpers/shaders/ssr_main.frag"
|
||||
}
|
||||
]
|
||||
commands: [
|
||||
BufferInput { buffer: ssrBufferMask; sampler: "ssrMaskSampler" }
|
||||
]
|
||||
}
|
||||
|
||||
Pass {
|
||||
id: ssrCompositionPass
|
||||
shaders: [
|
||||
Shader {
|
||||
stage: Shader.Fragment
|
||||
shader: "qrc:/qtquick3d_helpers/shaders/ssr_composition.frag"
|
||||
}
|
||||
]
|
||||
commands: [
|
||||
BufferInput { buffer: ssrBufferMainReflColorConf; sampler: "ssrSampler" }
|
||||
]
|
||||
}
|
||||
|
||||
passes: [
|
||||
ssrMaskPass, ssrMainPass, ssrCompositionPass
|
||||
]
|
||||
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
import QtQuick.tooling 1.2
|
||||
|
||||
// This file describes the plugin-supplied types contained in the library.
|
||||
// It is used for QML tooling purposes only.
|
||||
//
|
||||
// This file was auto-generated by qmltyperegistrar.
|
||||
|
||||
Module {
|
||||
Component {
|
||||
file: "private/sceneeffects_p.h"
|
||||
lineNumber: 64
|
||||
name: "DepthOfFieldEffect"
|
||||
accessSemantics: "reference"
|
||||
prototype: "SceneEffectBase"
|
||||
exports: ["QtQuick3D.Helpers.impl/DepthOfFieldEffect 6.0"]
|
||||
exportMetaObjectRevisions: [1536]
|
||||
Property {
|
||||
name: "enabled"
|
||||
type: "bool"
|
||||
read: "enabled"
|
||||
write: "setEnabled"
|
||||
notify: "enabledChanged"
|
||||
index: 0
|
||||
lineNumber: 67
|
||||
}
|
||||
Signal { name: "enabledChanged"; lineNumber: 76 }
|
||||
}
|
||||
Component {
|
||||
file: "private/sceneeffects_p.h"
|
||||
lineNumber: 52
|
||||
name: "MainSceneEffect"
|
||||
accessSemantics: "reference"
|
||||
prototype: "SceneEffectBase"
|
||||
exports: ["QtQuick3D.Helpers.impl/MainSceneEffect 6.0"]
|
||||
exportMetaObjectRevisions: [1536]
|
||||
}
|
||||
Component {
|
||||
file: "qabstractitemmodel.h"
|
||||
lineNumber: 451
|
||||
name: "QAbstractTableModel"
|
||||
accessSemantics: "reference"
|
||||
prototype: "QAbstractItemModel"
|
||||
}
|
||||
Component {
|
||||
file: "private/qquick3drenderstatsmeshesmodel_p.h"
|
||||
lineNumber: 26
|
||||
name: "QQuick3DRenderStatsMeshesModel"
|
||||
accessSemantics: "reference"
|
||||
prototype: "QAbstractTableModel"
|
||||
exports: [
|
||||
"QtQuick3D.Helpers.impl/RenderStatsMeshesModel 6.0",
|
||||
"QtQuick3D.Helpers.impl/RenderStatsMeshesModel 6.4"
|
||||
]
|
||||
exportMetaObjectRevisions: [1536, 1540]
|
||||
Property {
|
||||
name: "meshData"
|
||||
type: "QString"
|
||||
read: "meshData"
|
||||
write: "setMeshData"
|
||||
notify: "meshDataChanged"
|
||||
index: 0
|
||||
lineNumber: 29
|
||||
}
|
||||
Signal { name: "meshDataChanged"; lineNumber: 45 }
|
||||
Method {
|
||||
name: "setMeshData"
|
||||
lineNumber: 42
|
||||
Parameter { name: "newMeshData"; type: "QString" }
|
||||
}
|
||||
}
|
||||
Component {
|
||||
file: "private/qquick3drenderstatspassesmodel_p.h"
|
||||
lineNumber: 26
|
||||
name: "QQuick3DRenderStatsPassesModel"
|
||||
accessSemantics: "reference"
|
||||
prototype: "QAbstractTableModel"
|
||||
exports: [
|
||||
"QtQuick3D.Helpers.impl/RenderStatsPassesModel 6.0",
|
||||
"QtQuick3D.Helpers.impl/RenderStatsPassesModel 6.4"
|
||||
]
|
||||
exportMetaObjectRevisions: [1536, 1540]
|
||||
Property {
|
||||
name: "passData"
|
||||
type: "QString"
|
||||
read: "passData"
|
||||
write: "setPassData"
|
||||
notify: "passDataChanged"
|
||||
index: 0
|
||||
lineNumber: 29
|
||||
}
|
||||
Signal { name: "passDataChanged"; lineNumber: 44 }
|
||||
Method {
|
||||
name: "setPassData"
|
||||
lineNumber: 41
|
||||
Parameter { name: "newPassData"; type: "QString" }
|
||||
}
|
||||
}
|
||||
Component {
|
||||
file: "private/qquick3drenderstatstexturesmodel_p.h"
|
||||
lineNumber: 26
|
||||
name: "QQuick3DRenderStatsTexturesModel"
|
||||
accessSemantics: "reference"
|
||||
prototype: "QAbstractTableModel"
|
||||
exports: [
|
||||
"QtQuick3D.Helpers.impl/RenderStatsTexturesModel 6.0",
|
||||
"QtQuick3D.Helpers.impl/RenderStatsTexturesModel 6.4"
|
||||
]
|
||||
exportMetaObjectRevisions: [1536, 1540]
|
||||
Property {
|
||||
name: "textureData"
|
||||
type: "QString"
|
||||
read: "textureData"
|
||||
write: "setTextureData"
|
||||
notify: "textureDataChanged"
|
||||
index: 0
|
||||
lineNumber: 29
|
||||
}
|
||||
Signal { name: "textureDataChanged"; lineNumber: 45 }
|
||||
Method {
|
||||
name: "setTextureData"
|
||||
lineNumber: 42
|
||||
Parameter { name: "newTextureData"; type: "QString" }
|
||||
}
|
||||
}
|
||||
Component {
|
||||
file: "private/sceneeffects_p.h"
|
||||
lineNumber: 28
|
||||
name: "SceneEffectBase"
|
||||
accessSemantics: "reference"
|
||||
prototype: "QQuick3DEffect"
|
||||
exports: ["QtQuick3D.Helpers.impl/SceneEffectBase 6.0"]
|
||||
isCreatable: false
|
||||
exportMetaObjectRevisions: [1536]
|
||||
Property {
|
||||
name: "environment"
|
||||
type: "QQuick3DSceneEnvironment"
|
||||
isPointer: true
|
||||
read: "environment"
|
||||
write: "setEnvironment"
|
||||
notify: "environmentChanged"
|
||||
index: 0
|
||||
lineNumber: 31
|
||||
}
|
||||
Signal { name: "environmentChanged"; lineNumber: 41 }
|
||||
}
|
||||
Component {
|
||||
file: "private/sceneeffects_p.h"
|
||||
lineNumber: 124
|
||||
name: "SceneEffectEnvironment"
|
||||
accessSemantics: "reference"
|
||||
prototype: "QQuick3DSceneEnvironment"
|
||||
exports: [
|
||||
"QtQuick3D.Helpers.impl/SceneEffectEnvironment 6.0",
|
||||
"QtQuick3D.Helpers.impl/SceneEffectEnvironment 6.4",
|
||||
"QtQuick3D.Helpers.impl/SceneEffectEnvironment 6.5",
|
||||
"QtQuick3D.Helpers.impl/SceneEffectEnvironment 6.9",
|
||||
"QtQuick3D.Helpers.impl/SceneEffectEnvironment 6.11"
|
||||
]
|
||||
exportMetaObjectRevisions: [1536, 1540, 1541, 1545, 1547]
|
||||
}
|
||||
Component {
|
||||
file: "private/sceneeffects_p.h"
|
||||
lineNumber: 84
|
||||
name: "SsgiEnvEffect"
|
||||
accessSemantics: "reference"
|
||||
prototype: "SceneEffectBase"
|
||||
exports: ["QtQuick3D.Helpers.impl/SsgiEnvEffect 6.0"]
|
||||
exportMetaObjectRevisions: [1536]
|
||||
Property {
|
||||
name: "enabled"
|
||||
type: "bool"
|
||||
read: "enabled"
|
||||
write: "setEnabled"
|
||||
notify: "enabledChanged"
|
||||
index: 0
|
||||
lineNumber: 87
|
||||
}
|
||||
Signal { name: "enabledChanged"; lineNumber: 96 }
|
||||
}
|
||||
Component {
|
||||
file: "private/sceneeffects_p.h"
|
||||
lineNumber: 104
|
||||
name: "SsrEnvEffect"
|
||||
accessSemantics: "reference"
|
||||
prototype: "SceneEffectBase"
|
||||
exports: ["QtQuick3D.Helpers.impl/SsrEnvEffect 6.0"]
|
||||
exportMetaObjectRevisions: [1536]
|
||||
Property {
|
||||
name: "enabled"
|
||||
type: "bool"
|
||||
read: "enabled"
|
||||
write: "setEnabled"
|
||||
notify: "enabledChanged"
|
||||
index: 0
|
||||
lineNumber: 107
|
||||
}
|
||||
Signal { name: "enabledChanged"; lineNumber: 116 }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
module QtQuick3D.Helpers.impl
|
||||
linktarget Qt6::qtquick3dhelpersimplplugin
|
||||
plugin qtquick3dhelpersimplplugin
|
||||
classname QtQuick3DHelpersImplPlugin
|
||||
typeinfo plugins.qmltypes
|
||||
depends QtQuick3D auto
|
||||
prefer :/qt-project.org/imports/QtQuick3D/Helpers/impl/
|
||||
DepthOfFieldBlur 6.0 DepthOfFieldBlur.qml
|
||||
SsgiEffect 6.0 SsgiEffect.qml
|
||||
SsrEffect 6.0 SsrEffect.qml
|
||||
SceneEffect 6.0 SceneEffect.qml
|
||||
depends QtQuick
|
||||
|
||||
BIN
Binary file not shown.
Reference in New Issue
Block a user