ShaderSource

new SuperMap3D.ShaderSource(options)

An object containing various inputs that will be combined to form a final GLSL shader string.
Name Type Description
options Object optional Object with the following properties:
Name Type Default Description
sources Array.<String> optional An array of strings to combine containing GLSL code for the shader.
defines Array.<String> optional An array of strings containing GLSL identifiers to #define.
pickColorQualifier String optional The GLSL qualifier, uniform or varying, for the input czm_pickColor. When defined, a pick fragment shader is generated.
includeBuiltIns Boolean true optional If true, referenced built-in functions will be included with the combined shader. Set to false if this shader will become a source in another shader, to avoid duplicating functions.
Throws:
  • DeveloperError : options.pickColorQualifier must be 'uniform' or 'varying'.
Example:
// 1. Prepend #defines to a shader
var source = new SuperMap3D.ShaderSource({
  defines : ['WHITE'],
  sources : ['void main() { \n#ifdef WHITE\n gl_FragColor = vec4(1.0); \n#else\n gl_FragColor = vec4(0.0); \n#endif\n }']
});

// 2. Modify a fragment shader for picking
var source = new SuperMap3D.ShaderSource({
  sources : ['void main() { gl_FragColor = vec4(1.0); }'],
  pickColorQualifier : 'uniform'
});

Methods

createCombinedFragmentShader()String

Create a single string containing the full, combined fragment shader with all dependencies and defines.
Returns:
The combined shader string.

createCombinedVertexShader()String

Create a single string containing the full, combined vertex shader with all dependencies and defines.
Returns:
The combined shader string.