Skip to content

Commit 74ca7d8

Browse files
authored
WebGPURenderer: Compute Snow Example (#27400)
* NodeMaterial: Check toneMapped=true * Renderer: overrideMaterial compatible with positionNode * GaussianBlurNode: Added resolution * add `webgpu_compute_particles_snow` example * update * fix scale offset collision * update initial pos y
1 parent 73fafde commit 74ca7d8

File tree

7 files changed

+406
-2
lines changed

7 files changed

+406
-2
lines changed

examples/files.json

+1
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@
322322
"webgpu_compute_audio",
323323
"webgpu_compute_particles",
324324
"webgpu_compute_particles_rain",
325+
"webgpu_compute_particles_snow",
325326
"webgpu_compute_points",
326327
"webgpu_compute_texture",
327328
"webgpu_compute_texture_pingpong",

examples/jsm/nodes/display/GaussianBlurNode.js

+5
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,15 @@ class GaussianBlurNode extends TempNode {
2929

3030
this.updateBeforeType = NodeUpdateType.RENDER;
3131

32+
this.resolution = new Vector2( 1, 1 );
33+
3234
}
3335

3436
setSize( width, height ) {
3537

38+
width = Math.max( Math.round( width * this.resolution.x ), 1 );
39+
height = Math.max( Math.round( height * this.resolution.y ), 1 );
40+
3641
this._invSize.value.set( 1 / width, 1 / height );
3742
this._horizontalRT.setSize( width, height );
3843
this._verticalRT.setSize( width, height );

examples/jsm/nodes/materials/NodeMaterial.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ class NodeMaterial extends ShaderMaterial {
352352

353353
const toneMappingNode = builder.toneMappingNode;
354354

355-
if ( toneMappingNode ) {
355+
if ( this.toneMapped === true && toneMappingNode ) {
356356

357357
outputNode = vec4( toneMappingNode.context( { color: outputNode.rgb } ), outputNode.a );
358358

examples/jsm/renderers/common/Renderer.js

+27-1
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ class Renderer {
941941

942942
renderObject( object, scene, camera, geometry, material, group, lightsNode ) {
943943

944-
material = scene.overrideMaterial !== null ? scene.overrideMaterial : material;
944+
let overridePositionNode;
945945

946946
//
947947

@@ -951,6 +951,24 @@ class Renderer {
951951

952952
//
953953

954+
if ( scene.overrideMaterial !== null ) {
955+
956+
const overrideMaterial = scene.overrideMaterial;
957+
958+
if ( material.positionNode && material.positionNode.isNode ) {
959+
960+
overridePositionNode = overrideMaterial.positionNode;
961+
962+
overrideMaterial.positionNode = material.positionNode;
963+
964+
}
965+
966+
material = overrideMaterial;
967+
968+
}
969+
970+
//
971+
954972
if ( material.transparent === true && material.side === DoubleSide && material.forceSinglePass === false ) {
955973

956974
material.side = BackSide;
@@ -969,6 +987,14 @@ class Renderer {
969987

970988
//
971989

990+
if ( overridePositionNode !== undefined ) {
991+
992+
scene.overrideMaterial.positionNode = overridePositionNode;
993+
994+
}
995+
996+
//
997+
972998
object.onAfterRender( this, scene, camera, geometry, material, group );
973999

9741000
}
Loading

0 commit comments

Comments
 (0)