HDRBloomTonemap.qml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2020 The Qt Company Ltd.
  4. ** Contact: https://www.qt.io/licensing/
  5. **
  6. ** This file is part of Qt Quick 3D.
  7. **
  8. ** $QT_BEGIN_LICENSE:GPL$
  9. ** Commercial License Usage
  10. ** Licensees holding valid commercial Qt licenses may use this file in
  11. ** accordance with the commercial license agreement provided with the
  12. ** Software or, alternatively, in accordance with the terms contained in
  13. ** a written agreement between you and The Qt Company. For licensing terms
  14. ** and conditions see https://www.qt.io/terms-conditions. For further
  15. ** information use the contact form at https://www.qt.io/contact-us.
  16. **
  17. ** GNU General Public License Usage
  18. ** Alternatively, this file may be used under the terms of the GNU
  19. ** General Public License version 3 or (at your option) any later version
  20. ** approved by the KDE Free Qt Foundation. The licenses are as published by
  21. ** the Free Software Foundation and appearing in the file LICENSE.GPL3
  22. ** included in the packaging of this file. Please review the following
  23. ** information to ensure the GNU General Public License requirements will
  24. ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
  25. **
  26. ** $QT_END_LICENSE$
  27. **
  28. ****************************************************************************/
  29. import QtQuick
  30. import QtQuick3D
  31. import QtQuick3D.Effects
  32. Effect {
  33. readonly property TextureInput downsample2: TextureInput {
  34. texture: Texture {}
  35. }
  36. readonly property TextureInput downsample4: TextureInput {
  37. texture: Texture {}
  38. }
  39. property real gamma: 1 // 0.1 - 4
  40. property real exposure: 0 // -9 - 9
  41. readonly property real exposureExp2: Math.pow(2, exposure)
  42. property real bloomThreshold: 1
  43. property real blurFalloff: 0 // 0 - 10
  44. readonly property real negativeBlurFalloffExp2: Math.pow(2, -blurFalloff)
  45. property real tonemappingLerp: 1 // 0 - 1
  46. property real channelThreshold: 1
  47. readonly property real poissonRotation: 0
  48. readonly property real poissonDistance: 4
  49. Shader {
  50. id: luminosityVert
  51. stage: Shader.Vertex
  52. shader: "qrc:/qtquick3deffects/shaders/luminosity.vert"
  53. }
  54. Shader {
  55. id: luminosityFrag
  56. stage: Shader.Fragment
  57. shader: "qrc:/qtquick3deffects/shaders/luminosity.frag"
  58. }
  59. Shader {
  60. id: blurVert
  61. stage: Shader.Vertex
  62. shader: "qrc:/qtquick3deffects/shaders/poissonblur.vert"
  63. }
  64. Shader {
  65. id: blurFrag
  66. stage: Shader.Fragment
  67. shader: "qrc:/qtquick3deffects/shaders/poissonblur.frag"
  68. }
  69. Shader {
  70. id: combiner
  71. stage: Shader.Fragment
  72. shader: "qrc:/qtquick3deffects/shaders/combiner.frag"
  73. }
  74. Buffer {
  75. id: luminosity_buffer2
  76. name: "luminosity_buffer2"
  77. format: Buffer.RGBA8
  78. textureFilterOperation: Buffer.Linear
  79. textureCoordOperation: Buffer.ClampToEdge
  80. bufferFlags: Buffer.None
  81. sizeMultiplier: 0.5
  82. }
  83. Buffer {
  84. id: downsample_buffer2
  85. name: "downsample_buffer2"
  86. format: Buffer.RGBA8
  87. textureFilterOperation: Buffer.Linear
  88. textureCoordOperation: Buffer.ClampToEdge
  89. bufferFlags: Buffer.None
  90. sizeMultiplier: 0.5
  91. }
  92. Buffer {
  93. id: downsample_buffer4
  94. name: "downsample_buffer4"
  95. format: Buffer.RGBA8
  96. textureFilterOperation: Buffer.Linear
  97. textureCoordOperation: Buffer.ClampToEdge
  98. bufferFlags: Buffer.None
  99. sizeMultiplier: 0.25
  100. }
  101. passes: [
  102. Pass {
  103. shaders: [ luminosityVert, luminosityFrag ]
  104. output: downsample_buffer2
  105. },
  106. Pass {
  107. shaders: [ luminosityVert, luminosityFrag ]
  108. commands: BufferInput {
  109. buffer: downsample_buffer2
  110. }
  111. output: luminosity_buffer2
  112. },
  113. Pass {
  114. shaders: [ blurVert, blurFrag ]
  115. commands: BufferInput {
  116. buffer: luminosity_buffer2
  117. }
  118. output: downsample_buffer2
  119. },
  120. Pass {
  121. shaders: [ blurVert, blurFrag ]
  122. commands: [
  123. SetUniformValue {
  124. target: "poissonRotation"
  125. value: 0.62831
  126. },
  127. BufferInput {
  128. buffer: luminosity_buffer2
  129. }
  130. ]
  131. output: downsample_buffer4
  132. },
  133. Pass {
  134. shaders: combiner
  135. commands: [
  136. BufferInput {
  137. sampler: "downsample2"
  138. buffer: downsample_buffer2
  139. },
  140. BufferInput {
  141. sampler: "downsample4"
  142. buffer: downsample_buffer4
  143. }
  144. ]
  145. }
  146. ]
  147. }