DilationShader
Image dilation shader
Specialization of ShaderProgram performing dilation operation on a grayscale image. Dilation is a morphological operations adding pixels to the boundaries of objects in an image. The value of the output pixel is maximum value of all pixels in the neighbourhood which radius is a modifiable parameter.
Extends
Constructors
new DilationShader()
new DilationShader(
gl
,size
,radius
):DilationShader
Constructor
Parameters
• gl: WebGL2RenderingContext
WebGL context where program is instantiated
• size: Size
Size of processed (input & output) image
• radius: number
= 1
Dilation operation radius
Returns
Overrides
Properties
fragShader
protected
fragShader:null
|WebGLShader
Fragment shader
Inherited from
frameBuffer
protected
frameBuffer:null
|WebGLFramebuffer
Frame buffer (output)
Inherited from
gl
protected
gl:WebGL2RenderingContext
WebGL context where program is instantiated
Inherited from
inputs
protected
inputs:string
[]
Shader texture inputs (names of sampler uniforms)
Inherited from
outputTexture?
protected
optional
outputTexture:ImageTexture
Output image texture
Inherited from
shaderProgram
protected
shaderProgram:null
|WebGLProgram
Shader program
Inherited from
size
protected
size:Size
Size of processed (input & output) image
Inherited from
uniforms
protected
uniforms:object
Shader uniforms as name-type map object
Index Signature
[key
: string
]: UniformType
Inherited from
uniformsLoc
protected
uniformsLoc:object
Unifrom locations
Index Signature
[key
: string
]: WebGLUniformLocation
| null
Inherited from
vertAttrs
protected
vertAttrs:null
|WebGLVertexArrayObject
Vertex attributes
Inherited from
vertBuffer
protected
vertBuffer:null
|WebGLBuffer
Vertex buffer
Inherited from
vertShader
protected
vertShader:null
|WebGLShader
Vertex shader
Inherited from
Methods
compile()
protected
compile(fragSrc
,vertSrc
):void
Compile shader program
Allocates and sets up all resources required for shader program, compiles and links shaders.
Parameters
• fragSrc: string
Fragment shader source (copy shader by default)
• vertSrc: string
Vertex shader source (copy shader by default)
Returns
void
Inherited from
dispose()
dispose():
void
Dispose program object
Releases resources and instances allocated by program. Program object cannot be used after calling dispose().
Returns
void
Inherited from
output()
output():
null
|WebGLTexture
Output image texture
Returns
null
| WebGLTexture
Image texture
Inherited from
prepare()
protected
prepare(gl
,inputs
,uniforms
?):void
Prepare execution of the shader
Set input textures and provided uniform values, bind program and setup vertex attribute arrays.
Parameters
• gl: WebGL2RenderingContext
Context of shader program
• inputs: (null
| WebGLTexture
)[]
Input image textures
• uniforms?
Values of shader uniforms
Returns
void
Inherited from
process()
process(
inputs
,uniforms
?):null
|WebGLTexture
Process input image
Applies shader program to input image, output is written to image texture using framebuffer.
Parameters
• inputs: (null
| WebGLTexture
)[]
Input image textures
• uniforms?
Values of shader uniforms
Returns
null
| WebGLTexture
Output image texture
Inherited from
program()
program():
null
|WebGLProgram
Shader program instance
Returns
null
| WebGLProgram
Instance of shader program
Inherited from
render()
render(
inputs
,uniforms
?):void
Process input image and render the result
Applies shader program to input image, output is renderer to canvas providing WebGL context.
Parameters
• inputs: (null
| WebGLTexture
)[]
Input image textures
• uniforms?
Values of shader uniforms
Returns
void
Inherited from
resize()
resize(
size
):void
Resize
Resizes output image texture and updates uniforms.
Parameters
• size: Size
Main/output shader size
Returns
void
Inherited from
restore()
protected
restore(gl
,state
):void
Restore context state
Restores state of WebGL context to recorded checkpoint. This allows to safely share context with other engines.
Parameters
• gl: WebGL2RenderingContext
Context to restore state
• state
Previously recorded state
• state.activeTexture: number
• state.arrayBuffer: null
| WebGLBuffer
• state.colorMask: boolean
[]
• state.cullFace: boolean
• state.framebuffer: null
| WebGLFramebuffer
• state.program: null
| WebGLProgram
• state.scissor: Int32Array
• state.textures: (null
| WebGLTexture
)[]
• state.vertexArray: null
| WebGLVertexArrayObject
• state.viewport: Int32Array
Returns
void
Inherited from
save()
protected
save(gl
):object
Save context state
Saves state of WebGL including program in use, bound array buffers, framebuffer, and textures. Returned state can be restored later to safely share context with other frameworks or renderers.
Parameters
• gl: WebGL2RenderingContext
Context which state will be recorded
Returns
object
Current state of WebGL context
activeTexture
activeTexture:
number
arrayBuffer
arrayBuffer:
null
|WebGLBuffer
colorMask
colorMask:
boolean
[]
cullFace
cullFace:
boolean
framebuffer
framebuffer:
null
|WebGLFramebuffer
program
program:
null
|WebGLProgram
scissor
scissor:
Int32Array
textures
textures: (
null
|WebGLTexture
)[]
vertexArray
vertexArray:
null
|WebGLVertexArrayObject
viewport
viewport:
Int32Array
Inherited from
setUniform()
setUniform(
uniform
,val
):void
Set uniform value
Parameters
• uniform: string
Uniform name
• val: number
[]
Uniform value
Returns
void
Inherited from
setUniformUnsafe()
protected
setUniformUnsafe(uniform
,val
):void
Set uniform value unsafely
Parameters
• uniform: string
Uniform name
• val: number
[]
Uniform value
Returns
void