CesiumGS / CesiumGS/cesium

Shader Pipeline Roadmap

Open
#1,031 4 comments 0 reactions 1 assignee Claimed by @pjcozzi View on GitHub
category - graphics type - roadmap
Dominant language
JavaScript
Stars
15.8k
Forks
3.9k
Avg merge
4d 6h
Merged PRs (30d)
34

Description

**Current offline uses cases**
- Add default precision
- Add built-in constants, structs, and functions
- Add automatic uniforms

**Current runtime use cases**
- Concatenate sources for psuedo-polymorphism, e.g., `czm_getMaterial` (for [materials](https://github.com/AnalyticalGraphicsInc/cesium/wiki/Fabric)), `czm_computePosition` (for the [geometry pipeline](https://github.com/AnalyticalGraphicsInc/cesium/issues/766)), and `czm_getFilter` (for [post processing](https://github.com/AnalyticalGraphicsInc/cesium/wiki/Screen-Space-Rendering-Details)).
- Add `#define`s for uber-shaders.
- `main` renaming for picking via [`createPickFragmentShaderSource`](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Renderer/createPickFragmentShaderSource.js) for per-instance show in [Primitive.js](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Scene/Primitive.js).
- Duplicate uniforms for precision - #817

**Items**
- [ ] Pack uniforms for performance - #649
- [ ] GLSL minification. Similar to glTF [#36](https://github.com/KhronosGroup/glTF/issues/36).
- We can't minify quite as much as some of these tools, but I think we can come pretty close now with the compile-time-ish shader concatenation.
- [x] Write tech blog post.
- [ ] Handle precision correctly - #817
- In general, shader authors need to control precision; defaulting to `highp` for everything is suboptimal for mobile. See [Fast Mobile Shaders](http://aras-p.info/texts/files/FastMobileShaders_siggraph2011.pdf). Should be benchmark and optimize existing shaders?
- [ ] Compile/link shaders on workers when there is a WebGL extension. CC #797.
- [ ] Edit shaders in cache at runtime. See #1025
- [x] Route all shader usage through the shader cache. CC #640

**Ideas**
- [ ] Scriptable automatic uniforms, i.e., instead of hardcoding in [ShaderProgram.js](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Renderer/ShaderProgram.js).

**Done**
- [x] Automatically prepend `czm_` functions, types, and constants. Preserve useful line numbers with `#line`.
- Unfortunately, this should probably include automatic uniforms even though we expect them to get optimized out.
- Perhaps we can use the GLSL optimization for some of this.
- [x] Make `#define`-based uber-shaders easier to use, i.e., no explicit string concatenation.
- [x] ~~GLSL optimization. Similar to glTF [#34](https://github.com/KhronosGroup/glTF/issues/34).~~
- ~~How hard is it to integrate this and below into our build?~~
- ~~Do we notice the performance improvement on different hardware, including mobile?~~
- ~~Does this or minification (below) affect shader compile/link time?~~

**Reading**
- [Generating Shaders From HLSL Fragments](http://www.shawnhargreaves.com/hlsl_fragments/hlsl_fragments.html)
- [A high level shader construction syntax](http://blog.coherent-labs.com/2012/10/a-high-level-shader-construction-syntax.html) - Intro has a concise overview of techniques

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.