修复transition层级问题
This commit is contained in:
@@ -5,6 +5,7 @@ class PostProcessor {
|
||||
public shape: egret.Shape;
|
||||
|
||||
constructor(effect: egret.CustomFilter = null){
|
||||
this.enable = true;
|
||||
this.effect = effect;
|
||||
}
|
||||
|
||||
@@ -18,12 +19,10 @@ class PostProcessor {
|
||||
this.drawFullscreenQuad(source, this.effect);
|
||||
}
|
||||
|
||||
public onSceneBackBufferSizeChanged(newWidth: number, newHeight: number){}
|
||||
|
||||
protected drawFullscreenQuad(texture: egret.DisplayObject, effect: egret.CustomFilter = null){
|
||||
this.shape.graphics.clear();
|
||||
this.shape.graphics.beginFill(0x000000, 1);
|
||||
this.shape.graphics.drawRect(0, 0, texture.width, texture.height);
|
||||
this.shape.graphics.endFill();
|
||||
this.shape.filters = [effect];
|
||||
texture.filters = [effect];
|
||||
}
|
||||
|
||||
public unload(){
|
||||
@@ -31,7 +30,7 @@ class PostProcessor {
|
||||
this.effect = null;
|
||||
}
|
||||
|
||||
this.scene = null;
|
||||
this.scene.removeChild(this.shape);
|
||||
this.scene = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
class BloomSettings {
|
||||
public readonly threshold;
|
||||
public readonly blurAmount;
|
||||
public readonly intensity;
|
||||
public readonly baseIntensity;
|
||||
public readonly saturation;
|
||||
public readonly baseStaturation;
|
||||
|
||||
constructor(bloomThreshold: number, blurAmount: number, bloomIntensity: number,baseIntensity: number,
|
||||
bloomSaturation: number, baseSaturation: number){
|
||||
this.threshold = bloomThreshold;
|
||||
this.blurAmount = blurAmount;
|
||||
this.intensity = bloomIntensity;
|
||||
this.baseIntensity = baseIntensity;
|
||||
this.saturation = bloomSaturation;
|
||||
this.baseStaturation = baseSaturation;
|
||||
}
|
||||
|
||||
public static presetSettings: BloomSettings[] = [
|
||||
new BloomSettings(0.1, 0.6, 2, 1, 1, 0),
|
||||
new BloomSettings(0, 3, 1, 1, 1, 1),
|
||||
new BloomSettings(0.5, 8, 2, 1, 0, 1),
|
||||
new BloomSettings(0.25, 8, 1.3, 1, 1, 0),
|
||||
new BloomSettings(0, 2, 1, 0.1, 1, 1),
|
||||
new BloomSettings(0.5, 2, 1, 1, 1, 1)
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
class GaussianBlurPostProcessor extends PostProcessor {
|
||||
private _renderTargetScale = 1;
|
||||
public get renderTargetScale(){
|
||||
return this._renderTargetScale;
|
||||
}
|
||||
public set renderTargetScale(value: number){
|
||||
if (this._renderTargetScale != value){
|
||||
this._renderTargetScale = value;
|
||||
this.updateEffectDeltas();
|
||||
}
|
||||
}
|
||||
|
||||
public onAddedToScene(scene: Scene){
|
||||
super.onAddedToScene(scene);
|
||||
this.effect = new GaussianBlurEffect();
|
||||
}
|
||||
|
||||
public onSceneBackBufferSizeChanged(newWidth: number, newHeight: number){
|
||||
this.updateEffectDeltas();
|
||||
}
|
||||
|
||||
private updateEffectDeltas(){
|
||||
let effect = this.effect as GaussianBlurEffect;
|
||||
effect.horizontalBlurDelta = 1 / (this.scene.stage.stageWidth * this._renderTargetScale);
|
||||
effect.verticalBlurDelta = 1 / (this.scene.stage.stageHeight * this._renderTargetScale);
|
||||
}
|
||||
|
||||
public process(source: egret.DisplayObject){
|
||||
let effect = this.effect as GaussianBlurEffect;
|
||||
effect.prepareForHorizontalBlur();
|
||||
this.drawFullscreenQuad(source, this.effect);
|
||||
|
||||
effect.prepareForVerticalBlur();
|
||||
this.drawFullscreenQuad(source, this.effect);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user