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:
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_draw_legacy.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_draw_legacy.c121
1 files changed, 39 insertions, 82 deletions
diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c
index 7cb362ffb92..7272fc6b408 100644
--- a/source/blender/editors/space_view3d/view3d_draw_legacy.c
+++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c
@@ -48,7 +48,7 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
-#include "BLI_jitter.h"
+#include "BLI_jitter_2d.h"
#include "BLI_utildefines.h"
#include "BLI_endian_switch.h"
#include "BLI_threads.h"
@@ -100,7 +100,6 @@
#include "GPU_framebuffer.h"
#include "GPU_lamp.h"
#include "GPU_material.h"
-#include "GPU_compositing.h"
#include "GPU_extensions.h"
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
@@ -202,7 +201,7 @@ static void draw_view_icon(RegionView3D *rv3d, rcti *rect)
else return;
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
UI_icon_draw(5.0 + rect->xmin, 5.0 + rect->ymin, icon);
@@ -211,31 +210,32 @@ static void draw_view_icon(RegionView3D *rv3d, rcti *rect)
/* *********************** backdraw for selection *************** */
-static void backdrawview3d(const struct EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer, wmWindow *win, ARegion *ar, View3D *v3d)
+static void backdrawview3d(
+ const struct EvaluationContext *eval_ctx, Scene *scene,
+ ARegion *ar, View3D *v3d,
+ Object *obact, Object *obedit)
{
RegionView3D *rv3d = ar->regiondata;
- struct Base *base = view_layer->basact;
- int multisample_enabled;
BLI_assert(ar->regiontype == RGN_TYPE_WINDOW);
- if (base && (base->object->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT) ||
- BKE_paint_select_face_test(base->object)))
+ if (obact && (obact->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT) ||
+ BKE_paint_select_face_test(obact)))
{
/* do nothing */
}
/* texture paint mode sampling */
- else if (base && (base->object->mode & OB_MODE_TEXTURE_PAINT) &&
+ else if (obact && (obact->mode & OB_MODE_TEXTURE_PAINT) &&
(v3d->drawtype > OB_WIRE))
{
/* do nothing */
}
- else if ((base && (base->object->mode & OB_MODE_PARTICLE_EDIT)) &&
+ else if ((obact && (obact->mode & OB_MODE_PARTICLE_EDIT)) &&
V3D_IS_ZBUF(v3d))
{
/* do nothing */
}
- else if (scene->obedit &&
+ else if ((obedit && (obedit->mode & OB_MODE_EDIT)) &&
V3D_IS_ZBUF(v3d))
{
/* do nothing */
@@ -262,14 +262,13 @@ static void backdrawview3d(const struct EvaluationContext *eval_ctx, Scene *scen
/* dithering and AA break color coding, so disable */
glDisable(GL_DITHER);
- multisample_enabled = glIsEnabled(GL_MULTISAMPLE);
- if (multisample_enabled)
- glDisable(GL_MULTISAMPLE);
-
- if (win->multisamples != USER_MULTISAMPLE_NONE) {
+ if (false) {
/* for multisample we use an offscreen FBO. multisample drawing can fail
* with color coded selection drawing, and reading back depths from such
- * a buffer can also cause a few seconds freeze on OS X / NVidia. */
+ * a buffer can also cause a few seconds freeze on OS X / NVidia.
+ *
+ * NOTE: code is no longer used now, but offscreen drawing is likely
+ * what we will always want to do for the new viewport. */
int w = BLI_rcti_size_x(&ar->winrct);
int h = BLI_rcti_size_y(&ar->winrct);
char error[256];
@@ -284,7 +283,7 @@ static void backdrawview3d(const struct EvaluationContext *eval_ctx, Scene *scen
}
if (!rv3d->gpuoffscreen) {
- rv3d->gpuoffscreen = GPU_offscreen_create(w, h, 0, false, error);
+ rv3d->gpuoffscreen = GPU_offscreen_create(w, h, 0, true, false, error);
if (!rv3d->gpuoffscreen)
fprintf(stderr, "Failed to create offscreen selection buffer for multisample: %s\n", error);
@@ -310,10 +309,11 @@ static void backdrawview3d(const struct EvaluationContext *eval_ctx, Scene *scen
ED_view3d_clipping_set(rv3d);
G.f |= G_BACKBUFSEL;
-
- if (base && ((base->flag & BASE_VISIBLED) != 0))
- draw_object_backbufsel(eval_ctx, scene, v3d, rv3d, base->object);
-
+
+ if (obact && ((obact->base_flag & BASE_VISIBLED) != 0)) {
+ draw_object_backbufsel(eval_ctx, scene, v3d, rv3d, obact);
+ }
+
if (rv3d->gpuoffscreen)
GPU_offscreen_unbind(rv3d->gpuoffscreen, true);
else
@@ -325,8 +325,6 @@ static void backdrawview3d(const struct EvaluationContext *eval_ctx, Scene *scen
v3d->zbuf = false;
glDisable(GL_DEPTH_TEST);
glEnable(GL_DITHER);
- if (multisample_enabled)
- glEnable(GL_MULTISAMPLE);
if (rv3d->rflag & RV3D_CLIPPING)
ED_view3d_clipping_disable();
@@ -356,7 +354,7 @@ static void view3d_opengl_read_Z_pixels(ARegion *ar, int x, int y, int w, int h,
void ED_view3d_backbuf_validate(const struct EvaluationContext *eval_ctx, ViewContext *vc)
{
if (vc->v3d->flag & V3D_INVALID_BACKBUF) {
- backdrawview3d(eval_ctx, vc->scene, vc->view_layer, vc->win, vc->ar, vc->v3d);
+ backdrawview3d(eval_ctx, vc->scene, vc->ar, vc->v3d, vc->obact, vc->obedit);
}
}
@@ -734,7 +732,7 @@ static void view3d_draw_bgpic(Scene *scene, const Depsgraph *depsgraph,
glDepthMask(GL_FALSE);
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
gpuPushProjectionMatrix();
gpuPushMatrix();
@@ -1302,7 +1300,7 @@ void ED_view3d_draw_select_loop(
for (base = view_layer->object_bases.first; base; base = base->next) {
if ((base->flag & BASE_VISIBLED) != 0) {
if (((base->flag & BASE_SELECTABLED) == 0) ||
- (use_obedit_skip && (scene->obedit->data == base->object->data)))
+ (use_obedit_skip && (vc->obedit->data == base->object->data)))
{
base->object->select_color = 0;
}
@@ -1422,11 +1420,14 @@ static void gpu_update_lamps_shadows_world(const EvaluationContext *eval_ctx, Sc
mul_m4_m4m4(rv3d.persmat, rv3d.winmat, rv3d.viewmat);
invert_m4_m4(rv3d.persinv, rv3d.viewinv);
+ RenderEngineType *engine_type = RE_engines_find(scene->view_render.engine_id);
+
/* no need to call ED_view3d_draw_offscreen_init since shadow buffers were already updated */
ED_view3d_draw_offscreen(
- eval_ctx, scene, eval_ctx->view_layer, v3d, &ar, winsize, winsize, viewmat, winmat,
+ eval_ctx, scene, eval_ctx->view_layer, engine_type,
+ v3d, &ar, winsize, winsize, viewmat, winmat,
false, false, true,
- NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL);
GPU_lamp_shadow_buffer_unbind(shadow->lamp);
v3d->drawtype = drawtype;
@@ -1500,18 +1501,18 @@ static void view3d_draw_objects(
const EvaluationContext *eval_ctx,
Scene *scene, View3D *v3d, ARegion *ar,
const char **grid_unit,
- const bool do_bgpic, const bool draw_offscreen, GPUFX *fx)
+ const bool do_bgpic, const bool draw_offscreen)
{
ViewLayer *view_layer = C ? CTX_data_view_layer(C) : BKE_view_layer_from_scene_get(scene);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
RegionView3D *rv3d = ar->regiondata;
Base *base;
+ Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
const bool do_camera_frame = !draw_offscreen;
const bool draw_grids = !draw_offscreen && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0;
const bool draw_floor = (rv3d->view == RV3D_VIEW_USER) || (rv3d->persp != RV3D_ORTHO);
/* only draw grids after in solid modes, else it hovers over mesh wires */
- const bool draw_grids_after = draw_grids && draw_floor && (v3d->drawtype > OB_WIRE) && fx;
- bool do_composite_xray = false;
+ const bool draw_grids_after = draw_grids && draw_floor && (v3d->drawtype > OB_WIRE);
bool xrayclear = true;
if (!draw_offscreen) {
@@ -1522,7 +1523,7 @@ static void view3d_draw_objects(
view3d_draw_clipping(rv3d);
/* set zbuffer after we draw clipping region */
- v3d->zbuf = VP_legacy_use_depth(scene, v3d);
+ v3d->zbuf = VP_legacy_use_depth(v3d, obedit);
if (v3d->zbuf) {
glEnable(GL_DEPTH_TEST);
@@ -1599,7 +1600,7 @@ static void view3d_draw_objects(
draw_dupli_objects(eval_ctx, scene, view_layer, ar, v3d, base);
}
if ((base->flag & BASE_SELECTED) == 0) {
- if (base->object != scene->obedit)
+ if (base->object != obedit)
draw_object(eval_ctx, scene, view_layer, ar, v3d, base, 0);
}
}
@@ -1611,7 +1612,7 @@ static void view3d_draw_objects(
/* draw selected and editmode */
for (base = view_layer->object_bases.first; base; base = base->next) {
if ((base->flag & BASE_VISIBLED) != 0) {
- if (base->object == scene->obedit || (base->flag & BASE_SELECTED)) {
+ if (base->object == obedit || (base->flag & BASE_SELECTED)) {
draw_object(eval_ctx, scene, view_layer, ar, v3d, base, 0);
}
}
@@ -1636,19 +1637,9 @@ static void view3d_draw_objects(
/* transp and X-ray afterdraw stuff */
if (v3d->afterdraw_transp.first) view3d_draw_transp(eval_ctx, scene, view_layer, ar, v3d);
- /* always do that here to cleanup depth buffers if none needed */
- if (fx) {
- do_composite_xray = v3d->zbuf && (v3d->afterdraw_xray.first || v3d->afterdraw_xraytransp.first);
- GPU_fx_compositor_setup_XRay_pass(fx, do_composite_xray);
- }
-
if (v3d->afterdraw_xray.first) view3d_draw_xray(eval_ctx, scene, view_layer, ar, v3d, &xrayclear);
if (v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(eval_ctx, scene, view_layer, ar, v3d, xrayclear);
- if (fx && do_composite_xray) {
- GPU_fx_compositor_XRay_resolve(fx);
- }
-
if (!draw_offscreen) {
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
}
@@ -1956,9 +1947,6 @@ static void view3d_main_region_draw_objects(const bContext *C, Scene *scene, Vie
CTX_data_eval_ctx(C, &eval_ctx);
- /* post processing */
- bool do_compositing = false;
-
/* shadow buffers, before we setup matrices */
if (draw_glsl_material(scene, view_layer, NULL, v3d, v3d->drawtype))
gpu_update_lamps_shadows_world(&eval_ctx, scene, v3d);
@@ -1986,40 +1974,9 @@ static void view3d_main_region_draw_objects(const bContext *C, Scene *scene, Vie
update_lods(scene, rv3d->viewinv[3]);
}
#endif
-
- /* framebuffer fx needed, we need to draw offscreen first */
- if (v3d->fx_settings.fx_flag && v3d->drawtype >= OB_SOLID) {
- BKE_screen_gpu_fx_validate(&v3d->fx_settings);
- GPUFXSettings fx_settings = v3d->fx_settings;
- if (!rv3d->compositor)
- rv3d->compositor = GPU_fx_compositor_create();
-
- if (rv3d->persp == RV3D_CAMOB && v3d->camera)
- BKE_camera_to_gpu_dof(v3d->camera, &fx_settings);
- else {
- fx_settings.dof = NULL;
- }
-
- do_compositing = GPU_fx_compositor_initialize_passes(rv3d->compositor, &ar->winrct, &ar->drawrct, &fx_settings);
- }
- /* enables anti-aliasing for 3D view drawing */
- if (win->multisamples != USER_MULTISAMPLE_NONE) {
- glEnable(GL_MULTISAMPLE);
- }
-
/* main drawing call */
- view3d_draw_objects(C, &eval_ctx, scene, v3d, ar, grid_unit, true, false, do_compositing ? rv3d->compositor : NULL);
-
- /* post process */
- if (do_compositing) {
- GPU_fx_do_composite_pass(rv3d->compositor, rv3d->winmat, rv3d->is_persp, scene, NULL);
- }
-
- /* Disable back anti-aliasing */
- if (win->multisamples != USER_MULTISAMPLE_NONE) {
- glDisable(GL_MULTISAMPLE);
- }
+ view3d_draw_objects(C, &eval_ctx, scene, v3d, ar, grid_unit, true, false);
if (v3d->lay_used != lay_used) { /* happens when loading old files or loading with UI load */
/* find header and force tag redraw */
@@ -2176,9 +2133,9 @@ void VP_deprecated_view3d_draw_objects(
const EvaluationContext *eval_ctx,
Scene *scene, View3D *v3d, ARegion *ar,
const char **grid_unit,
- const bool do_bgpic, const bool draw_offscreen, GPUFX *fx)
+ const bool do_bgpic, const bool draw_offscreen)
{
- view3d_draw_objects(C, eval_ctx, scene, v3d, ar, grid_unit, do_bgpic, draw_offscreen, fx);
+ view3d_draw_objects(C, eval_ctx, scene, v3d, ar, grid_unit, do_bgpic, draw_offscreen);
}
void VP_deprecated_gpu_update_lamps_shadows_world(const EvaluationContext *eval_ctx, Scene *scene, View3D *v3d)