.
This commit is contained in:
parent
507d635433
commit
1c13514a4d
45 changed files with 2615 additions and 2014 deletions
67
data/batcher.glsl
Normal file
67
data/batcher.glsl
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
@ctype vec2 vec2
|
||||
@ctype vec4 vec4
|
||||
|
||||
@vs vs
|
||||
layout(binding=0) uniform render_data {
|
||||
vec2 one_over_window_size;
|
||||
float zoom;
|
||||
};
|
||||
|
||||
in vec4 quad;
|
||||
in vec4 tex_quad;
|
||||
in vec4 colour;
|
||||
|
||||
out vec2 uv;
|
||||
out vec4 fs_colour;
|
||||
|
||||
const int indices[6] = {
|
||||
0, 1, 2, 2, 3, 0,
|
||||
};
|
||||
|
||||
const vec3 positions[4] = {
|
||||
vec3(0, 0, 0),
|
||||
vec3(0, 1, 0),
|
||||
vec3(1, 1, 0),
|
||||
vec3(1, 0, 0),
|
||||
};
|
||||
|
||||
const vec2 uvs[4] = {
|
||||
vec2(0.0f, 0.0f),
|
||||
vec2(0.0f, 1.0f),
|
||||
vec2(1.0f, 1.0f),
|
||||
vec2(1.0f, 0.0f),
|
||||
};
|
||||
|
||||
void main() {
|
||||
int vtx = indices[gl_VertexIndex];
|
||||
vec3 pos = positions[vtx];
|
||||
uv = uvs[vtx];
|
||||
|
||||
pos.xy = ((pos.xy * quad.zw) + quad.xy) * zoom;
|
||||
pos.xy = (pos.xy * one_over_window_size) * 2.0 - 1.0;
|
||||
pos.y = -pos.y;
|
||||
|
||||
uv *= tex_quad.zw;
|
||||
uv += tex_quad.xy;
|
||||
|
||||
gl_Position = vec4(pos, 1);
|
||||
fs_colour = colour;
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs
|
||||
layout(binding=0) uniform texture2D tex;
|
||||
layout(binding=0) uniform sampler smp;
|
||||
in vec2 uv;
|
||||
in vec4 fs_colour;
|
||||
|
||||
out vec4 frag_colour;
|
||||
|
||||
void main() {
|
||||
vec4 c = texture(sampler2D(tex, smp), uv) * fs_colour;
|
||||
if (c.a < 1) discard;
|
||||
frag_colour = c;
|
||||
}
|
||||
@end
|
||||
|
||||
@program batcher vs fs
|
||||
Loading…
Add table
Add a link
Reference in a new issue