2022-06-08 12:47:24 +00:00
|
|
|
// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
|
2024-02-23 14:41:04 +00:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
2014-09-08 08:06:54 +00:00
|
|
|
|
2015-10-15 14:05:37 +00:00
|
|
|
import Qt3D.Core 2.0
|
2015-10-18 08:58:19 +00:00
|
|
|
import Qt3D.Render 2.0
|
2014-10-28 09:43:34 +00:00
|
|
|
|
2014-09-08 08:06:54 +00:00
|
|
|
Effect {
|
|
|
|
id : sceneMaterialEffect
|
|
|
|
techniques : [
|
|
|
|
// OpenGL 3.1
|
|
|
|
Technique {
|
2015-11-03 09:29:17 +00:00
|
|
|
graphicsApiFilter {api : GraphicsApiFilter.OpenGL; profile : GraphicsApiFilter.CoreProfile; minorVersion : 1; majorVersion : 3 }
|
2014-09-08 08:06:54 +00:00
|
|
|
renderPasses : RenderPass {
|
2016-03-03 11:57:38 +00:00
|
|
|
filterKeys : FilterKey { name : "pass"; value : "geometry" }
|
2014-09-08 08:06:54 +00:00
|
|
|
shaderProgram : ShaderProgram {
|
|
|
|
id : sceneShaderGL3
|
2014-09-20 14:52:08 +00:00
|
|
|
vertexShaderCode:
|
2014-10-02 09:59:25 +00:00
|
|
|
"#version 140
|
2014-09-08 08:06:54 +00:00
|
|
|
|
|
|
|
in vec4 vertexPosition;
|
|
|
|
in vec3 vertexNormal;
|
|
|
|
|
|
|
|
out vec4 color0;
|
|
|
|
out vec3 position0;
|
|
|
|
out vec3 normal0;
|
|
|
|
|
|
|
|
uniform mat4 mvp;
|
2017-08-02 16:02:40 +00:00
|
|
|
uniform mat4 modelMatrix;
|
|
|
|
uniform mat3 modelNormalMatrix;
|
2014-09-08 08:06:54 +00:00
|
|
|
uniform vec4 meshColor;
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
color0 = meshColor;
|
2017-08-02 16:02:40 +00:00
|
|
|
position0 = vec3(modelMatrix * vertexPosition);
|
|
|
|
normal0 = normalize(modelNormalMatrix * vertexNormal);
|
2014-09-08 08:06:54 +00:00
|
|
|
gl_Position = mvp * vertexPosition;
|
|
|
|
}
|
|
|
|
"
|
2014-09-20 14:52:08 +00:00
|
|
|
fragmentShaderCode:
|
2014-10-02 09:59:25 +00:00
|
|
|
"#version 140
|
2014-09-08 08:06:54 +00:00
|
|
|
|
|
|
|
in vec4 color0;
|
|
|
|
in vec3 position0;
|
|
|
|
in vec3 normal0;
|
|
|
|
|
|
|
|
out vec4 color;
|
2017-06-22 15:34:28 +00:00
|
|
|
out vec4 position;
|
|
|
|
out vec4 normal;
|
2014-09-08 08:06:54 +00:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
color = color0;
|
2017-06-22 15:34:28 +00:00
|
|
|
position = vec4(position0, 0.0);
|
|
|
|
normal = vec4(normal0, 0.0);
|
2014-09-08 08:06:54 +00:00
|
|
|
}
|
|
|
|
"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// OpenGL 2.0
|
|
|
|
Technique {
|
2015-11-03 09:29:17 +00:00
|
|
|
graphicsApiFilter {api : GraphicsApiFilter.OpenGL; profile : GraphicsApiFilter.CoreProfile; minorVersion : 0; majorVersion : 2 }
|
2014-09-08 08:06:54 +00:00
|
|
|
renderPasses : RenderPass {
|
2016-03-03 11:57:38 +00:00
|
|
|
filterKeys : FilterKey { name : "pass"; value : "geometry" }
|
2014-09-08 08:06:54 +00:00
|
|
|
shaderProgram : ShaderProgram {
|
|
|
|
id : sceneShaderGL2
|
2014-09-20 14:52:08 +00:00
|
|
|
vertexShaderCode:
|
2014-10-02 09:59:25 +00:00
|
|
|
"#version 110
|
2014-09-08 08:06:54 +00:00
|
|
|
|
|
|
|
attribute vec4 vertexPosition;
|
|
|
|
attribute vec3 vertexNormal;
|
|
|
|
|
|
|
|
varying vec4 color0;
|
|
|
|
varying vec3 position0;
|
|
|
|
varying vec3 normal0;
|
|
|
|
|
|
|
|
uniform mat4 mvp;
|
2017-08-02 16:02:40 +00:00
|
|
|
uniform mat4 modelMatrix;
|
|
|
|
uniform mat3 modelNormalMatrix;
|
2014-09-08 08:06:54 +00:00
|
|
|
uniform vec4 meshColor;
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
color0 = meshColor;
|
2017-08-02 16:02:40 +00:00
|
|
|
position0 = vec3(modelMatrix * vertexPosition);
|
|
|
|
normal0 = normalize(modelNormalMatrix * vertexNormal);
|
2014-09-08 08:06:54 +00:00
|
|
|
gl_Position = mvp * vertexPosition;
|
|
|
|
}
|
|
|
|
"
|
2014-09-20 14:52:08 +00:00
|
|
|
fragmentShaderCode:
|
2014-10-02 09:59:25 +00:00
|
|
|
"#version 110
|
2014-09-08 08:06:54 +00:00
|
|
|
|
|
|
|
varying vec4 color0;
|
|
|
|
varying vec3 position0;
|
|
|
|
varying vec3 normal0;
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
gl_FragData[0] = color0;
|
|
|
|
gl_FragData[1] = vec4(position0, 0);
|
|
|
|
gl_FragData[2] = vec4(normal0, 0);
|
|
|
|
}
|
|
|
|
"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|