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 implementeffectMain
.- It can include other functions, variables, etc outside of
effectMain
.
- It can include other functions, variables, etc outside of
- 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) vsin
andout
(WebGL2); andTEXTURE
,TEXTURE_CUBE
, andTEXTURE_PROJ
macros are provided to replacetexture2D
,textureCube
, andtexture2DProj
with their WebGL2 equivalents when applicable.
extensions
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: 30 November, 2023