Skip to content
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] - Apply vertex colors to ColorMaterial and Mesh2D #4812

Closed
wants to merge 4 commits into from

Conversation

thebracket
Copy link
Contributor

Objective

Solution

  • Added #ifdef wrapped support for vertex colors in the 2D mesh shader and ColorMaterial shader.
  • Added an example, mesh2d_vertex_color_texture to demonstrate it in action.

image


Changelog

  • Added optional (ifdef wrapped) vertex color support to the 2dmesh and color material systems.

…outputs. Add an example demonstrating it in action.
@thebracket
Copy link
Contributor Author

This is my first try at submitting a PR to Bevy. I hope I did it properly! Thanks for all your hard work.

@alice-i-cecile alice-i-cecile added C-Enhancement A new feature A-Rendering Drawing game state to the screen labels May 20, 2022
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

Just some comments on clarifying the example :) Change itself makes sense; I'm impressed at how easy this was to add.

@@ -0,0 +1,39 @@
//! Shows how to render a polygonal [`Mesh`], generated from a [`Quad`] primitive, in a 2D scene.
Copy link
Member

Choose a reason for hiding this comment

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

This should mention the colored vertexes presumably.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added a second line (the first is copied from the mesh2d example). I wasn't sure how to reference the other example, if that's preferred.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I don't think there's a need to crosslink examples. I'm happy with this description now.

// Build a default quad mesh
let mut mesh = Mesh::from(shape::Quad::default());
// Build vertex colors for the quad
let vertex_colors: Vec<[f32; 4]> = vec![
Copy link
Member

Choose a reason for hiding this comment

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

This matrix is a little inscrutable for beginners. What do these numbers mean?

I can guess that they're RGBA, with each row representing another vertex, but beginners won't be able to guess that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, so I've replaced them with a much more readable Color::RED.as_rgba_f32(). Thanks!

@thebracket
Copy link
Contributor Author

Hopefully the last couple of commits resolved things: it removed a needless clone of texture_handle, added the example to the examples README, expanded the header of the example (it's basically the mesh2d example with colors and a texture added), and replaced the inscrutable [f32; 4] colors (they are RGBA quads) with named colors.

Copy link

@dyc3 dyc3 left a comment

Choose a reason for hiding this comment

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

Seems pretty straightforward. LGTM!

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label May 20, 2022
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

bors r+

bors bot pushed a commit that referenced this pull request May 30, 2022
# Objective

- Add Vertex Color support to 2D meshes and ColorMaterial. This extends the work from #4528 (which in turn builds on the excellent tangent handling).

## Solution

- Added `#ifdef` wrapped support for vertex colors in the 2D mesh shader and `ColorMaterial` shader.
- Added an example, `mesh2d_vertex_color_texture` to demonstrate it in action.

![image](https://user-images.githubusercontent.com/14896751/169530930-6ae0c6be-2f69-40e3-a600-ba91d7178bc3.png)


---

## Changelog

- Added optional (ifdef wrapped) vertex color support to the 2dmesh and color material systems.
@bors bors bot changed the title Apply vertex colors to ColorMaterial and Mesh2D [Merged by Bors] - Apply vertex colors to ColorMaterial and Mesh2D May 30, 2022
@bors bors bot closed this May 30, 2022
james7132 pushed a commit to james7132/bevy that referenced this pull request Jun 7, 2022
# Objective

- Add Vertex Color support to 2D meshes and ColorMaterial. This extends the work from bevyengine#4528 (which in turn builds on the excellent tangent handling).

## Solution

- Added `#ifdef` wrapped support for vertex colors in the 2D mesh shader and `ColorMaterial` shader.
- Added an example, `mesh2d_vertex_color_texture` to demonstrate it in action.

![image](https://user-images.githubusercontent.com/14896751/169530930-6ae0c6be-2f69-40e3-a600-ba91d7178bc3.png)


---

## Changelog

- Added optional (ifdef wrapped) vertex color support to the 2dmesh and color material systems.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
# Objective

- Add Vertex Color support to 2D meshes and ColorMaterial. This extends the work from bevyengine#4528 (which in turn builds on the excellent tangent handling).

## Solution

- Added `#ifdef` wrapped support for vertex colors in the 2D mesh shader and `ColorMaterial` shader.
- Added an example, `mesh2d_vertex_color_texture` to demonstrate it in action.

![image](https://user-images.githubusercontent.com/14896751/169530930-6ae0c6be-2f69-40e3-a600-ba91d7178bc3.png)


---

## Changelog

- Added optional (ifdef wrapped) vertex color support to the 2dmesh and color material systems.
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-Enhancement A new feature S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants