Skip to content

Custom shader buffer (b0) for instanced draws #382

@JollyNox

Description

@JollyNox

Custom shader buffer (b0) for instanced draws

Right now the b0 register is locked out when not using Immediate draws with spriteBatch, but that gets rid of its awesome instancing code.

Spritebatch "batch renders" draw calls between begin-end as long as you don't tell it to use SpriteSortMode::SpriteSortMode_Immediate.

The issue here is, that when it does batch draws, it didn't allow me to use a custom b0 register. It has a good reason, its using a custom matrix for 2D sprite rendering, but it also kind of moots the ability to add custom shaders to a batch. I made a copy of the matrix, it's used instead of an mvp to multiply with each vert. It's strange but also sets the geo in the right location; ref the first img.

I added a bool to spritebatch->end to handle custom shaders, this fixed it for me. Added a screenshot of the diff.

I hope for a proper implementation from the team, this is just a patch for my work, thanks!

Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions