Skip to content

Commit

Permalink
Changed depth functions to better match PR godotengine#73527
Browse files Browse the repository at this point in the history
  • Loading branch information
apples committed Sep 10, 2023
1 parent 83ec6f8 commit be85b5c
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 38 deletions.
12 changes: 6 additions & 6 deletions doc/classes/BaseMaterial3D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -654,18 +654,18 @@
<constant name="DEPTH_FUNCTION_LESS" value="1" enum="DepthFunction">
Depth check succeeds if less than existing depth.
</constant>
<constant name="DEPTH_FUNCTION_GREATER_OR_EQUAL" value="2" enum="DepthFunction">
Depth check succeeds if greater than or equal to existing depth.
<constant name="DEPTH_FUNCTION_EQUAL" value="2" enum="DepthFunction">
Depth check succeeds if equal to existing depth.
</constant>
<constant name="DEPTH_FUNCTION_GREATER" value="3" enum="DepthFunction">
Depth check succeeds if greater than existing depth.
</constant>
<constant name="DEPTH_FUNCTION_EQUAL" value="4" enum="DepthFunction">
Depth check succeeds if equal to existing depth.
</constant>
<constant name="DEPTH_FUNCTION_NOT_EQUAL" value="5" enum="DepthFunction">
<constant name="DEPTH_FUNCTION_NOT_EQUAL" value="4" enum="DepthFunction">
Depth check succeeds if not equal to existing depth.
</constant>
<constant name="DEPTH_FUNCTION_GREATER_OR_EQUAL" value="5" enum="DepthFunction">
Depth check succeeds if greater than or equal to existing depth.
</constant>
<constant name="DEPTH_FUNCTION_ALWAYS" value="6" enum="DepthFunction">
Depth check always succeeds.
</constant>
Expand Down
4 changes: 2 additions & 2 deletions drivers/gles3/rasterizer_scene_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2174,10 +2174,10 @@ void RasterizerSceneGLES3::_render_list_template(RenderListParameters *p_params,
GLenum depth_function_table[GLES3::SceneShaderData::DEPTH_FUNCTION_MAX] = {
GL_LEQUAL,
GL_LESS,
GL_GEQUAL,
GL_GREATER,
GL_EQUAL,
GL_GREATER,
GL_NOTEQUAL,
GL_GEQUAL,
GL_ALWAYS,
GL_NEVER,
};
Expand Down
8 changes: 4 additions & 4 deletions drivers/gles3/storage/material_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2886,12 +2886,12 @@ void SceneShaderData::set_code(const String &p_code) {

actions.render_mode_values["depth_test_disabled"] = Pair<int *, int>(&depth_testi, DEPTH_TEST_DISABLED);

actions.render_mode_values["depth_function_lequal"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_LESS_OR_EQUAL);
actions.render_mode_values["depth_function_less_or_equal"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_LESS_OR_EQUAL);
actions.render_mode_values["depth_function_less"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_LESS);
actions.render_mode_values["depth_function_gequal"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_GREATER_OR_EQUAL);
actions.render_mode_values["depth_function_greater"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_GREATER);
actions.render_mode_values["depth_function_equal"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_EQUAL);
actions.render_mode_values["depth_function_notequal"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_NOT_EQUAL);
actions.render_mode_values["depth_function_greater"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_GREATER);
actions.render_mode_values["depth_function_not_equal"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_NOT_EQUAL);
actions.render_mode_values["depth_function_greater_or_equal"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_GREATER_OR_EQUAL);
actions.render_mode_values["depth_function_always"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_ALWAYS);
actions.render_mode_values["depth_function_never"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_NEVER);

Expand Down
4 changes: 2 additions & 2 deletions drivers/gles3/storage/material_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,10 @@ struct SceneShaderData : public ShaderData {
enum DepthFunction {
DEPTH_FUNCTION_LESS_OR_EQUAL,
DEPTH_FUNCTION_LESS,
DEPTH_FUNCTION_GREATER_OR_EQUAL,
DEPTH_FUNCTION_GREATER,
DEPTH_FUNCTION_EQUAL,
DEPTH_FUNCTION_GREATER,
DEPTH_FUNCTION_NOT_EQUAL,
DEPTH_FUNCTION_GREATER_OR_EQUAL,
DEPTH_FUNCTION_ALWAYS,
DEPTH_FUNCTION_NEVER,
DEPTH_FUNCTION_MAX
Expand Down
18 changes: 9 additions & 9 deletions scene/resources/material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,22 +712,22 @@ void BaseMaterial3D::_update_shader() {

switch (depth_function) {
case DEPTH_FUNCTION_LESS_OR_EQUAL:
code += ",depth_function_lequal";
code += ",depth_function_less_or_equal";
break;
case DEPTH_FUNCTION_LESS:
code += ",depth_function_less";
break;
case DEPTH_FUNCTION_GREATER_OR_EQUAL:
code += ",depth_function_gequal";
case DEPTH_FUNCTION_EQUAL:
code += ",depth_function_equal";
break;
case DEPTH_FUNCTION_GREATER:
code += ",depth_function_greater";
break;
case DEPTH_FUNCTION_EQUAL:
code += ",depth_function_equal";
break;
case DEPTH_FUNCTION_NOT_EQUAL:
code += ",depth_function_notequal";
code += ",depth_function_not_equal";
break;
case DEPTH_FUNCTION_GREATER_OR_EQUAL:
code += ",depth_function_greater_or_equal";
break;
case DEPTH_FUNCTION_ALWAYS:
code += ",depth_function_always";
Expand Down Expand Up @@ -3256,10 +3256,10 @@ void BaseMaterial3D::_bind_methods() {

BIND_ENUM_CONSTANT(DEPTH_FUNCTION_LESS_OR_EQUAL);
BIND_ENUM_CONSTANT(DEPTH_FUNCTION_LESS);
BIND_ENUM_CONSTANT(DEPTH_FUNCTION_GREATER_OR_EQUAL);
BIND_ENUM_CONSTANT(DEPTH_FUNCTION_GREATER);
BIND_ENUM_CONSTANT(DEPTH_FUNCTION_EQUAL);
BIND_ENUM_CONSTANT(DEPTH_FUNCTION_GREATER);
BIND_ENUM_CONSTANT(DEPTH_FUNCTION_NOT_EQUAL);
BIND_ENUM_CONSTANT(DEPTH_FUNCTION_GREATER_OR_EQUAL);
BIND_ENUM_CONSTANT(DEPTH_FUNCTION_ALWAYS);
BIND_ENUM_CONSTANT(DEPTH_FUNCTION_NEVER);

Expand Down
4 changes: 2 additions & 2 deletions scene/resources/material.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,10 @@ class BaseMaterial3D : public Material {
enum DepthFunction {
DEPTH_FUNCTION_LESS_OR_EQUAL,
DEPTH_FUNCTION_LESS,
DEPTH_FUNCTION_GREATER_OR_EQUAL,
DEPTH_FUNCTION_GREATER,
DEPTH_FUNCTION_EQUAL,
DEPTH_FUNCTION_GREATER,
DEPTH_FUNCTION_NOT_EQUAL,
DEPTH_FUNCTION_GREATER_OR_EQUAL,
DEPTH_FUNCTION_ALWAYS,
DEPTH_FUNCTION_NEVER,
DEPTH_FUNCTION_MAX
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ void SceneShaderForwardClustered::ShaderData::set_code(const String &p_code) {

actions.render_mode_values["depth_test_disabled"] = Pair<int *, int>(&depth_testi, DEPTH_TEST_DISABLED);

actions.render_mode_values["depth_function_lequal"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_LESS_OR_EQUAL);
actions.render_mode_values["depth_function_less_or_equal"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_LESS_OR_EQUAL);
actions.render_mode_values["depth_function_less"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_LESS);
actions.render_mode_values["depth_function_gequal"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_GREATER_OR_EQUAL);
actions.render_mode_values["depth_function_greater"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_GREATER);
actions.render_mode_values["depth_function_equal"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_EQUAL);
actions.render_mode_values["depth_function_notequal"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_NOT_EQUAL);
actions.render_mode_values["depth_function_greater"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_GREATER);
actions.render_mode_values["depth_function_not_equal"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_NOT_EQUAL);
actions.render_mode_values["depth_function_greater_or_equal"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_GREATER_OR_EQUAL);
actions.render_mode_values["depth_function_always"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_ALWAYS);
actions.render_mode_values["depth_function_never"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_NEVER);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ class SceneShaderForwardClustered {
enum DepthFunction {
DEPTH_FUNCTION_LESS_OR_EQUAL,
DEPTH_FUNCTION_LESS,
DEPTH_FUNCTION_GREATER_OR_EQUAL,
DEPTH_FUNCTION_GREATER,
DEPTH_FUNCTION_EQUAL,
DEPTH_FUNCTION_GREATER,
DEPTH_FUNCTION_NOT_EQUAL,
DEPTH_FUNCTION_GREATER_OR_EQUAL,
DEPTH_FUNCTION_ALWAYS,
DEPTH_FUNCTION_NEVER,
DEPTH_FUNCTION_MAX
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ void SceneShaderForwardMobile::ShaderData::set_code(const String &p_code) {

actions.render_mode_values["depth_test_disabled"] = Pair<int *, int>(&depth_testi, DEPTH_TEST_DISABLED);

actions.render_mode_values["depth_function_lequal"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_LESS_OR_EQUAL);
actions.render_mode_values["depth_function_less_or_equal"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_LESS_OR_EQUAL);
actions.render_mode_values["depth_function_less"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_LESS);
actions.render_mode_values["depth_function_gequal"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_GREATER_OR_EQUAL);
actions.render_mode_values["depth_function_greater"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_GREATER);
actions.render_mode_values["depth_function_equal"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_EQUAL);
actions.render_mode_values["depth_function_notequal"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_NOT_EQUAL);
actions.render_mode_values["depth_function_greater"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_GREATER);
actions.render_mode_values["depth_function_not_equal"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_NOT_EQUAL);
actions.render_mode_values["depth_function_greater_or_equal"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_GREATER_OR_EQUAL);
actions.render_mode_values["depth_function_always"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_ALWAYS);
actions.render_mode_values["depth_function_never"] = Pair<int *, int>(&depth_functioni, DEPTH_FUNCTION_NEVER);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ class SceneShaderForwardMobile {
enum DepthFunction {
DEPTH_FUNCTION_LESS_OR_EQUAL,
DEPTH_FUNCTION_LESS,
DEPTH_FUNCTION_GREATER_OR_EQUAL,
DEPTH_FUNCTION_GREATER,
DEPTH_FUNCTION_EQUAL,
DEPTH_FUNCTION_GREATER,
DEPTH_FUNCTION_NOT_EQUAL,
DEPTH_FUNCTION_GREATER_OR_EQUAL,
DEPTH_FUNCTION_ALWAYS,
DEPTH_FUNCTION_NEVER,
DEPTH_FUNCTION_MAX
Expand Down
2 changes: 1 addition & 1 deletion servers/rendering/shader_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ ShaderTypes::ShaderTypes() {
{
shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("blend"), "mix", "add", "sub", "mul" });
shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("depth_draw"), "opaque", "always", "never" });
shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("depth_function"), { "lequal", "less", "gequal", "greater", "equal", "notequal", "always", "never" } });
shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("depth_function"), { "less_or_equal", "less", "equal", "greater", "not_equal", "greater_or_equal", "always", "never" } });
shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("depth_prepass_alpha") });
shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("depth_test_disabled") });
shader_modes[RS::SHADER_SPATIAL].modes.push_back({ PNAME("sss_mode_skin") });
Expand Down

0 comments on commit be85b5c

Please sign in to comment.