From cd737eed2f8ccd63b8cda783adccbd3bf0ca492d Mon Sep 17 00:00:00 2001 From: Squamto <25984337+Squamto@users.noreply.github.com> Date: Mon, 28 Jul 2025 17:39:54 +0200 Subject: [PATCH] Fix disallow stencil mode outline and xray for RENDER_PRIORITY_MAX --- scene/resources/material.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 935f5f12373..2b0e48faaa1 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -64,6 +64,7 @@ Ref Material::get_next_pass() const { void Material::set_render_priority(int p_priority) { ERR_FAIL_COND(p_priority < RENDER_PRIORITY_MIN); ERR_FAIL_COND(p_priority > RENDER_PRIORITY_MAX); + render_priority = p_priority; if (material.is_valid()) { @@ -3217,6 +3218,11 @@ void BaseMaterial3D::set_stencil_mode(StencilMode p_stencil_mode) { return; } + if (p_stencil_mode == StencilMode::STENCIL_MODE_OUTLINE || p_stencil_mode == StencilMode::STENCIL_MODE_XRAY) { + ERR_FAIL_COND_EDMSG(get_render_priority() >= RENDER_PRIORITY_MAX, + vformat("Cannot use stencil mode Outline or Xray, when render priority is RENDER_PRIORITY_MAX(%d).", RENDER_PRIORITY_MAX)); + } + stencil_mode = p_stencil_mode; _prepare_stencil_effect(); _queue_shader_change();