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

Custom material always requires vertex position, normal and UV #5147

Open
afonsolage opened this issue Jun 30, 2022 · 2 comments
Open

Custom material always requires vertex position, normal and UV #5147

afonsolage opened this issue Jun 30, 2022 · 2 comments
Labels
A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use

Comments

@afonsolage
Copy link
Contributor

Bevy version

0.7

What you did

Created a custom material without using Vertex_UV attribute

What went wrong

The custom material requires vertex POSITION, NORMAL and UV attributes to be set on Mesh even if the custom material layout doesn't specifies so. This seems to be a requirement of the mesh pipeline.

Additional information

This was first reported and discussed here

superdump

This passes the mesh layout into the mesh pipeline specialization function:

let mut descriptor = self.mesh_pipeline.specialize(key.mesh_key, layout)?;

Which requires these attributes:
let mut vertex_attributes = vec![

So even if you want to override the vertex attributes and layout, that code already required them and if your mesh doesn’t have them, it will fail

cart

Gotcha that makes sense. Fixing that will probably require some design work. Ex: do we build an api to let people override vertex layouts (specifically), or add a lifecycle hook that allows people to specialize the mesh pipeline. Do we add another generic to MeshPipeline that lets users plug their custom logic in or take a more retroactive approach?

@afonsolage afonsolage added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jun 30, 2022
@kulkalkul
Copy link

I also encountered this, alternative to this is writing a pipeline, which is a lot boilerplate. Here it is for reference:
https://discord.com/channels/691052431525675048/970964103516532746/970998522679816222

@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use and removed S-Needs-Triage This issue needs to be labelled C-Bug An unexpected or incorrect behavior labels Jun 30, 2022
@nicopap
Copy link
Contributor

nicopap commented Apr 16, 2023

Seems to be fixed in 0.10. Am I mistaken? in mesh.wgsl I see all vertex attributes are conditionally added.

struct Vertex {
#ifdef VERTEX_POSITIONS
    @location(0) position: vec3<f32>,
#endif
#ifdef VERTEX_NORMALS
    @location(1) normal: vec3<f32>,
#endif
#ifdef VERTEX_UVS
    @location(2) uv: vec2<f32>,
#endif
#ifdef VERTEX_TANGENTS
    @location(3) tangent: vec4<f32>,
#endif
#ifdef VERTEX_COLORS
    @location(4) color: vec4<f32>,
#endif
#ifdef SKINNED
    @location(5) joint_indices: vec4<u32>,
    @location(6) joint_weights: vec4<f32>,
#endif
};

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-Usability A targeted quality-of-life change that makes Bevy easier to use
Projects
None yet
Development

No branches or pull requests

4 participants