summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-05-24 17:46:06 +0200
committerGitHub <noreply@github.com>2019-05-24 17:46:06 +0200
commitda617b7943abc5a042e690c7133097dc137b3970 (patch)
tree38815db8c572c8240010a02853b0c945c4e4d6df /drivers
parent147ff2095d8c7b52400654bdb31671909af9da47 (diff)
parent2abe7deae8cbb5932ed35d9bc937e0913a454c5c (diff)
Merge pull request #29132 from clayjohn/sort_depth_fix
Fix "no depth test" and render_priority sorting
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gles2/rasterizer_scene_gles2.cpp17
-rw-r--r--drivers/gles2/rasterizer_scene_gles2.h6
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp2
3 files changed, 12 insertions, 13 deletions
diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp
index 71d7a1bf42..268b0f1c90 100644
--- a/drivers/gles2/rasterizer_scene_gles2.cpp
+++ b/drivers/gles2/rasterizer_scene_gles2.cpp
@@ -1011,7 +1011,7 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G
has_alpha = false;
}
- RenderList::Element *e = has_alpha ? render_list.add_alpha_element() : render_list.add_element();
+ RenderList::Element *e = (has_alpha || p_material->shader->spatial.no_depth_test) ? render_list.add_alpha_element() : render_list.add_element();
if (!e) {
return;
@@ -2878,13 +2878,6 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
}
}
- if (env && env->bg_mode == VS::ENV_BG_SKY && (!storage->frame.current_rt || !storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT])) {
-
- if (sky && sky->panorama.is_valid()) {
- _draw_sky(sky, p_cam_projection, cam_transform, false, env->sky_custom_fov, env->bg_energy, env->sky_orientation);
- }
- }
-
if (probe_interior) {
env_radiance_tex = 0; //do not use radiance texture on interiors
state.default_ambient = Color(0, 0, 0, 1); //black as default ambient for interior
@@ -2895,6 +2888,14 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
render_list.sort_by_key(false);
_render_render_list(render_list.elements, render_list.element_count, cam_transform, p_cam_projection, p_shadow_atlas, env, env_radiance_tex, 0.0, 0.0, reverse_cull, false, false);
+ // then draw the sky after
+ if (env && env->bg_mode == VS::ENV_BG_SKY && (!storage->frame.current_rt || !storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT])) {
+
+ if (sky && sky->panorama.is_valid()) {
+ _draw_sky(sky, p_cam_projection, cam_transform, false, env->sky_custom_fov, env->bg_energy, env->sky_orientation);
+ }
+ }
+
if (storage->frame.current_rt && state.used_screen_texture) {
//copy screen texture
diff --git a/drivers/gles2/rasterizer_scene_gles2.h b/drivers/gles2/rasterizer_scene_gles2.h
index d805984dca..bd1a61688c 100644
--- a/drivers/gles2/rasterizer_scene_gles2.h
+++ b/drivers/gles2/rasterizer_scene_gles2.h
@@ -603,12 +603,10 @@ public:
struct SortByReverseDepthAndPriority {
_FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const {
- uint32_t layer_A = uint32_t(A->sort_key >> SORT_KEY_PRIORITY_SHIFT);
- uint32_t layer_B = uint32_t(B->sort_key >> SORT_KEY_PRIORITY_SHIFT);
- if (layer_A == layer_B) {
+ if (A->priority == B->priority) {
return A->instance->depth > B->instance->depth;
} else {
- return layer_A < layer_B;
+ return A->priority < B->priority;
}
}
};
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index 9aec348291..4552fddfe8 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -2374,7 +2374,7 @@ void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::G
has_alpha = false;
}
- RenderList::Element *e = has_alpha ? render_list.add_alpha_element() : render_list.add_element();
+ RenderList::Element *e = (has_alpha || p_material->shader->spatial.no_depth_test) ? render_list.add_alpha_element() : render_list.add_element();
if (!e)
return;