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

Allow creating meshes without vertex positions #62046

Merged
merged 1 commit into from
Aug 20, 2022

Conversation

clayjohn
Copy link
Member

@clayjohn clayjohn commented Jun 14, 2022

Implements the second half of: #19473

This allows meshes to be created without using vertex positions (for example, a mesh can be created with just an index array. In certain cases it can be much more efficient to only pass an index array and then pull your vertex information from a storage buffer or texture.

@clayjohn clayjohn added this to the 4.0 milestone Jun 14, 2022
@clayjohn clayjohn force-pushed the vertexless-draw branch 2 times, most recently from d34d12d to e0cf325 Compare June 24, 2022 18:23
@clayjohn clayjohn marked this pull request as ready for review June 24, 2022 18:23
@clayjohn clayjohn requested a review from a team as a code owner June 24, 2022 18:23
@clayjohn clayjohn requested a review from reduz June 24, 2022 18:23
@clayjohn clayjohn changed the title Allow creating meshes with only an Index buffer Allow creating meshes without vertex positions Jun 24, 2022
@reduz
Copy link
Member

reduz commented Jun 24, 2022

This looks good, but I fear users maaay make a mistake using the API and get no error because now this is valid? I was wondering if a format flag should be supplied (like RS::MESH_ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY) to make sure you do want this behavior.

@clayjohn clayjohn force-pushed the vertexless-draw branch 3 times, most recently from 2ac813b to 06a47ea Compare June 27, 2022 20:44
@clayjohn
Copy link
Member Author

@reduz Should be good to go now. It prints an error if drawing to create a mesh without a vertex buffer and without the ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY flag

@reduz
Copy link
Member

reduz commented Aug 19, 2022

needs rebase

Copy link
Member

@mhilbrunner mhilbrunner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor nitpicks, besides that this seems ready to go :)

…hes can now be constructed from an index buffer alone
@mhilbrunner mhilbrunner merged commit 5e0d2b5 into godotengine:master Aug 20, 2022
@mhilbrunner
Copy link
Member

Thank you!

@clayjohn clayjohn deleted the vertexless-draw branch August 20, 2022 03:52
Adrian-Samoticha added a commit to Adrian-Samoticha/godot that referenced this pull request Jun 24, 2024
While the `RenderingServer::mesh_create_surface_data_from_arrays`
method does support vertexless meshes (see godotengine#62046 and godotengine#83446),
it enforces that the size of custom arrays is dependent on the size of
the vertex array. This effectively means  that custom arrays cannot be
used in vertexless meshes.

This commit changes the way the array length is computed so that if no
vertex array is provided, its length will be inferred from the custom
arrays, if provided. It therefore adds support for custom arrays in
vertexless meshes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants