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

custom batched mesh and WebGPURenderer #30007

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

vegarringdal
Copy link
Contributor

Just tried the WebGPURenderer to see how its going.
But it did not like my custom batched mesh, only need the multidraw part to keep drawcalls low.
I dont use _matricesTexture, _indirectTexture or _colorsTexture

It worked when I added 2 checks for _matricesTexture

Copy link

github-actions bot commented Dec 1, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 339.11
78.98
339.11
78.98
+0 B
+0 B
WebGPU 484.59
134.49
484.64
134.49
+49 B
+9 B
WebGPU Nodes 484.06
134.39
484.11
134.4
+49 B
+10 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 464.62
111.98
464.62
111.98
+0 B
+0 B
WebGPU 553.38
149.78
553.43
149.79
+49 B
+6 B
WebGPU Nodes 509.26
139.49
509.31
139.49
+49 B
+4 B

@RenaudRohlinger
Copy link
Collaborator

Wouldn't it be easier to manually handle the setupPosition in that case?

const yourCustomBatchMaterial = new NodeMaterial()

yourCustomBatchMaterial.setupPosition = function ( builder ) {

const { object } = builder;
const geometry = object.geometry;

builder.addStack();

// Vertex

if ( object.isBatchedMesh ) {

	yourCustomBatch( object ).append();

}

if ( this.positionNode !== null ) {

	positionLocal.assign( this.positionNode );

}

this.setupHardwareClipping( builder );

const mvp = modelViewProjection();

builder.context.vertex = builder.removeStack();
builder.context.mvp = mvp;

return mvp;

}

@vegarringdal
Copy link
Contributor Author

Dont know, just replaced from webgl to webgpu to see how it worked. And it failed to render because it assumed I used all parts of batched mesh. if we can avoid issues without any core edits, then great.

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