mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 07:17:42 -05:00
Merge pull request #107808 from apples/apples-stencil-preset-readwrite-fix
Fix stencil preset `next_pass` stencil flags
This commit is contained in:
@@ -3175,7 +3175,7 @@ void BaseMaterial3D::_prepare_stencil_effect() {
|
|||||||
stencil_next_pass->set_grow(stencil_effect_outline_thickness);
|
stencil_next_pass->set_grow(stencil_effect_outline_thickness);
|
||||||
stencil_next_pass->set_albedo(stencil_effect_color);
|
stencil_next_pass->set_albedo(stencil_effect_color);
|
||||||
stencil_next_pass->set_stencil_mode(STENCIL_MODE_CUSTOM);
|
stencil_next_pass->set_stencil_mode(STENCIL_MODE_CUSTOM);
|
||||||
stencil_next_pass->set_stencil_flags(STENCIL_FLAG_READ | STENCIL_FLAG_WRITE);
|
stencil_next_pass->set_stencil_flags(STENCIL_FLAG_READ);
|
||||||
stencil_next_pass->set_stencil_compare(STENCIL_COMPARE_NOT_EQUAL);
|
stencil_next_pass->set_stencil_compare(STENCIL_COMPARE_NOT_EQUAL);
|
||||||
stencil_next_pass->set_stencil_reference(stencil_reference);
|
stencil_next_pass->set_stencil_reference(stencil_reference);
|
||||||
break;
|
break;
|
||||||
@@ -3190,7 +3190,7 @@ void BaseMaterial3D::_prepare_stencil_effect() {
|
|||||||
stencil_next_pass->set_grow(0);
|
stencil_next_pass->set_grow(0);
|
||||||
stencil_next_pass->set_albedo(stencil_effect_color);
|
stencil_next_pass->set_albedo(stencil_effect_color);
|
||||||
stencil_next_pass->set_stencil_mode(STENCIL_MODE_CUSTOM);
|
stencil_next_pass->set_stencil_mode(STENCIL_MODE_CUSTOM);
|
||||||
stencil_next_pass->set_stencil_flags(STENCIL_FLAG_READ | STENCIL_FLAG_WRITE);
|
stencil_next_pass->set_stencil_flags(STENCIL_FLAG_READ);
|
||||||
stencil_next_pass->set_stencil_compare(STENCIL_COMPARE_NOT_EQUAL);
|
stencil_next_pass->set_stencil_compare(STENCIL_COMPARE_NOT_EQUAL);
|
||||||
stencil_next_pass->set_stencil_reference(stencil_reference);
|
stencil_next_pass->set_stencil_reference(stencil_reference);
|
||||||
break;
|
break;
|
||||||
@@ -3232,14 +3232,21 @@ void BaseMaterial3D::set_stencil_flags(int p_stencil_flags) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If enabling read while already writing, switch to read only.
|
||||||
if ((p_stencil_flags & STENCIL_FLAG_READ) && (stencil_flags & (STENCIL_FLAG_WRITE | STENCIL_FLAG_WRITE_DEPTH_FAIL))) {
|
if ((p_stencil_flags & STENCIL_FLAG_READ) && (stencil_flags & (STENCIL_FLAG_WRITE | STENCIL_FLAG_WRITE_DEPTH_FAIL))) {
|
||||||
p_stencil_flags = p_stencil_flags & STENCIL_FLAG_READ;
|
p_stencil_flags = p_stencil_flags & STENCIL_FLAG_READ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If enabling write while already reading, switch to write or write_depth_fail.
|
||||||
if ((p_stencil_flags & (STENCIL_FLAG_WRITE | STENCIL_FLAG_WRITE_DEPTH_FAIL)) && (stencil_flags & STENCIL_FLAG_READ)) {
|
if ((p_stencil_flags & (STENCIL_FLAG_WRITE | STENCIL_FLAG_WRITE_DEPTH_FAIL)) && (stencil_flags & STENCIL_FLAG_READ)) {
|
||||||
p_stencil_flags = p_stencil_flags & (STENCIL_FLAG_WRITE | STENCIL_FLAG_WRITE_DEPTH_FAIL);
|
p_stencil_flags = p_stencil_flags & (STENCIL_FLAG_WRITE | STENCIL_FLAG_WRITE_DEPTH_FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If enabling read+write while already doing neither, only allow read.
|
||||||
|
if ((p_stencil_flags & STENCIL_FLAG_READ) && (p_stencil_flags & (STENCIL_FLAG_WRITE | STENCIL_FLAG_WRITE_DEPTH_FAIL))) {
|
||||||
|
p_stencil_flags = p_stencil_flags & STENCIL_FLAG_READ;
|
||||||
|
}
|
||||||
|
|
||||||
stencil_flags = p_stencil_flags;
|
stencil_flags = p_stencil_flags;
|
||||||
_queue_shader_change();
|
_queue_shader_change();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user