mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-13 04:10:13 +00:00
64bcdb713c
This introduces the rect object and adds a rect_distance() and rect_coverage() function. _distance() returns the signed distance tp the rectangle. _coverage() returns the coverage of a pixel centered at that position. Note that the pixel size is computed using dFdx/dFdy.
17 lines
327 B
GLSL
17 lines
327 B
GLSL
#ifndef _RECT_FRAG_
|
|
#define _RECT_FRAG_
|
|
|
|
#include "rect.glsl"
|
|
|
|
float
|
|
rect_coverage (Rect r, vec2 p)
|
|
{
|
|
vec2 dFdp = abs(fwidth (p));
|
|
Rect prect = Rect(vec4(p - 0.5 * dFdp, p + 0.5 * dFdp));
|
|
Rect coverect = rect_intersect (r, prect);
|
|
vec2 coverage = rect_size(coverect) / dFdp;
|
|
return coverage.x * coverage.y;
|
|
}
|
|
|
|
#endif
|