1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import Qt3D.Core 2.0
import Qt3D.Render 2.0
Effect {
id : sceneMaterialEffect
techniques : [
// OpenGL 3.1
Technique {
graphicsApiFilter {api : GraphicsApiFilter.OpenGL; profile : GraphicsApiFilter.CoreProfile; minorVersion : 1; majorVersion : 3 }
renderPasses : RenderPass {
filterKeys : FilterKey { name : "pass"; value : "geometry" }
shaderProgram : ShaderProgram {
id : sceneShaderGL3
vertexShaderCode:
"#version 140
in vec4 vertexPosition;
in vec3 vertexNormal;
out vec4 color0;
out vec3 position0;
out vec3 normal0;
uniform mat4 mvp;
uniform mat4 modelMatrix;
uniform mat3 modelNormalMatrix;
uniform vec4 meshColor;
void main()
{
color0 = meshColor;
position0 = vec3(modelMatrix * vertexPosition);
normal0 = normalize(modelNormalMatrix * vertexNormal);
gl_Position = mvp * vertexPosition;
}
"
fragmentShaderCode:
"#version 140
in vec4 color0;
in vec3 position0;
in vec3 normal0;
out vec4 color;
out vec4 position;
out vec4 normal;
void main()
{
color = color0;
position = vec4(position0, 0.0);
normal = vec4(normal0, 0.0);
}
"
}
}
},
// OpenGL 2.0
Technique {
graphicsApiFilter {api : GraphicsApiFilter.OpenGL; profile : GraphicsApiFilter.CoreProfile; minorVersion : 0; majorVersion : 2 }
renderPasses : RenderPass {
filterKeys : FilterKey { name : "pass"; value : "geometry" }
shaderProgram : ShaderProgram {
id : sceneShaderGL2
vertexShaderCode:
"#version 110
attribute vec4 vertexPosition;
attribute vec3 vertexNormal;
varying vec4 color0;
varying vec3 position0;
varying vec3 normal0;
uniform mat4 mvp;
uniform mat4 modelMatrix;
uniform mat3 modelNormalMatrix;
uniform vec4 meshColor;
void main()
{
color0 = meshColor;
position0 = vec3(modelMatrix * vertexPosition);
normal0 = normalize(modelNormalMatrix * vertexNormal);
gl_Position = mvp * vertexPosition;
}
"
fragmentShaderCode:
"#version 110
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);
}
"
}
}
}
]
}
|