Debian Codegraph @

tests/manual/shadow-map-qml/shaders/rhi/ads.vert

raw
1 // Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4 #version 450
5
6 layout(location = 0) in vec3 vertexPosition;
7 layout(location = 1) in vec3 vertexNormal;
8
9 layout(location = 0) out vec4 positionInLightSpace;
10 layout(location = 1) out vec3 position;
11 layout(location = 2) out vec3 normal;
12
13
14 layout(std140, binding = 0) uniform qt3d_render_view_uniforms {
15 mat4 viewMatrix;
16 mat4 projectionMatrix;
17 mat4 viewProjectionMatrix;
18 mat4 inverseViewMatrix;
19 mat4 inverseProjectionMatrix;
20 mat4 inverseViewProjectionMatrix;
21 mat4 viewportMatrix;
22 mat4 inverseViewportMatrix;
23 vec4 textureTransformMatrix;
24 vec3 eyePosition;
25 float aspectRatio;
26 float gamma;
27 float exposure;
28 float time;
29 };
30
31 layout(std140, binding = 1) uniform qt3d_command_uniforms {
32 mat4 modelMatrix;
33 mat4 inverseModelMatrix;
34 mat4 modelView;
35 mat3 modelNormalMatrix;
36 mat4 inverseModelViewMatrix;
37 mat4 mvp;
38 mat4 inverseModelViewProjectionMatrix;
39 mat3 modelViewNormal;
40 };
41
42 layout(std140, binding = 2) uniform qt3d_custom_uniforms {
43 mat4 lightViewProjection;
44 vec3 lightPosition;
45 vec3 lightIntensity;
46
47 vec3 ka; // Ambient reflectivity
48 vec3 kd; // Diffuse reflectivity
49 vec3 ks; // Specular reflectivity
50 float shininess; // Specular shininess factor
51 };
52
53 void main()
54 {
55 // positionInLightSpace = lightViewProjection * modelMatrix * vec4(vertexPosition, 1.0);
56 const mat4 shadowMatrix = mat4(0.5, 0.0, 0.0, 0.0,
57 0.0, 0.5, 0.0, 0.0,
58 0.0, 0.0, 0.5, 0.0,
59 0.5, 0.5, 0.5, 1.0);
60
61 positionInLightSpace = shadowMatrix * lightViewProjection * modelMatrix * vec4(vertexPosition, 1.0);
62
63 normal = normalize(modelViewNormal * vertexNormal);
64 position = vec3(modelView * vec4(vertexPosition, 1.0));
65
66 gl_Position = mvp * vec4(vertexPosition, 1.0);
67 }