Skip to content

TilemapChunk single quad; TileData (color/visibility) #19924

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ConnerPetzold
Copy link
Contributor

Objective

  • Use a single quad to render a TilemapChunk
  • Add support for tile color and visibility

Testing

  • Tested using example -- there doesn't appear to be any visual tile bleeding or rounding issues. Open to ideas on further testing

@ConnerPetzold ConnerPetzold force-pushed the tilemap-chunk-single-quad branch from 058304a to edbc343 Compare July 2, 2025 03:36
@alice-i-cecile alice-i-cecile added the A-Rendering Drawing game state to the screen label Jul 2, 2025
@alice-i-cecile alice-i-cecile added C-Feature A new feature, making something new possible M-Needs-Release-Note Work that should be called out in the blog due to impact S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jul 2, 2025
@alice-i-cecile alice-i-cecile added this to the 0.17 milestone Jul 2, 2025
Copy link
Contributor

github-actions bot commented Jul 2, 2025

It looks like your PR has been selected for a highlight in the next release blog post, but you didn't provide a release note.

Please review the instructions for writing release notes, then expand or revise the content in the release notes directory to showcase your changes.

@atlv24 atlv24 self-requested a review July 8, 2025 19:59
@ConnerPetzold ConnerPetzold force-pushed the tilemap-chunk-single-quad branch from edbc343 to 5e026ef Compare July 8, 2025 20:11
tileset_index: u16,
flags: u16, // flags (visibility, etc.)
color_red_green: u16, // r in low 8 bits, g in high 8 bits
color_blue_alpha: u16, // b in low 8 bits, a in high 8 bits
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this type is repr(C) and it's being transmuted to be sent to the GPU (from my understanding), could RGBA be stored in 4 separate bytes? Or is there something about endianness or something else I'm missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah good point -- maybe just do color: [u8; 4]?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh right, I remember why I wrote it this way to begin with, although it's not super clear.. I wanted to make it more obvious that this was mapping to a Rgba16Uint texture, so each of these fields is one of the color channels. I guess the same can be accomplished with comments though. I'd love a clearer way to accomplish this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe something like this?

#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct PackedTileData {
    tileset_index: u16, // red channel
    color: [u8; 4], // green and blue channels
    flags: u16, // alpha channel
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, admittedly that took me a while to understand. With the doc comment on the type it's definitely clearer.

@ConnerPetzold ConnerPetzold force-pushed the tilemap-chunk-single-quad branch 2 times, most recently from cb566bf to aa512c7 Compare July 9, 2025 06:40
@ConnerPetzold ConnerPetzold force-pushed the tilemap-chunk-single-quad branch from aa512c7 to 606bcb4 Compare July 9, 2025 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible M-Needs-Release-Note Work that should be called out in the blog due to impact S-Needs-Review Needs reviewer attention (from anyone!) to move forward
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants