-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Rendering masks #1209
Rendering masks #1209
Conversation
I dig this. I only have one comment: With the current masking approach (empty is default, empty matches empty) I don't think there is a way to encode the intent "draw everything". If you set all of the bits in the mask to 1, it will draw everything but the default empty mask. And if you set all of the bits to 0, it will only draw things that are also 0. I think it makes more sense to default to "group 1" and implicitly assume things without the mask component are also "group 1". This has the added benefit of being the behavior used in Godot, which makes it more familiar. This would mean camera masks would need to default to "group 1" (or maybe all groups, which is what godot does). |
…, private mask, docs, fn names, added all_groups and no_groups
7c0a540
to
b1a43f8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very good, just a few code style nits/duplications for me.
/// | ||
/// The [`Default`] instance of `RenderLayers` contains layer `0`, the first layer. | ||
/// | ||
/// An entity with this component without any layers is invisible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still cautious about making this guarantee, since we still seem to require that every entity has a Visible
, which this overlaps with.
That being said, I don't think there is necessarily better behaviour. Maybe we could have a warning log which prints once (i.e. if any entity matches this, then print and set an AtomicBool to true)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's a bit sketchy but it does help describe the feature. I think this is the best we can do at the moment. I personally plan on using the "invisiblity" of RenderLayers::none()
so I don't think we should add a warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I thought a bit about just replacing Visible with RenderLayers. But I think we need a "global" visible/invisible toggle:
- That way visibility can still be toggled without needing to know what layers the current entity is visible on
- Visibility will likely eventually propagate down a hierarchy, while RenderLayers might not. Its worth discussing at some point, but imo doesn't need to be settled in this pr.
- I want entity visibility to be easily toggle-able in the editor from the "Entity Inspector" (ex: have an "eye" toggle next to the entity name), which would be much harder for arbitrary layers
Just left one last baby comment, then I think this is good to go. Very nicely done! |
Adds RenderLayers, which enable cameras and entities to opt in to layers that apply to them
tl;dr adds
RenderLayers
to link groups of entities to cameras.This describes which rendering layers an entity belongs to. A layer is a collection of entities that only get rendered by cameras in that layer.
Entities and cameras without a
RenderLayers
component can be considered to belong to the "default" layer (layer 0), which is the same as entities and cameras with the componentRenderLayers::default()
.Entities and cameras can belong to multiple layers:
Using a mask of u32 we have 32 possible rendering layers, 0-31 plus the empty mask
RenderLayers::none()
.More takeaways:
RenderLayers::none()
) are invisible, as if they had the componentVisible { is_visible: false }