Sandman13sq / DmrVBM-blender-to-gms2

Vertex Buffers from Blender to Game Maker Studio 2
25 stars 0 forks source link

Thanks for the update - still troubles #13

Open Grisgram opened 2 weeks ago

Grisgram commented 2 weeks ago

Hello again,

I have updated both blender and gms, and created a simple object in blender, which i wanted to show in your tutorial project (tut 2 - "load vb").

However, sometimes it loads, sometimes it crashes but it never looks like the geometry I designed in blender. As i see your other tutorials are running fine, even animating, the error must be on my side, but I can't figure out, what I do wrong.

Please see attached blender file of a simple chimney-like object.

Here's what I did: The object looks like this: \ image

These are my export settings, as far as I can tell, they match your "native" vbf: image

The attributes are set to: image

I have also attached a .vb file, the add-on generates from the blender file.

Could you please tell me, what I am doing wrong? For a totally-zero-pre-knowledge-person, the tutorials seem not to be enough to get it working, or I missed something completely.

Thanks for your help!

Cheers, Gris

gms-test.zip

Sandman13sq commented 2 weeks ago

TLDR: I wrote the exporter for my specific workflow and missed an edge case. Thanks for bringing this to my attention.

The vertex buffer function will crash if there's no data in the exported vb file. This can happen if you use the Export Selected option without objects being selected, where the exporter will create a file with only compression data and no vertex data. Clicking around in Blender may deselect the object(s) you wish to export.

For the incorrect geometry, your mesh color attribute uses Vertex as its domain, which is a case I did not test for: blender_DxYRthGugd

The exporter expects Face Corner dormain, as this is aligned per triangle (the way gms2 handles vertex buffers) instead of per vertex. Using vertex domain stores less data and can screw up the space between vertices when creating data on export. The vertex buffer is only "valid" if the length of the buffer = (number_of_vertices x byte_size_of_format), which is why the vertex_create_buffer() and vertex_submit() calls fail sometimes. When it doesn't error, the position attribute is only aligned correctly for some vertices and other attributes bleed over (note the white and alpha on the top of the mesh): Runner_TroRMZMz2I

Converting the color attribute to domain Face Corner and data type Byte Color fixes this issue: facecorner_bytecolor

I'll work on a fix that can read the Vertex domain correctly so color attributes don't need to be converted beforehand. Expect an update to the development repo soon.

Grisgram commented 2 weeks ago

oh my -- thank you very much! I really didn't expect that there's an edge case on your end -- glad, we found it! 💯