diff --git a/examples/screenshots/webgpu_instance_points.jpg b/examples/screenshots/webgpu_instance_points.jpg index cb60814449a427..ca3484aa73688e 100644 Binary files a/examples/screenshots/webgpu_instance_points.jpg and b/examples/screenshots/webgpu_instance_points.jpg differ diff --git a/examples/webgpu_instance_points.html b/examples/webgpu_instance_points.html index 03affcf5e4e3d8..171c6c09456d43 100644 --- a/examples/webgpu_instance_points.html +++ b/examples/webgpu_instance_points.html @@ -26,7 +26,7 @@ diff --git a/src/materials/nodes/InstancedPointsNodeMaterial.js b/src/materials/nodes/InstancedPointsNodeMaterial.js index 29505ef4d3618b..b0ff584c3fecad 100644 --- a/src/materials/nodes/InstancedPointsNodeMaterial.js +++ b/src/materials/nodes/InstancedPointsNodeMaterial.js @@ -30,6 +30,8 @@ class InstancedPointsNodeMaterial extends NodeMaterial { this.pointColorNode = null; + this.pointWidthNode = null; + this.setDefaultValues( _defaultValues ); this.setupShaders(); @@ -56,7 +58,7 @@ class InstancedPointsNodeMaterial extends NodeMaterial { //vUv = uv; varying( vec2(), 'vUv' ).assign( uv() ); // @TODO: Analyze other way to do this - const instancePosition = attribute( 'instancePosition' ); + const instancePosition = attribute( 'instancePosition' ).xyz; // camera space const mvPos = property( 'vec4', 'mvPos' ); @@ -70,7 +72,9 @@ class InstancedPointsNodeMaterial extends NodeMaterial { // offset in ndc space const offset = property( 'vec2', 'offset' ); offset.assign( positionGeometry.xy ); - offset.assign( offset.mul( materialPointWidth ) ); + + offset.mulAssign( this.pointWidthNode ? this.pointWidthNode : materialPointWidth ); + offset.assign( offset.div( viewport.z ) ); offset.y.assign( offset.y.mul( aspect ) );