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

wireframe = true; Forces the drawIndexed / drawIndirectIndexed path #29708

Open
Spiri0 opened this issue Oct 21, 2024 · 0 comments
Open

wireframe = true; Forces the drawIndexed / drawIndirectIndexed path #29708

Spiri0 opened this issue Oct 21, 2024 · 0 comments

Comments

@Spiri0
Copy link
Contributor

Spiri0 commented Oct 21, 2024

Description

wireframe = true; Forces the drawIndexed / drawIndirectIndexed path even if the geometry does not have an index attribute.

This is because of this function in: renderers/common/Geometries.js

	getIndex( renderObject ) {

		const { geometry, material } = renderObject;

		let index = geometry.index;

		if ( material.wireframe === true ) {

			const wireframes = this.wireframes;

			let wireframeAttribute = wireframes.get( geometry );

			if ( wireframeAttribute === undefined ) {

				wireframeAttribute = getWireframeIndex( geometry );

				wireframes.set( geometry, wireframeAttribute );

			} else if ( wireframeAttribute.version !== getWireframeVersion( geometry ) ) {

				this.attributes.delete( wireframeAttribute );

				wireframeAttribute = getWireframeIndex( geometry );

				wireframes.set( geometry, wireframeAttribute );

			}

			index = wireframeAttribute;

		}

		return index;

	}

Because of drawIndirect, I experimented with a threejs example to find the cause of the error in my app. To do this, I installed a console command in the draw function in each of the 4 possible branches (draw, drawIndirect, drawIndexed, drawIndexedIndirect) in the WebGPUBackend.js to see which path is called.
The error has nothing to do with drawIndirect or drawIndexedIndirect. It's due to wireframe = true, because wireframe = true creates indexes and this forces the indexed draw path. This applies to draw and drawIndirect in the same way. Now that's nothing critical. Since I as a user now that I know this, I can compensate accordingly on the user side. Plus, I don't think anyone else will stumble upon it any time soon. But it would be best if wirefrae = true does not change the draw / drawIndirect path desired by the user to drawIndexed / drawIndexedIndirect, because that is problematic if you don't know how to compensate for it.

Reproduction steps

1.In WebGPUBackend.js, add an indicator to each draw path console.log("draw"), console.log("drawIndexed"), console.log("drawIndirect"), console.log(" drawIndexedIndirect") to see which branch is chosen by the system.
2. Using my codePen example locally. Once with and once without material.wireframe = true; Let it run and look in the console which draw branch is used in the backend.
3. If a user uses drawIndirect for his unindexed geometry, the draw path change forced by wireframe = true then results in an error.

Code

see live example

Live example

](https://codepen.io/Spiri0/pen/zYgzgJR)

Screenshots

No response

Version

r169

Device

No response

Browser

No response

OS

No response

@Spiri0 Spiri0 changed the title wireframe = true; Forces the drawIndexed / drawIndirecIndexed path wireframe = true; Forces the drawIndexed / drawIndirectIndexed path Oct 21, 2024
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

No branches or pull requests

1 participant