Blender V4.3
overlay_background.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 "DRW_render.hh"
10
11#include "UI_resources.hh"
12
13#include "draw_manager_text.hh"
14#include "overlay_private.hh"
15
17{
18 OVERLAY_PassList *psl = vedata->psl;
19 OVERLAY_PrivateData *pd = vedata->stl->pd;
21 const DRWContextState *draw_ctx = DRW_context_state_get();
22 const Scene *scene = draw_ctx->scene;
23 const RegionView3D *rv3d = draw_ctx->rv3d;
24 const BoundBox *bb = rv3d ? rv3d->clipbb : nullptr;
25 const View3D *v3d = draw_ctx->v3d;
26 bool draw_clipping_bounds = (pd->clipping_state != 0);
27
28 {
30 float color_override[4] = {0.0f, 0.0f, 0.0f, 0.0f};
31 int background_type;
32
34 background_type = BG_SOLID;
35 color_override[3] = 1.0f;
36 }
37 else if (pd->space_type == SPACE_IMAGE) {
38 background_type = BG_SOLID_CHECKER;
39 }
40 else if (pd->space_type == SPACE_NODE) {
41 background_type = BG_MASK;
43 }
44 else if (!DRW_state_draw_background()) {
45 background_type = BG_CHECKER;
46 }
47 else if (v3d->shading.background_type == V3D_SHADING_BACKGROUND_WORLD && scene->world) {
48 background_type = BG_SOLID;
49 /* TODO(fclem): this is a scene referred linear color. we should convert
50 * it to display linear here. */
51 copy_v3_v3(color_override, &scene->world->horr);
52 color_override[3] = 1.0f;
53 }
55 v3d->shading.type <= OB_SOLID)
56 {
57 background_type = BG_SOLID;
58 copy_v3_v3(color_override, v3d->shading.background_color);
59 color_override[3] = 1.0f;
60 }
61 else {
64 background_type = BG_GRADIENT;
65 break;
67 background_type = BG_RADIAL;
68 break;
69 default:
71 background_type = BG_SOLID;
72 break;
73 }
74 }
75
77
80 DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
81 DRW_shgroup_uniform_texture_ref(grp, "colorBuffer", &dtxl->color);
82 DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth);
83 DRW_shgroup_uniform_vec4_copy(grp, "colorOverride", color_override);
84 DRW_shgroup_uniform_int_copy(grp, "bgType", background_type);
86 }
87
88 if (draw_clipping_bounds) {
91
95 DRW_shgroup_uniform_vec3(grp, "boundbox", &bb->vec[0][0], 8);
96
97 blender::gpu::Batch *cube = DRW_cache_cube_get();
98 DRW_shgroup_call(grp, cube, nullptr);
99 }
100 else {
101 psl->clipping_frustum_ps = nullptr;
102 }
103}
104
106{
107 OVERLAY_PassList *psl = vedata->psl;
108
109 if (DRW_state_is_fbo()) {
110 if (psl->clipping_frustum_ps) {
112 }
113
115 }
116}
MINLINE void copy_v3_v3(float r[3], const float a[3])
@ OB_SOLID
@ SPACE_NODE
@ SPACE_IMAGE
@ TH_BACKGROUND_GRADIENT_RADIAL
@ TH_BACKGROUND_SINGLE_COLOR
@ TH_BACKGROUND_GRADIENT_LINEAR
@ V3D_SHADING_BACKGROUND_VIEWPORT
@ V3D_SHADING_BACKGROUND_WORLD
#define DRW_PASS_CREATE(pass, state)
#define DRW_shgroup_uniform_block(shgroup, name, ubo)
#define DRW_shgroup_call(shgroup, geom, ob)
@ TH_BACKGROUND_TYPE
int UI_GetThemeValue(int colorid)
struct GPUShader GPUShader
blender::gpu::Batch * DRW_cache_cube_get()
DRW_Global G_draw
bool DRW_state_draw_background()
bool DRW_state_is_viewport_image_render()
DefaultTextureList * DRW_viewport_texture_list_get()
const DRWContextState * DRW_context_state_get()
bool DRW_state_is_fbo()
DRWShadingGroup * DRW_shgroup_create(GPUShader *shader, DRWPass *pass)
void DRW_shgroup_uniform_vec3(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize)
void DRW_shgroup_uniform_int_copy(DRWShadingGroup *shgroup, const char *name, const int value)
void DRW_shgroup_call_procedural_triangles(DRWShadingGroup *shgroup, const Object *ob, uint tri_count)
void DRW_shgroup_uniform_vec4_copy(DRWShadingGroup *shgroup, const char *name, const float *value)
void DRW_shgroup_uniform_texture_ref(DRWShadingGroup *shgroup, const char *name, GPUTexture **tex)
void DRW_draw_pass(DRWPass *pass)
DRWState
Definition draw_state.hh:25
@ DRW_STATE_BLEND_ALPHA
Definition draw_state.hh:55
@ DRW_STATE_BLEND_BACKGROUND
Definition draw_state.hh:58
@ DRW_STATE_WRITE_COLOR
Definition draw_state.hh:30
@ DRW_STATE_CULL_BACK
Definition draw_state.hh:43
@ DRW_STATE_BLEND_MUL
Definition draw_state.hh:60
static ulong state[N]
void OVERLAY_background_cache_init(OVERLAY_Data *vedata)
void OVERLAY_background_draw(OVERLAY_Data *vedata)
GPUShader * OVERLAY_shader_clipbound()
GPUShader * OVERLAY_shader_background()
#define BG_MASK
#define BG_SOLID_CHECKER
#define BG_GRADIENT
#define BG_RADIAL
#define BG_CHECKER
#define BG_SOLID
float vec[8][3]
RegionView3D * rv3d
GlobalsUboStorage block
GPUUniformBuf * block_ubo
OVERLAY_PassList * psl
OVERLAY_StorageList * stl
DRWPass * clipping_frustum_ps
OVERLAY_PrivateData * pd
struct BoundBox * clipbb
float background_color[3]
View3DShading shading