summaryrefslogtreecommitdiffstats
path: root/virtual-programs
diff options
context:
space:
mode:
authorOmar Rizwan <omar@omar.website>2023-09-18 20:40:17 +0000
committerOmar Rizwan <omar@omar.website>2023-09-18 20:40:17 +0000
commit8d96d1883fd2a476f2fa6aa0b7539166547aeaea (patch)
treec3d1fe3a6d2ed0f7f1d3736669c2048cfa587c67 /virtual-programs
parentWIP: Add per-pipeline vertex shader (diff)
downloadfolk-8d96d1883fd2a476f2fa6aa0b7539166547aeaea.tar.gz
folk-8d96d1883fd2a476f2fa6aa0b7539166547aeaea.zip
display: Add fullscreen vertex shaders to start
Diffstat (limited to 'virtual-programs')
-rw-r--r--virtual-programs/display.folk11
1 files changed, 8 insertions, 3 deletions
diff --git a/virtual-programs/display.folk b/virtual-programs/display.folk
index b9dcfe84..a1aa9583 100644
--- a/virtual-programs/display.folk
+++ b/virtual-programs/display.folk
@@ -109,8 +109,10 @@ On process {
}]
variable glyph [Gpu::pipeline {sampler2D atlas vec2 atlasSize
vec4 atlasGlyphBounds
- vec2 a vec2 b vec2 c vec2 d} \
- {invBilinear glyphMsd median} {
+ vec2 a vec2 b vec2 c vec2 d} {
+ vec2 vertices[4] = vec2[4](vec2(-1, -1), vec2(1, -1), vec2(-1, 1), vec2(1, 1));
+ return vec4(vertices[gl_VertexIndex], 0.0, 1.0);
+ } {invBilinear glyphMsd median} {
vec2 glyphUv = invBilinear(gl_FragCoord.xy, a, b, c, d);
if( max( abs(glyphUv.x-0.5), abs(glyphUv.y-0.5))>=0.5 ) {
return vec4(0, 0, 0, 0);
@@ -123,6 +125,9 @@ On process {
}]
variable line [Gpu::pipeline {vec2 from vec2 to float thickness} {
+ vec2 vertices[4] = vec2[4](vec2(-1, -1), vec2(1, -1), vec2(-1, 1), vec2(1, 1));
+ return vec4(vertices[gl_VertexIndex], 0.0, 1.0);
+ } {
float l = length(to - from);
vec2 d = (to - from) / l;
vec2 q = (gl_FragCoord.xy - (from + to)*0.5);
@@ -168,7 +173,7 @@ On process {
[list [+ $x $right] [- $y $bottom]] \
[list [+ $x $left] [- $y $bottom]]]
# stroke $quad 10 red
- Gpu::draw $glyph $quad $fontAtlas $fontAtlasSize \
+ Gpu::draw $glyph $fontAtlas $fontAtlasSize \
$atlasBounds {*}$quad
}
set x [+ $x [* $advance $em]]