Skip to content

Conversation

@alice-i-cecile
Copy link
Member

Fixes #1980. No image yet: none of the existing ones properly show off this feature.

@alice-i-cecile
Copy link
Member Author

@naasblod, here are the promised release notes to review!

Co-authored-by: IceSentry <IceSentry@users.noreply.github.com>
@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review Ready for a maintainer to consider for merging and removed S-Needs-Review labels Apr 8, 2025
This can be mitigated by creating textures that are bigger than the effect, giving the decal more space to stretch.
To create a forward decal, spawn a [`ForwardDecal`] entity, which uses a [`ForwardDecalMaterial`] using the [`ForwardDecalMaterialExt`] material extension.

Clustered decals (or decal projectors) work by projecting images from a 1x1x1 cube onto surfaces found in the +Z direction.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the +z direction part correct?

I’m not certain how this feature works so don’t rely on my feedback without verifying. I was thinking that this is like a 2D image on the right-handed x-right, y-up, z-back cube’s z faces being projected through the cube along its z-axis and covering any surfaces along the path. I have a feeling that I also saw it project onto both front and back faces from the cube’s perspective. Here a picture would surely be a thousand words. :)

Copy link
Member Author

Choose a reason for hiding this comment

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

That was taken from the existing docs :)

@naasblod
Copy link

naasblod commented Apr 8, 2025

I'll check at this in a little while when I arrive at the office. Got some time before I start. Great job!

This can be mitigated by creating textures that are bigger than the effect, giving the decal more space to stretch.
To create a forward decal, spawn a [`ForwardDecal`] entity, which uses a [`ForwardDecalMaterial`] using the [`ForwardDecalMaterialExt`] material extension.

Clustered decals (or decal projectors) work by projecting images from a 1x1x1 cube onto surfaces found in the +Z direction.
Copy link
Contributor

Choose a reason for hiding this comment

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

Feels like too much pointless technical info. Even I don't really care about cubes or +z direction.

To create a forward decal, spawn a [`ForwardDecal`] entity, which uses a [`ForwardDecalMaterial`] using the [`ForwardDecalMaterialExt`] material extension.

Clustered decals (or decal projectors) work by projecting images from a 1x1x1 cube onto surfaces found in the +Z direction.
They are clusterable objects, just like point lights and light probes, which means that decals are only evaluated for objects within the bounds of the projector, and they don't require a second rendering pass.
Copy link
Contributor

Choose a reason for hiding this comment

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

and they don't require a second rendering pass.

Kind of implies that forward decals do require a second rendering pass, which sorta isn't true.

Small summary of how they work:

  1. Forward decals basically map to mesh + material under the hood, I just did some fancy API stuff to make it ergonomic for users to spawn. It's literately just an extra alpha-blended mesh that gets rendered in the transparent phase.
  2. Clustered decals get binned into froxels(iirc?), and then during the opaque pass each fragments lookup what froxel they're in, and then iterate over the decals in the froxel and apply them. Same as how points/spot lights work, and I guess light probes although I forgot about that bit.

Copy link
Contributor

Choose a reason for hiding this comment

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

So forward decals results in the same fragment being shaded twice? In which case:

Suggested change
They are clusterable objects, just like point lights and light probes, which means that decals are only evaluated for objects within the bounds of the projector, and they don't require a second rendering pass.
They are clusterable objects, just like point lights and light probes, which means that decals are only evaluated for objects within the bounds of the projector, and they don't require shading the same fragment an additional time to blend the decal on top.

They are clusterable objects, just like point lights and light probes, which means that decals are only evaluated for objects within the bounds of the projector, and they don't require a second rendering pass.
To create a clustered decal, spawn a [`ClusteredDecal`] entity.

Ultimately, forward decals offer broader hardware and driver support, while clustered decals are higher quality and don't require the creation of bounding geometry, improving performance.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think forward decals are also a little easier to customize, since it's 99% just using the material API. Clustered decals can be customized, but are a little harder.

There might also be other quality differences and situations where one or the other is better, but idk enough about decals to say.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh yeah forward decals are basically transparent objects, so they won't work as well with TAA and such.

Co-authored-by: JMS55 <47158642+JMS55@users.noreply.github.com>
@alice-i-cecile alice-i-cecile added S-Waiting-On-Author and removed S-Ready-For-Final-Review Ready for a maintainer to consider for merging labels Apr 8, 2025
@ChristopherBiscardi
Copy link
Contributor

ChristopherBiscardi commented Apr 10, 2025

Here's some decals, as requested @alice-i-cecile

graffiti, arrow, "footprint", and wall dirt are all forward decals.

screenshot-2025-04-10-at-06 43 08@2x

Here's the blender setup, for kicks if anyone is interested.

screenshot-2025-04-10-at-06 45 52@2x

screenshot-2025-04-10-at-06 48 05@2x

@alice-i-cecile alice-i-cecile added S-Adopt-Me This PR could use some love: make a new PR with this work! and removed S-Waiting-On-Author labels Apr 11, 2025
@cart
Copy link
Member

cart commented Apr 23, 2025

Closing in favor of #2106

@cart cart closed this Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Release-Notes S-Adopt-Me This PR could use some love: make a new PR with this work!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write release notes for PR #16600: Forward decals (port of bevy_contact_projective_decals)

7 participants