Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shader_material manual example #5925

Closed
wants to merge 5 commits into from

Conversation

Vrixyz
Copy link
Member

@Vrixyz Vrixyz 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.

@Vrixyz
Copy link
Member Author

Vrixyz commented May 11, 2023

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

@Vrixyz Vrixyz closed this May 11, 2023
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