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