Selaa lähdekoodia

add PointsMaterial node system

sunag 4 vuotta sitten
vanhempi
commit
99cced52d1

+ 1 - 1
examples/jsm/renderers/webgpu/WebGPUNodeBuilder.js

@@ -47,7 +47,7 @@ class WebGPUNodeBuilder extends NodeBuilder {
 		
 		const material = this.material;
 		
-		if ( material.isMeshBasicMaterial ) {
+		if ( material.isMeshBasicMaterial || material.isPointsMaterial ) {
 			
 			if ( material.colorNode !== undefined ) {
 				

+ 15 - 1
examples/jsm/renderers/webgpu/WebGPURenderPipelines.js

@@ -797,6 +797,7 @@ class WebGPURenderPipelines {
 const ShaderLib = {
 	mesh_basic: {
 		vertexShader: `#version 450
+
 		layout(location = 0) in vec3 position;
 		layout(location = 1) in vec2 uv;
 
@@ -818,6 +819,7 @@ const ShaderLib = {
 			gl_Position = cameraUniforms.projectionMatrix * modelUniforms.modelViewMatrix * vec4( position, 1.0 );
 		}`,
 		fragmentShader: `#version 450
+
 		layout(set = 0, binding = 2) uniform OpacityUniforms {
 			float opacity;
 		} opacityUniforms;
@@ -869,10 +871,22 @@ const ShaderLib = {
 		}`,
 		fragmentShader: `#version 450
 
+		#ifdef NODE_UNIFORMS
+		layout(set = 0, binding = 2) uniform NodeUniforms {
+			NODE_UNIFORMS
+		} nodeUniforms;
+		#endif
+
 		layout(location = 0) out vec4 outColor;
 
 		void main() {
-			outColor = vec4( 1.0, 0.0, 0.0, 1.0 );
+
+			outColor = vec4( 1.0, 1.0, 1.0, 1.0 );
+
+			#ifdef NODE_COLOR
+				outColor.rgb = NODE_COLOR;
+			#endif
+
 		}`
 	},
 	line_basic: {

+ 2 - 0
examples/webgpu_sandbox.html

@@ -95,6 +95,8 @@
 				const geometryPoints = new THREE.BufferGeometry().setFromPoints( points );
 				const materialPoints = new THREE.PointsMaterial();
 
+				materialPoints.colorNode = new Vector3Node( new THREE.Vector3( 0, .6, 1 ) );
+
 				const pointCloud = new THREE.Points( geometryPoints, materialPoints );
 				pointCloud.position.set( 2, - 1, 0 );
 				scene.add( pointCloud );