Debian Codegraph @

tests/manual/planets-qml/shaders/rhi/planetDShadow.vert

raw
1 // Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
2 // Copyright (C) 2017 The Qt Company Ltd.
3 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
4
5 #version 450 core
6
7 layout(location=0) in vec3 vertexPosition;
8 layout(location=1) in vec3 vertexNormal;
9 layout(location=2) in vec2 vertexTexCoord;
10
11 layout(location = 3) out vec4 positionInLightSpace;
12
13 layout(location = 0) out vec3 position;
14 layout(location = 1) out vec3 normal;
15 layout(location = 2) out vec2 texCoord;
16
17 layout(std140, binding = 1) uniform qt3d_command_uniforms {
18 mat4 modelMatrix;
19 mat4 inverseModelMatrix;
20 mat4 modelViewMatrix;
21 mat3 modelNormalMatrix;
22 mat4 inverseModelViewMatrix;
23 mat4 modelViewProjection;
24 mat4 inverseModelViewProjectionMatrix;
25 };
26
27 layout(std140, binding = 2) uniform extras_uniforms {
28 float texCoordScale;
29 vec3 ka; // Ambient reflectivity
30 vec3 ks; // Specular reflectivity
31 float shininess; // Specular shininess factor
32 float opacity; // Alpha channel
33 vec3 lightPosition;
34 vec3 lightIntensity;
35 mat4 lightViewProjection;
36 };
37
38 void main()
39 {
40 const mat4 shadowMatrix = mat4(0.5, 0.0, 0.0, 0.0,
41 0.0, 0.5, 0.0, 0.0,
42 0.0, 0.0, 0.5, 0.0,
43 0.5, 0.5, 0.5, 1.0);
44
45 positionInLightSpace = shadowMatrix * lightViewProjection * modelMatrix * vec4(vertexPosition, 1.0);
46
47 texCoord = vertexTexCoord * texCoordScale;
48 normal = normalize(modelNormalMatrix * vertexNormal);
49 position = vec3(modelViewMatrix * vec4(vertexPosition, 1.0));
50
51 gl_Position = modelViewProjection * vec4(vertexPosition, 1.0);
52 }