webgpu / webgpufundamentals

https://webgpufundamentals.org
BSD 3-Clause "New" or "Revised" License
624 stars 88 forks source link

Question about wireframes and multiple index buffers #127

Closed qq1792569310 closed 2 months ago

qq1792569310 commented 2 months ago

I'm working on a model preview program and two problems are bothering me right now, so forgive me for asking here because I can't find a direct solution on other sites.

One of the problems is: my model uses custom indexing to combine vertices into triangles, all vertices are divided into polygon groups, and each polygon group has its own array of vertex coordinates and index array. But I found that webgpu's GPURenderPassEncoder.setIndexBuffer function can only set one vertex index buffer, my current thinking is to build multiple GPUCommandEncoders and render each polygon group separately, but I haven't tried it yet, and I'm wondering if there is a simpler solution, and if not, whether my solution is feasible.

Another problem is: I can't seem to choose to render out only the wireframe of the model with the topology: 'triangle-list' mode selected, I tried the topology: 'line-list' mode, which displays the wireframe of the model, but this mode is described as: front and back vertices are connected, and this description It seems to imply that the vertices of my model will not form triangles in the correct order, I'm wondering if there is an easy way to make my model show only wireframes in topology: 'triangle-list' mode, and if I can only implement my idea in topology: 'line-list' mode, do I need to change the vertex index array?

English is not my native language and I might have missed the answer location, if you can answer me or tell me where I can find the answer to my question, both can help.

Looking forward to your replies!