Better control for which visual istances Decals project onto #4853
TamerSoup625
started this conversation in
3D
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When making sure that Decals project only on the wanted meshes, things can become complicated in my opinion, especially when making them at runtime (like bullet holes)
You can use cull masks, but you'd have to manage them and if you want it to apply on a dynamic object (like a physics prop), there may be a chance you run out of cull layers.
You could resize the extents so that it's less subtle however it's not a perfect fix on curved surfaces as the decal can be still projected on other meshes.
I think an useful feature would be some way to control which meshes the decal project onto.
For the RenderingServer API you can have a method named
decal_set_exceptions(decal: RID, exceptions: Array[RID], reversed: bool = false)
, when called andreversed
is false, the decaldecal
will not project on all the visual instances whose RID is inexceptions
, ifreversed
is true it will only project on the instances whose RID is inexceptions
.Meshes on different cull layer of the decal will still never recieve projection.
For the Decal node, you can have a property named something like
project_targets
which is an enumProjectTargetsMode
:TARGETS_DEFAULT
projects only on the parent (if possible) and the parent's children;TARGETS_NONE
does not project on anything, you have to manually include nodes (explained later);TARGETS_ALL
includes all the nodes on any of the cull layer of the decal's layers, also used to keep compatibilityYou could still manually include/exclude nodes, the node keeps track of these with internal arrays, similar to how
PhysicsBody*
does with collision exceptions.You would access these arrays with methods:
add_projection_inclusion(mesh: Node)
makes the decal also project on this node;add_projection_exclusion(mesh: Node)
makes the decal not project on this node;remove_projection_inclusion/exclusion(mesh: Node)
removes the node from the list of projection inclusions or exclusions;get_projection_inclusions/exclusions()
returns the list of nodes the decal will also/not project onto.Here are some images showing how I imagine it to work (notice the tree hiearchy and imagine all the meshes are on the same cull layer):
Now on these images the code is attached to the decal's tool script
TL,DR: Being able to set which meshes a decal project onto without using cull masks; both hierarchy-based and array-based.
This change should make using decals much easier, both in using them as fixed overlays and creating them at runtime.
Beta Was this translation helpful? Give feedback.
All reactions