You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the problem or limitation you are having in your project
GLSL aligns vec3s to 4 byte boundaries, so any array of vec3 that you use is going to have the same memory footprint as an array of vec4. This means that any array of vec3 data that you write from a GLSL shader is going to be an array of 4-tuples of floats. This poses a problem with Godot objects like ArrayMesh that require PackedVector3Arrays for vertex and normal data.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Allow ArrayMesh to be able to use buffers of PackedFloat32Array. Also allow the user to specify the stride so that 4-tupes of values can be used. Also, PackedVector4Array is not part of the API yet, but since Vector4 has been added, it would make sense to have PackedVector4Arrays and to have objects like ArrayMesh be able to accept them as input.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
ArrayMesh currently accepts an array of arrays containing data. It could detect the datatype of the array passed to it and load the data differently depending on if it is an array for float, Vector3 or Vector4. The create method could also have a parameter added that lets you specify the stride of different data arrays.
If this enhancement will not be used often, can it be worked around with a few lines of script?
Not having this requires you to do a lot of post processing on the CPU (to copy the data into a new buffer with a Vector3 datatype) which negates the point of using a GLSL shader in the first place. There is no good workaround.
Is there a reason why this should be core and not an add-on in the asset library?
Requires changing how mesh data is used on the GPU.
The text was updated successfully, but these errors were encountered:
blackears
changed the title
Need a way to initialize an ArrayMesh with 4-ples of floats
Need a way to initialize an ArrayMesh with 4-tuples of floats
Nov 29, 2023
Calinou
changed the title
Need a way to initialize an ArrayMesh with 4-tuples of floats
Add a way to initialize an ArrayMesh with 4-tuples of floats
Nov 29, 2023
Is there a reason that you need to have the data go through the CPU before creating the mesh? Otherwise, it may be preferable to have the data just remain on the GPU (which was proposed in #7209) which is planned.
In my mind, the ideal situation would be that you populate the buffers directly on the GPU in a compute shader and then use them without ever making a round trip to the CPU.
Describe the project you are working on
Using a GLSL compute shader to generate vertices
Describe the problem or limitation you are having in your project
GLSL aligns vec3s to 4 byte boundaries, so any array of vec3 that you use is going to have the same memory footprint as an array of vec4. This means that any array of vec3 data that you write from a GLSL shader is going to be an array of 4-tuples of floats. This poses a problem with Godot objects like ArrayMesh that require PackedVector3Arrays for vertex and normal data.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Allow ArrayMesh to be able to use buffers of PackedFloat32Array. Also allow the user to specify the stride so that 4-tupes of values can be used. Also, PackedVector4Array is not part of the API yet, but since Vector4 has been added, it would make sense to have PackedVector4Arrays and to have objects like ArrayMesh be able to accept them as input.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
ArrayMesh currently accepts an array of arrays containing data. It could detect the datatype of the array passed to it and load the data differently depending on if it is an array for float, Vector3 or Vector4. The create method could also have a parameter added that lets you specify the stride of different data arrays.
If this enhancement will not be used often, can it be worked around with a few lines of script?
Not having this requires you to do a lot of post processing on the CPU (to copy the data into a new buffer with a Vector3 datatype) which negates the point of using a GLSL shader in the first place. There is no good workaround.
Is there a reason why this should be core and not an add-on in the asset library?
Requires changing how mesh data is used on the GPU.
The text was updated successfully, but these errors were encountered: