Debian Codegraph @

src/extras/shaders/rhi/default_pos_norm_tex_tan.vert

raw
1 // Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only 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 layout(location = 2) in vec4 vertexTangent;
9 layout(location = 3) in vec2 vertexTexCoord;
10
11 layout(location = 0) out vec3 worldPosition;
12 layout(location = 1) out vec3 worldNormal;
13 layout(location = 2) out vec4 worldTangent;
14 layout(location = 3) out vec2 texCoord;
15
16 layout(std140, binding = 0) uniform qt3d_render_view_uniforms {
17 mat4 viewMatrix;
18 mat4 projectionMatrix;
19 mat4 uncorrectedProjectionMatrix;
20 mat4 clipCorrectionMatrix;
21 mat4 viewProjectionMatrix;
22 mat4 inverseViewMatrix;
23 mat4 inverseProjectionMatrix;
24 mat4 inverseViewProjectionMatrix;
25 mat4 viewportMatrix;
26 mat4 inverseViewportMatrix;
27 vec4 textureTransformMatrix;
28 vec3 eyePosition;
29 float aspectRatio;
30 float gamma;
31 float exposure;
32 float time;
33 };
34
35 layout(std140, binding = 1) uniform qt3d_command_uniforms {
36 mat4 modelMatrix;
37 mat4 inverseModelMatrix;
38 mat4 modelViewMatrix;
39 mat3 modelNormalMatrix;
40 mat4 inverseModelViewMatrix;
41 mat4 modelViewProjection;
42 mat4 inverseModelViewProjectionMatrix;
43 };
44
45 layout(std140, binding = 2) uniform qt3d_extras_uniforms {
46 float texCoordScale;
47 };
48
49 void main()
50 {
51 // Pass through scaled texture coordinates
52 texCoord = vertexTexCoord * texCoordScale;
53
54 // Transform position, normal, and tangent to world space
55 worldPosition = vec3(modelMatrix * vec4(vertexPosition, 1.0));
56 worldNormal = normalize(modelNormalMatrix * vertexNormal);
57 vec3 wt = normalize(vec3(modelMatrix * vec4(vertexTangent.xyz, 0.0)));
58 worldTangent = vec4(wt, vertexTangent.w);
59
60 // Calculate vertex position in clip coordinates
61 gl_Position = modelViewProjection * vec4(vertexPosition, 1.0);
62 }