Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

[core] fix rendering of dashed lines with round caps - #15947

Merged
kkaefer merged 1 commit into
masterfrom
fix-dashed-lines
Nov 22, 2019
Merged

kkaefer merged 1 commit into
masterfrom
fix-dashed-lines

Conversation

@kkaefer

@kkaefer kkaefer commented Nov 19, 2019 •

Copy link
Copy Markdown
Member

In #15862, we introduced individual textures for line dash patterns to eliminate atlas overflows. Unfortunately, this broke dashed lines that had round caps (dashed lines with straight caps still rendered correctly). Line pattern textures for round caps were now using 256×15 pixel textures.

The OpenGL ES 2.0 spec, section 3.8.2 states:

Calling a sampler from a fragment shader will return (R,G,B,A) = (0,0,0,1) if any of the following conditions are true:

  • […]
  • A two-dimensional sampler is called, the corresponding texture image is a non-power-of-two image […], and either the texture wrap mode is not CLAMP_TO_EDGE, or the minification filter is neither NEAREST nor LINEAR.
  • […]

This means that texture lookups won't work for NPOT textures unless they use GL_CLAMP_TO_EDGE. We're using GL_CLAMP_TO_EDGE for the vertical direction, but GL_REPEAT for the horizontal direction, which means that we need a power-of-two texture for our line dash patterns to work on OpenGL ES 2.0 conforming implementations. Fortunately, this just means changing the height from 15 to 16, and from 30 to 32, so we don't waste many pixels.

@kkaefer kkaefer added bug Core The cross-platform C++ core, aka mbgl labels Nov 19, 2019
In #15862, we introduced individual textures for line dash patterns to eliminate atlas overflows. Unfortunately, this broke dashed lines that had round caps (dashed lines with straight caps still rendered correctly). Line pattern textures for round caps were now using 256×15 pixel textures.

The OpenGL ES 2.0 spec, section 3.8.2 states:

    Calling a sampler from a fragment shader will return `(R,G,B,A) = (0,0,0,1)` if any of the following conditions are true:
    […]
    - A two-dimensional sampler is called, the corresponding texture image is a non-power-of-two image […], and either the texture wrap mode is not `CLAMP_TO_EDGE`, or the minification filter is neither `NEAREST` nor `LINEAR`.
    […]

This means that texture lookups won't work for NPOT textures unless they use `GL_CLAMP_TO_EDGE`. We're using `GL_CLAMP_TO_EDGE` for the vertical direction, but GL_REPEAT for the horizontal direction, which means that we need a power-of-two texture for our line dash patterns to work on OpenGL ES 2.0 conforming implementations. Fortunately, this just means changing the height from 15 to 16, and from 30 to 32, so we don't waste many pixels.

@alexshalamov alexshalamov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chloekraw chloekraw added regression needs changelog Indicates PR needs a changelog entry prior to merging. labels Nov 20, 2019
@tmpsantos

Copy link
Copy Markdown
Contributor

Merge?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Core The cross-platform C++ core, aka mbgl needs changelog Indicates PR needs a changelog entry prior to merging. regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants