Blender V4.3
overlay_fade.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2020 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "BKE_paint.hh"
10#include "BLI_math_color.h"
11#include "DRW_render.hh"
12
13#include "ED_view3d.hh"
14
15#include "overlay_private.hh"
16
17void OVERLAY_fade_init(OVERLAY_Data * /*vedata*/) {}
18
20{
21 OVERLAY_PassList *psl = vedata->psl;
22 OVERLAY_PrivateData *pd = vedata->stl->pd;
23
24 for (int i = 0; i < 2; i++) {
25 /* Non Meshes Pass (Camera, empties, lights ...) */
28
30 pd->fade_grp[i] = DRW_shgroup_create(sh, psl->fade_ps[i]);
31
32 const DRWContextState *draw_ctx = DRW_context_state_get();
33 float color[4];
34 ED_view3d_background_color_get(draw_ctx->scene, draw_ctx->v3d, color);
35 color[3] = pd->overlay.fade_alpha;
37 srgb_to_linearrgb_v4(color, color);
38 }
39 DRW_shgroup_uniform_vec4_copy(pd->fade_grp[i], "ucolor", color);
40 }
41
42 if (!pd->use_in_front) {
44 }
45}
46
48{
49 OVERLAY_PrivateData *pd = vedata->stl->pd;
50
51 if (pd->xray_enabled) {
52 return;
53 }
54
55 const DRWContextState *draw_ctx = DRW_context_state_get();
56 const bool use_sculpt_pbvh = BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->rv3d) &&
58 const bool is_xray = (ob->dtx & OB_DRAW_IN_FRONT) != 0;
59
60 if (use_sculpt_pbvh) {
61 DRW_shgroup_call_sculpt(pd->fade_grp[is_xray], ob, false, false, false, false, false);
62 }
63 else {
64 blender::gpu::Batch *geom = DRW_cache_object_surface_get(ob);
65 if (geom) {
66 DRW_shgroup_call(pd->fade_grp[is_xray], geom, ob);
67 }
68 }
69}
70
72{
73 OVERLAY_PassList *psl = vedata->psl;
74
76}
77
79{
80 OVERLAY_PassList *psl = vedata->psl;
81
83}
bool BKE_sculptsession_use_pbvh_draw(const Object *ob, const RegionView3D *rv3d)
Definition paint.cc:2862
MINLINE void srgb_to_linearrgb_v4(float linear[4], const float srgb[4])
@ OB_DRAW_IN_FRONT
@ V3D_SHADING_BACKGROUND_THEME
#define DRW_PASS_CREATE(pass, state)
#define DRW_shgroup_call(shgroup, geom, ob)
void ED_view3d_background_color_get(const Scene *scene, const View3D *v3d, float r_color[3])
struct GPUShader GPUShader
blender::gpu::Batch * DRW_cache_object_surface_get(Object *ob)
bool DRW_state_is_image_render()
const DRWContextState * DRW_context_state_get()
DRWShadingGroup * DRW_shgroup_create(GPUShader *shader, DRWPass *pass)
void DRW_shgroup_call_sculpt(DRWShadingGroup *shgroup, Object *ob, bool use_wire, bool use_mask, bool use_fset, bool use_color, bool use_uv)
void DRW_shgroup_uniform_vec4_copy(DRWShadingGroup *shgroup, const char *name, const float *value)
void DRW_draw_pass(DRWPass *pass)
DRWState
Definition draw_state.hh:25
@ DRW_STATE_BLEND_ALPHA
Definition draw_state.hh:55
@ DRW_STATE_WRITE_COLOR
Definition draw_state.hh:30
@ DRW_STATE_DEPTH_LESS_EQUAL
Definition draw_state.hh:38
static ulong state[N]
void OVERLAY_fade_cache_populate(OVERLAY_Data *vedata, Object *ob)
void OVERLAY_fade_draw(OVERLAY_Data *vedata)
void OVERLAY_fade_infront_draw(OVERLAY_Data *vedata)
void OVERLAY_fade_init(OVERLAY_Data *)
void OVERLAY_fade_cache_init(OVERLAY_Data *vedata)
GPUShader * OVERLAY_shader_uniform_color()
#define IN_FRONT
#define NOT_IN_FRONT
RegionView3D * rv3d
OVERLAY_PassList * psl
OVERLAY_StorageList * stl
DRWShadingGroup * fade_grp[2]
OVERLAY_PrivateData * pd
View3DShading shading