Blender  V3.3
overlay_background.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2020 Blender Foundation. */
3 
8 #include "DRW_render.h"
9 
10 #include "UI_resources.h"
11 
12 #include "draw_manager_text.h"
13 #include "overlay_private.h"
14 
16 {
17  OVERLAY_PassList *psl = vedata->psl;
18  OVERLAY_PrivateData *pd = vedata->stl->pd;
20  const DRWContextState *draw_ctx = DRW_context_state_get();
21  const Scene *scene = draw_ctx->scene;
22  const RegionView3D *rv3d = draw_ctx->rv3d;
23  const BoundBox *bb = rv3d ? rv3d->clipbb : NULL;
24  const View3D *v3d = draw_ctx->v3d;
25  bool draw_clipping_bounds = (pd->clipping_state != 0);
26 
27  {
29  float color_override[4] = {0.0f, 0.0f, 0.0f, 0.0f};
30  int background_type;
31 
33  background_type = BG_SOLID;
34  color_override[3] = 1.0f;
35  }
36  else if (pd->space_type == SPACE_IMAGE) {
37  background_type = BG_SOLID_CHECKER;
38  }
39  else if (pd->space_type == SPACE_NODE) {
40  background_type = BG_MASK;
42  }
43  else if (!DRW_state_draw_background()) {
44  background_type = BG_CHECKER;
45  }
47  background_type = BG_SOLID;
48  /* TODO(fclem): this is a scene referred linear color. we should convert
49  * it to display linear here. */
50  copy_v3_v3(color_override, &scene->world->horr);
51  color_override[3] = 1.0f;
52  }
54  v3d->shading.type <= OB_SOLID) {
55  background_type = BG_SOLID;
56  copy_v3_v3(color_override, v3d->shading.background_color);
57  color_override[3] = 1.0f;
58  }
59  else {
62  background_type = BG_GRADIENT;
63  break;
65  background_type = BG_RADIAL;
66  break;
67  default:
69  background_type = BG_SOLID;
70  break;
71  }
72  }
73 
75 
78  DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
79  DRW_shgroup_uniform_texture_ref(grp, "colorBuffer", &dtxl->color);
80  DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth);
81  DRW_shgroup_uniform_vec4_copy(grp, "colorOverride", color_override);
82  DRW_shgroup_uniform_int_copy(grp, "bgType", background_type);
84  }
85 
86  if (draw_clipping_bounds) {
89 
93  DRW_shgroup_uniform_vec3(grp, "boundbox", &bb->vec[0][0], 8);
94 
95  struct GPUBatch *cube = DRW_cache_cube_get();
96  DRW_shgroup_call(grp, cube, NULL);
97  }
98  else {
100  }
101 }
102 
104 {
105  OVERLAY_PassList *psl = vedata->psl;
106 
107  if (DRW_state_is_fbo()) {
108  if (psl->clipping_frustum_ps) {
110  }
111 
113  }
114 }
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
DRWState
Definition: DRW_render.h:298
@ DRW_STATE_BLEND_ALPHA
Definition: DRW_render.h:328
@ DRW_STATE_BLEND_BACKGROUND
Definition: DRW_render.h:331
@ DRW_STATE_WRITE_COLOR
Definition: DRW_render.h:303
@ DRW_STATE_CULL_BACK
Definition: DRW_render.h:316
@ DRW_STATE_BLEND_MUL
Definition: DRW_render.h:333
#define DRW_PASS_CREATE(pass, state)
Definition: DRW_render.h:690
#define DRW_shgroup_uniform_block(shgroup, name, ubo)
Definition: DRW_render.h:651
#define DRW_shgroup_call(shgroup, geom, ob)
Definition: DRW_render.h:414
GPUBatch
Definition: GPU_batch.h:78
struct GPUShader GPUShader
Definition: GPU_shader.h:20
@ TH_BACKGROUND_TYPE
Definition: UI_resources.h:311
int UI_GetThemeValue(int colorid)
Definition: resources.c:1147
Scene scene
GPUBatch * DRW_cache_cube_get(void)
Definition: draw_cache.c:695
struct DRW_Global G_draw
Definition: draw_common.c:32
bool DRW_state_is_opengl_render(void)
bool DRW_state_is_fbo(void)
const DRWContextState * DRW_context_state_get(void)
bool DRW_state_draw_background(void)
DefaultTextureList * DRW_viewport_texture_list_get(void)
Definition: draw_manager.c:638
void DRW_shgroup_uniform_vec3(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize)
void DRW_shgroup_call_procedural_triangles(DRWShadingGroup *shgroup, Object *ob, uint tri_count)
void DRW_shgroup_uniform_int_copy(DRWShadingGroup *shgroup, const char *name, const int value)
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_shgroup_uniform_texture_ref(DRWShadingGroup *shgroup, const char *name, GPUTexture **tex)
void DRW_draw_pass(DRWPass *pass)
const int state
ccl_gpu_kernel_postfix ccl_global float int int int int sh
void OVERLAY_background_cache_init(OVERLAY_Data *vedata)
void OVERLAY_background_draw(OVERLAY_Data *vedata)
GPUShader * OVERLAY_shader_background(void)
GPUShader * OVERLAY_shader_clipbound(void)
#define BG_MASK
#define BG_SOLID_CHECKER
#define BG_GRADIENT
#define BG_RADIAL
#define BG_CHECKER
#define BG_SOLID
float vec[8][3]
struct Scene * scene
Definition: DRW_render.h:979
struct View3D * v3d
Definition: DRW_render.h:976
struct RegionView3D * rv3d
Definition: DRW_render.h:975
GlobalsUboStorage block
Definition: draw_common.h:127
struct GPUUniformBuf * block_ubo
Definition: draw_common.h:129
struct GPUTexture * depth
struct GPUTexture * color
OVERLAY_PassList * psl
OVERLAY_StorageList * stl
DRWPass * clipping_frustum_ps
DRWPass * background_ps
struct OVERLAY_PrivateData * pd
struct BoundBox * clipbb
struct World * world
float background_color[3]
View3DShading shading
float horr