You've already forked flecs_tests
Testing without sokol_gp.h
This commit is contained in:
60
src/shaders/base.glsl
Normal file
60
src/shaders/base.glsl
Normal 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
|
||||
Reference in New Issue
Block a user