get curves data in shader

This commit is contained in:
jrkb 2023-04-01 17:36:00 +02:00
parent 6661f7eb0f
commit d8a7bc7a98
6 changed files with 274 additions and 55 deletions

View file

@ -20,7 +20,7 @@ uniform vec4 color;
// Size of the window (in pixels) used for 1-dimensional anti-aliasing along each rays.
// 0 - no anti-aliasing
// 1 - normal anti-aliasing
// >=2 - exaggerated effect
// >=2 - exaggerated effect
uniform float antiAliasingWindowSize = 1.0;
// Enable a second ray along the y-axis to achieve 2-dimensional anti-aliasing.
@ -65,7 +65,7 @@ float computeCoverage(float inverseDiameter, vec2 p0, vec2 p1, vec2 p2) {
// Quadratic segment, solve abc formula to find roots.
float radicand = b.y*b.y - a.y*c.y;
if (radicand <= 0) return 0.0;
float s = sqrt(radicand);
t0 = (b.y - s) / a.y;
t1 = (b.y + s) / a.y;
@ -86,7 +86,7 @@ float computeCoverage(float inverseDiameter, vec2 p0, vec2 p1, vec2 p2) {
}
float alpha = 0;
if (t0 >= 0 && t0 < 1) {
float x = (a.x*t0 - 2.0*b.x)*t0 + c.x;
alpha += clamp(x * inverseDiameter + 0.5, 0, 1);
@ -123,6 +123,10 @@ void main() {
alpha += computeCoverage(inverseDiameter.y, rotate(p0), rotate(p1), rotate(p2));
}
}
vec4 debug = texelFetch(curves, int(uv.x * textureSize(curves)));
result = vec4(debug.rgb, 1.0);
return;
if (enableSuperSamplingAntiAliasing) {
alpha *= 0.5;