-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
base: main
Are you sure you want to change the base?
TilemapChunk single quad; TileData (color/visibility) #19924
Conversation
058304a
to
edbc343
Compare
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. |
edbc343
to
5e026ef
Compare
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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]
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
}
There was a problem hiding this comment.
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.
cb566bf
to
aa512c7
Compare
aa512c7
to
606bcb4
Compare
Objective
Testing