Skip to content

0.12 Migration: Reduce the size of MeshUniform section shader code is broken #824

@rparrett

Description

@rparrett

affine_to_square isn't even in mesh_functions anymore. It was moved in bevyengine/bevy#9597.

But also, it seems that you want to use mesh_functions::get_model_matrix for this now instead, due to it handling the details of some workaround for some DX12 bug.

Relevant bit of the migration guide:

`MeshUniform` now stores its current and previous model transforms as 4x3 matrices. Helper functions were added to bevy_pbr::mesh_functions to unpack the data.
```rust
// 0.11
var model = mesh[instance_index].model;
// 0.12
#import bevy_pbr::mesh_functions::affine_to_square
var model = affine_to_square(mesh[instance_index].model);
```

Relevant text from Discord:

robswain — Today at 7:11 AM
yes. i'd recommend doing what mesh.wgsl does (if i'm remembering the correct file)

robswain — Today at 7:12 AM
https://github.com/bevyengine/bevy/blob/4852fc7578b7a55db4c05a6fb9f8ebdd290571e1/crates/bevy_pbr/src/render/mesh.wgsl#L46
https://github.com/bevyengine/bevy/blob/4852fc7578b7a55db4c05a6fb9f8ebdd290571e1/crates/bevy_pbr/src/render/mesh_functions.wgsl#L15

robswain — Today at 7:27 AM
and if you want to see a bit more about what the problem with instance index is, there's a comment here: https://github.com/bevyengine/bevy/blob/main/crates/bevy_render/src/instance_index.wgsl
get_model_matrix was to abstract that away and give people something simpler to use

mesh[vertex.instance_index].model seems to show up elsewhere in the migration guide as well...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions