LittleJS 1.28.0

PostProcess

PostProcessPlugin

Post Process Plugin - Applies a full screen shader to the rendered output

  • Create it after any plugin that draws, since plugins render in the order they are made and this one shades what is on the canvas when its turn comes
  • It runs after gameRenderPost, so a HUD drawn there with WebGL is shaded (and bloomed) too; draw the HUD with useWebGL=false (the main canvas) or from a plugin created after this one

Constructor

new PostProcessPlugin(shaderCode, includeMainCanvas, feedbackTexture)postProcess.js:31

Create global post processing shader

shaderCode string optional

Shadertoy style mainImage code, or an effect alone like postProcessVignette(), which postProcessEffects joins; a pass-through when left out

includeMainCanvas boolean optional, default false

combine mainCanvas onto glCanvas

feedbackTexture boolean optional, default false

also pass the shader's own output from the previous frame as iChannel1, for trails and echoes; iChannel0 is still the frame just drawn

// create the post process plugin object
new PostProcessPlugin(shaderCode);

Members

Methods

Members

enabled : booleanpostProcess.js:55

Is the pass on? Off, the frame shows as the engine drew it, the shader is kept, and the feedback texture holds the last frame drawn with it on

feedbackTexture : WebGLTexture|undefinedpostProcess.js:77

The previous frame's output, iChannel1, when feedbackTexture is set

shader : WebGLProgram|undefinedpostProcess.js:71

Shader for post processing

shaderCode : stringpostProcess.js:51

The shadertoy style mainImage code it shades with, see setShaderCode

texture : WebGLTexture|undefinedpostProcess.js:74

Texture for post processing

values : Object<string, (number|Array<number>)>postProcess.js:65

The game's own values for the shader, a uniform each by its name, a number a float and a list of 2 to 4 numbers a vector, set every frame as they are; an effect setting can be one of these names, so it changes every frame without making the shader again, all but glow's size, which sets how many samples it takes; adding or removing a name makes the shader again, and the shader is first made at the first render, so values set right after the plugin are in it; a name is a GLSL name not starting with an underscore, which the effects keep for their own, nor i and a capital or gl_, and not c, uv or p, the names mainImage works on

vao : WebGLVertexArrayObject|undefinedpostProcess.js:80

Vertex array object

Methods

setShaderCode(shaderCode)postProcess.js:268

Shade with new code from the next frame on, to switch effects while the game runs; the shader is made again

shaderCode string optional

Shadertoy style mainImage code, postProcessEffects builds it, or an effect alone; none passes the frame through