Skip to content

steffenhaug/plox

Repository files navigation

graphics project for tdt4230

gpu-accelerated plotting.

(plox = plot + oxidize or some shit)

(and by plotting i mean falling head first into the text rendering rabbit hole)

(plese send help)

demos

https://www.youtube.com/watch?v=4fCdzTGNJhs

https://www.youtube.com/watch?v=f_acrKbyFL4

inspiration, background

problem: implicit geometry is difficult in the gpu pipeline.

Uses a variant of Evan Wallaces color flipping method but replaces the color accumulation techniques for winding number calculation and anti-aliasing by drawing with XOR color logic into a multisample α-texture.

Disadvangage: This method generates a fuck ton of vertices. Storing the curves in pixel-coordinates would speed up vertex processing, so that's a possible optimization.

tentative progression plan:

  1. ✅font loading (utilize a libraty hopefully) and obtain bezier curves
  2. ✅single-character software rasterizer (write a png or something)
    • figure out AA here
  3. ✅single-character hardware rasterizer
  4. ✅application of transformations to single character (translation and scaling)
  5. ✅ (kinda) typesetting of "latex"
  6. typesetting of non-character bezier-curve based things (axes, tick marks, etc)
  7. typeseting geometric primitives
    • ✅ circles
    • ✅ circle arcs
    • ✅ lines
    • ✅ linear splines
  8. ✅tesselating parametric curves
  9. window size independence / positioning relative to center etc.
  10. tesselation with compute shader

immediate to-do list:

  • profiling, tracing and logging
  • ECS into library?
  • custom shader API

future work

  • restructure rasterization of typeset expressions to mask the whole expression in one go and then rasterize
    • saves a lot of shader switches
  • latex parser or some shit
  • run Lua/Fennel in a separate thread with an event loop proxy
  • better gl abstraction or use vulkan
  • replace the arc mess (crossbeam atomic cells maybe)
  • parallel tesselation of curves (compute shader?)

simplifying assumptions:

  • use latex font (include in repo, ttf only, hardcoded path, cant go wrong) legal to redistribute

resources

curves in general + backround math

https://www.youtube.com/watch?v=aVwxzDHniEw&t=1282s freya bezier curves https://www.youtube.com/watch?v=N-KXStupwsc MATHOLOGER CUBIC

https://news.ycombinator.com/item?id=30901537

https://blog.mecheye.net/2019/05/why-is-2d-graphics-is-harder-than-3d-graphics/

FONT FORGE FONT RELATED MATH https://fontforge.org/docs/techref/pfaeditmath.html

FONT RENDERING PIPELINE https://mrandri19.github.io/2019/07/24/modern-text-rendering-linux-overview.html

https://pomax.github.io/bezierinfo/

FontForge to inspect curve data

curve preprocessing: https://www.sirver.net/blog/2011/08/23/degree-reduction-of-bezier-curves/

algorithm for tesselating bezier curves https://github.com/alexheretic/ab-glyph/blob/master/rasterizer/src/raster.rs

nice lines. https://jcgt.org/published/0002/02/08/paper.pdf https://developer.nvidia.com/gpugems/gpugems2/part-iii-high-quality-rendering/chapter-22-fast-prefiltered-lines

https://crates.io/crates/hyphenation

opengl in general

https://www.glprogramming.com/red/chapter10.html

maybe this can simplify anti aliasing https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/fwidth.xhtml

MSAA texture https://stackoverflow.com/questions/42878216/opengl-how-to-draw-to-a-multisample-framebuffer-and-then-use-the-result-as-a-n

Specifically Off-screen AA https://learnopengl.com/Advanced-OpenGL/Anti-Aliasing

read about Blitting, might be possible to not invoke the shader pipeline to copy rasterized texture to the screen i think what i really want is a multisampled renderbuffer and not a texture, since im literally just copying

wallaces method

http://www.glprogramming.com/red/chapter14.html#name13 backround on stencil buffer flippign method https://medium.com/@evanwallace/easy-scalable-text-rendering-on-the-gpu-c3f4d782c5ac - winding nuymber / bezier curves https://www.microsoft.com/en-us/research/wp-content/uploads/2005/01/p1000-loop.pdf https://news.ycombinator.com/item?id=11440599

font stuff

https://simoncozens.github.io/fonts-and-layout/opentype.html

https://people.eecs.berkeley.edu/~fateman/temp/neuform.pdf

MATH symbols unicode table https://unicode-search.net/unicode-namesearch.pl?term=MATHEMATICAL

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published