diff options
| author | Omar Rizwan <omar@omar.website> | 2023-09-18 22:49:36 +0000 |
|---|---|---|
| committer | Omar Rizwan <omar@omar.website> | 2023-09-18 22:49:36 +0000 |
| commit | 2cf8c2e68424d3deec758a417a490b4d13e6327f (patch) | |
| tree | 989e1fd26eb7e24bc1644742be92ccd486bf2f16 /virtual-programs | |
| parent | Gpu: Quads work (diff) | |
| download | folk-2cf8c2e68424d3deec758a417a490b4d13e6327f.tar.gz folk-2cf8c2e68424d3deec758a417a490b4d13e6327f.zip | |
display: WIP: Move to clipped drawing using vertex shaders
Letters/lines are clipped a bit wrong rn.
Diffstat (limited to 'virtual-programs')
| -rw-r--r-- | virtual-programs/display.folk | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/virtual-programs/display.folk b/virtual-programs/display.folk index a1aa9583..201c348e 100644 --- a/virtual-programs/display.folk +++ b/virtual-programs/display.folk @@ -110,8 +110,9 @@ On process { variable glyph [Gpu::pipeline {sampler2D atlas vec2 atlasSize vec4 atlasGlyphBounds 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); + vec2 vertices[4] = vec2[4](a, b, c, d); + vec2 v = (2.0*vertices[gl_VertexIndex] - _resolution)/_resolution; + return vec4(v, 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 ) { @@ -125,8 +126,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); + vec2 vertices[4] = vec2[4](from - thickness, vec2(from.x - thickness, to.y + thickness), vec2(to.x + thickness, from.y - thickness), to + thickness); + vec2 v = (2.0*vertices[gl_VertexIndex] - _resolution)/_resolution; + return vec4(v, 0.0, 1.0); } { float l = length(to - from); vec2 d = (to - from) / l; |
