#Masking out Entities from Post Processing Shader

1 messages · Page 1 of 1 (latest)

wary sage
#

Hey!
I pretty much copied the Post Processing - Custom Render Pass Example and changed it so it works in 2d.

I can now successfully make everything more blue based on a number!
but, i'd like to have some entities (which would have a mesh 2d) not be affected by this!

I figured I could maybe create a mask on the meshes, and pass that to the post processing shader?
But i'm unsure how.
any guidance, or even better maybe examples, would be very appreciated!

while going through the code and looking at some resources i found, i figured that i:

  1. create a marker entity that says this entity should not be effected by the shader
  2. collect all 2d meshes with this marker
  3. extracting them into the render app(?)
  4. creating a texture for each of them
  5. and passing that into the shader

i think the meshes are actually already being extracted into the render world, so maybe i actually only have to insert the Marker on the render app to the matching entities?
and i'm very unsure on 4 and 5, like how i'd do exactly that.

fickle lodge
#

I don't have time to give more details right now, but you most likely don't want a separate texture for each mesh. You probably just want one texture where all those meshes are rendered to with a solid color. If you need to identify those meshes separately you can use a different color for each mesh

#

And yes, meshes are already in the render world, so you would only need to make sure your marker component is extracted correctly

wary sage
#

i am extracting the component, and inserting it on the render side to each entity

pub fn extract_day_night_mask_marker(
    mut commands: Commands,
    outlines: Extract<Query<(Entity, &DayNightPostProcessMaskMarker)>>,
) {
    for (entity, _) in &outlines {
        commands
            .get_or_spawn(entity)
            .insert(DayNightPostProcessMaskMarker::default());
    }
}
#

but where i'm lost at is pretty much:

  1. how do i collect all the visible 2d meshes with that marker
  2. how do i create this single texture
  3. how do i give this texture to the shader