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

NodeMaterial: Arrays of uniforms #22497

Merged
merged 3 commits into from
Sep 6, 2021
Merged

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Sep 6, 2021

Description

This is the first approach for Arrays of uniform using ArrayInputNode.

Soon we can optimize all VBO of NodeMaterial using WebGPUUniformBuffer but it can take a while.

Include

import ArrayInputNode from './jsm/renderers/nodes/core/ArrayInputNode.js';

Example 1 - Vector3

material.colorNode = new FunctionNode( `
vec3 ( vec3[2] value ) {

	// 0 -> cornflower blue
	// 1 -> orange

	return value[0];

}` ).call( {
	value: new ArrayInputNode( [
		new Vector3Node( new THREE.Vector3( 0, .5, 1 ) ), // cornflower blue
		new Vector3Node( new THREE.Vector3( 1, .5, 0 ) ) // orange
	] )
} );

Example 2 - Matrix4

material.colorNode = new FunctionNode( `
vec3 ( mat4[2] value ) {

	// 0 -> cornflower blue
	// 1 -> orange

	mat4 mtx = value[0];
	vec3 mtxPos = vec3( mtx[3] );

	return mtxPos;

}` ).call( {
	value: new ArrayInputNode( [
		new Matrix4Node( new THREE.Matrix4().setPosition( 0, .5, 1 ) ), // cornflower blue
		new Matrix4Node( new THREE.Matrix4().setPosition( 1, .5, 0 ) ) // orange
	] )
} );

@mrdoob mrdoob added this to the r133 milestone Sep 6, 2021
@mrdoob mrdoob merged commit 540c0e1 into mrdoob:dev Sep 6, 2021
@mrdoob
Copy link
Owner

mrdoob commented Sep 6, 2021

Thanks!

@joshuaellis joshuaellis mentioned this pull request Sep 18, 2021
23 tasks
@sunag sunag deleted the dev-arrayinputnode branch September 27, 2021 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants