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

Add instanced rendering #81

Merged
merged 4 commits into from
Aug 5, 2024
Merged

Add instanced rendering #81

merged 4 commits into from
Aug 5, 2024

Conversation

paulcscharf
Copy link
Member

✨ What's this?

Allows us to use multiple vertex buffers for renderables, enabling instanced rendering (as well as non-interleaved buffers generally).

πŸ— How is it done?

I refactored renderable construction heavily, removing all the separate classes for different cases and just using a single builder and composition. The builder also supports the instanced draw calls now.

The other change that makes instanced rendering possible is adding the divisor parameter to vertex attributes.

πŸ’₯ Breaking changes

I removed the old renderable construction methods.

private IIndexBuffer? indexBuffer;
private Func<int>? instanceCount;

public Builder With(IVertexBuffer buffer)
Copy link
Member

Choose a reason for hiding this comment

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

I would probably be more explicit here. With for records replaces, here it appends. This gets especially confusing since the index buffer, which also uses With, indeed does replace. So I would consider calling this AddBuffer (or even AddVertexBuffer) or AppendBuffer.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't disagree. But all the name changes I tried I ended up not being happy with. Perhaps the builder itself isn't quite ideal. I'll leave it like it is for now, and will see if I can come up with a better interface in the future.

@paulcscharf paulcscharf merged commit 5f3cd72 into master Aug 5, 2024
1 check passed
@paulcscharf paulcscharf deleted the instanced-rendering branch August 5, 2024 21:36
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.

2 participants