How to convert a PackedByteArray into a PackedVector3Array?
Asked Answered
V

2

0

I'm doing some development work with GLSL shaders and have one returning a buffer of PackedByteArray that represents point information. I'd like to convert this to a PackedVector3Array so that I can then pass it to an ArrayMesh to create a mesh - however, Godot seems to lack any way to create PackedVector3Arrays from byte arrays. PackedByteArray has to_float32_array() and to_float64_array(), but neither of those have a way to then convert it to PackedVector3Array.

Is there some way to convert my buffer to a PackedVector3Array, or do I have to do a slow CPU copy into a new array?

Vesuvius answered 28/11, 2023 at 11:18 Comment(0)
L
0

The first three elements of the PackedByteArray will be the first element of the PackedVector3Array, the second three elements of the PackedByteArray will be the second element of the PackedVector3Array, etc.?

Lithuanian answered 28/11, 2023 at 12:56 Comment(0)
V
0

Lithuanian
Well, the issue I was having was that my returned buffer didn't consist of triplets of floats but rather quadruplets of floats. Essentially I was forced into padding every vec3 with an extra float set to 0. But then I realized I could buffer objects instead of image objects for transferring the data, so this is no longer an issue.

Vesuvius answered 4/12, 2023 at 3:7 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.