mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 22:00:10 +00:00
Add depth function for spatial materials
This commit is contained in:
parent
52ecb5ab9e
commit
7574a5dbb3
14 changed files with 197 additions and 34 deletions
|
|
@ -2941,7 +2941,8 @@ void SceneShaderData::set_code(const String &p_code) {
|
|||
|
||||
// Actual enums set further down after compilation.
|
||||
int blend_modei = BLEND_MODE_MIX;
|
||||
int depth_testi = DEPTH_TEST_ENABLED;
|
||||
int depth_test_disabledi = 0;
|
||||
int depth_test_invertedi = 0;
|
||||
int alpha_antialiasing_modei = ALPHA_ANTIALIASING_OFF;
|
||||
int cull_modei = RS::CULL_MODE_BACK;
|
||||
int depth_drawi = DEPTH_DRAW_OPAQUE;
|
||||
|
|
@ -2964,7 +2965,8 @@ void SceneShaderData::set_code(const String &p_code) {
|
|||
actions.render_mode_values["depth_draw_opaque"] = Pair<int *, int>(&depth_drawi, DEPTH_DRAW_OPAQUE);
|
||||
actions.render_mode_values["depth_draw_always"] = Pair<int *, int>(&depth_drawi, DEPTH_DRAW_ALWAYS);
|
||||
|
||||
actions.render_mode_values["depth_test_disabled"] = Pair<int *, int>(&depth_testi, DEPTH_TEST_DISABLED);
|
||||
actions.render_mode_values["depth_test_disabled"] = Pair<int *, int>(&depth_test_disabledi, 1);
|
||||
actions.render_mode_values["depth_test_inverted"] = Pair<int *, int>(&depth_test_invertedi, 1);
|
||||
|
||||
actions.render_mode_values["cull_disabled"] = Pair<int *, int>(&cull_modei, RS::CULL_MODE_DISABLED);
|
||||
actions.render_mode_values["cull_front"] = Pair<int *, int>(&cull_modei, RS::CULL_MODE_FRONT);
|
||||
|
|
@ -3026,7 +3028,13 @@ void SceneShaderData::set_code(const String &p_code) {
|
|||
blend_mode = BlendMode(blend_modei);
|
||||
alpha_antialiasing_mode = AlphaAntiAliasing(alpha_antialiasing_modei);
|
||||
depth_draw = DepthDraw(depth_drawi);
|
||||
depth_test = DepthTest(depth_testi);
|
||||
if (depth_test_disabledi) {
|
||||
depth_test = DEPTH_TEST_DISABLED;
|
||||
} else if (depth_test_invertedi) {
|
||||
depth_test = DEPTH_TEST_ENABLED_INVERTED;
|
||||
} else {
|
||||
depth_test = DEPTH_TEST_ENABLED;
|
||||
}
|
||||
cull_mode = RS::CullMode(cull_modei);
|
||||
|
||||
vertex_input_mask = RS::ARRAY_FORMAT_VERTEX | RS::ARRAY_FORMAT_NORMAL; // We can always read vertices and normals.
|
||||
|
|
@ -3114,7 +3122,7 @@ bool SceneShaderData::casts_shadows() const {
|
|||
bool has_base_alpha = (uses_alpha && !uses_alpha_clip) || has_read_screen_alpha;
|
||||
bool has_alpha = has_base_alpha || uses_blend_alpha;
|
||||
|
||||
return !has_alpha || (uses_depth_prepass_alpha && !(depth_draw == DEPTH_DRAW_DISABLED || depth_test == DEPTH_TEST_DISABLED));
|
||||
return !has_alpha || (uses_depth_prepass_alpha && !(depth_draw == DEPTH_DRAW_DISABLED || depth_test != DEPTH_TEST_ENABLED));
|
||||
}
|
||||
|
||||
RS::ShaderNativeSourceCode SceneShaderData::get_native_source_code() const {
|
||||
|
|
|
|||
|
|
@ -257,7 +257,8 @@ struct SceneShaderData : public ShaderData {
|
|||
|
||||
enum DepthTest {
|
||||
DEPTH_TEST_DISABLED,
|
||||
DEPTH_TEST_ENABLED
|
||||
DEPTH_TEST_ENABLED,
|
||||
DEPTH_TEST_ENABLED_INVERTED,
|
||||
};
|
||||
|
||||
enum AlphaAntiAliasing {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue