CesiumGS / CesiumGS/cesium

Model: GPU Styling

Open
#9,944 0 comments 0 reactions 0 assignees View on GitHub
category - model/gltf
Dominant language
JavaScript
Stars
15.8k
Forks
3.9k
Avg merge
4d 6h
Merged PRs (30d)
34

Description

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](https://github.com/CesiumGS/cesium/blob/4e1a92c817ee37af619983f631f6d7f7ce1ca9d9/Source/Scene/CustomShader.js#L926-L972) 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

Contributor guide

Open the contributing guide

Research direction

The issue does not identify a target file, test, or concrete behavior beyond the CustomShader.js excerpt. Start by reading Source/Scene/CustomShader.js at the linked section and tracing the existing CPU and GPU styling paths. A completion condition is not defined; the work first needs a scoped implementation target and verification criteria.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.