Skip to content

Conversation

@beicause
Copy link
Contributor

@beicause beicause commented Nov 22, 2025

Objective

MaterialExtension::enable_shadows wrongly returns E::enable_prepass() instead of E::enable_shadows()

Solution

Fix it.

Also disable shadows for forward decals because decals typically should not cast shadows.

Testing

Run the decals example.

@beicause
Copy link
Contributor Author

This is included in #21909

@beicause beicause closed this Nov 22, 2025
@beicause beicause deleted the Fix-MaterialExtension-shadows branch November 22, 2025 01:45
@beicause beicause restored the Fix-MaterialExtension-shadows branch December 17, 2025 14:12
@beicause
Copy link
Contributor Author

Reopen it. I think this fix is ready for review and might be worth for the next release.

@beicause beicause reopened this Dec 17, 2025
@beicause beicause force-pushed the Fix-MaterialExtension-shadows branch from 0ec9399 to c4757f8 Compare December 17, 2025 14:25
@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Dec 29, 2025
@alice-i-cecile alice-i-cecile added the D-Straightforward Simple bug fixes and API improvements, docs, test and examples label Dec 29, 2025
@alice-i-cecile alice-i-cecile added this to the 0.18 milestone Dec 29, 2025
Copy link
Contributor

@NicoZweifel NicoZweifel left a comment

Choose a reason for hiding this comment

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

After thinking about it some more I think to make it consistent that it should check the base and extension (can't activate shadows/prepass on a base and its pipeline that don't support it) but it probably doesn't have to be part of this PR.

    fn enable_prepass() -> bool {
        B::enable_prepass() && E::enable_prepass()
    }

    fn enable_shadows() -> bool {
        B::enable_shadows() && E::enable_shadows()
    }


fn enable_shadows() -> bool {
E::enable_prepass()
E::enable_shadows()
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure if we want to ignore the base here. I think this can lead to some bugs, similar to what got fixed here. Arguably enable_shadows is not as fatal but I think silent inconsistencies and bugs could still happen when ignoring the base.

Suggested change
E::enable_shadows()
B::enable_shadows() && E::enable_shadows()

I think the same applies to enable_prepass, but it might be out of scope for this PR.

@beicause
Copy link
Contributor Author

I'm not sure if using && might not work as expected, since if the base is false, the extended cannot override it. Making them overridable makes more sense to me.

@NicoZweifel
Copy link
Contributor

I'm not sure if using && might not work as expected, since if the base is false, the extended cannot override it. Making them overridable makes more sense to me.

I get that it makes sense for flexibility, but I just don't see a practical use-case where force overriding is the correct/safe way in this case. If a user wants to do this, they can always use a base with shadows/prepass enabled and extend that.

I think the end user shouldn't be able to override something that isn't supported. Making the materials and pipeline agree seems like cleaner architecture imo and avoids the potential pitfalls (crashes, silent failures).

There is also the assumption that the user has to use MaterialPlugin, which isn't guaranteed either and also kinda locks the architecture in place to some extent, as well as making it all-or-nothing.

I don't think this is the right place to discuss this though so I might create an issue or draft PR for that.

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Dec 29, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Dec 30, 2025
Merged via the queue into bevyengine:main with commit e930a4b Dec 30, 2025
46 checks passed
mockersf pushed a commit that referenced this pull request Dec 30, 2025
…rd decals (#21908)

# Objective

`MaterialExtension::enable_shadows` wrongly returns
`E::enable_prepass()` instead of `E::enable_shadows()`

## Solution

Fix it.

Also disable shadows for forward decals because decals typically should
not cast shadows.

## Testing

Run the decals example.
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-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants