Skip to content

Conversation

@pcwalton
Copy link
Contributor

@pcwalton pcwalton commented Dec 5, 2025

This commit expands the number of textures associated with each clustered decal from 1 to 4. The additional 3 textures apply normal maps, metallic-roughness maps, and emissive maps respectively to the surfaces onto which decals are projected.

Normal maps are combined using the [Whiteout blending method] from SIGGRAPH 2007. This approach was chosen because, subjectively, it appeared better than the more complex [reoriented normal mapping (RNM)] approach. Additionally, Whiteout normal map blending is commutative and associative, unlike RNM, which is a useful property for our decals, which are currently applied in an unspecified order. (The fact that the order in which our decals are applied is unspecified is unfortunate, but is a long-standing issue and should probably be fixed in a followup.) In particular, commutativity is desirable because otherwise one must specify which normal map is the base normal map and which normal map is the detail normal map, but that's not a policy decision that Bevy can unconditionally make, as decals aren't necessary more detailed than the base normal map. (For instance, consider a bullet hole decal embedded in a wall with a subtle rough texture; one might reasonably argue that the base material's normal map is the detail map and the bullet hole is the base map, even though the bullet hole's normal map comes from a decal.)

Note that, with a custom material shader, it's possible for application code to use the decal images for arbitrary other purposes. For example, with a custom shader an application might use the metallic-roughness map as a clearcoat map instead if it has no need for a metallic-roughness map on a decal. And, of course, a custom material shader could adopt RNM blending for decals if it wishes.

A new example, clustered_decal_maps, has been added. This example demonstrates the new maps by spawning clustered decals with maps randomly over time and projecting them onto a wall.

Screenshot 2025-12-05 095953

to clustered decals.

This commit expands the number of textures associated with each
clustered decal from 1 to 4. The additional 3 textures apply normal
maps, metallic-roughness maps, and emissive maps respectively to the
surfaces onto which decals are projected.

Normal maps are combined using the [*Whiteout* blending method] from
SIGGRAPH 2007. This approach was chosen because, subjectively, it
appeared better than the more complex [*reoriented normal mapping*
(RNM)] approach. Additionally, *Whiteout* normal map blending is
commutative and associative, unlike RNM, which is a useful property for
our decals, which are currently applied in an unspecified order. (The
fact that the order in which our decals are applied is unspecified is
unfortunate, but is a long-standing issue and should probably be fixed
in a followup.) In particular, commutativity is desirable because
otherwise one must specify which normal map is the *base* normal map and
which normal map is the *detail* normal map, but that's not a policy
decision that Bevy can unconditionally make, as decals aren't necessary
more detailed than the base normal map. (For instance, consider a bullet
hole decal embedded in a wall with a subtle rough texture; one might
reasonably argue that the base material's normal map is the detail map
and the bullet hole is the base map, even though the bullet hole's
normal map comes from a decal.)

Note that, with a custom material shader, it's possible for application
code to use the decal images for arbitrary other purposes. For example,
with a custom shader an application might use the metallic-roughness map
as a clearcoat map instead if it has no need for a metallic-roughness
map on a decal. And, of course, a custom material shader could adopt RNM
blending for decals if it wishes.

A new example, `clustered_decal_maps`, has been added. This example
demonstrates the new maps by spawning clustered decals with maps
randomly over time and projecting them onto a wall.
@pcwalton pcwalton requested review from IceSentry and atlv24 December 5, 2025 18:14
@pcwalton pcwalton added the A-Rendering Drawing game state to the screen label Dec 5, 2025
@pcwalton pcwalton added C-Feature A new feature, making something new possible S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Dec 5, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke!
You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-22039

If it's expected, please add the M-Deliberate-Rendering-Change label.

If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it.

Copy link
Member

@janhohenheim janhohenheim left a comment

Choose a reason for hiding this comment

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

Could you consider moving the assets to https://github.com/bevyengine/bevy_asset_files and loading them via the http asset loader? :) See https://github.com/bevyengine/bevy/blob/main/examples/asset/web_asset.rs

@pcwalton
Copy link
Contributor Author

pcwalton commented Dec 5, 2025

Copy link
Contributor

@IceSentry IceSentry left a comment

Choose a reason for hiding this comment

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

Very minor nits.

The assets should be removed from the PR before merging and once they are available in the bevy_asset_file repo.

Other than that LGTM

@alice-i-cecile alice-i-cecile added the M-Release-Note Work that should be called out in the blog due to impact label Dec 6, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 6, 2025

It looks like your PR has been selected for a highlight in the next release blog post, but you didn't provide a release note.

Please review the instructions for writing release notes, then expand or revise the content in the release notes directory to showcase your changes.

@alice-i-cecile
Copy link
Member

I would really love a usage example focused on the use of this feature for mirrors, but won't insist that it goes in this PR :)

@janhohenheim
Copy link
Member

For maintainers: I'll retract my requested changes when the files are no longer in this PR, which is presumably when bevyengine/bevy_asset_files#6 is merged

@pcwalton
Copy link
Contributor Author

pcwalton commented Dec 6, 2025

@alice-i-cecile Did you mean for that comment to go in #13797? (I mistakenly linked this PR in Discord instead of that one when talking about mirrors)

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-Feature A new feature, making something new possible M-Release-Note Work that should be called out in the blog due to impact S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants