Skip to content

Commit

Permalink
Merge pull request #13068 from sebavan/master
Browse files Browse the repository at this point in the history
fix glow layer kernel set

Former-commit-id: 021fbd52b7e3623a72c88b385db7bf02c06e90e3
  • Loading branch information
sebavan authored Oct 5, 2022
2 parents cd2619c + 9e998da commit 47b4e73
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions packages/dev/core/src/Layers/glowLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,17 @@ export class GlowLayer extends EffectLayer {
* Sets the kernel size of the blur.
*/
public set blurKernelSize(value: number) {
this._horizontalBlurPostprocess1.kernel = value;
this._verticalBlurPostprocess1.kernel = value;
this._horizontalBlurPostprocess2.kernel = value;
this._verticalBlurPostprocess2.kernel = value;
if (value === this._options.blurKernelSize) {
return;
}

this._options.blurKernelSize = value;

const effectiveKernel = this._getEffectiveBlurKernelSize();
this._horizontalBlurPostprocess1.kernel = effectiveKernel;
this._verticalBlurPostprocess1.kernel = effectiveKernel;
this._horizontalBlurPostprocess2.kernel = effectiveKernel;
this._verticalBlurPostprocess2.kernel = effectiveKernel;
}

/**
Expand Down Expand Up @@ -286,10 +293,11 @@ export class GlowLayer extends EffectLayer {

this._textures = [this._blurTexture1, this._blurTexture2];

const effectiveKernel = this._getEffectiveBlurKernelSize();
this._horizontalBlurPostprocess1 = new BlurPostProcess(
"GlowLayerHBP1",
new Vector2(1.0, 0),
this._options.blurKernelSize / 2,
effectiveKernel,
{
width: blurTextureWidth,
height: blurTextureHeight,
Expand All @@ -310,7 +318,7 @@ export class GlowLayer extends EffectLayer {
this._verticalBlurPostprocess1 = new BlurPostProcess(
"GlowLayerVBP1",
new Vector2(0, 1.0),
this._options.blurKernelSize / 2,
effectiveKernel,
{
width: blurTextureWidth,
height: blurTextureHeight,
Expand All @@ -325,7 +333,7 @@ export class GlowLayer extends EffectLayer {
this._horizontalBlurPostprocess2 = new BlurPostProcess(
"GlowLayerHBP2",
new Vector2(1.0, 0),
this._options.blurKernelSize / 2,
effectiveKernel,
{
width: blurTextureWidth2,
height: blurTextureHeight2,
Expand All @@ -346,7 +354,7 @@ export class GlowLayer extends EffectLayer {
this._verticalBlurPostprocess2 = new BlurPostProcess(
"GlowLayerVBP2",
new Vector2(0, 1.0),
this._options.blurKernelSize / 2,
effectiveKernel,
{
width: blurTextureWidth2,
height: blurTextureHeight2,
Expand Down Expand Up @@ -382,6 +390,14 @@ export class GlowLayer extends EffectLayer {
});
}

/**
* @returns The blur kernel size used by the glow.
* Note: The value passed in the options is divided by 2 for back compatibility.
*/
private _getEffectiveBlurKernelSize() {
return this._options.blurKernelSize / 2;
}

/**
* Checks for the readiness of the element composing the layer.
* @param subMesh the mesh to check for
Expand Down

0 comments on commit 47b4e73

Please sign in to comment.