-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Merged by Bors] - Fix mesh2d_manual example #4037
Conversation
// This is the sum of the size of position and color attributes (12 + 16 = 28) | ||
let vertex_array_stride = 28; | ||
|
||
let vertex_layout = |
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.
Much more robust!
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.
Much more robust and clear than before, and confirmed to fix the issue. I'm unsure about the color question, but otherwise this LGTM.
I updated the description with slightly more info about the color situation. |
@bevyengine/rendering-team, can I get a review from one of y'all? Then I'll be able to merge this in to fix the broken example :) |
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.
It feels clunky that ATTRIBUTE_COLOR
is a u32
but that's not your fault.
That said, it feels like it would be nicer to have Color::as_rgba_u32(self: Color) -> u32
and Color::as_linear_rgba_u32(self: Color) -> u32
to support use of ATTRIBUTE_COLOR
.
|
# Objective - `Mesh::ATTRIBUTE_COLOR` expects colors as `u32`s but there is no function for easy conversion. - See #4037 (review) ## Solution - Added `Color::as_rgba_u32` and `Color::as_linear_rgba_u32`
5744410
to
3cccfd0
Compare
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.
We definitely need shader utilities for handling conversion back to vec4, but that's for another time. This works well as an example.
@@ -243,7 +230,7 @@ fn vertex(vertex: Vertex) -> VertexOutput { | |||
var out: VertexOutput; | |||
// Project the world position of the mesh into screen position | |||
out.clip_position = view.view_proj * mesh.model * vec4<f32>(vertex.position, 1.0); | |||
out.color = vertex.color; | |||
out.color = vec4<f32>((vec4<u32>(vertex.color) >> vec4<u32>(0u, 8u, 16u, 24u)) & vec4<u32>(255u)) / 255.0; |
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.
a comment explaining this line could be nice
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.
I'm not sure that I can adequately explain the process, but I added a comment that hopefully communicates the intent of the code.
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.
good enough for me, thanks!
bors r+ |
# Objective Fixes #4036 ## Solution - Use `VertexBufferLayout::from_vertex_formats` - Actually put a u32 into `ATTRIBUTE_COLOR` and convert it in the shader I'm not 100% sure about the color stuff. It seems like `ATTRIBUTE_COLOR` has been `Uint32` this whole time, but this example previously worked with `[f32; 4]` somehow, perhaps because the vertex layout was manually specified. Let me know if that can be improved, or feel free to close for an alternative fix.
# Objective - `Mesh::ATTRIBUTE_COLOR` expects colors as `u32`s but there is no function for easy conversion. - See bevyengine#4037 (review) ## Solution - Added `Color::as_rgba_u32` and `Color::as_linear_rgba_u32`
# Objective Fixes bevyengine#4036 ## Solution - Use `VertexBufferLayout::from_vertex_formats` - Actually put a u32 into `ATTRIBUTE_COLOR` and convert it in the shader I'm not 100% sure about the color stuff. It seems like `ATTRIBUTE_COLOR` has been `Uint32` this whole time, but this example previously worked with `[f32; 4]` somehow, perhaps because the vertex layout was manually specified. Let me know if that can be improved, or feel free to close for an alternative fix.
# Objective - `Mesh::ATTRIBUTE_COLOR` expects colors as `u32`s but there is no function for easy conversion. - See bevyengine#4037 (review) ## Solution - Added `Color::as_rgba_u32` and `Color::as_linear_rgba_u32`
# Objective Fixes bevyengine#4036 ## Solution - Use `VertexBufferLayout::from_vertex_formats` - Actually put a u32 into `ATTRIBUTE_COLOR` and convert it in the shader I'm not 100% sure about the color stuff. It seems like `ATTRIBUTE_COLOR` has been `Uint32` this whole time, but this example previously worked with `[f32; 4]` somehow, perhaps because the vertex layout was manually specified. Let me know if that can be improved, or feel free to close for an alternative fix.
Objective
Fixes #4036
Solution
VertexBufferLayout::from_vertex_formats
ATTRIBUTE_COLOR
and convert it in the shaderI'm not 100% sure about the color stuff. It seems like
ATTRIBUTE_COLOR
has beenUint32
this whole time, but this example previously worked with[f32; 4]
somehow, perhaps because the vertex layout was manually specified.Let me know if that can be improved, or feel free to close for an alternative fix.