diff options
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 1 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 9 |
2 files changed, 7 insertions, 3 deletions
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index c8900d64935..4761e8b755f 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -2801,7 +2801,6 @@ void DRW_draw_depth_object( GPU_framebuffer_restore(); GPU_framebuffer_free(depth_fb); - DRW_opengl_context_disable(); } /** \} */ diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 151fa02cd5c..fe347e89600 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2297,8 +2297,13 @@ static ViewDepths *view3d_depths_create(ARegion *region) { GPUViewport *viewport = WM_draw_region_get_viewport(region); GPUTexture *depth_tx = GPU_viewport_depth_texture(viewport); - d->depths = GPU_texture_read(depth_tx, GPU_DATA_FLOAT, 0); - + uint32_t *int_depths = GPU_texture_read(depth_tx, GPU_DATA_UINT_24_8, 0); + d->depths = (float *)int_depths; + /* Convert in-place. */ + int pixel_count = GPU_texture_width(depth_tx) * GPU_texture_height(depth_tx); + for (int i = 0; i < pixel_count; i++) { + d->depths[i] = (int_depths[i] >> 8u) / (float)0xFFFFFF; + } /* Assumed to be this as they are never changed. */ d->depth_range[0] = 0.0; d->depth_range[1] = 1.0; |