bevy/examples/2d
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
..
2d_gizmos.rs Instanced line rendering for gizmos based on bevy_polyline (#8427) 2023-06-13 06:49:47 +00:00
2d_shapes.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
bloom_2d.rs add a default font (#8445) 2023-04-21 22:30:18 +00:00
custom_gltf_vertex_attribute.rs Allow tuples and single plugins in add_plugins, deprecate add_plugin (#8097) 2023-06-21 20:51:03 +00:00
mesh2d.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
mesh2d_manual.rs improve shader import model (#5703) 2023-06-27 00:29:22 +00:00
mesh2d_vertex_color_texture.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
move_sprite.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
pixel_perfect.rs Explain why default_nearest is used in pixel_perfect example (#8370) 2023-04-13 17:58:06 +00:00
rotation.rs Non-breaking change* from UK spellings to US (#8291) 2023-04-08 16:22:46 +00:00
sprite.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
sprite_flipping.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
sprite_sheet.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
text2d.rs Changed spelling linebreak_behaviour to linebreak_behavior (#8285) 2023-04-05 21:25:53 +00:00
texture_atlas.rs Remove OnUpdate system set (#8260) 2023-04-04 00:49:41 +00:00
transparency_2d.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00