Debian Codegraph @

third_party/spirv-cross/reference/opt/shaders/vert/ground.vert

raw
1 #version 310 es
2 #ifdef GL_ARB_shader_draw_parameters
3 #extension GL_ARB_shader_draw_parameters : enable
4 #endif
5
6 struct PatchData
7 {
8 vec4 Position;
9 vec4 LODs;
10 };
11
12 layout(binding = 0, std140) uniform PerPatch
13 {
14 PatchData Patches[256];
15 } _53;
16
17 layout(binding = 2, std140) uniform GlobalGround
18 {
19 vec4 GroundScale;
20 vec4 GroundPosition;
21 vec4 InvGroundSize_PatchScale;
22 } _156;
23
24 layout(binding = 0, std140) uniform GlobalVSData
25 {
26 vec4 g_ViewProj_Row0;
27 vec4 g_ViewProj_Row1;
28 vec4 g_ViewProj_Row2;
29 vec4 g_ViewProj_Row3;
30 vec4 g_CamPos;
31 vec4 g_CamRight;
32 vec4 g_CamUp;
33 vec4 g_CamFront;
34 vec4 g_SunDir;
35 vec4 g_SunColor;
36 vec4 g_TimeParams;
37 vec4 g_ResolutionParams;
38 vec4 g_CamAxisRight;
39 vec4 g_FogColor_Distance;
40 vec4 g_ShadowVP_Row0;
41 vec4 g_ShadowVP_Row1;
42 vec4 g_ShadowVP_Row2;
43 vec4 g_ShadowVP_Row3;
44 } _236;
45
46 layout(binding = 1) uniform mediump sampler2D TexLOD;
47 layout(binding = 0) uniform mediump sampler2D TexHeightmap;
48
49 layout(location = 1) in vec4 LODWeights;
50 #ifdef GL_ARB_shader_draw_parameters
51 #define SPIRV_Cross_BaseInstance gl_BaseInstanceARB
52 #else
53 uniform int SPIRV_Cross_BaseInstance;
54 #endif
55 layout(location = 0) in vec2 Position;
56 layout(location = 1) out vec3 EyeVec;
57 layout(location = 0) out vec2 TexCoord;
58
59 void main()
60 {
61 float _301 = all(equal(LODWeights, vec4(0.0))) ? _53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.w : dot(LODWeights, _53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].LODs);
62 float _303 = floor(_301);
63 uint _308 = uint(_303);
64 uvec2 _310 = uvec2(Position);
65 uvec2 _317 = (uvec2(1u) << uvec2(_308, _308 + 1u)) - uvec2(1u);
66 uint _384;
67 if (_310.x < 32u)
68 {
69 _384 = _317.x;
70 }
71 else
72 {
73 _384 = 0u;
74 }
75 uint _385;
76 if (_310.y < 32u)
77 {
78 _385 = _317.y;
79 }
80 else
81 {
82 _385 = 0u;
83 }
84 vec4 _345 = vec4((_310 + uvec2(_384, _385)).xyxy & (~_317).xxyy);
85 vec2 _173 = ((_53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.xz * _156.InvGroundSize_PatchScale.zw) + mix(_345.xy, _345.zw, vec2(_301 - _303))) * _156.InvGroundSize_PatchScale.xy;
86 mediump float _362 = textureLod(TexLOD, _173, 0.0).x * 7.96875;
87 float _364 = floor(_362);
88 vec2 _185 = _156.InvGroundSize_PatchScale.xy * exp2(_364);
89 vec3 _230 = (vec3(_173.x, mix(textureLod(TexHeightmap, _173 + (_185 * 0.5), _364).x, textureLod(TexHeightmap, _173 + (_185 * 1.0), _364 + 1.0).x, _362 - _364), _173.y) * _156.GroundScale.xyz) + _156.GroundPosition.xyz;
90 EyeVec = _230 - _236.g_CamPos.xyz;
91 TexCoord = _173 + (_156.InvGroundSize_PatchScale.xy * 0.5);
92 gl_Position = (((_236.g_ViewProj_Row0 * _230.x) + (_236.g_ViewProj_Row1 * _230.y)) + (_236.g_ViewProj_Row2 * _230.z)) + _236.g_ViewProj_Row3;
93 }
94