module:extras/kernelmatrixshader

Back to documentation index.

### module:extras/kernelmatrixshader()

The extras/kernelmatrixshader.js module. To import all symbols in this module, either of the following can be used:

import * from "extras/kernelmatrixshader.js";
// -- or --
import * as CustomModuleName from "extras/kernelmatrixshader.js";

Members

Methods

### module:extras/kernelmatrixshader.kernelMatrixShader (constant)

GLSL shader code for a family of image processing filters, such as blurring, sharpening, edge detection, and embossing, that process each pixel and its neighbors. This filter takes a 3 × 3 matrix called a convolution kernel, which gives the contribution of each pixel’s color to the final color. All the numbers in the matrix usually add up to 1. An example of a convolution kernel:

[ 0, 1/8, 0,
1/8, 1/2, 1/8,
0, 1/8, 0 ]

This matrix means that the destination pixel will have 1/2 of the original pixel’s color, and 1/8 of the colors of its 4 adjacent pixels. Note that this example adds up to 1. **Blur filtered image** **Edge detect filtered image** This shader program takes three uniforms: “sample”, the source texture; “textureSize”, the width and height of the texture in pixels; “matrix”, the 3 × 3 convolution kernel.

### (static) module:extras/kernelmatrixshader.getKernelMatrix(kind)

Creates a 3 × 3 (9-element) kernel matrix for using as the “matrix” uniform of the kernel matrix shader.

Parameters

Return Value

The created matrix. (Type: Array.<number>)

### (static) module:extras/kernelmatrixshader.normalizeKernelInPlace(matrix)

TODO: Not documented yet.

Parameters

Return Value

Return value. (Type: *)

Back to documentation index.