-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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] - Make vertex colors work without textures in bevy_sprite #5685
Conversation
Improved the example a bit. Before I was cloning the entire mesh to use it in two entities, now I'm only cloning the handle. |
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 think updating the example is a good call.
var output_color: vec4<f32> = material.color; | ||
#ifdef VERTEX_COLORS | ||
output_color = output_color * in.color; | ||
#endif | ||
if ((material.flags & COLOR_MATERIAL_FLAGS_TEXTURE_BIT) != 0u) { | ||
#ifdef VERTEX_COLORS | ||
output_color = output_color * textureSample(texture, texture_sampler, in.uv) * in.color; | ||
#else | ||
output_color = output_color * textureSample(texture, texture_sampler, in.uv); | ||
#endif | ||
} | ||
return output_color; |
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 think you should keep the #ifdef
and #endif
start of line for consistency with all other shader 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 point, pushed an update.
// Spawn the quad with vertex colors | ||
commands.spawn_bundle(MaterialMesh2dBundle { | ||
mesh: mesh_handle.clone(), | ||
transform: Transform::default() |
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.
This could use from_translation
.
Same for below :)
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.
Thanks for the hint. Changed it.
bors r+ |
# Objective This PR changes it possible to use vertex colors without a texture using the bevy_sprite ColorMaterial. Fixes #5679 ## Solution - Made multiplication of the output color independent of the COLOR_MATERIAL_FLAGS_TEXTURE_BIT bit - Extended mesh2d_vertex_color_texture example to show off both vertex colors and tinting Not sure if extending the existing example was the right call but it seems to be reasonable to me. I couldn't find any tests for the shaders and I think adding shader testing would be beyond the scope of this PR. So no tests in this PR. 😬 Co-authored-by: Jonas Wagner <jonas@29a.ch>
Pull request successfully merged into main. Build succeeded: |
) # Objective This PR changes it possible to use vertex colors without a texture using the bevy_sprite ColorMaterial. Fixes bevyengine#5679 ## Solution - Made multiplication of the output color independent of the COLOR_MATERIAL_FLAGS_TEXTURE_BIT bit - Extended mesh2d_vertex_color_texture example to show off both vertex colors and tinting Not sure if extending the existing example was the right call but it seems to be reasonable to me. I couldn't find any tests for the shaders and I think adding shader testing would be beyond the scope of this PR. So no tests in this PR. 😬 Co-authored-by: Jonas Wagner <jonas@29a.ch>
) # Objective This PR changes it possible to use vertex colors without a texture using the bevy_sprite ColorMaterial. Fixes bevyengine#5679 ## Solution - Made multiplication of the output color independent of the COLOR_MATERIAL_FLAGS_TEXTURE_BIT bit - Extended mesh2d_vertex_color_texture example to show off both vertex colors and tinting Not sure if extending the existing example was the right call but it seems to be reasonable to me. I couldn't find any tests for the shaders and I think adding shader testing would be beyond the scope of this PR. So no tests in this PR. 😬 Co-authored-by: Jonas Wagner <jonas@29a.ch>
) # Objective This PR changes it possible to use vertex colors without a texture using the bevy_sprite ColorMaterial. Fixes bevyengine#5679 ## Solution - Made multiplication of the output color independent of the COLOR_MATERIAL_FLAGS_TEXTURE_BIT bit - Extended mesh2d_vertex_color_texture example to show off both vertex colors and tinting Not sure if extending the existing example was the right call but it seems to be reasonable to me. I couldn't find any tests for the shaders and I think adding shader testing would be beyond the scope of this PR. So no tests in this PR. 😬 Co-authored-by: Jonas Wagner <jonas@29a.ch>
Objective
This PR changes it possible to use vertex colors without a texture using the bevy_sprite ColorMaterial.
Fixes #5679
Solution
Not sure if extending the existing example was the right call but it seems to be reasonable to me.
I couldn't find any tests for the shaders and I think adding shader testing would be beyond the scope of this PR. So no tests in this PR. 😬