101 lines
1.6 KiB
Plaintext
101 lines
1.6 KiB
Plaintext
|
|
#version 460
|
||
|
|
|
||
|
|
out vec4 frag_colour;
|
||
|
|
|
||
|
|
uniform vec3 diffuse;
|
||
|
|
|
||
|
|
uniform vec2 position;
|
||
|
|
|
||
|
|
uniform sampler2DArray samplerArray;
|
||
|
|
|
||
|
|
|
||
|
|
in vec2 vertex_textureCoordinates;
|
||
|
|
|
||
|
|
in float vertex_meshIndex;
|
||
|
|
|
||
|
|
in vec3 vertex_color;
|
||
|
|
|
||
|
|
|
||
|
|
layout( std430, binding = 0 ) buffer inputBlock {
|
||
|
|
|
||
|
|
int characters[ 100 ];
|
||
|
|
|
||
|
|
};
|
||
|
|
|
||
|
|
layout( std430, binding = 1 ) buffer fontData {
|
||
|
|
|
||
|
|
vec2 fontOffsets[ 240 ];
|
||
|
|
|
||
|
|
vec2 fontSizes[ 240 ];
|
||
|
|
|
||
|
|
};
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
struct quadDetails{
|
||
|
|
|
||
|
|
int textLength;
|
||
|
|
|
||
|
|
float text[];
|
||
|
|
|
||
|
|
};
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
float roundedFrame( vec2 pos, vec2 size, float radius, float thickness )
|
||
|
|
{
|
||
|
|
float d = length(max(abs(vertex_textureCoordinates - pos),size) - size) - radius;
|
||
|
|
return smoothstep(0.55, 0.45, abs(d / thickness) * 5.0);
|
||
|
|
}
|
||
|
|
|
||
|
|
void main() {
|
||
|
|
|
||
|
|
int charactersPerLine = 10;
|
||
|
|
|
||
|
|
vec2 grid = vec2( floor( vertex_textureCoordinates.x * charactersPerLine ), floor( vertex_textureCoordinates.y * charactersPerLine ) );
|
||
|
|
|
||
|
|
|
||
|
|
int index = int( grid.x + ( grid.y * charactersPerLine ) );
|
||
|
|
|
||
|
|
vec2 newCoordinates = vertex_textureCoordinates * charactersPerLine;
|
||
|
|
|
||
|
|
|
||
|
|
newCoordinates = vec2( mod( newCoordinates.x, 1) , mod( newCoordinates.y, 1) );
|
||
|
|
|
||
|
|
|
||
|
|
vec2 fontSize = fontSizes[ index ];
|
||
|
|
|
||
|
|
vec2 offset = fontOffsets[ index ];
|
||
|
|
|
||
|
|
int characterIndex = characters[ index ];
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
vec2 correction = fontSize;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
newCoordinates.xy += (offset / fontSize) / 128;
|
||
|
|
|
||
|
|
//newCoordinates.xy *= fontSize / 128;
|
||
|
|
|
||
|
|
|
||
|
|
if( characterIndex > 0 ) {
|
||
|
|
|
||
|
|
vec3 coordinate = vec3( newCoordinates, characterIndex );
|
||
|
|
|
||
|
|
float inverse = ( ( texture( samplerArray, coordinate ).r * -1. ) + 1. );
|
||
|
|
|
||
|
|
frag_colour = vec4( 1.0, 1.0, 1.0, inverse );
|
||
|
|
|
||
|
|
} else {
|
||
|
|
|
||
|
|
frag_colour = vec4( 1.0 );
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|