bevy/crates
robtfm 10f5c92068
improve shader import model (#5703)
# Objective

operate on naga IR directly to improve handling of shader modules.
- give codespan reporting into imported modules
- allow glsl to be used from wgsl and vice-versa

the ultimate objective is to make it possible to 
- provide user hooks for core shader functions (to modify light
behaviour within the standard pbr pipeline, for example)
- make automatic binding slot allocation possible

but ... since this is already big, adds some value and (i think) is at
feature parity with the existing code, i wanted to push this now.

## Solution

i made a crate called naga_oil (https://github.com/robtfm/naga_oil -
unpublished for now, could be part of bevy) which manages modules by
- building each module independantly to naga IR
- creating "header" files for each supported language, which are used to
build dependent modules/shaders
- make final shaders by combining the shader IR with the IR for imported
modules

then integrated this into bevy, replacing some of the existing shader
processing stuff. also reworked examples to reflect this.

## Migration Guide

shaders that don't use `#import` directives should work without changes.

the most notable user-facing difference is that imported
functions/variables/etc need to be qualified at point of use, and
there's no "leakage" of visible stuff into your shader scope from the
imports of your imports, so if you used things imported by your imports,
you now need to import them directly and qualify them.

the current strategy of including/'spreading' `mesh_vertex_output`
directly into a struct doesn't work any more, so these need to be
modified as per the examples (e.g. color_material.wgsl, or many others).
mesh data is assumed to be in bindgroup 2 by default, if mesh data is
bound into bindgroup 1 instead then the shader def `MESH_BINDGROUP_1`
needs to be added to the pipeline shader_defs.
2023-06-27 00:29:22 +00:00
..
bevy_a11y Require #[derive(Event)] on all Events (#7086) 2023-06-06 14:44:32 +00:00
bevy_animation Add morph targets (#8158) 2023-06-22 20:00:01 +00:00
bevy_app Allow tuples and single plugins in add_plugins, deprecate add_plugin (#8097) 2023-06-21 20:51:03 +00:00
bevy_asset improve shader import model (#5703) 2023-06-27 00:29:22 +00:00
bevy_audio Allow tuples and single plugins in add_plugins, deprecate add_plugin (#8097) 2023-06-21 20:51:03 +00:00
bevy_core Allow tuples and single plugins in add_plugins, deprecate add_plugin (#8097) 2023-06-21 20:51:03 +00:00
bevy_core_pipeline improve shader import model (#5703) 2023-06-27 00:29:22 +00:00
bevy_derive bevy_derive: Add #[deref] attribute (#8552) 2023-05-16 18:29:09 +00:00
bevy_diagnostic Allow tuples and single plugins in add_plugins, deprecate add_plugin (#8097) 2023-06-21 20:51:03 +00:00
bevy_dylib Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
bevy_dynamic_plugin Remove stray boilerplate line in bevy_dynamic_plugin/Cargo.toml (#8830) 2023-06-12 19:10:48 +00:00
bevy_ecs Add/fix track_caller attribute on panicking entity accessor methods (#8951) 2023-06-26 18:35:11 +00:00
bevy_ecs_compile_fail_tests Resolve clippy issues for rust 1.70.0 (#8738) 2023-06-01 21:05:05 +00:00
bevy_encase_derive update syn, encase, glam and hexasphere (#8573) 2023-05-16 01:24:17 +00:00
bevy_gilrs Add gamepad rumble support to bevy_input (#8398) 2023-04-24 15:28:53 +00:00
bevy_gizmos improve shader import model (#5703) 2023-06-27 00:29:22 +00:00
bevy_gltf Add morph targets (#8158) 2023-06-22 20:00:01 +00:00
bevy_hierarchy Change despawn_descendants to return &mut Self (#8928) 2023-06-23 02:08:13 +00:00
bevy_input Add get_unclamped to Axis (#8871) 2023-06-19 23:06:11 +00:00
bevy_internal Instanced line rendering for gizmos based on bevy_polyline (#8427) 2023-06-13 06:49:47 +00:00
bevy_log log to stderr instead of stdout (#8886) 2023-06-19 23:36:02 +00:00
bevy_macro_utils update syn, encase, glam and hexasphere (#8573) 2023-05-16 01:24:17 +00:00
bevy_macros_compile_fail_tests bevy_derive: Add #[deref] attribute (#8552) 2023-05-16 18:29:09 +00:00
bevy_math Add integer equivalents for Rect (#7984) 2023-06-12 19:10:48 +00:00
bevy_mikktspace update syn, encase, glam and hexasphere (#8573) 2023-05-16 01:24:17 +00:00
bevy_pbr improve shader import model (#5703) 2023-06-27 00:29:22 +00:00
bevy_ptr Fixed several missing links in docs. (#8117) 2023-04-23 17:28:36 +00:00
bevy_reflect Don't ignore additional entries in UntypedReflectDeserializerVisitor (#7112) 2023-06-26 19:32:27 +00:00
bevy_reflect_compile_fail_tests reflect: stable type path v2 (#7184) 2023-06-05 20:31:20 +00:00
bevy_render improve shader import model (#5703) 2023-06-27 00:29:22 +00:00
bevy_scene Move AppTypeRegistry to bevy_ecs (#8901) 2023-06-21 17:25:01 +00:00
bevy_sprite improve shader import model (#5703) 2023-06-27 00:29:22 +00:00
bevy_tasks remove some use of once_cell that can be replace with new std (#8739) 2023-06-01 21:55:18 +00:00
bevy_text improve shader import model (#5703) 2023-06-27 00:29:22 +00:00
bevy_time Hide naga info logs & Derive PartialEq on Timer and Stopwatch (#8664) 2023-05-24 15:16:15 +00:00
bevy_transform Allow tuples and single plugins in add_plugins, deprecate add_plugin (#8097) 2023-06-21 20:51:03 +00:00
bevy_ui improve shader import model (#5703) 2023-06-27 00:29:22 +00:00
bevy_utils Bump hashbrown to 0.14 (#8904) 2023-06-21 13:04:44 +00:00
bevy_window Update and improve Window Documentation (#8858) 2023-06-22 03:00:40 +00:00
bevy_winit Allow tuples and single plugins in add_plugins, deprecate add_plugin (#8097) 2023-06-21 20:51:03 +00:00