ScreenSpaceEffectSource Interface

The GLSL implementation of the effect produced by a ScreenSpaceEffectBuilder, to be integrated into a complete shader program. The effect shader code differs slightly from that of an ordinary shader:

  • Instead of main, it should implement effectMain.
    • It can include other functions, variables, etc outside of effectMain.
  • It should omit declarations of uniform and varying variables - these will be generated from those supplied to ScreenSpaceEffectBuilder.addUniform and ScreenSpaceEffectBuilder.addVarying. The program receives one pre-defined uniform sampler2D u_diffuse representing the viewport's rendered image. Because the RenderSystem uses either WebGL1 or WebGL2 based on the capabilities of the client, the effect shader should be written to compile with either; or, ScreenSpaceEffectBuilder.isWebGL2 should be tested. The RenderSystem takes care of adjusting the source code for some of these differences, e.g., varying (WebGL1) vs in and out (WebGL2); and TEXTURE, TEXTURE_CUBE, and TEXTURE_PROJ macros are provided to replace texture2D, textureCube, and texture2DProj with their WebGL2 equivalents when applicable.

Properties

Name Type Description
fragment string The GLSL implementation of the fragment shader.  
sampleSourcePixel undefined | string If the fragment shader shifts pixels from their original locations, then by default element locate will not work, because it expects the pixels produced by an element  
vertex string The GLSL implementation of the vertex shader.  

Defined in

Last Updated: 29 November, 2022