Blender  V2.93
overlay_fade.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * Copyright 2020, Blender Foundation.
17  */
18 
23 #include "BKE_paint.h"
24 #include "DRW_render.h"
25 
26 #include "ED_view3d.h"
27 
28 #include "overlay_private.h"
29 
31 {
32 }
33 
35 {
36  OVERLAY_PassList *psl = vedata->psl;
37  OVERLAY_PrivateData *pd = vedata->stl->pd;
38 
39  for (int i = 0; i < 2; i++) {
40  /* Non Meshes Pass (Camera, empties, lights ...) */
43 
45  pd->fade_grp[i] = DRW_shgroup_create(sh, psl->fade_ps[i]);
46  DRW_shgroup_uniform_block(pd->fade_grp[i], "globalsBlock", G_draw.block_ubo);
47 
48  const DRWContextState *draw_ctx = DRW_context_state_get();
49  float color[4];
50  ED_view3d_background_color_get(draw_ctx->scene, draw_ctx->v3d, color);
51  color[3] = pd->overlay.fade_alpha;
53  srgb_to_linearrgb_v4(color, color);
54  }
55  DRW_shgroup_uniform_vec4_copy(pd->fade_grp[i], "color", color);
56  }
57 
58  if (!pd->use_in_front) {
60  }
61 }
62 
64 {
65  OVERLAY_PrivateData *pd = vedata->stl->pd;
66 
67  if (pd->xray_enabled) {
68  return;
69  }
70 
71  const DRWContextState *draw_ctx = DRW_context_state_get();
72  const bool use_sculpt_pbvh = BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->v3d) &&
74  const bool is_xray = (ob->dtx & OB_DRAW_IN_FRONT) != 0;
75 
76  if (use_sculpt_pbvh) {
77  DRW_shgroup_call_sculpt(pd->fade_grp[is_xray], ob, false, false);
78  }
79  else {
80  struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
81  if (geom) {
82  DRW_shgroup_call(pd->fade_grp[is_xray], geom, ob);
83  }
84  }
85 }
86 
88 {
89  OVERLAY_PassList *psl = vedata->psl;
90 
92 }
93 
95 {
96  OVERLAY_PassList *psl = vedata->psl;
97 
99 }
bool BKE_sculptsession_use_pbvh_draw(const struct Object *ob, const struct View3D *v3d)
MINLINE void srgb_to_linearrgb_v4(float linear[4], const float srgb[4])
#define UNUSED(x)
@ OB_DRAW_IN_FRONT
@ V3D_SHADING_BACKGROUND_THEME
DRWState
Definition: DRW_render.h:312
@ DRW_STATE_BLEND_ALPHA
Definition: DRW_render.h:340
@ DRW_STATE_DEPTH_EQUAL
Definition: DRW_render.h:324
@ DRW_STATE_WRITE_COLOR
Definition: DRW_render.h:315
#define DRW_PASS_CREATE(pass, state)
Definition: DRW_render.h:593
#define DRW_shgroup_call(shgroup, geom, ob)
Definition: DRW_render.h:420
void ED_view3d_background_color_get(const struct Scene *scene, const struct View3D *v3d, float r_color[3])
GPUBatch
Definition: GPU_batch.h:93
struct GPUShader GPUShader
Definition: GPU_shader.h:33
GPUBatch * DRW_cache_object_surface_get(Object *ob)
Definition: draw_cache.c:886
struct DRW_Global G_draw
Definition: draw_common.c:45
const DRWContextState * DRW_context_state_get(void)
bool DRW_state_is_image_render(void)
void DRW_shgroup_uniform_block(DRWShadingGroup *shgroup, const char *name, const GPUUniformBuf *ubo)
void DRW_shgroup_call_sculpt(DRWShadingGroup *shgroup, Object *ob, bool use_wire, bool use_mask)
DRWShadingGroup * DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass)
void DRW_shgroup_uniform_vec4_copy(DRWShadingGroup *shgroup, const char *name, const float *value)
void DRW_draw_pass(DRWPass *pass)
static ulong state[N]
void OVERLAY_fade_cache_populate(OVERLAY_Data *vedata, Object *ob)
Definition: overlay_fade.c:63
void OVERLAY_fade_draw(OVERLAY_Data *vedata)
Definition: overlay_fade.c:87
void OVERLAY_fade_infront_draw(OVERLAY_Data *vedata)
Definition: overlay_fade.c:94
void OVERLAY_fade_init(OVERLAY_Data *UNUSED(vedata))
Definition: overlay_fade.c:30
void OVERLAY_fade_cache_init(OVERLAY_Data *vedata)
Definition: overlay_fade.c:34
#define IN_FRONT
#define NOT_IN_FRONT
GPUShader * OVERLAY_shader_uniform_color(void)
struct Scene * scene
Definition: DRW_render.h:745
struct View3D * v3d
Definition: DRW_render.h:742
struct GPUUniformBuf * block_ubo
Definition: draw_common.h:210
OVERLAY_PassList * psl
OVERLAY_StorageList * stl
DRWPass * fade_ps[2]
View3DOverlay overlay
DRWShadingGroup * fade_grp[2]
struct OVERLAY_PrivateData * pd
View3DShading shading