Skip to content

Commit

Permalink
fix(HDRBloomPost): add luminosityThreshold arg (#106)
Browse files Browse the repository at this point in the history
add luminosityThreshold arg
  • Loading branch information
Codeboy-cn committed May 7, 2023
1 parent efc5f4d commit 34ba5d9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/Engine3D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,9 @@ export class Engine3D {
enable: false,
blurX: 4,
blurY: 4,
intensity: 0.25,
brightness: 1.3,
strength: 0.25,
radius: 1.3,
luminosityThreshold: 0.98,
debug: false,
},
fxaa: {
Expand Down
20 changes: 11 additions & 9 deletions src/gfx/renderJob/post/HDRBloomPost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ export class HDRBloomPost extends PostBase {
public blurY: number = 1;
constructor() {
super();
Engine3D.setting.render.postProcessing.bloom.enable = true;
const bloomSetting = Engine3D.setting.render.postProcessing.bloom;

bloomSetting.enable = true;

this.blurX = Engine3D.setting.render.postProcessing.bloom.blurX;
this.blurY = Engine3D.setting.render.postProcessing.bloom.blurY;
this.blurX = bloomSetting.blurX;
this.blurY = bloomSetting.blurY;

let presentationSize = webGPUContext.presentationSize;
let outTextures = this.createRTTexture('HDRBloomPost-outTextures', presentationSize[0], presentationSize[1], GPUTextureFormat.rgba16float, false);
Expand All @@ -41,7 +43,7 @@ export class HDRBloomPost extends PostBase {
let brightnessTextures = this.createRTTexture('brightnessTextures', presentationSize[0], presentationSize[1], GPUTextureFormat.rgba16float, false);

this.brightnessView = this.createViewQuad(`brightnessView`, `Bloom_Brightness_frag_wgsl`, brightnessTextures, {
luminosityThreshold: new UniformNode(Engine3D.setting.render.postProcessing.bloom.brightness),
luminosityThreshold: new UniformNode(bloomSetting.luminosityThreshold),
});
}

Expand Down Expand Up @@ -78,7 +80,7 @@ export class HDRBloomPost extends PostBase {

{
this.compositeView = this.createViewQuad(`compositeView`, `Bloom_composite_frag_wgsl`, outTextures, {
bloomStrength: new UniformNode(Engine3D.setting.render.postProcessing.bloom.intensity),
bloomStrength: new UniformNode(bloomSetting.strength),
bloomRadius: new UniformNode(1),
});
}
Expand All @@ -94,19 +96,19 @@ export class HDRBloomPost extends PostBase {
public debug() {
}

public get bloomStrength() {
public get strength() {
return this.compositeView.uniforms['bloomStrength'].value;
}

public set bloomStrength(value: number) {
public set strength(value: number) {
this.compositeView.uniforms['bloomStrength'].value = value;
}

public get bloomRadius() {
public get radius() {
return this.compositeView.uniforms['bloomRadius'].value;
}

public set bloomRadius(value: number) {
public set radius(value: number) {
this.compositeView.uniforms['bloomRadius'].value = value;
}

Expand Down
10 changes: 7 additions & 3 deletions src/setting/post/BloomSetting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ export type BloomSetting = {
/**
* Strength setting
*/
intensity: number;
strength: number;
/**
* Brightness setting
* Radius setting
*/
brightness: number;
radius: number;
/**
* Luminosity threshold
*/
luminosityThreshold: number;
/**
* use debug or not
*/
Expand Down

0 comments on commit 34ba5d9

Please sign in to comment.