Skip to content

shader_material manual example#5925

Closed
ThierryBerger wants to merge 5 commits intobevyengine:mainfrom
ThierryBerger:5843-shader_low_level_example
Closed

shader_material manual example#5925
ThierryBerger wants to merge 5 commits intobevyengine:mainfrom
ThierryBerger:5843-shader_low_level_example

Conversation

@ThierryBerger
Copy link
Member

@ThierryBerger ThierryBerger commented Sep 9, 2022

Objective

Part of #5843.

Solution

  • Add a shader example being the macro-expanded "shader_material" but with code cleaned up and additional comments.

I'll try to do a follow up PR with a different example using lower level API:

  • RenderAssets
  • EntityRenderCommand
  • SpecializedMeshPipeline

@@ -0,0 +1,187 @@
//! A shader and a material that uses it using Bevy's Material API via manual implementation
//! See shader_material example for a higher level implementation.
//! See shader_material_low_level example for a lower level implementation.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet implemented, should be removed from this PR

Comment on lines +19 to +22
use bevy_internal::render::render_resource::{
BindGroupLayoutDescriptor, BindGroupLayoutEntry, BindingType, BufferBindingType,
SamplerBindingType, ShaderStages, ShaderType, TextureSampleType, TextureViewDimension,
};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably from cargo-expand, they are probably exposed in render ?

Comment on lines +90 to +100
// Step 1: retrieve information from our extracted type.
let color_texture = {
let color_texture_handle: Option<&Handle<Image>> = (&self.color_texture).into();
if let Some(handle) = color_texture_handle {
images
.get(handle)
.ok_or(AsBindGroupError::RetryNextUpdate)?
} else {
fallback_image
}
};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to note: this logic was duplicated with cargo-expand, to get :

  • the sampler
  • the texture

I refactored a bit to make only one call to retrieve the image and have 1 failure path.

@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen C-Examples An addition or correction to our examples labels Sep 9, 2022
@IceSentry
Copy link
Contributor

I added a couple of suggestions, mostly to provide a bit more details. Feel free to use them as is or change them.

ThierryBerger and others added 2 commits September 12, 2022 10:58
Co-authored-by: Charles <IceSentry@users.noreply.github.com>
@ThierryBerger
Copy link
Member Author

I'm closing this because the example was completely reworked with #8376

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen C-Examples An addition or correction to our examples

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants