-
Notifications
You must be signed in to change notification settings - Fork 37
Distance Fields
A gridded structure, where each cell represents the shortest distance to a cell with some other property. Example (Designing with Distance Fields - S. Frisken): The distance field can be signed, to distinguish between the inside and outside of an object.
Using distance fields allows us to represent binary texture information with better accuracy, while using less dense grid for the texture. Essentially, we trade color information for positional accuracy. Example (Improved Alpha-Tested Magnification for Vector Textures and Special Effects - Chris Green, Valve)
All painting operations in Pepr3d are limited to N=4 user-defined colors. Compared to traditional approach, using distance fields requires lower texture resolution, saves memory and improves accuracy and speed of operations.
To store information for each of the N colors, we will require log₂(N) distance field textures total. (Colors are mutually exclusive, textures represent a binary value)
While painging the model we can either use either 2D or 3D texture to store the distance field. Both have their advantages and disadvantages:
- Lower memory consumption, faster operations
- Allows painting on the surface directly, with no depth limitation
- Requires unwrapping the mesh, while preserving correct triangle sizes
- 2D distance field texture would not be continuous - this could cause issues with texture filtering
- Texture lookup from a DF could cause "leaks" at triangle edges, even inside connected surfaces (unless we overdraw every time).
- More physically plausible painting. Ultra thin surfaces will be overdrawn through, but this behavior is to be expected while printing anyway.
- Does not require mesh unwrapping
- Easier to set resolution to correctly represent printing accuracy
- Higher memory consumption, operations slower by a constant factor
For our purposes, we only require the distance field data for the painted shape and a narrow shell around it, big enough to allow texture interpolation to work. Therefore we can avoid calculating the distance field outside this region.
** TODO ** Adaptively sampled distance fields
At export time, all triangles will need to be sampled for color at multiple points. Triangles can be divided into smaller ones as required, until we can export color accurately.
❤️ Pepr3D 2018-2019 · Home