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

Mesh-visualizer: uncomment and update to the new serializing format #17

Open
tinmarino opened this issue Feb 22, 2021 · 3 comments
Open

Comments

@tinmarino
Copy link

Hi @chinedufn: Awesome work. Thank you for sharing the water demo and the deserializer.
I got well impressed with the water demo and could reproduce it (Blender 2.7).

Problem: I would like to upload my own Blender 2.8 files.
So trying to make mesh-visualizer work but it is pretty hard for me (noob: never heard of multi-index)
If someone manage to do it before me, I would be pretty glad.

Solution: Very little changes seems required: getting data from a subobject (positions.attribute.data).

Like in mesh-visualizer/src/render/mod.rs

GpuBufferer::buffer_f32_data(&gl, &mesh.multi_indexed_vertex_attributes.positions.attribute.data as &[f32], pos_attrib as u32, 3);
GpuBufferer::buffer_u16_indices(&gl, &mesh.multi_indexed_vertex_attributes.positions.indices as &[u16]);

Reason: It is difficult to count, get the good order, well do the good thing.
That is why a deserializer helps a lot to use a serializer (one could even load a class mesh-visualizer in its code and use some nice object forgetting the 1d array nightmare)

@chinedufn
Copy link
Owner

Hey there.

So the multi vs. single concept is a bit confusing and I plan to re-work it at some point.

For now though, I'll explain.

Multi indexed just means that instead of repeating the same position, normal and uv data we use a position index, normal index and uv index to point to the data so that if we need to use the second vertex normal 10 times we can just say "use vertex normal number 2 10 times". Same idea for positions and uvs.

Modern graphics APIs have no notion of this though. You can't have three different indices. You can only have one.

So instead of saying "Hey use vertex normal number 2 ten different times". You instead just have to duplicate that data ten times.


It looks like you started trying to use some of the more recent blender-mesh APIs.

Buffering the multi indexed vertex attributes won't work for the reasons mentioned above.

Instead you want to first call blender_mesh.combine_vertex_indices and then buffer that vertex data.


Please let me know if that works for you or if there is any other way that I can help.

@Fedoresko
Copy link

Anyway I can find no working renderind example for combined index. It would look nice if it could convert SingleIndexedVertexAttributes to &[f32] arrays to pass to GL array buffer ))

@chinedufn
Copy link
Owner

chinedufn commented Apr 17, 2022

Hey.

I use landon in my engine to render using a single vertex buffer, but I'm not sure that there's a working example of using a single vertex buffer from blender-mesh floating around..

I'm not sure when I'll get around to writing one.

If it helps at all (apologies for not having a working example for you), it should be no different from how you'd render using an interleaved vertex buffer anywhere else. Create a vertex buffer on the GPU and set up your vertex attributes with the proper stride.

Actually it should probably be renamed from SingleIndexedVertexAttributes to InterleavedVertexBuffer ...

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

3 participants