Skip to content
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

Add decals_disabled render mode and BaseMaterial3D property #89235

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Mar 7, 2024

This adds a decals_disabled render mode that can be used in shaders and toggled in BaseMaterial3D. When this flag is used, decals will not be displayed on the material regardless of the layers its mesh are present on. This may be more convenient or flexible for certain materials that should never receive decals, such as VFX materials or parts of a mesh that use a separate material (such as eyes on a character).

Testing project: test_debug_draw_modes_decals.zip

Preview

The cyan toruses have the Disable Decals property enabled on their material, but are still on the default VisualInstance3D layer. A white torus in the decal's area had its layer changed (with the decal's cull mask being modified) so it doesn't receive the decal.

Forward+

Screenshot_20240307_004452

Mobile

Screenshot_20240307_005648

@Calinou Calinou added this to the 4.x milestone Mar 7, 2024
@Calinou Calinou requested a review from a team as a code owner March 7, 2024 00:05
@clayjohn
Copy link
Member

clayjohn commented Mar 7, 2024

I don't think we should add a new render mode for this. I think we should disable decals the same way we disable other clustered elements when we use the UNSHADED debug mode. I.e. by ignoring the decal element array:

if (get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_UNSHADED) {
render_data.lights = ∅
render_data.reflection_probes = ∅
render_data.voxel_gi_instances = ∅
}

I think we can just add:

render_data.decals = ∅

Which saves us a lot of complexity.

@Calinou Calinou changed the title Make Overdraw, Lighting and Shadow Splits debug draw modes ignore decals Add decals_disabled render mode and BaseMaterial3D property Mar 7, 2024
@Calinou
Copy link
Member Author

Calinou commented Mar 7, 2024

I don't think we should add a new render mode for this. I think we should disable decals the same way we disable other clustered elements when we use the UNSHADED debug mode. I.e. by ignoring the decal element array:

I've done this in #89253. I'll leave this PR open as it addresses an existing proposal.

@Calinou Calinou force-pushed the debug-draw-modes-ignore-decals branch 2 times, most recently from 9b44667 to f667754 Compare March 9, 2024 17:43
@Calinou Calinou requested a review from a team as a code owner March 9, 2024 17:43
@Mickeon
Copy link
Contributor

Mickeon commented Mar 9, 2024

(I do agree with clayjohn by the way, just making sure everything is clean in case of a change of heart)

This adds a `decals_disabled` render mode that can be used in shaders
and toggled in BaseMaterial3D. When this flag is used, decals will not be
displayed on the material regardless of the layers its mesh are present on.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a material flag to set a specific material to not receive decals
3 participants