GLSL Details - vistone/cesium_Language_cn GitHub Wiki
Design and implementation ideas for our GLSL shader system.
Features
- Auto
#include
functions, types, etc. starting withagi_
. Most of these are in .glsl files, but some are prepended at runtime, but donโt have to be. Search forgetBuiltinConstants
inShaderProgram.js
. - In addition to auto includes, I suppose we need manual includes for things like
SensorVolume.glsl
, which are not global across Cesium, but useful for a few primitives. - Report useful line numbers from compile/link warning/errors.
- Work well with uber-shaders determined at runtime. Search for
getShaderProgram
inCentralBody.js
. - Work well with our material system, which dynamically creates shaders โ think GLSL compile-time polymorphism. Each shader implementations a virtual function so-to-speak, e.g., see
VerticalStripeMaterial
and its shader,VerticalStripeMaterial.glsl
. Anyone who can use a material calls this "virtual function." For a simple example, search forgetShaderProgram
inPolygon.js
. A single primitive may have multiple materials for different surfaces (rendered in the same pass), so I rename uniforms like I am an out-of-order processor renaming registers. Search forcombine
inComplexConicSensorVolume.js
. - Control over precision used in the fragment shader. This is particularly important for mobile performance. See
getShaderPrecisionFormat
. - Consider GLSL minification.
- Performance idea: async shader compile/link. Let's time
linkProgram
first because I think that is actually synchronous on most drivers.