#version 150 uniform int curveType; uniform float flatWidth; in vec2 vertTexCoord; in vec4 vertColor; out vec4 fragColor; #define CURVE_TYPE_LINEAR 0 #define CURVE_TYPE_CONVEX 1 #define CURVE_TYPE_CONCAVE 2 #define CURVE_TYPE_SMOOTH 3 #define M_PI 3.14159265358979323846 float sampleFunction(float position) { if (position < 0.0) { return 0.0; } if (position > 1.0) { return 1.0; } if (curveType == CURVE_TYPE_LINEAR) { return position; } if (curveType == CURVE_TYPE_CONVEX) { return sin(position * M_PI * 0.5); } if (curveType == CURVE_TYPE_CONCAVE) { return 1.0 - cos(position * M_PI * 0.5); } if (curveType == CURVE_TYPE_SMOOTH) { return 0.5 * sin(M_PI * (position - 0.5)) + 0.5; } return 0.0; } void main() { float distance = sqrt(vertTexCoord.x * vertTexCoord.x + vertTexCoord.y * vertTexCoord.y); distance = (distance - flatWidth) / (1.0 - flatWidth); float curveSample = sampleFunction(1.0 - distance); fragColor = vertColor * curveSample; }