SimpleMaterial.qml Example File
simplecustommaterial/SimpleMaterial.qml
import Qt3D.Core 2.0
import Qt3D.Render 2.0
Material {
id: root
property color maincolor: Qt.rgba(0.0, 0.0, 0.0, 1.0)
parameters: [
Parameter {
name: "maincolor"
value: Qt.vector3d(root.maincolor.r, root.maincolor.g, root.maincolor.b)
}
]
effect: Effect {
property string vertex: "qrc:/shaders/gl3/simpleColor.vert"
property string fragment: "qrc:/shaders/gl3/simpleColor.frag"
property string vertexES: "qrc:/shaders/es2/simpleColor.vert"
property string fragmentES: "qrc:/shaders/es2/simpleColor.frag"
FilterKey {
id: forward
name: "renderingStyle"
value: "forward"
}
ShaderProgram {
id: gl3Shader
vertexShaderCode: loadSource(parent.vertex)
fragmentShaderCode: loadSource(parent.fragment)
}
ShaderProgram {
id: es2Shader
vertexShaderCode: loadSource(parent.vertexES)
fragmentShaderCode: loadSource(parent.fragmentES)
}
techniques: [
Technique {
filterKeys: [forward]
graphicsApiFilter {
api: GraphicsApiFilter.OpenGL
profile: GraphicsApiFilter.CoreProfile
majorVersion: 3
minorVersion: 1
}
renderPasses: RenderPass {
shaderProgram: gl3Shader
}
},
Technique {
filterKeys: [forward]
graphicsApiFilter {
api: GraphicsApiFilter.OpenGL
profile: GraphicsApiFilter.NoProfile
majorVersion: 2
minorVersion: 0
}
renderPasses: RenderPass {
shaderProgram: es2Shader
}
},
Technique {
filterKeys: [forward]
graphicsApiFilter {
api: GraphicsApiFilter.OpenGLES
profile: GraphicsApiFilter.CoreProfile
majorVersion: 2
minorVersion: 0
}
renderPasses: RenderPass {
shaderProgram: es2Shader
}
}
]
}
}