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

WebGPURenderer: AfterImageNode fix toneMapping #28442

Merged
merged 2 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
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
16 changes: 14 additions & 2 deletions examples/jsm/nodes/display/AfterImageNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import { uniform } from '../core/UniformNode.js';
import { RenderTarget } from 'three';
import { sign, max } from '../math/MathNode.js';
import QuadMesh from '../../objects/QuadMesh.js';
import { NoToneMapping, Vector2 } from 'three';

const _size = new Vector2();

const quadMeshComp = new QuadMesh();

Expand Down Expand Up @@ -58,12 +61,21 @@ class AfterImageNode extends TempNode {
this._compRT.texture.type = textureType;
this._oldRT.texture.type = textureType;

renderer.getDrawingBufferSize( _size );

this.setSize( _size.x, _size.y );


const currentToneMapping = renderer.toneMapping;
const currentToneMappingNode = renderer.toneMappingNode;
const currentRenderTarget = renderer.getRenderTarget();
const currentTexture = textureNode.value;

this.textureNodeOld.value = this._oldRT.texture;

// comp
renderer.toneMapping = NoToneMapping;
renderer.toneMappingNode = null;
renderer.setRenderTarget( this._compRT );
quadMeshComp.render( renderer );

Expand All @@ -72,9 +84,9 @@ class AfterImageNode extends TempNode {
this._oldRT = this._compRT;
this._compRT = temp;

// set size before swapping fails
this.setSize( map.image.width, map.image.height );

renderer.toneMapping = currentToneMapping;
renderer.toneMappingNode = currentToneMappingNode;
renderer.setRenderTarget( currentRenderTarget );
textureNode.value = currentTexture;

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/functions/ToonLightingModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const getGradientIrradiance = tslFn( ( { normal, lightDirection, builder } ) =>

// dotNL will be from -1.0 to 1.0
const dotNL = normal.dot( lightDirection );
const coord = vec2( dotNL.mul( 0.5 ).add( 0.5 ), 0.0 );
const coord = vec2( dotNL.mul( 0.5 ).add( 0.5 ), 0.0 );

if ( builder.material.gradientMap ) {

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/materials/Line2NodeMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class Line2NodeMaterial extends NodeMaterial {

const worldPos = varyingProperty( 'vec4', 'worldPos' );

worldPos.assign( positionGeometry.y.lessThan( 0.5 ).cond( start, end) );
worldPos.assign( positionGeometry.y.lessThan( 0.5 ).cond( start, end ) );

// height offset
const hw = materialLineWidth.mul( 0.5 );
Expand Down
2 changes: 1 addition & 1 deletion examples/webgpu_compute_particles_snow.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"three": "../build/three.module.js",
"three/addons/": "./jsm/",
"three/nodes": "./jsm/nodes/Nodes.js",
"stats-gl": "https://cdn.jsdelivr.net/npm/stats-gl@2.2.6/dist/main.js"
"stats-gl": "https://cdn.jsdelivr.net/npm/stats-gl@2.2.8/dist/main.js"
}
}
</script>
Expand Down