Description
What problem does this solve or what need does it fill?
It seems that it is currently impossible to use vertex colors (Mesh::ATTRIBUTE_COLOR) without a texture in the 2D Color Material.
I currently have two use cases for this, one is drawing flat colored meshes, the other is in my debug renderer.
What solution would you like?
I would like vertex colors to have an effect even if no texture is applied to the ColorMaterial.
I'm new to bevy and WGSL but at least from a quick test it looks like this can be achieved by a simple change to the fragment shader:
@fragment
fn fragment(in: FragmentInput) -> @location(0) vec4<f32> {
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) {
output_color = output_color * textureSample(texture, texture_sampler, in.uv);
}
return output_color;
}
What alternative(s) have you considered?
The alternative is to use a white texture to make vertex colors work. :))
Additional context
I couldn't come up with a good reason why it shouldn't be possible to use vertex colors without a texture but I might be missing something.
Happy to create a PR if this is considered desirable behavior in bevy.