Debian Codegraph @

shaders/src/depth_main.vs

raw
1 // The sole purpose of this no-op function is to improve parity between the depth vertex shader
2 // and color vertex shader, thus working around a variance issue seen with NVIDIA drivers.
3 void materialVertex(inout MaterialVertexInputs m) { }
4
5 // NOTE: This shader is only used when the user's material does not have custom vertex code.
6 // There is no need to check anything related to material inputs in this file.
7 void main() {
8
9 // World position is used to compute gl_Position, except for vertices already in the device domain.
10 // Regardless of vertex domain, if VSM is turned on, then we need to compute world position to pass
11 // to the fragment shader.
12 #if !defined(VERTEX_DOMAIN_DEVICE) || defined(HAS_VSM)
13 // Run initMaterialVertex to compute material.worldPosition.
14 MaterialVertexInputs material;
15 initMaterialVertex(material);
16 materialVertex(material);
17 #endif
18
19 #if defined(VERTEX_DOMAIN_DEVICE)
20 gl_Position = getPosition();
21 #else
22 gl_Position = getClipFromWorldMatrix() * getWorldPosition(material);
23 #endif
24
25 #if defined(HAS_VSM)
26 vertex_worldPosition = material.worldPosition.xyz;
27 #endif
28
29 #if defined(TARGET_VULKAN_ENVIRONMENT)
30 // In Vulkan, clip space is Y-down. In OpenGL and Metal, clip space is Y-up.
31 gl_Position.y = -gl_Position.y;
32 #endif
33
34 gl_Position.z = dot(gl_Position.zw, frameUniforms.clipControl.xy);
35 }