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

UV of Float32x3 causes GPU buffer issue in 0.6.0 (works fine in 0.5.0) #3604

Open
WAFFO opened this issue Jan 9, 2022 · 6 comments
Open
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior

Comments

@WAFFO
Copy link

WAFFO commented Jan 9, 2022

Bevy version

Release 0.6.0

Operating system & version

Tested: Windows 10, MacOS 12.1

What you did

Follow duplication steps in https://github.com/WAFFO/bevy_0.6.0_mesh_issue

I originally ran into this issue migrating my project and encountered a computer killing monster where my heightmap mesh once was. (Pictured below)

This was OS breaking, and I had to hold my power button to escape.

What you expected to happen

To draw a flat square made of two triangles, 4 vertices. (Pictured: 0.5.0)
0.5.0

What actually happened

One triangle, standing. (Pictured: Same mesh code in 0.6.0)
0.6.0

Additional information

If the mesh is really big (like for a heightmap) my computer comes to a halt and I have to hold the power button to reset. I suspect something is not aligned in the GPU buffer.

my poor macbook

The Culprit!

It's this line here: https://github.com/WAFFO/bevy_0.6.0_mesh_issue/blob/v6/src/main.rs#L83

let uvs = vec![[0.0, 0.0, 0.0]; vertices.len()];

Change it from a [f32; 3] to a [f32; 2]

let uvs = vec![[0.0, 0.0]; vertices.len()];

And now it works perfectly!

This shouldn't be allowed to happen :(

It took a long time for me to figure out why my mesh was breaking in 0.6.0.

Since it worked in 0.5.0, I have to ask if it's intended for [f32; 3] to not work for the UV attribute. If so, a type check or some error is needed. Otherwise, it's a bug!

@WAFFO WAFFO added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jan 9, 2022
@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen and removed S-Needs-Triage This issue needs to be labelled labels Jan 9, 2022
@ruabmbua
Copy link

ruabmbua commented Jan 9, 2022

Nice find. This also killed my voxel renderer!
Very confusing to debug, since I also had reduced it to one plane, and it generated a standing triangle, which should be impossible, because I did not have any varying vertex in y-plane.

@sdfgeoff
Copy link
Contributor

sdfgeoff commented Jan 18, 2022

Same issue occurs if UV attribute does not exist.

sdfgeoff added a commit to sdfgeoff/blender_bevy_toolkit that referenced this issue Jan 18, 2022
@sdfgeoff
Copy link
Contributor

Same issue occurs if TANGENT attribute is not a vec4

@mockersf
Copy link
Member

should be fixed by #3959

@cart
Copy link
Member

cart commented Feb 16, 2022

Kind of sort of. That enables flexible layouts, but it also standardizes the formats of specific vertex attributes. Mesh::ATTRIBUTE_POSITION must be a vec3. Mesh::ATTRIBUTE_UV_0 must be a vec2. This is because shaders expect specific attributes / sizes.

Users are free to create a new "three dimensional" UV attribute and use that in their custom shaders with custom meshes. They can even use that in our built in shaders (provided they also provide a 2d UV attribute). But we cant (and won't) allow using three dimensional uvs in places where our core shaders expect two dimensional uvs. Same goes for all of the "core" vertex attributes defined on Mesh.

@cart
Copy link
Member

cart commented Feb 16, 2022

I guess "can't" and "won't" are strong words. I'm open to discussing solutions to specific scenarios.

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-Bug An unexpected or incorrect behavior
Projects
None yet
Development

No branches or pull requests

6 participants