Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples: Improve AO demo. #28886

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions examples/webgpu_postprocessing_ao.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<script type="module">

import * as THREE from 'three';
import { pass, mrt, output, transformedNormalView, texture, ao } from 'three/tsl';
import { pass, mrt, output, transformedNormalView, texture, ao, denoise } from 'three/tsl';

import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';
Expand All @@ -33,7 +33,7 @@

let camera, scene, renderer, postProcessing, controls, clock, stats, mixer;

let aoPass, blendPassAO, blendPassDenoise, scenePassColor;
let aoPass, denoisePass, blendPassAO, blendPassDenoise, scenePassColor;

const params = {
distanceExponent: 1,
Expand All @@ -42,7 +42,11 @@
scale: 1,
thickness: 1,
denoised: true,
enabled: true
enabled: true,
denoiseRadius: 5,
lumaPhi: 5,
depthPhi: 5,
normalPhi: 5
};

init();
Expand Down Expand Up @@ -99,7 +103,7 @@
// denoise (optional)

const noiseTexture = texture( generateNoise() );
const denoisePass = aoPass.getTextureNode().denoise( scenePassDepth, scenePassNormal, noiseTexture, camera );
denoisePass = denoise( aoPass.getTextureNode(), scenePassDepth, scenePassNormal, noiseTexture, camera );
blendPassDenoise = denoisePass.mul( scenePassColor );

postProcessing.outputNode = blendPassDenoise;
Expand Down Expand Up @@ -136,6 +140,11 @@
gui.add( params, 'thickness' ).min( 0.01 ).max( 2 ).onChange( updateParameters );
gui.add( params, 'denoised' ).onChange( updatePassChain );
gui.add( params, 'enabled' ).onChange( updatePassChain );
const folder = gui.addFolder( 'Denoise settings' );
folder.add( params, 'denoiseRadius' ).min( 0.01 ).max( 10 ).name( 'radius' ).onChange( updateParameters );
folder.add( params, 'lumaPhi' ).min( 0.01 ).max( 10 ).onChange( updateParameters );
folder.add( params, 'depthPhi' ).min( 0.01 ).max( 10 ).onChange( updateParameters );
folder.add( params, 'normalPhi' ).min( 0.01 ).max( 10 ).onChange( updateParameters );

}

Expand Down Expand Up @@ -172,6 +181,11 @@
aoPass.scale.value = params.scale;
aoPass.thickness.value = params.thickness;

denoisePass.radius.value = params.denoiseRadius;
denoisePass.lumaPhi.value = params.lumaPhi;
denoisePass.depthPhi.value = params.depthPhi;
denoisePass.normalPhi.value = params.normalPhi;

}

function generateNoise( size = 64 ) {
Expand Down