Skip to content

Commit

Permalink
renamed lastMipLevel -> blurLevel
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Valigursky committed Nov 25, 2024
1 parent 312c42c commit 52a6219
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ assetListLoader.load(() => {
const cameraFrame = new pc.CameraFrame(app, camera.camera);
cameraFrame.rendering.samples = 4;
cameraFrame.bloom.intensity = 0.01;
cameraFrame.bloom.lastMipLevel = 4;
cameraFrame.bloom.blurLevel = 4;
cameraFrame.update();

// if the device renders in HDR mode, disable tone mapping to output HDR values without any processing
Expand Down
6 changes: 3 additions & 3 deletions examples/src/examples/graphics/post-processing.controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
),
jsx(
LabelGroup,
{ text: 'last mip level' },
{ text: 'blur level' },
jsx(SliderInput, {
binding: new BindingTwoWay(),
link: { observer, path: 'data.bloom.lastMipLevel' },
link: { observer, path: 'data.bloom.blurLevel' },
min: 1,
max: 10,
max: 16,
precision: 0
})
)
Expand Down
4 changes: 2 additions & 2 deletions examples/src/examples/graphics/post-processing.example.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ assetListLoader.load(() => {

// Bloom
cameraFrame.bloom.intensity = data.get('data.bloom.enabled') ? pc.math.lerp(0, 0.1, data.get('data.bloom.intensity') / 100) : 0;
cameraFrame.bloom.lastMipLevel = data.get('data.bloom.lastMipLevel');
cameraFrame.bloom.blurLevel = data.get('data.bloom.blurLevel');

// grading
cameraFrame.grading.enabled = data.get('data.grading.enabled');
Expand Down Expand Up @@ -284,7 +284,7 @@ assetListLoader.load(() => {
bloom: {
enabled: true,
intensity: 5,
lastMipLevel: 1
blurLevel: 16
},
grading: {
enabled: false,
Expand Down
6 changes: 3 additions & 3 deletions scripts/utils/camera-frame.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ class Bloom {

/**
* @attribute
* @range [0, 12]
* @range [0, 16]
* @precision 0
* @step 0
*/
lastMipLevel = 1;
blurLevel = 1;
}

/** @interface */
Expand Down Expand Up @@ -336,7 +336,7 @@ class CameraFrame extends Script {
const dstBloom = cf.bloom;
dstBloom.intensity = bloom.enabled ? bloom.intensity : 0;
if (bloom.enabled) {
dstBloom.lastMipLevel = bloom.lastMipLevel;
dstBloom.blurLevel = bloom.blurLevel;
}

// grading
Expand Down
8 changes: 5 additions & 3 deletions src/extras/render-passes/camera-frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ import { CameraFrameOptions, RenderPassCameraFrame } from './render-pass-camera-
* @typedef {Object} Bloom
* @property {number} intensity - The intensity of the bloom effect, 0-0.1 range. Defaults to 0,
* making it disabled.
* @property {number} lastMipLevel - The last mip level of the bloom effect, 0-12 range. Defaults to 1.
* @property {number} blurLevel - The number of iterations for blurring the bloom effect, with each
* level doubling the blur size. Once the blur size matches the dimensions of the render target,
* further blur passes are skipped. The default value is 16.
*/

/**
Expand Down Expand Up @@ -187,7 +189,7 @@ class CameraFrame {
*/
bloom = {
intensity: 0,
lastMipLevel: 1
blurLevel: 16
};

/**
Expand Down Expand Up @@ -345,7 +347,7 @@ class CameraFrame {

if (options.bloomEnabled && bloomPass) {
composePass.bloomIntensity = bloom.intensity;
bloomPass.lastMipLevel = bloom.lastMipLevel;
bloomPass.blurLevel = bloom.blurLevel;
}

if (options.ssaoType !== SSAOTYPE_NONE) {
Expand Down
7 changes: 4 additions & 3 deletions src/extras/render-passes/render-pass-bloom.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { FILTER_LINEAR, ADDRESS_CLAMP_TO_EDGE } from '../../platform/graphics/co

import { RenderPassDownsample } from './render-pass-downsample.js';
import { RenderPassUpsample } from './render-pass-upsample.js';
import { math } from '../../core/math/math.js';

// based on https://learnopengl.com/Guest-Articles/2022/Phys.-Based-Bloom
/**
Expand All @@ -18,7 +19,7 @@ import { RenderPassUpsample } from './render-pass-upsample.js';
class RenderPassBloom extends RenderPass {
bloomTexture;

lastMipLevel = 1;
blurLevel = 16;

bloomRenderTarget;

Expand Down Expand Up @@ -151,8 +152,8 @@ class RenderPassBloom extends RenderPass {
super.frameUpdate();

// create an appropriate amount of render passes
let numPasses = this.calcMipLevels(this._sourceTexture.width, this._sourceTexture.height, 2 ** this.lastMipLevel);
numPasses = Math.max(1, numPasses);
const maxNumPasses = this.calcMipLevels(this._sourceTexture.width, this._sourceTexture.height, 1);
const numPasses = math.clamp(maxNumPasses, 1, this.blurLevel);

if (this.renderTargets.length !== numPasses) {

Expand Down

0 comments on commit 52a6219

Please sign in to comment.