2023-02-12 15:25:52 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
#include <string>
|
|
|
|
std::string shader_chunk_vert = R"("
|
|
|
|
#version 300 es
|
|
|
|
precision mediump float;
|
|
|
|
|
2023-03-06 00:33:43 -05:00
|
|
|
//layout (location = 0) in vec3 vertex;
|
|
|
|
//layout (location = 1) in vec3 texture_coord;
|
|
|
|
|
|
|
|
const vec2 UV_COORDS[4] = vec2[4](
|
|
|
|
vec2(0, 0),
|
|
|
|
vec2(1, 0),
|
|
|
|
vec2(0, 1),
|
|
|
|
vec2(1, 1)
|
|
|
|
);
|
|
|
|
|
|
|
|
layout (location = 0) in float data;
|
2023-03-04 23:24:36 -05:00
|
|
|
|
|
|
|
out vec2 uv;
|
2023-03-05 00:01:54 -05:00
|
|
|
out float index;
|
2023-02-12 15:25:52 -05:00
|
|
|
|
2023-02-13 16:30:01 -05:00
|
|
|
uniform mat4 translation;
|
|
|
|
|
2023-02-12 15:25:52 -05:00
|
|
|
layout (std140) uniform StandardMatrices
|
|
|
|
{
|
|
|
|
mat4 projection;
|
|
|
|
mat4 view;
|
|
|
|
// projection view matrix
|
|
|
|
mat4 pvm;
|
2023-02-15 00:49:27 -05:00
|
|
|
// orthographic projection matrix
|
|
|
|
mat4 orthographic;
|
2023-02-12 15:25:52 -05:00
|
|
|
};
|
|
|
|
|
2023-03-04 23:24:36 -05:00
|
|
|
void main() {
|
2023-03-06 00:33:43 -05:00
|
|
|
const int texture_index_loc = 32 - 8;
|
|
|
|
const int uv_index_loc = texture_index_loc - 2;
|
|
|
|
const int x_coord_loc = uv_index_loc - 6;
|
|
|
|
const int y_coord_loc = x_coord_loc - 6;
|
|
|
|
const int z_coord_loc = y_coord_loc - 6;
|
|
|
|
|
|
|
|
int idata = floatBitsToInt(data);
|
|
|
|
|
|
|
|
int texture_index = idata >> texture_index_loc;
|
|
|
|
int uv_index = ((idata >> uv_index_loc) & 0x3);
|
|
|
|
float x_coord = float((idata >> x_coord_loc) & 0x3F);
|
|
|
|
float y_coord = float((idata >> y_coord_loc) & 0x3F);
|
|
|
|
float z_coord = float((idata >> z_coord_loc) & 0x3F);
|
|
|
|
|
|
|
|
index = float(texture_index);
|
|
|
|
gl_Position = projection * view * translation * vec4(-0.5 + x_coord, -0.5 + y_coord, -0.5 + z_coord, 1.0);
|
|
|
|
uv = UV_COORDS[uv_index].xy;
|
2023-02-12 15:25:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
")";
|
|
|
|
#endif
|