Use altitude: f32 and index: u32 instead of respectively position: vec3 and tex_coords: vec2

It reduces GPU memory usage from 20-21MiB to 16-17MiB.
This commit is contained in:
2022-10-17 01:38:18 +02:00
parent e6e30712b0
commit 02e28b2bc8
2 changed files with 48 additions and 19 deletions
+25 -4
View File
@@ -38,17 +38,38 @@ fn main() {
uniform mat4 persp_matrix;
uniform mat4 view_matrix;
in vec3 position;
in vec3 normal;
in vec2 tex_coords;
in uint index;
in float altitude;
out vec3 v_normal;
out vec2 v_tex_coords;
void main() {
v_normal = normal;
v_tex_coords = tex_coords;
gl_Position = persp_matrix * view_matrix * vec4(position * 0.005, 1.0);
uint index_mod = index % 6u;
uint index_div = index / 6u;
uint z = index_div / 250u;
uint x = index_div % 250u;
if(index_mod == 0u)
v_tex_coords = vec2(0, 0);
else if(index_mod == 1u || index_mod == 4u)
{
v_tex_coords = vec2(0, 1);
x++;
}
else if(index_mod == 2u || index_mod == 3u)
{
v_tex_coords = vec2(1, 0);
z++;
}
else //if(index_mod == 5u)
{
v_tex_coords = vec2(1, 1);
x++;
z++;
}
gl_Position = persp_matrix * view_matrix * vec4(vec3(x, altitude, z) * 0.005, 1.0);
}
",