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

Nodes & WebGPURenderer: RangeNode #24240

Merged
merged 3 commits into from
Jun 17, 2022
Merged

Nodes & WebGPURenderer: RangeNode #24240

merged 3 commits into from
Jun 17, 2022

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Jun 15, 2022

Description

This simplify the process of creating of procedural values for instances in order to implement this in NodeEditor soon.
This is also widely used in particle system.

A range( min, max ) can contain variations of values like velocity, scale, direction, etc.

Live
https://raw.githack.com/sunag/three.js/dev-node-range/examples/webgpu_instance_mesh.html

image

Usage

// random [ 0, 1 ] values between instances
const randomFloat = range( 0, 1 );

// random [ vec3( 0, 0, 0 ), vec3( 1, 1, 1 ) ] values between instances
const randomSomeVector = range( new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 1, 1, 1 ) );

// random colors between instances from 0x000000 to 0xFFFFFF
const randomColor = range( new THREE.Color( 0x000000 ), new THREE.Color( 0xFFFFFF ) );

material.colorNode = randomColor;
material.opacityNode = randomFloat;

//...
child.isInstancedMesh = true;
child.count = 100;

/ping @mrdoob @Mugen87 @LeviPesin

This contribution is funded by Igalia via Google

@sunag sunag marked this pull request as ready for review June 15, 2022 22:42
@mrdoob
Copy link
Owner

mrdoob commented Jun 17, 2022

Nice WebGPURenderer clean up! 👍

@mrdoob mrdoob added this to the r142 milestone Jun 17, 2022
@mrdoob mrdoob merged commit 4224d83 into mrdoob:dev Jun 17, 2022
@sunag sunag deleted the dev-node-range branch August 16, 2022 03:30
abernier pushed a commit to abernier/three.js that referenced this pull request Sep 16, 2022
* Move render object dependencies to renderObject() like WebGLRenderer

* add RangeNode

* update webgpu examples
snagy pushed a commit to snagy/three.js-1 that referenced this pull request Sep 21, 2022
* Move render object dependencies to renderObject() like WebGLRenderer

* add RangeNode

* update webgpu examples
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.

2 participants