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

Emit alpha masked effects with proper drawfunc #222

Merged
merged 2 commits into from
Sep 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2036,6 +2036,8 @@ pub(crate) struct QueueEffectsReadOnlyParams<'w, 's> {
draw_functions_2d: Res<'w, DrawFunctions<Transparent2d>>,
#[cfg(feature = "3d")]
draw_functions_3d: Res<'w, DrawFunctions<Transparent3d>>,
#[cfg(feature = "3d")]
draw_functions_alpha_mask: Res<'w, DrawFunctions<AlphaMask3d>>,
dispatch_indirect_pipeline: Res<'w, DispatchIndirectPipeline>,
init_pipeline: Res<'w, ParticlesInitPipeline>,
update_pipeline: Res<'w, ParticlesUpdatePipeline>,
Expand Down Expand Up @@ -2526,15 +2528,16 @@ pub(crate) fn queue_effects(
// Loop over all 3D cameras/views that need to render effects
#[cfg(feature = "3d")]
{
let draw_effects_function_3d = read_params
.draw_functions_3d
.read()
.get_id::<DrawEffects>()
.unwrap();

// Effects with full alpha blending
if !views_3d.is_empty() {
trace!("Emit effect draw calls for alpha blended 3D views...");

let draw_effects_function_3d = read_params
.draw_functions_3d
.read()
.get_id::<DrawEffects>()
.unwrap();

emit_draw(
&mut views_3d,
&effect_batches,
Expand All @@ -2560,6 +2563,13 @@ pub(crate) fn queue_effects(
// Effects with alpha mask
if !views_alpha_mask.is_empty() {
trace!("Emit effect draw calls for alpha masked 3D views...");

let draw_effects_function_alpha_mask = read_params
.draw_functions_alpha_mask
.read()
.get_id::<DrawEffects>()
.unwrap();

emit_draw(
&mut views_alpha_mask,
&effect_batches,
Expand All @@ -2571,7 +2581,7 @@ pub(crate) fn queue_effects(
&pipeline_cache,
msaa.samples(),
|id, entity, _batch| AlphaMask3d {
draw_function: draw_effects_function_3d,
draw_function: draw_effects_function_alpha_mask,
pipeline: id,
entity,
distance: 0.0, // TODO
Expand Down
Loading