Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model: GPU Styling #9944

Open
ptrgags opened this issue Nov 29, 2021 · 0 comments
Open

Model: GPU Styling #9944

ptrgags opened this issue Nov 29, 2021 · 0 comments

Comments

@ptrgags
Copy link
Contributor

ptrgags commented Nov 29, 2021

Though CustomShaders is the new way to do GPU styling, we still are supporting the existing styling language. some parts of that must be handled on the GPU (e.g. per-point styling).

Some notes from @lilleyse excerpted from This branch describe when to use which type of styling:

Styles may be evaluated on the CPU or GPU depending on the style and the
types of properties involved. On the CPU styles are evaluated per-feature
and the color/show results are stored in a batch texture, which is later
applied on the GPU, either in the vertex shader or fragment shader.
For GPU styling the style is converted to a shader and executed in the
vertex shader or fragment shader directly. CPU styling is preferred.

In some cases a style may require both CPU styling and GPU styling, in which
case the style can't be applied and an error is thrown.

Situations where CPU styling is required:

  • Style uses language features not supported in GLSL like strings or regex
  • Style uses properties that are not GPU compatible like strings, variable-size arrays, or fixed sized arrays with more than 4 components
  • Style uses properties in JsonMetadataTable or BatchTableHierarchy
  • Style uses custom evaluate functions, see Cesium3DTileStyle#color

Situations where GPU styling is required:

  • Style uses per-point properties. Large point clouds are generally impractical to style on the CPU.
  • Style uses per-vertex properties. Per-vertex properties need to be interpolated before being styled.
  • Style uses feature texture properties
  • Style uses vertex attributes like position, color, etc
  • Style uses uniforms
  • Style references features in different feature tables
  • Point size style is used

Situations where the style must be applied in the fragment shader:

  • Primitive uses a feature ID texture
  • Style uses feature texture properties
  • Style uses per-vertex properties
  • Style uses interpolated vertex attributes
  • Style is evaluated on the CPU and vertex texture fetch is not supported

Situations where the style must be applied in the vertex shader:

  • Point size style is used

Since style variables aren't scoped there can be name collisions. They are
resolved in the following order of precedence:

  1. Input semantics (e.g. POSITION)
  2. Attributes (e.g. _TEMPERATURE)
  3. Uniforms
  4. Properties (for each item below, search by semantic first, then by property ID)
    a. Feature
    b. Tile
    c. Group
    d. Tileset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant