bevyengine / bevyengine/bevy

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

Open
#3,604 6 comments 0 reactions 0 assignees View on GitHub
A-Rendering C-Bug
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
4d 8m
Merged PRs (30d)
147

Description

## 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](https://camo.githubusercontent.com/16fb9b7c05185a0a083ee6dcec18e4988d37597e0a92bd25711fbfb7bf2912a1/68747470733a2f2f692e696d6775722e636f6d2f3068776f6554562e706e67)

## What actually happened

One triangle, standing. (Pictured: Same mesh code in 0.6.0)
![0.6.0](https://camo.githubusercontent.com/1f5f559996ef56baeb407a1c129776b26c75784ec3879d0aa97886c464b6ace8/68747470733a2f2f692e696d6775722e636f6d2f75654c6d526b5a2e706e67)

## 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](https://media.discordapp.net/attachments/929632185760219197/929632811625881630/bevy_bad.jpg?width=2588&height=1456)

# The Culprit!

It's this line here: https://github.com/WAFFO/bevy_0.6.0_mesh_issue/blob/v6/src/main.rs#L83
```rust
let uvs = vec![[0.0, 0.0, 0.0]; vertices.len()];
```
Change it from a `[f32; 3]` to a `[f32; 2]`
```rust
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!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.