Skip to content

Commit

Permalink
Added: TilemapMaterial::specialize
Browse files Browse the repository at this point in the history
  • Loading branch information
443eb9 committed Mar 4, 2024
1 parent d8e0939 commit bcc0766
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
Binary file added docs/imgs/baking.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion release_note.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
- Rotations to Tiled objects are no longer recommended if you want to use them more than a static object.
- Some render code cleanup.
- Tilemap z indices are now using `f32` instead of `i32`.
- Pathfinding rework. Use `PathTilemaps` instead.
- Pathfinding rework. Use `PathTilemaps` instead of adding `PathTilemap`s as components.
- Single threaded algorithm implementations for special cases. Disable `multi-threaded` feature to use them.
- Transform `TileFlip` into bitflags, and make fields in `TileLayer` public.
- Some helper functions for `TileLayer` to help create a layer neater.
- Added `TilemapMaterial::specialize()` to customize the tilemap pipeline.

# What's Fixed:

Expand Down
7 changes: 6 additions & 1 deletion src/render/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ use bevy::{
reflect::TypePath,
render::{
render_phase::AddRenderCommand,
render_resource::{AsBindGroup, ShaderRef, SpecializedRenderPipelines},
render_resource::{
AsBindGroup, RenderPipelineDescriptor, ShaderRef, SpecializedRenderPipelines,
},
ExtractSchedule, Render, RenderApp, RenderSet,
},
};
Expand Down Expand Up @@ -89,6 +91,9 @@ pub trait TilemapMaterial: Default + Asset + AsBindGroup + TypePath + Clone {
fn fragment_shader() -> ShaderRef {
super::TILEMAP_SHADER.into()
}

#[allow(unused_variables)]
fn specialize(descriptor: &mut RenderPipelineDescriptor) {}
}

#[derive(Component, Default, Debug, Clone)]
Expand Down
8 changes: 6 additions & 2 deletions src/render/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl<M: TilemapMaterial> SpecializedRenderPipeline for EntiTilesPipeline<M> {
layout.push(self.storage_buffers_layout.clone());
}

RenderPipelineDescriptor {
let mut desc=RenderPipelineDescriptor {
label: Some("tilemap_pipeline".into()),
layout,
push_constant_ranges: vec![],
Expand Down Expand Up @@ -158,6 +158,10 @@ impl<M: TilemapMaterial> SpecializedRenderPipeline for EntiTilesPipeline<M> {
mask: !0,
alpha_to_coverage_enabled: false,
},
}
};

M::specialize(&mut desc);

desc
}
}

0 comments on commit bcc0766

Please sign in to comment.