90 lines
1.5 KiB
Plaintext
90 lines
1.5 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 quad_color;
|
|
|
|
in vec2 quad_position;
|
|
|
|
in vec2 quad_size;
|
|
|
|
flat in float quad_opacity;
|
|
|
|
flat in int quad_useTexture;
|
|
|
|
flat in int quad_textureIndex;
|
|
|
|
|
|
|
|
layout ( packed, binding = 0 ) uniform events
|
|
{
|
|
|
|
vec2 mouse;
|
|
|
|
vec2 window;
|
|
|
|
};
|
|
|
|
|
|
void main() {
|
|
|
|
|
|
vec2 grid = vec2( floor( vertex_textureCoordinates.x * 10.0 ), floor( vertex_textureCoordinates.y * 10.0 ) );
|
|
|
|
int index = int( grid.x + ( grid.y * 10.0 ) );
|
|
|
|
|
|
vec2 newCoordinates = vertex_textureCoordinates;
|
|
|
|
newCoordinates = vec2( mod( newCoordinates.x, 1) , mod( newCoordinates.y, 1) );
|
|
|
|
|
|
vec4 diffuseColor = vec4( 1.0 );
|
|
|
|
if( quad_useTexture == 1 ) {
|
|
|
|
diffuseColor = texture( samplerArray, vec3( newCoordinates, quad_textureIndex ) );
|
|
|
|
} else {
|
|
|
|
vec2 size = quad_size;
|
|
|
|
vec2 halfSize = size / 2.0;
|
|
|
|
vec2 fragCoord = vertex_textureCoordinates * size;
|
|
|
|
float radius = 100.;
|
|
|
|
float borderSmoothing = 2.0;
|
|
|
|
vec2 centerPosition = fragCoord - halfSize;
|
|
|
|
float a = length( abs( centerPosition ) + size + radius ) - radius;
|
|
|
|
//float b = max( a, length( halfSize / 2. ) );
|
|
|
|
//float c = length( a );
|
|
|
|
|
|
|
|
|
|
diffuseColor.rgb = quad_color * (1.0 - a);//( 1.0 - smoothstep( radius, radius + borderSmoothing, b ) );
|
|
|
|
}
|
|
|
|
diffuseColor.w *= quad_opacity;
|
|
|
|
frag_colour = diffuseColor;
|
|
|
|
} |