| 1 |
// Copyright (C) 2015 Paul Lemire |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
|
| 4 |
import Qt3D.Core 2.0 |
| 5 |
import Qt3D.Render 2.0 |
| 6 |
|
| 7 |
Material { |
| 8 |
id:root |
| 9 |
property color ambient: Qt.rgba( 0.05, 0.05, 0.05, 1.0 ) |
| 10 |
property color diffuse: Qt.rgba( 0.7, 0.7, 0.7, 1.0 ) |
| 11 |
property color specular: Qt.rgba( 0.95, 0.95, 0.95, 1.0 ) |
| 12 |
property real shininess: 150.0 |
| 13 |
property real alpha: 0.5 |
| 14 |
|
| 15 |
|
| 16 |
ShaderProgram { |
| 17 |
id: gl3PhongAlphaShader |
| 18 |
vertexShaderCode: loadSource("qrc:/default.vert") |
| 19 |
fragmentShaderCode: loadSource("qrc:/phongalpha.frag") |
| 20 |
} |
| 21 |
|
| 22 |
effect: Effect { |
| 23 |
|
| 24 |
parameters: [ |
| 25 |
Parameter { name: "alpha"; value: root.alpha }, |
| 26 |
Parameter { name: "ka"; value: Qt.vector3d(root.ambient.r, root.ambient.g, root.ambient.b) }, |
| 27 |
Parameter { name: "kd"; value: Qt.vector3d(root.diffuse.r, root.diffuse.g, root.diffuse.b) }, |
| 28 |
Parameter { name: "ks"; value: Qt.vector3d(root.specular.r, root.specular.g, root.specular.b) }, |
| 29 |
Parameter { name: "shininess"; value: root.shininess }, |
| 30 |
Parameter { name: "lightPosition"; value: Qt.vector4d(1.0, 1.0, 0.0, 1.0) }, |
| 31 |
Parameter { name: "lightIntensity"; value: Qt.vector3d(1.0, 1.0, 1.0) } |
| 32 |
] |
| 33 |
|
| 34 |
techniques: [ |
| 35 |
// GL 3 Technique |
| 36 |
Technique { |
| 37 |
graphicsApiFilter { |
| 38 |
api: GraphicsApiFilter.OpenGL |
| 39 |
profile: GraphicsApiFilter.CoreProfile |
| 40 |
majorVersion: 3 |
| 41 |
minorVersion: 1 |
| 42 |
} |
| 43 |
renderPasses: RenderPass { |
| 44 |
shaderProgram: gl3PhongAlphaShader |
| 45 |
renderStates: [ |
| 46 |
NoDepthMask { }, |
| 47 |
BlendEquationArguments { |
| 48 |
sourceRgb: BlendEquationArguments.SourceAlpha |
| 49 |
destinationRgb: BlendEquationArguments.OneMinusSourceAlpha |
| 50 |
}, |
| 51 |
BlendEquation {blendFunction: BlendEquation.Add} |
| 52 |
] |
| 53 |
filterKeys: FilterKey { name: "pass"; value: "material" } |
| 54 |
} |
| 55 |
} |
| 56 |
] |
| 57 |
} |
| 58 |
} |
| 59 |
|