Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormano-wii <germano.costa@ig.com.br>2019-04-19 17:49:17 +0300
committermano-wii <germano.costa@ig.com.br>2019-04-19 17:49:17 +0300
commit8f4ba1c0467d9e6169451e03be5efffbd1f7a896 (patch)
treeb07091db6d074739eefcc7023103e553264453ef /source/blender/draw/intern/draw_manager.c
parentb6a9e88aff5b9be3fa8351c6578554400fcb32ab (diff)
Fix T63669: Particle editing bypassing occlusion.
The problem occurs because status changes between BackBuffer and Offscreen. Reviewers: fclem Differential Revision: https://developer.blender.org/D4703
Diffstat (limited to 'source/blender/draw/intern/draw_manager.c')
-rw-r--r--source/blender/draw/intern/draw_manager.c117
1 files changed, 66 insertions, 51 deletions
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index b3546092667..394cb6a144f 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -2332,42 +2332,6 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph,
#endif /* USE_GPU_SELECT */
}
-static void draw_depth_texture_to_screen(GPUTexture *texture)
-{
- const float w = (float)GPU_texture_width(texture);
- const float h = (float)GPU_texture_height(texture);
-
- GPUVertFormat *format = immVertexFormat();
- uint texcoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_3D_IMAGE_DEPTH_COPY);
-
- GPU_texture_bind(texture, 0);
-
- immUniform1i("image", 0); /* default GL_TEXTURE0 unit */
-
- immBegin(GPU_PRIM_TRI_STRIP, 4);
-
- immAttr2f(texcoord, 0.0f, 0.0f);
- immVertex2f(pos, 0.0f, 0.0f);
-
- immAttr2f(texcoord, 1.0f, 0.0f);
- immVertex2f(pos, w, 0.0f);
-
- immAttr2f(texcoord, 0.0f, 1.0f);
- immVertex2f(pos, 0.0f, h);
-
- immAttr2f(texcoord, 1.0f, 1.0f);
- immVertex2f(pos, w, h);
-
- immEnd();
-
- GPU_texture_unbind(texture);
-
- immUnbindProgram();
-}
-
/**
* object mode select-loop, see: ED_view3d_draw_depth_loop (legacy drawing).
*/
@@ -2484,21 +2448,6 @@ void DRW_draw_depth_loop(struct Depsgraph *depsgraph,
drw_engines_disable();
- /* XXX Drawing the resulting buffer to the BACK_BUFFER */
- GPU_matrix_push();
- GPU_matrix_push_projection();
- wmOrtho2_region_pixelspace(DST.draw_ctx.ar);
- GPU_matrix_identity_set();
-
- glEnable(GL_DEPTH_TEST); /* Cannot write to depth buffer without testing */
- glDepthFunc(GL_ALWAYS);
- DefaultTextureList *dtxl = (DefaultTextureList *)GPU_viewport_texture_list_get(DST.viewport);
- draw_depth_texture_to_screen(dtxl->depth);
- glDepthFunc(GL_LEQUAL);
-
- GPU_matrix_pop();
- GPU_matrix_pop_projection();
-
#ifdef DEBUG
/* Avoid accidental reuse. */
drw_state_ensure_not_reused(&DST);
@@ -2544,6 +2493,72 @@ void DRW_draw_depth_loop_gpencil(struct Depsgraph *depsgraph,
#endif
}
+/**
+ * Clears the Depth Buffer and draws only the specified object.
+ */
+void DRW_draw_depth_object(ARegion *ar,
+ View3D *v3d,
+ GPUViewport *viewport,
+ Object *object)
+{
+ RegionView3D *rv3d = ar->regiondata;
+
+ DRW_opengl_context_enable();
+
+ /* Setup framebuffer */
+ DefaultFramebufferList *fbl = GPU_viewport_framebuffer_list_get(viewport);
+
+ GPU_framebuffer_bind(fbl->depth_only_fb);
+ GPU_framebuffer_clear_depth(fbl->depth_only_fb, 1.0f);
+ GPU_depth_test(true);
+ GPU_matrix_mul(object->obmat);
+
+ const float(*world_clip_planes)[4] = NULL;
+ if (rv3d->rflag & RV3D_CLIPPING) {
+ ED_view3d_clipping_set(rv3d);
+ ED_view3d_clipping_local(rv3d, object->obmat);
+ world_clip_planes = rv3d->clip_local;
+ }
+
+ switch (object->type) {
+ case OB_MESH: {
+ GPUBatch *batch;
+
+ Mesh *me = object->data;
+
+ if (object->mode & OB_MODE_EDIT) {
+ batch = DRW_mesh_batch_cache_get_edit_triangles(me);
+ }
+ else {
+ batch = DRW_mesh_batch_cache_get_surface(me);
+ }
+
+ DRW_mesh_batch_cache_create_requested(object, me, NULL, false, true);
+
+ const eGPUShaderConfig sh_cfg = world_clip_planes ? GPU_SHADER_CFG_CLIPPED :
+ GPU_SHADER_CFG_DEFAULT;
+ GPU_batch_program_set_builtin_with_config(batch, GPU_SHADER_3D_DEPTH_ONLY, sh_cfg);
+ if (world_clip_planes != NULL) {
+ GPU_batch_uniform_4fv_array(batch, "WorldClipPlanes", 6, world_clip_planes[0]);
+ }
+
+ GPU_batch_draw(batch);
+ } break;
+ case OB_CURVE:
+ case OB_SURF:
+ break;
+ }
+
+ if (rv3d->rflag & RV3D_CLIPPING) {
+ ED_view3d_clipping_disable();
+ }
+
+ GPU_matrix_set(rv3d->viewmat);
+ GPU_depth_test(false);
+ GPU_framebuffer_restore();
+ DRW_opengl_context_disable();
+}
+
/* Set an opengl context to be used with shaders that draw on U32 colors. */
void DRW_framebuffer_select_id_setup(ARegion *ar, const bool clear)
{