VideoMergePlugin
Video merge plugin
@geenee/armature!ShaderPlugin merges input video stream with the background texture. Merge is done by linear interpolation between images and interpolation weight (alpha) is a tunable input parameter that can be changed on runtime for smooth transition between streams. Background texture is allocated by the plugin and has the same size as the input stream, it can be accessed and updated on runtime, this, for example, allows to replace input video stream with a background video.
Extends
Section titled “Extends”ShaderPlugin
<any
>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new VideoMergePlugin(
alpha
,mirror
):VideoMergePlugin
Constructor
Parameters
Section titled “Parameters”number
= 0.5
Interpolation factor
mirror
Section titled “mirror”boolean
= false
Mirror background
Returns
Section titled “Returns”VideoMergePlugin
Overrides
Section titled “Overrides”Properties
Section titled “Properties”
protected
alpha:number
=0.5
Interpolation factor
bgTexture?
Section titled “bgTexture?”
protected
optional
bgTexture:ImageTexture
Background texture
fragSrc?
Section titled “fragSrc?”
protected
optional
fragSrc:string
Code of fragment shader (copy shader by default)
Inherited from
Section titled “Inherited from”inputs?
Section titled “inputs?”
protected
optional
inputs:string
[]
Shader texture inputs (names of sampler uniforms)
Inherited from
Section titled “Inherited from”loaded
Section titled “loaded”loaded:
boolean
Loaded state
Inherited from
Section titled “Inherited from”mirror
Section titled “mirror”
protected
mirror:boolean
=false
Mirror background
ordinal
Section titled “ordinal”ordinal:
number
Ordinal number
Inherited from
Section titled “Inherited from”renderer?
Section titled “renderer?”
protected
optional
renderer:Renderer
<any
>
Renderer loaded the plugin
Inherited from
Section titled “Inherited from”shader?
Section titled “shader?”
protected
optional
shader:ShaderProgram
Rendering shader
Inherited from
Section titled “Inherited from”shaderCtx?
Section titled “shaderCtx?”
protected
optional
shaderCtx:WebGL2RenderingContext
Rendering context
Inherited from
Section titled “Inherited from”
protected
size:Size
Image size
Inherited from
Section titled “Inherited from”uniforms?
Section titled “uniforms?”
protected
optional
uniforms:object
Shader uniforms as name-type map object
Index Signature
Section titled “Index Signature”[key
: string
]: UniformType
Inherited from
Section titled “Inherited from”vertSrc?
Section titled “vertSrc?”
protected
optional
vertSrc:string
Vertex shader source (copy shader by default)
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”background()
Section titled “background()”background():
undefined
|ImageTexture
Background texture merged with the video
Returns
Section titled “Returns”undefined
| ImageTexture
Background texture
dispose()
Section titled “dispose()”dispose():
void
Dispose video plugin
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”load()
Section titled “load()”load(
renderer
):Promise
<void
>
Initialize plugin
Initializes resources required for the shader effect. Allocates texture that will be merged with the video.
Parameters
Section titled “Parameters”renderer
Section titled “renderer”Renderer
<any
>
Renderer this plugin is attached to
Returns
Section titled “Returns”Promise
<void
>
Promise resolving when initialization is finished
Overrides
Section titled “Overrides”process()
Section titled “process()”process(
result
,input
):Promise
<boolean
>
Process the image
Merges the video with a background texture.
Parameters
Section titled “Parameters”result
Section titled “result”any
Results of video processing
WebGLTexture
Current image texture
Returns
Section titled “Returns”Promise
<boolean
>
True on success, false otherwise
Overrides
Section titled “Overrides”setAlpha()
Section titled “setAlpha()”setAlpha(
alpha
):void
Set interpolation factor
Parameters
Section titled “Parameters”number
Interpolation factor
Returns
Section titled “Returns”void
setMirror()
Section titled “setMirror()”setMirror(
mirror
):void
Set background mirror mode
Parameters
Section titled “Parameters”mirror
Section titled “mirror”boolean
Mirror flag
Returns
Section titled “Returns”void
setupCamera()
Section titled “setupCamera()”setupCamera(
ratio
,angle
):void
Set camera parameters
Could be overridden to adjust plugin’s pipeline.
Parameters
Section titled “Parameters”number
Aspect ration of input video
number
Vertical field of view in radians
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setupVideo()
Section titled “setupVideo()”setupVideo(
size
):void
Set video size
Adjusts shader and texture to a new size.
Parameters
Section titled “Parameters”Resolution of input video
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”unload()
Section titled “unload()”unload():
void
Reset plugin
Releases all resources and instances created in load().
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”update()
Section titled “update()”update(
result
,stream
):Promise
<void
>
Sealed
Update the image
Main method implementing webgl shader effect or filter. ShaderRenderer keeps track of the current iamge texture that will be be rendered. ShaderPlugin uses the current texture as input and writes results to ShaderPlugin#output. ShaderPlugin#output becomes new current texture of ShaderRenderer. This way all ShaderPlugins attached to renderer organize a chain of effects applied on top of each other. Method process() implements shader effect itself, it’s intended to be overridden by effect authors.
Parameters
Section titled “Parameters”result
Section titled “result”any
Results of video processing
stream
Section titled “stream”HTMLCanvasElement
Captured video frame
Returns
Section titled “Returns”Promise
<void
>
Promise resolving when update is finished