Skip to content

Instance mesh coordinates are changing #11097

Open
@wk39

Description

@wk39

Bevy version

0.12.1

Relevant system information

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

`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

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<f32>(position, 1.0)
);

// changed
out.clip_position = mesh_position_local_to_clip(
        mat4x4<f32>(
            vec4<f32>(1.0, 0.0, 0.0, 0.0),
            vec4<f32>(0.0, 1.0, 0.0, 0.0),
            vec4<f32>(0.0, 0.0, 1.0, 0.0),
            vec4<f32>(0.0, 0.0, 0.0, 1.0)
        ),
        vec4<f32>(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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-BugAn unexpected or incorrect behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions