SDF label pixel ratio inconsistency
- Dominant language
- JavaScript
- Stars
- 15.7k
- Forks
- 3.9k
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 34
Description
Discussion started here: https://github.com/AnalyticalGraphicsInc/cesium/pull/8351#issuecomment-550308173
The SDF label looks different at 1.0 vs 2.0 pixel ratio:

But with a `czm_pixelRatio` "fix" in `BillboardCollectionFS.glsl`, they look the same:

However, this removes the crispness on normal labels:
1.0 PR:
2.0 PR
2.0 PR with `pixelRatio` "fix"

I'm not sure which of these approaches to use. The underlying problem is shader derivatives. The smoothing is based off the `fwidth` of the texture's distance value and the sample offset is based of the `dFdx` and `dFdy` of the texture coordinates. For `pixelRatio` 2.0 these values are effectively half of `pixelRatio` 1.0, resulting in the cripser image. Might require a deeper dive into SDF labels at some point.
Contributor guide
Research direction
Start in BillboardCollectionFS.glsl and review the SDF label shader's fwidth, dFdx, and dFdy handling across pixel ratios. Compare the reported normal and SDF label results at 1.0 and 2.0 pixel ratios. Done means the labels remain visually consistent without losing the crispness of normal labels.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100