-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[Merged by Bors] - bevy_pbr2: Add support for not casting/receiving shadows #2726
[Merged by Bors] - bevy_pbr2: Add support for not casting/receiving shadows #2726
Conversation
4f8292d
to
a1a5b01
Compare
Having to add a zero-sized type component to every entity to mark it as a shadow caster or shadow receiver by default feels quite unnecessary. As such, I have added NotShadowCaster and NotShadowReceiver components. This introduces double-negatives like Without<NotShadowReceiver>, etc but it means that only the exceptions have to be specified in user code. I also added an example to illustrate the effect.
a1a5b01
to
1de89e7
Compare
This looks good to me / I think its worth merging as-is for now. My biggest questions are around "ideal user facing apis". There are lots of options here. Some engines make "shadow receiving" a material property, which might make sense here. I also want to consider something like: struct ShadowCaster {
enabled: bool,
} To avoid the need for adding removing components / make the settings more discoverable. But yeah this impl looks solid and I'd rather integrate it sooner than later. I removed the camera controls from the new example because they make it bigger / more complicated and I dont think the example benefits from freedom of movement. |
bors r+ |
# Objective Allow marking meshes as not casting / receiving shadows. ## Solution - Added `NotShadowCaster` and `NotShadowReceiver` zero-sized type components. - Extract these components into `bool`s in `ExtractedMesh` - Only generate `DrawShadowMesh` `Drawable`s for meshes _without_ `NotShadowCaster` - Add a `u32` bit `flags` member to `MeshUniform` with one flag indicating whether the mesh is a shadow receiver - If a mesh does _not_ have the `NotShadowReceiver` component, then it is a shadow receiver, and so the bit in the `MeshUniform` is set, otherwise it is not set. - Added an example illustrating the functionality. NOTE: I wanted to have the default state of a mesh as being a shadow caster and shadow receiver, hence the `Not*` components. However, I am on the fence about this. I don't want to have a negative performance impact, nor have people wondering why their custom meshes don't have shadows because they forgot to add `ShadowCaster` and `ShadowReceiver` components, but I also really don't like the double negatives the `Not*` approach incurs. What do you think? Co-authored-by: Carter Anderson <mcanders1@gmail.com>
Pull request successfully merged into pipelined-rendering. Build succeeded: |
Objective
Allow marking meshes as not casting / receiving shadows.
Solution
NotShadowCaster
andNotShadowReceiver
zero-sized type components.bool
s inExtractedMesh
DrawShadowMesh
Drawable
s for meshes withoutNotShadowCaster
u32
bitflags
member toMeshUniform
with one flag indicating whether the mesh is a shadow receiverNotShadowReceiver
component, then it is a shadow receiver, and so the bit in theMeshUniform
is set, otherwise it is not set.NOTE: I wanted to have the default state of a mesh as being a shadow caster and shadow receiver, hence the
Not*
components. However, I am on the fence about this. I don't want to have a negative performance impact, nor have people wondering why their custom meshes don't have shadows because they forgot to addShadowCaster
andShadowReceiver
components, but I also really don't like the double negatives theNot*
approach incurs. What do you think?