|
@@ -1,7 +1,23 @@
|
|
module BABYLON {
|
|
module BABYLON {
|
|
|
|
+ /**
|
|
|
|
+ * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
|
|
|
|
+ * input texture to perform effects such as edge detection or sharpening
|
|
|
|
+ * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
|
|
|
|
+ */
|
|
export class ConvolutionPostProcess extends PostProcess{
|
|
export class ConvolutionPostProcess extends PostProcess{
|
|
- constructor(name: string, public kernel: number[], options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean) {
|
|
|
|
- super(name, "convolution", ["kernel", "screenSize"], null, options, camera, samplingMode, engine, reusable);
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Creates a new instance of @see ConvolutionPostProcess
|
|
|
|
+ * @param name The name of the effect.
|
|
|
|
+ * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
|
|
|
|
+ * @param options The required width/height ratio to downsize to before computing the render pass.
|
|
|
|
+ * @param camera The camera to apply the render pass to.
|
|
|
|
+ * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
|
|
|
|
+ * @param engine The engine which the post process will be applied. (default: current engine)
|
|
|
|
+ * @param reusable If the post process can be reused on the same frame. (default: false)
|
|
|
|
+ * @param textureType Type of textures used when performing the post process. (default: 0)
|
|
|
|
+ */
|
|
|
|
+ constructor(name: string, /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ public kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType: number = Engine.TEXTURETYPE_UNSIGNED_INT) {
|
|
|
|
+ super(name, "convolution", ["kernel", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType);
|
|
|
|
|
|
this.onApply = (effect: Effect) => {
|
|
this.onApply = (effect: Effect) => {
|
|
effect.setFloat2("screenSize", this.width, this.height);
|
|
effect.setFloat2("screenSize", this.width, this.height);
|
|
@@ -10,12 +26,29 @@
|
|
}
|
|
}
|
|
|
|
|
|
// Statics
|
|
// Statics
|
|
- // Based on http://en.wikipedia.org/wiki/Kernel_(image_processing)
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
|
|
|
|
+ */
|
|
public static EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1];
|
|
public static EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1];
|
|
|
|
+ /**
|
|
|
|
+ * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
|
|
|
|
+ */
|
|
public static EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0];
|
|
public static EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0];
|
|
|
|
+ /**
|
|
|
|
+ * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
|
|
|
|
+ */
|
|
public static EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1];
|
|
public static EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1];
|
|
|
|
+ /**
|
|
|
|
+ * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
|
|
|
|
+ */
|
|
public static SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0];
|
|
public static SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0];
|
|
|
|
+ /**
|
|
|
|
+ * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
|
|
|
|
+ */
|
|
public static EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2];
|
|
public static EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2];
|
|
|
|
+ /**
|
|
|
|
+ * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
|
|
|
|
+ */
|
|
public static GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0];
|
|
public static GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0];
|
|
}
|
|
}
|
|
}
|
|
}
|