Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion examples/webgpu_materials.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<script type="module">

import * as THREE from 'three';
import { tslFn, wgslFn, positionLocal, positionWorld, normalLocal, normalWorld, normalView, color, texture, uv, float, vec2, vec3, vec4, oscSine, triplanarTexture, viewportBottomLeft, js, string, global, loop } from 'three/tsl';
import { tslFn, wgslFn, positionLocal, positionWorld, normalLocal, normalWorld, normalView, color, texture, uv, float, vec2, vec3, vec4, oscSine, triplanarTexture, viewportBottomLeft, js, string, global, loop, cameraProjectionMatrix } from 'three/tsl';

import { TeapotGeometry } from 'three/addons/geometries/TeapotGeometry.js';

Expand Down Expand Up @@ -117,6 +117,12 @@
material.alphaTestNode = 0.5;
materials.push( material );

// camera
material = new THREE.MeshBasicNodeMaterial();
material.colorNode = cameraProjectionMatrix.mul( positionLocal );
materials.push( material );


// Normal
material = new THREE.MeshNormalMaterial();
material.opacity = .5;
Expand Down
5 changes: 3 additions & 2 deletions src/nodes/core/NodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,15 @@ class NodeBuilder {

if ( bindGroup === undefined ) {

bindGroup = new BindGroup( groupName, bindingsArray );
bindGroup = new BindGroup( groupName, bindingsArray, this.bindingsIndexes[ groupName ].group );

bindGroupsCache.set( bindingsArray, bindGroup );

}

} else {

bindGroup = new BindGroup( groupName, bindingsArray );
bindGroup = new BindGroup( groupName, bindingsArray, this.bindingsIndexes[ groupName ].group );

}

Expand Down
3 changes: 2 additions & 1 deletion src/renderers/common/BindGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ let _id = 0;

class BindGroup {

constructor( name = '', bindings = [] ) {
constructor( name = '', bindings = [], index = 0 ) {

this.name = name;
this.bindings = bindings;
this.index = index;

this.id = _id ++;

Expand Down
2 changes: 1 addition & 1 deletion src/renderers/common/nodes/NodeBuilderState.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class NodeBuilderState {

if ( shared !== true ) {

const bindingsGroup = new BindGroup( instanceGroup.name );
const bindingsGroup = new BindGroup( instanceGroup.name, [], instanceGroup.index );
bindings.push( bindingsGroup );

for ( const instanceBinding of instanceGroup.bindings ) {
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/webgpu/WebGPUBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ class WebGPUBackend extends Backend {
const bindGroup = bindings[ i ];
const bindingsData = this.get( bindGroup );

passEncoderGPU.setBindGroup( i, bindingsData.group );
passEncoderGPU.setBindGroup( bindGroup.index, bindingsData.group );

}

Expand Down