forked from bevyengine/bevy
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split mesh shader files (bevyengine#4867)
# Objective - Split PBR and 2D mesh shaders into types and bindings to prepare the shaders to be more reusable. - See bevyengine#3969 for details. I'm doing this in multiple steps to make review easier. --- ## Changelog - Changed: 2D and PBR mesh shaders are now split into types and bindings, the following shader imports are available: `bevy_pbr::mesh_view_types`, `bevy_pbr::mesh_view_bindings`, `bevy_pbr::mesh_types`, `bevy_pbr::mesh_bindings`, `bevy_sprite::mesh2d_view_types`, `bevy_sprite::mesh2d_view_bindings`, `bevy_sprite::mesh2d_types`, `bevy_sprite::mesh2d_bindings` ## Migration Guide - In shaders for 3D meshes: - `#import bevy_pbr::mesh_view_bind_group` -> `#import bevy_pbr::mesh_view_bindings` - `#import bevy_pbr::mesh_struct` -> `#import bevy_pbr::mesh_types` - NOTE: If you are using the mesh bind group at bind group index 2, you can remove those binding statements in your shader and just use `#import bevy_pbr::mesh_bindings` which itself imports the mesh types needed for the bindings. - In shaders for 2D meshes: - `#import bevy_sprite::mesh2d_view_bind_group` -> `#import bevy_sprite::mesh2d_view_bindings` - `#import bevy_sprite::mesh2d_struct` -> `#import bevy_sprite::mesh2d_types` - NOTE: If you are using the mesh2d bind group at bind group index 2, you can remove those binding statements in your shader and just use `#import bevy_sprite::mesh2d_bindings` which itself imports the mesh2d types needed for the bindings.
- Loading branch information
Showing
26 changed files
with
207 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#define_import_path bevy_pbr::mesh_bindings | ||
|
||
#import bevy_pbr::mesh_types | ||
|
||
[[group(2), binding(0)]] | ||
var<uniform> mesh: Mesh; | ||
#ifdef SKINNED | ||
[[group(2), binding(1)]] | ||
var<uniform> joint_matrices: SkinnedMesh; | ||
#import bevy_pbr::skinning | ||
#endif |
2 changes: 1 addition & 1 deletion
2
crates/bevy_pbr/src/render/mesh_struct.wgsl → crates/bevy_pbr/src/render/mesh_types.wgsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#define_import_path bevy_pbr::mesh_view_bindings | ||
|
||
#import bevy_pbr::mesh_view_types | ||
|
||
[[group(0), binding(0)]] | ||
var<uniform> view: View; | ||
[[group(0), binding(1)]] | ||
var<uniform> lights: Lights; | ||
#ifdef NO_ARRAY_TEXTURES_SUPPORT | ||
[[group(0), binding(2)]] | ||
var point_shadow_textures: texture_depth_cube; | ||
#else | ||
[[group(0), binding(2)]] | ||
var point_shadow_textures: texture_depth_cube_array; | ||
#endif | ||
[[group(0), binding(3)]] | ||
var point_shadow_textures_sampler: sampler_comparison; | ||
#ifdef NO_ARRAY_TEXTURES_SUPPORT | ||
[[group(0), binding(4)]] | ||
var directional_shadow_textures: texture_depth_2d; | ||
#else | ||
[[group(0), binding(4)]] | ||
var directional_shadow_textures: texture_depth_2d_array; | ||
#endif | ||
[[group(0), binding(5)]] | ||
var directional_shadow_textures_sampler: sampler_comparison; | ||
|
||
#ifdef NO_STORAGE_BUFFERS_SUPPORT | ||
[[group(0), binding(6)]] | ||
var<uniform> point_lights: PointLights; | ||
[[group(0), binding(7)]] | ||
var<uniform> cluster_light_index_lists: ClusterLightIndexLists; | ||
[[group(0), binding(8)]] | ||
var<uniform> cluster_offsets_and_counts: ClusterOffsetsAndCounts; | ||
#else | ||
[[group(0), binding(6)]] | ||
var<storage> point_lights: PointLights; | ||
[[group(0), binding(7)]] | ||
var<storage> cluster_light_index_lists: ClusterLightIndexLists; | ||
[[group(0), binding(8)]] | ||
var<storage> cluster_offsets_and_counts: ClusterOffsetsAndCounts; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#define_import_path bevy_pbr::pbr_bindings | ||
|
||
#import bevy_pbr::pbr_types | ||
|
||
[[group(1), binding(0)]] | ||
var<uniform> material: StandardMaterial; | ||
[[group(1), binding(1)]] | ||
var base_color_texture: texture_2d<f32>; | ||
[[group(1), binding(2)]] | ||
var base_color_sampler: sampler; | ||
[[group(1), binding(3)]] | ||
var emissive_texture: texture_2d<f32>; | ||
[[group(1), binding(4)]] | ||
var emissive_sampler: sampler; | ||
[[group(1), binding(5)]] | ||
var metallic_roughness_texture: texture_2d<f32>; | ||
[[group(1), binding(6)]] | ||
var metallic_roughness_sampler: sampler; | ||
[[group(1), binding(7)]] | ||
var occlusion_texture: texture_2d<f32>; | ||
[[group(1), binding(8)]] | ||
var occlusion_sampler: sampler; | ||
[[group(1), binding(9)]] | ||
var normal_map_texture: texture_2d<f32>; | ||
[[group(1), binding(10)]] | ||
var normal_map_sampler: sampler; |
Oops, something went wrong.