bevyengine / bevyengine/bevy

Instance mesh coordinates are changing

Open
#11,097 4 comments 0 reactions 0 assignees View on GitHub
A-Rendering C-Bug
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## Bevy version

0.12.1

## Relevant system information

cargo 1.74.0 (ecb9851af 2023-10-18)
Ubuntu 22.04

```ignore
`AdapterInfo { name: "NVIDIA GeForce RTX 2080 Ti", vendor: 4318, device: 7684, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "535.129.03", backend: Vulkan }`
```

## What you did

I added some PBR mesh in the **examples/shader/shader_instancing.rs**.

## What went wrong

When I add a PBR Mesh, there is an issue where the coordinates of the instance mesh are changing.

![Peek 2023-12-27 15-37](https://github.com/bevyengine/bevy/assets/30580945/1ce531e7-5fc5-41cd-8573-ea6379f101e3)

## Additional information

After several trial and error attempts, I modified 'instancing.wgsl' as follows:

```
// original
out.clip_position = mesh_position_local_to_clip(
get_model_matrix(0u), vec4(position, 1.0)
);

// changed
out.clip_position = mesh_position_local_to_clip(
mat4x4(
vec4(1.0, 0.0, 0.0, 0.0),
vec4(0.0, 1.0, 0.0, 0.0),
vec4(0.0, 0.0, 1.0, 0.0),
vec4(0.0, 0.0, 0.0, 1.0)
),
vec4(position, 1.0)
);
```

by forcing model_matrix as identity it resolved.

Modified example to reproduce this issue is here:

https://github.com/wk39/temporary/blob/4acf99b967d3f5ab678177502db71523eb0f2e59/shader_instancing.rs

Be careful. bevy version is v0.12.1
(shader_instancing.rs in latest commit has some change)

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.