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?
While I have no experience with shaders, in Godot any variant can be converted to bytes by using
var_to_bytesand bytes can be converted back again to variant using
var v3array : PackedVector3Array = [Vector3.ZERO,Vector3.ONE,Vector3.LEFT] print(v3array) # To convert it into bytes var v3array_bytes : PackedByteArray = var_to_bytes(v3array) # To convert it back again from bytes to PackedVector3Array var convert : PackedVector3Array = bytes_to_var(v3array_bytes) print(convert)
Hope it helps