bevy/crates/bevy_pbr/src
Robert Swain 84991d34f3 Array texture example (#5077)
# Objective

- Make the reusable PBR shading functionality a little more reusable
  - Add constructor functions for `StandardMaterial` and `PbrInput` structs to populate them with default values
  - Document unclear `PbrInput` members
- Demonstrate how to reuse the bevy PBR shading functionality
- The final important piece from #3969 as the initial shot at making the PBR shader code reusable in custom materials

## Solution

- Add back and rework the 'old' `array_texture` example from pre-0.6.
- Create a custom shader material
  - Use a single array texture binding and sampler for the material bind group
  - Use a shader that calls `pbr()` from the `bevy_pbr::pbr_functions` import
- Spawn a row of cubes using the custom material
- In the shader, select the array texture layer to sample by using the world position x coordinate modulo the number of array texture layers

<img width="1392" alt="Screenshot 2022-06-23 at 12 28 05" src="https://user-images.githubusercontent.com/302146/175278593-2296f519-f577-4ece-81c0-d842283784a1.png">

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2022-06-28 00:58:50 +00:00
..
render Array texture example (#5077) 2022-06-28 00:58:50 +00:00
alpha.rs add #[reflect(Default)] to create default value for reflected types (#3733) 2022-05-03 19:20:13 +00:00
bundle.rs add Visibility for lights (#3958) 2022-03-05 03:23:01 +00:00
lib.rs Callable PBR functions (#4939) 2022-06-21 20:50:06 +00:00
light.rs Camera Driven Viewports (#4898) 2022-06-05 00:27:49 +00:00
material.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
pbr_material.rs Split mesh shader files (#4867) 2022-05-31 23:23:25 +00:00
wireframe.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00