gaussianblur 特效

This commit is contained in:
yhh
2020-06-23 17:36:39 +08:00
parent 7399b9f5ca
commit d7385654ef
12 changed files with 91 additions and 57 deletions

View File

@@ -12,17 +12,20 @@ class PostProcessor {
public onAddedToScene(scene: Scene){
this.scene = scene;
this.shape = new egret.Shape();
this.shape.graphics.beginFill(0xFFFFFF, 1);
this.shape.graphics.drawRect(0, 0, SceneManager.stage.stageWidth, SceneManager.stage.stageHeight);
this.shape.graphics.endFill();
scene.addChild(this.shape);
}
public process(source: egret.DisplayObject){
this.drawFullscreenQuad(source, this.effect);
public process(){
this.drawFullscreenQuad();
}
public onSceneBackBufferSizeChanged(newWidth: number, newHeight: number){}
protected drawFullscreenQuad(texture: egret.DisplayObject, effect: egret.CustomFilter = null){
texture.filters = [effect];
protected drawFullscreenQuad(){
this.shape.filters = [this.effect];
}
public unload(){

View File

@@ -25,12 +25,12 @@ class GaussianBlurPostProcessor extends PostProcessor {
effect.verticalBlurDelta = 1 / (this.scene.stage.stageHeight * this._renderTargetScale);
}
public process(source: egret.DisplayObject){
public process(){
let effect = this.effect as GaussianBlurEffect;
effect.prepareForHorizontalBlur();
this.drawFullscreenQuad(source, this.effect);
this.drawFullscreenQuad();
effect.prepareForVerticalBlur();
this.drawFullscreenQuad(source, this.effect);
this.drawFullscreenQuad();
}
}