Testing without sokol_gp.h

This commit is contained in:
Clément Pons
2025-03-27 18:03:02 +01:00
parent 7798c762ae
commit ceaa78ea1a
5 changed files with 578 additions and 51 deletions

60
src/shaders/base.glsl Normal file
View File

@@ -0,0 +1,60 @@
@block common
struct cell
{
vec2 pos;
};
vec3 color(int i)
{
float r = ((i >> 0) & 0xff)/255.0f;
float g = ((i >> 8) & 0xff)/255.0f;
float b = ((i >> 16) & 0xff)/255.0f;
return vec3(r, g, b);
}
@end
@vs vs
@include_block common
layout(binding = 0) uniform vs_uniform {
float radius;
};
layout(location = 0) in vec2 in_quad;
layout(location = 1) out vec2 _quad;
layout(location = 2) out vec2 _centroid;
layout(location = 3) flat out vec3 _color;
layout(binding = 0) readonly buffer vs_ssbo
{
cell cells[];
};
void main()
{
_centroid = cells[gl_InstanceIndex].pos;
_color = color(gl_InstanceIndex);
_quad = radius * in_quad + _centroid;
gl_Position = vec4(_quad, 0.0, 1.0);
}
@end
@fs fs
@include_block common
layout(binding = 1) uniform fs_uniform {
float radius;
};
layout(location = 1) in vec2 _quad;
layout(location = 2) in vec2 _centroid;
layout(location = 3) flat in vec3 _color;
layout(location = 4) out vec4 frag_color;
void main()
{
gl_FragDepth = length(_quad - _centroid);
if(gl_FragDepth > radius) discard;
frag_color = vec4(_color, 1.0);
}
@end
@program base vs fs