MaterialPropertiesPane.qml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. // Copyright (C) 2021 The Qt Company Ltd.
  2. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
  3. import QtQuick
  4. import QtQuick.Controls
  5. import QtQuick.Layouts
  6. import QtQuick3D
  7. import QtQuick3D.MaterialEditor
  8. Pane {
  9. id: root
  10. required property MaterialAdapter targetMaterial
  11. ColumnLayout {
  12. RowLayout {
  13. Label {
  14. text: qsTr("Source Blend")
  15. Layout.fillWidth: true
  16. }
  17. ComboBox {
  18. id: sourceBlendComboBox
  19. textRole: "text"
  20. valueRole: "value"
  21. implicitContentWidthPolicy: ComboBox.WidestText
  22. onActivated: root.targetMaterial.sourceBlend = currentValue
  23. Component.onCompleted: currentIndex = indexOfValue(root.targetMaterial.sourceBlend)
  24. model: [
  25. { value: CustomMaterial.NoBlend, text: qsTr("No Blend") },
  26. { value: CustomMaterial.Zero, text: qsTr("Zero") },
  27. { value: CustomMaterial.One, text: qsTr("One") },
  28. { value: CustomMaterial.SrcColor, text: qsTr("Source Color") },
  29. { value: CustomMaterial.OneMinusSrcColor, text: qsTr("1 - Source Color") },
  30. { value: CustomMaterial.DstColor, text: qsTr("Destination Color") },
  31. { value: CustomMaterial.OneMinusDstColor, text: qsTr("1 - Destination Color") },
  32. { value: CustomMaterial.SrcAlpha, text: qsTr("Source Alpha") },
  33. { value: CustomMaterial.OneMinusSrcAlpha, text: qsTr("1 - Source Alpha") },
  34. { value: CustomMaterial.DstAlpha, text: qsTr("Destination Alpha") },
  35. { value: CustomMaterial.OneMinusDstAlpha, text: qsTr("1 - Destination Alpha") },
  36. { value: CustomMaterial.ConstantColor, text: qsTr("Constant Color") },
  37. { value: CustomMaterial.OneMinusConstantColor, text: qsTr("1 - Constant Color") },
  38. { value: CustomMaterial.ConstantAlpha, text: qsTr("Constant Alpha") },
  39. { value: CustomMaterial.OneMinusConstantAlpha, text: qsTr("1 - Constant Alpha") },
  40. { value: CustomMaterial.SrcAlphaSaturate, text: qsTr("Source Alpha Saturate") }
  41. ]
  42. }
  43. }
  44. RowLayout {
  45. Label {
  46. text: qsTr("Destination Blend")
  47. Layout.fillWidth: true
  48. }
  49. ComboBox {
  50. id: destinationBlendComboBox
  51. textRole: "text"
  52. valueRole: "value"
  53. implicitContentWidthPolicy: ComboBox.WidestText
  54. onActivated: root.targetMaterial.destinationBlend = currentValue
  55. Component.onCompleted: currentIndex = indexOfValue(root.targetMaterial.destinationBlend)
  56. model: [
  57. { value: CustomMaterial.NoBlend, text: qsTr("No Blend") },
  58. { value: CustomMaterial.Zero, text: qsTr("Zero") },
  59. { value: CustomMaterial.One, text: qsTr("One") },
  60. { value: CustomMaterial.SrcColor, text: qsTr("Source Color") },
  61. { value: CustomMaterial.OneMinusSrcColor, text: qsTr("1 - Source Color") },
  62. { value: CustomMaterial.DstColor, text: qsTr("Destination Color") },
  63. { value: CustomMaterial.OneMinusDstColor, text: qsTr("1 - Destination Color") },
  64. { value: CustomMaterial.SrcAlpha, text: qsTr("Source Alpha") },
  65. { value: CustomMaterial.OneMinusSrcAlpha, text: qsTr("1 - Source Alpha") },
  66. { value: CustomMaterial.DstAlpha, text: qsTr("Destination Alpha") },
  67. { value: CustomMaterial.OneMinusDstAlpha, text: qsTr("1 - Destination Alpha") },
  68. { value: CustomMaterial.ConstantColor, text: qsTr("Constant Color") },
  69. { value: CustomMaterial.OneMinusConstantColor, text: qsTr("1 - Constant Color") },
  70. { value: CustomMaterial.ConstantAlpha, text: qsTr("Constant Alpha") },
  71. { value: CustomMaterial.OneMinusConstantAlpha, text: qsTr("1 - Constant Alpha") },
  72. { value: CustomMaterial.SrcAlphaSaturate, text: qsTr("Source Alpha Saturate") }
  73. ]
  74. }
  75. }
  76. RowLayout {
  77. Label {
  78. text: qsTr("Cull Mode")
  79. Layout.fillWidth: true
  80. }
  81. ComboBox {
  82. id: cullModeComboBox
  83. textRole: "text"
  84. valueRole: "value"
  85. implicitContentWidthPolicy: ComboBox.WidestText
  86. onActivated: root.targetMaterial.cullMode = currentValue
  87. Component.onCompleted: currentIndex = indexOfValue(root.targetMaterial.cullMode)
  88. model: [
  89. { value: CustomMaterial.BackFaceCulling, text: qsTr("Back Face Culling") },
  90. { value: CustomMaterial.FrontFaceCulling, text: qsTr("Front Face Culling") },
  91. { value: CustomMaterial.NoCulling, text: qsTr("No Culling") }
  92. ]
  93. }
  94. }
  95. RowLayout {
  96. Label {
  97. text: qsTr("Depth Draw Mode")
  98. Layout.fillWidth: true
  99. }
  100. ComboBox {
  101. id: depthDrawModeComboBox
  102. textRole: "text"
  103. valueRole: "value"
  104. implicitContentWidthPolicy: ComboBox.WidestText
  105. onActivated: root.targetMaterial.depthDrawMode = currentValue
  106. Component.onCompleted: currentIndex = indexOfValue(root.targetMaterial.depthDrawMode)
  107. model: [
  108. { value: CustomMaterial.OpaqueOnlyDepthDraw, text: qsTr("Opaque Only") },
  109. { value: CustomMaterial.AlwaysDepthDraw, text: qsTr("Always") },
  110. { value: CustomMaterial.NeverDepthDraw, text: qsTr("Never") },
  111. { value: CustomMaterial.OpaquePrePassDepthDraw, text: qsTr("Opaque Pre-pass") }
  112. ]
  113. }
  114. }
  115. RowLayout {
  116. Label {
  117. text: qsTr("Shading Mode")
  118. Layout.fillWidth: true
  119. }
  120. ComboBox {
  121. id: shadingModeComboBox
  122. textRole: "text"
  123. valueRole: "value"
  124. implicitContentWidthPolicy: ComboBox.WidestText
  125. onActivated: root.targetMaterial.shadingMode = currentValue
  126. Component.onCompleted: currentIndex = indexOfValue(root.targetMaterial.shadingMode)
  127. model: [
  128. { value: CustomMaterial.Shaded, text: qsTr("Shaded") },
  129. { value: CustomMaterial.Unshaded, text: qsTr("Unshaded") }
  130. ]
  131. }
  132. }
  133. }
  134. }