Refactor book and add more about font rendering

This commit is contained in:
Maximilian Ammann 2022-04-07 15:01:54 +02:00
parent b728369237
commit 98c4f0fb5c
18 changed files with 133 additions and 60 deletions

View File

@ -2,19 +2,26 @@
[Introduction](./introduction.md)
[Supported Platforms](./supported-platforms.md)
[Building](./building.md)
## Developer Resources
- [Developer Resources](./developer-resources.md)
- [Architecture](./architecture.md)
- [Caching](./caching.md)
- [Stencil Masking](./stencil-masking.md)
- [Developer Log](./developer-log.md)
## Appendix
- [Appendix](./appendix.md)
- [Further Technical Reading](./further_technical_reading.md)
[Developer Log](./developer-log.md)
- [User Guide](./user-guide/index.md)
- [Development Guide](./development-guide/index.md)
- [Building](./development-guide/building.md)
- [Debugging](./development-guide/debugging.md)
- [Development Documents](./development-documents/index.md)
- [Architecture](./development-documents/architecture.md)
- [Design](./development-documents/design.md)
- [Caching](./development-documents/caching.md)
- [Stencil Masking](./development-documents/stencil-masking.md)
- [Font Rendering](./development-documents/font-rendering.md)
- [Appendix](./appendix/index.md)
- [Link Collection](./appendix/link-collection.md)

View File

@ -1,5 +1,42 @@
# Appendix
## Goals
### Next Major Goals
* ~~Improve buffer_pool eviction rules~~
* ~~Use MPI: https://doc.rust-lang.org/book/ch16-02-message-passing.html~~
* Input-handling via events and functional pipelines
* ~~Show old tiles until new tile is ready / Show mixed tiles, based on availability~~
* Use a simple style definition
* type: background/fill/line
* minzoom/maxzoom
* source
* source-layer
* paint (fill-color)
* Map feeling:
* Wrap world around in x direction
* Limit panning in y direction
* Nicer default map style
### Intermediate Goals
* Support multiple projections? PoC such that we are sure the renderer is acceptable
### Future Goals
* Very simple text rendering
* Cache tessellation results
* We have three "caches": downloaded tiles, tessellated tiles, gpu tiles
* Handle missing tiles
* Support different tile raster addressing
## Future Ideas
* Use [rust-gpu](https://github.com/EmbarkStudios/rust-gpu) as shading language
* Focus on accessibility of maps: https://www.w3.org/WAI/RD/wiki/Accessible_Maps
* Display in AR: https://developer.apple.com/documentation/arkit/displaying_an_ar_experience_with_metal
* Use tracing framework: [tracing](https://docs.rs/tracing/0.1.31/tracing)
## Challenges:
* Accuracy of floating point numbers is very bad for big world view
@ -12,15 +49,3 @@ Streets can have unusual shaped like shown [here](https://www.google.de/maps/@48
does not offer such data and therefore just renders an ordinary street contour like
shown [here](https://www.openstreetmap.org/query?lat=48.13533&lon=11.57143).
Because the data is probably not available this is a very hard challenge.
## Future Ideas
* Use [rust-gpu](https://github.com/EmbarkStudios/rust-gpu) as shading language
* Focus on accessibility of maps: https://www.w3.org/WAI/RD/wiki/Accessible_Maps
* Display in AR: https://developer.apple.com/documentation/arkit/displaying_an_ar_experience_with_metal
* Use tracing framework: [tracing](https://docs.rs/tracing/0.1.31/tracing)
## Debugging Rendering
For WebGL there is SpectorJS is enabled by default right now. For debugging on a desktop environment you can use
[RenderDoc](https://renderdoc.org/).

View File

@ -109,12 +109,11 @@ Projects:
## Specifications
* [TileJSON](https://github.com/mapbox/tilejson-spec)
*
## Render Graphs
* https://github.com/metal-by-example/simple-instancing/blob/master/MetalSimpleInstancing/Renderer.swift
* https://github.com/troughton/Substrate
* https://de.slideshare.net/DICEStudio/framegraph-extensible-rendering-architecture-in-frostbite
* http://themaister.net/blog/2017/08/15/render-graphs-and-vulkan-a-deep-dive/

View File

@ -1,29 +0,0 @@
# Developer Resources
## Next Major Goals
* Improve buffer_pool eviction rules
* Use MPI: https://doc.rust-lang.org/book/ch16-02-message-passing.html
* Input-handling via events and functional pipelines
* Show old tiles until new tile is ready / Show mixed tiles, based on availability
* Use a simple style definition
* type: background/fill/line
* minzoom/maxzoom
* source
* source-layer
* paint (fill-color)
* Map feeling:
* Wrap world around in x direction
* Limit panning in y direction
* Nicer default map style
## Intermediate Goals
* Support multiple projections? PoC such that we are sure the renderer is acceptable
## Future Goals
* Very simple text rendering
* Cache tessellation results
* We have three "caches": downloaded tiles, tessellated tiles, gpu tiles
* Handle missing tiles
* Support different tile raster addressing

View File

@ -1,7 +1,6 @@
# Architecture
## GPU Architecture
## Rendering Architecture
The big picture of wgpu is as follows:

View File

@ -6,7 +6,7 @@ the format of the network requests. The mapr library is not introducing a separa
Instead, caching functionality of HTTP client libraries of the web platform are used. This has the advantage that we can
honor HTTP headers which configure caching. This is very important for fetched tiles, as they can have an expiry date.
* On the web we are using service workers to cache network requests.
* On the web the browser is automatically caching raw tiles.
* On Linux, MacOs, iOS and Android we are
utilizing [reqwest-middleware-cache](https://crates.io/crates/reqwest-middleware-cache/), which writes raw network
requests to disk.

View File

@ -0,0 +1,3 @@
# Design
![](./figures/domain-model.drawio.svg)

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 31 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 425 KiB

After

Width:  |  Height:  |  Size: 425 KiB

View File

@ -0,0 +1,49 @@
# Font Rendering
There exists no universally perfect solution to font rendering. Depending on the runtime environment a method needs to
be chosen. [This StackOverflow post](https://stackoverflow.com/a/5278471) outlines some state-of-the-art methods. Some
more approaches are described [here](https://aras-p.info/blog/2017/02/15/Font-Rendering-is-Getting-Interesting/).
From my perspective the following approaches could work potentially:
1. Tessellate Fonts
2. SDF Font Rendering
3. GPU Text Rendering directly from Bezier Curves
4. Draw text using a Web Canvas and load them to GPU
There is a thesis which summarizes some methods [here](https://lup.lub.lu.se/luur/download?func=downloadFile&recordOId=9024910&fileOId=9024911).
A link collection about font related projects can be viewed [here](../appendix/link-collection.md#font-rendering).
## Approaches
### Tessellate Fonts
There is [ttf2mesh](https://github.com/fetisov/ttf2mesh) which generates meshes. I was already able to generate about 1k
glyphs with ~40FPS.
### SDF Font Rendering
There is a blogpost by Mapbox [here](https://blog.mapbox.com/drawing-text-with-signed-distance-fields-in-mapbox-gl-b0933af6f817).
Some more implementation documents are available [here](https://github.com/mapbox/mapbox-gl-native/wiki/Text-Rendering).
A good foundation for SDF fonts was created by Chlumsky with [msdfgen](https://github.com/Chlumsky/msdfgen).
### GPU Text Rendering from Bezier Curves
The solutions exist:
* [By Will Dobbie](https://wdobbie.com/post/gpu-text-rendering-with-vector-textures/) with an
implementation [here](https://github.com/azsn/gllabel)
* [Slug Library](http://sluglibrary.com/) which is patented and probably therefore not usable
[Here](https://jcgt.org/published/0006/02/02/paper.pdf) is the whitepaper of the Slug library. There is also
a [poster](http://sluglibrary.com/slug_algorithm.pdf) about it. There also exists
an [open implementation](https://github.com/mightycow/Sluggish).
### Draw text using a Web Canvas
This approach has the downside that we can not dynamically scale rendered fonts according to the current zoom level.
## Other Approaches
* [16x AA font rendering using coverage masks](https://superluminal.eu/16x-aa-font-rendering-using-coverage-masks-part-iii/)

View File

@ -0,0 +1 @@
# Development Documents

View File

@ -0,0 +1,13 @@
# Debugging
## Frame Profiling
## CPU Profiling
## GPU Profiling
* For WebGL there is SpectorJS is enabled by default right now. For debugging on a desktop environment you can use
[RenderDoc](https://renderdoc.org/).

View File

@ -0,0 +1 @@
# Development Guide

View File

@ -1 +1,2 @@
# Introduction