Question about wireframes and multiple index buffers #128
Replies: 3 comments 1 reply
-
I just asked ai about the first multi-indexed array problem and it seems to be solved by passing the coding command
|
Beta Was this translation helpful? Give feedback.
-
If you want to do your own indexing you'd probably need to put your vertex data into storage buffers instead of vertex buffers. Then you can index them however you want to. For wire-frame there are multiple issues (1) You probably need different shaders instead of just changing the topology. (2) WebGPU only supports 1 pixel wide textures. If you want thicker lines you'll need some other technique. There are suggestions in this article. |
Beta Was this translation helpful? Give feedback.
-
It is common to have to re-make vertices for drawing wireframes. But, like I said, if you put your vertex data in a storage buffer, then you can index it however you want. I put up an example here https://jsgist.org/?src=4e741a29abc629586b99ef07f09693eb The buffer the vertices are in is marked as both The important part is the vertex shader for wireframes.
You can see it takes in It then emits 6 vertices for each triangle
If the vertices don't have any indices then you can change
to
The sample assumes 32bit indices. For 16bit indices you'd have to read the indices and u32 and separate them in the shader From
to
|
Beta Was this translation helpful? Give feedback.
-
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
'sGPURenderPassEncoder.setIndexBuffer
function can only set one vertex index buffer, my current thinking is to build multipleGPUCommandEncoder
s 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 thetopology: '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 intopology: 'triangle-list'
mode, and if I can only implement my idea intopology: '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!
Beta Was this translation helpful? Give feedback.
All reactions