Rename any instance of scene layer or render layer in code with view layer
[blender.git] / source / blender / draw / intern / draw_common.c
1 /*
2  * Copyright 2016, Blender Foundation.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * Contributor(s): Blender Institute
19  *
20  */
21
22 /** \file blender/draw/intern/draw_common.c
23  *  \ingroup draw
24  */
25
26 #include "DRW_render.h"
27
28 #include "GPU_shader.h"
29 #include "GPU_texture.h"
30
31 #include "UI_resources.h"
32
33 #include "BKE_global.h"
34 #include "BKE_texture.h"
35
36 #include "draw_common.h"
37
38
39 #if 0
40 #define UI_COLOR_RGB_FROM_U8(r, g, b, v4) \
41         ARRAY_SET_ITEMS(v4, (float)r / 255.0f, (float)g / 255.0f, (float)b / 255.0f, 1.0)
42 #endif
43 #define UI_COLOR_RGBA_FROM_U8(r, g, b, a, v4) \
44         ARRAY_SET_ITEMS(v4, (float)r / 255.0f, (float)g / 255.0f, (float)b / 255.0f, (float)a / 255.0f)
45
46 /* Colors & Constant */
47 GlobalsUboStorage ts;
48 struct GPUUniformBuffer *globals_ubo = NULL;
49 struct GPUTexture *globals_ramp = NULL;
50
51 void DRW_globals_update(void)
52 {
53         UI_GetThemeColor4fv(TH_WIRE, ts.colorWire);
54         UI_GetThemeColor4fv(TH_WIRE_EDIT, ts.colorWireEdit);
55         UI_GetThemeColor4fv(TH_ACTIVE, ts.colorActive);
56         UI_GetThemeColor4fv(TH_SELECT, ts.colorSelect);
57         UI_GetThemeColor4fv(TH_TRANSFORM, ts.colorTransform);
58         UI_GetThemeColor4fv(TH_GROUP_ACTIVE, ts.colorGroupActive);
59         UI_GetThemeColorShade4fv(TH_GROUP_ACTIVE, -25, ts.colorGroupSelect);
60         UI_GetThemeColor4fv(TH_GROUP, ts.colorGroup);
61         UI_COLOR_RGBA_FROM_U8(0x88, 0xFF, 0xFF, 155, ts.colorLibrarySelect);
62         UI_COLOR_RGBA_FROM_U8(0x55, 0xCC, 0xCC, 155, ts.colorLibrary);
63         UI_GetThemeColor4fv(TH_LAMP, ts.colorLamp);
64         UI_GetThemeColor4fv(TH_SPEAKER, ts.colorSpeaker);
65         UI_GetThemeColor4fv(TH_CAMERA, ts.colorCamera);
66         UI_GetThemeColor4fv(TH_EMPTY, ts.colorEmpty);
67         UI_GetThemeColor4fv(TH_VERTEX, ts.colorVertex);
68         UI_GetThemeColor4fv(TH_VERTEX_SELECT, ts.colorVertexSelect);
69         UI_GetThemeColor4fv(TH_EDITMESH_ACTIVE, ts.colorEditMeshActive);
70         UI_GetThemeColor4fv(TH_EDGE_SELECT, ts.colorEdgeSelect);
71         UI_GetThemeColor4fv(TH_EDGE_SEAM, ts.colorEdgeSeam);
72         UI_GetThemeColor4fv(TH_EDGE_SHARP, ts.colorEdgeSharp);
73         UI_GetThemeColor4fv(TH_EDGE_CREASE, ts.colorEdgeCrease);
74         UI_GetThemeColor4fv(TH_EDGE_BEVEL, ts.colorEdgeBWeight);
75         UI_GetThemeColor4fv(TH_EDGE_FACESEL, ts.colorEdgeFaceSelect);
76         UI_GetThemeColor4fv(TH_FACE, ts.colorFace);
77         UI_GetThemeColor4fv(TH_FACE_SELECT, ts.colorFaceSelect);
78         UI_GetThemeColor4fv(TH_NORMAL, ts.colorNormal);
79         UI_GetThemeColor4fv(TH_VNORMAL, ts.colorVNormal);
80         UI_GetThemeColor4fv(TH_LNORMAL, ts.colorLNormal);
81         UI_GetThemeColor4fv(TH_FACE_DOT, ts.colorFaceDot);
82         UI_GetThemeColor4fv(TH_BACK, ts.colorBackground);
83
84         /* Grid */
85         UI_GetThemeColorShade4fv(TH_GRID, 10, ts.colorGrid);
86         /* emphasise division lines lighter instead of darker, if background is darker than grid */
87         UI_GetThemeColorShade4fv(
88                 TH_GRID,
89                 (ts.colorGrid[0] + ts.colorGrid[1] + ts.colorGrid[2] + 0.12f >
90                  ts.colorBackground[0] + ts.colorBackground[1] + ts.colorBackground[2]) ?
91                 20 : -10, ts.colorGridEmphasise);
92         /* Grid Axis */
93         UI_GetThemeColorBlendShade4fv(TH_GRID, TH_AXIS_X, 0.5f, -10, ts.colorGridAxisX);
94         UI_GetThemeColorBlendShade4fv(TH_GRID, TH_AXIS_Y, 0.5f, -10, ts.colorGridAxisY);
95         UI_GetThemeColorBlendShade4fv(TH_GRID, TH_AXIS_Z, 0.5f, -10, ts.colorGridAxisZ);
96
97         UI_GetThemeColorShadeAlpha4fv(TH_TRANSFORM, 0, -80, ts.colorDeselect);
98         UI_GetThemeColorShadeAlpha4fv(TH_WIRE, 0, -30, ts.colorOutline);
99         UI_GetThemeColorShadeAlpha4fv(TH_LAMP, 0, 255, ts.colorLampNoAlpha);
100
101         ts.sizeLampCenter = (U.obcenter_dia + 1.5f) * U.pixelsize;
102         ts.sizeLampCircle = U.pixelsize * 9.0f;
103         ts.sizeLampCircleShadow = ts.sizeLampCircle + U.pixelsize * 3.0f;
104
105         /* M_SQRT2 to be at least the same size of the old square */
106         ts.sizeVertex = ceilf(UI_GetThemeValuef(TH_VERTEX_SIZE) * (float)M_SQRT2 / 2.0f);
107         ts.sizeFaceDot = ceilf(UI_GetThemeValuef(TH_FACEDOT_SIZE) * (float)M_SQRT2);
108         ts.sizeEdge = 1.0f / 2.0f; /* TODO Theme */
109         ts.sizeEdgeFix = 0.5f + 2.0f * (2.0f * (MAX2(ts.sizeVertex, ts.sizeEdge)) * (float)M_SQRT1_2);
110
111         /* TODO Waiting for notifiers to invalidate cache */
112         if (globals_ubo) {
113                 DRW_uniformbuffer_free(globals_ubo);
114         }
115
116         globals_ubo = DRW_uniformbuffer_create(sizeof(GlobalsUboStorage), &ts);
117
118         ColorBand ramp = {0};
119         float *colors;
120         int col_size;
121
122         ramp.tot = 3;
123         ramp.data[0].a = 1.0f;
124         ramp.data[0].b = 1.0f;
125         ramp.data[0].pos = 0.0f;
126         ramp.data[1].a = 1.0f;
127         ramp.data[1].g = 1.0f;
128         ramp.data[1].pos = 0.5f;
129         ramp.data[2].a = 1.0f;
130         ramp.data[2].r = 1.0f;
131         ramp.data[2].pos = 1.0f;
132
133         colorband_table_RGBA(&ramp, &colors, &col_size);
134
135         if (globals_ramp) {
136                 GPU_texture_free(globals_ramp);
137         }
138         globals_ramp = GPU_texture_create_1D(col_size, colors, NULL);
139
140         MEM_freeN(colors);
141 }
142
143 /* ********************************* SHGROUP ************************************* */
144
145 DRWShadingGroup *shgroup_dynlines_uniform_color(DRWPass *pass, float color[4])
146 {
147         GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
148
149         DRWShadingGroup *grp = DRW_shgroup_line_batch_create(sh, pass);
150         DRW_shgroup_uniform_vec4(grp, "color", color, 1);
151
152         return grp;
153 }
154
155 DRWShadingGroup *shgroup_dynpoints_uniform_color(DRWPass *pass, float color[4], float *size)
156 {
157         GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA);
158
159         DRWShadingGroup *grp = DRW_shgroup_point_batch_create(sh, pass);
160         DRW_shgroup_uniform_vec4(grp, "color", color, 1);
161         DRW_shgroup_uniform_float(grp, "size", size, 1);
162         DRW_shgroup_state_enable(grp, DRW_STATE_POINT);
163
164         return grp;
165 }
166
167 DRWShadingGroup *shgroup_groundlines_uniform_color(DRWPass *pass, float color[4])
168 {
169         GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_GROUNDLINE);
170
171         DRWShadingGroup *grp = DRW_shgroup_point_batch_create(sh, pass);
172         DRW_shgroup_uniform_vec4(grp, "color", color, 1);
173
174         return grp;
175 }
176
177 DRWShadingGroup *shgroup_groundpoints_uniform_color(DRWPass *pass, float color[4])
178 {
179         GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_GROUNDPOINT);
180
181         DRWShadingGroup *grp = DRW_shgroup_point_batch_create(sh, pass);
182         DRW_shgroup_uniform_vec4(grp, "color", color, 1);
183         DRW_shgroup_state_enable(grp, DRW_STATE_POINT);
184
185         return grp;
186 }
187
188 DRWShadingGroup *shgroup_instance_screenspace(DRWPass *pass, struct Gwn_Batch *geom, float *size)
189 {
190         GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_SCREENSPACE_VARIYING_COLOR);
191
192         DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom);
193         DRW_shgroup_attrib_float(grp, "world_pos", 3);
194         DRW_shgroup_attrib_float(grp, "color", 3);
195         DRW_shgroup_uniform_float(grp, "size", size, 1);
196         DRW_shgroup_uniform_float(grp, "pixel_size", DRW_viewport_pixelsize_get(), 1);
197         DRW_shgroup_uniform_vec3(grp, "screen_vecs[0]", DRW_viewport_screenvecs_get(), 2);
198         DRW_shgroup_state_enable(grp, DRW_STATE_STIPPLE_3);
199
200         return grp;
201 }
202
203 DRWShadingGroup *shgroup_instance_objspace_solid(DRWPass *pass, struct Gwn_Batch *geom, float (*obmat)[4])
204 {
205         static float light[3] = {0.0f, 0.0f, 1.0f};
206         GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_OBJECTSPACE_SIMPLE_LIGHTING_VARIYING_COLOR);
207
208         DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom);
209         DRW_shgroup_attrib_float(grp, "InstanceModelMatrix", 16);
210         DRW_shgroup_attrib_float(grp, "color", 4);
211         DRW_shgroup_uniform_mat4(grp, "ObjectModelMatrix", (float *)obmat);
212         DRW_shgroup_uniform_vec3(grp, "light", light, 1);
213
214         return grp;
215 }
216
217 DRWShadingGroup *shgroup_instance_objspace_wire(DRWPass *pass, struct Gwn_Batch *geom, float (*obmat)[4])
218 {
219         GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_OBJECTSPACE_VARIYING_COLOR);
220
221         DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom);
222         DRW_shgroup_attrib_float(grp, "InstanceModelMatrix", 16);
223         DRW_shgroup_attrib_float(grp, "color", 4);
224         DRW_shgroup_uniform_mat4(grp, "ObjectModelMatrix", (float *)obmat);
225
226         return grp;
227 }
228
229 DRWShadingGroup *shgroup_instance_screen_aligned(DRWPass *pass, struct Gwn_Batch *geom)
230 {
231         GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED);
232
233         DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom);
234         DRW_shgroup_attrib_float(grp, "color", 3);
235         DRW_shgroup_attrib_float(grp, "size", 1);
236         DRW_shgroup_attrib_float(grp, "InstanceModelMatrix", 16);
237         DRW_shgroup_uniform_vec3(grp, "screen_vecs[0]", DRW_viewport_screenvecs_get(), 2);
238
239         return grp;
240 }
241
242 DRWShadingGroup *shgroup_instance_axis_names(DRWPass *pass, struct Gwn_Batch *geom)
243 {
244         GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED_AXIS);
245
246         DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom);
247         DRW_shgroup_attrib_float(grp, "color", 3);
248         DRW_shgroup_attrib_float(grp, "size", 1);
249         DRW_shgroup_attrib_float(grp, "InstanceModelMatrix", 16);
250         DRW_shgroup_uniform_vec3(grp, "screen_vecs[0]", DRW_viewport_screenvecs_get(), 2);
251
252         return grp;
253 }
254
255 DRWShadingGroup *shgroup_instance_scaled(DRWPass *pass, struct Gwn_Batch *geom)
256 {
257         GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SCALE);
258
259         DRWShadingGroup *grp = DRW_shgroup_instance_create(sh_inst, pass, geom);
260         DRW_shgroup_attrib_float(grp, "color", 3);
261         DRW_shgroup_attrib_float(grp, "size", 3);
262         DRW_shgroup_attrib_float(grp, "InstanceModelMatrix", 16);
263
264         return grp;
265 }
266
267 DRWShadingGroup *shgroup_instance(DRWPass *pass, struct Gwn_Batch *geom)
268 {
269         GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE);
270
271         DRWShadingGroup *grp = DRW_shgroup_instance_create(sh_inst, pass, geom);
272         DRW_shgroup_attrib_float(grp, "color", 3);
273         DRW_shgroup_attrib_float(grp, "size", 1);
274         DRW_shgroup_attrib_float(grp, "InstanceModelMatrix", 16);
275
276         return grp;
277 }
278
279 DRWShadingGroup *shgroup_camera_instance(DRWPass *pass, struct Gwn_Batch *geom)
280 {
281         GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_CAMERA);
282
283         DRWShadingGroup *grp = DRW_shgroup_instance_create(sh_inst, pass, geom);
284         DRW_shgroup_attrib_float(grp, "color", 3);
285         DRW_shgroup_attrib_float(grp, "corners", 8);
286         DRW_shgroup_attrib_float(grp, "depth", 1);
287         DRW_shgroup_attrib_float(grp, "tria", 4);
288         DRW_shgroup_attrib_float(grp, "InstanceModelMatrix", 16);
289
290         return grp;
291 }
292
293 DRWShadingGroup *shgroup_distance_lines_instance(DRWPass *pass, struct Gwn_Batch *geom)
294 {
295         GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_DISTANCE_LINES);
296         static float point_size = 4.0f;
297
298         DRWShadingGroup *grp = DRW_shgroup_instance_create(sh_inst, pass, geom);
299         DRW_shgroup_attrib_float(grp, "color", 3);
300         DRW_shgroup_attrib_float(grp, "start", 1);
301         DRW_shgroup_attrib_float(grp, "end", 1);
302         DRW_shgroup_attrib_float(grp, "InstanceModelMatrix", 16);
303         DRW_shgroup_uniform_float(grp, "size", &point_size, 1);
304
305         return grp;
306 }
307
308 DRWShadingGroup *shgroup_spot_instance(DRWPass *pass, struct Gwn_Batch *geom)
309 {
310         GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_EDGES_VARIYING_COLOR);
311         static bool True = true;
312         static bool False = false;
313
314         DRWShadingGroup *grp = DRW_shgroup_instance_create(sh_inst, pass, geom);
315         DRW_shgroup_attrib_float(grp, "color", 3);
316         DRW_shgroup_attrib_float(grp, "InstanceModelMatrix", 16);
317         DRW_shgroup_uniform_bool(grp, "drawFront", &False, 1);
318         DRW_shgroup_uniform_bool(grp, "drawBack", &False, 1);
319         DRW_shgroup_uniform_bool(grp, "drawSilhouette", &True, 1);
320
321         return grp;
322 }
323
324 DRWShadingGroup *shgroup_instance_bone_envelope_wire(DRWPass *pass, struct Gwn_Batch *geom, float (*obmat)[4])
325 {
326         GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_BONE_ENVELOPE_WIRE);
327
328         DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom);
329         DRW_shgroup_attrib_float(grp, "InstanceModelMatrix", 16);
330         DRW_shgroup_attrib_float(grp, "color", 4);
331         DRW_shgroup_attrib_float(grp, "radius_head", 1);
332         DRW_shgroup_attrib_float(grp, "radius_tail", 1);
333         DRW_shgroup_attrib_float(grp, "distance", 1);
334         DRW_shgroup_uniform_mat4(grp, "ObjectModelMatrix", (float *)obmat);
335
336         return grp;
337 }
338
339 DRWShadingGroup *shgroup_instance_bone_envelope_solid(DRWPass *pass, struct Gwn_Batch *geom, float (*obmat)[4])
340 {
341         static float light[3] = {0.0f, 0.0f, 1.0f};
342         GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_BONE_ENVELOPE_SOLID);
343
344         DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom);
345         DRW_shgroup_attrib_float(grp, "InstanceModelMatrix", 16);
346         DRW_shgroup_attrib_float(grp, "color", 4);
347         DRW_shgroup_attrib_float(grp, "radius_head", 1);
348         DRW_shgroup_attrib_float(grp, "radius_tail", 1);
349         DRW_shgroup_uniform_mat4(grp, "ObjectModelMatrix", (float *)obmat);
350         DRW_shgroup_uniform_vec3(grp, "light", light, 1);
351
352         return grp;
353 }
354
355 DRWShadingGroup *shgroup_instance_mball_helpers(DRWPass *pass, struct Gwn_Batch *geom)
356 {
357         GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_MBALL_HELPERS);
358
359         DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom);
360         DRW_shgroup_attrib_float(grp, "ScaleTranslationMatrix", 12);
361         DRW_shgroup_attrib_float(grp, "radius", 1);
362         DRW_shgroup_attrib_float(grp, "color", 3);
363         DRW_shgroup_uniform_vec3(grp, "screen_vecs[0]", DRW_viewport_screenvecs_get(), 2);
364
365         return grp;
366 }
367
368
369 /* ******************************************** COLOR UTILS *********************************************** */
370
371 /* TODO FINISH */
372 /**
373  * Get the wire color theme_id of an object based on it's state
374  * \a r_color is a way to get a pointer to the static color var associated
375  */
376 int DRW_object_wire_theme_get(Object *ob, ViewLayer *view_layer, float **r_color)
377 {
378         const bool is_edit = (ob->mode & OB_MODE_EDIT) != 0;
379         const bool active = (view_layer->basact && view_layer->basact->object == ob);
380         /* confusing logic here, there are 2 methods of setting the color
381          * 'colortab[colindex]' and 'theme_id', colindex overrides theme_id.
382          *
383          * note: no theme yet for 'colindex' */
384         int theme_id = is_edit ? TH_WIRE_EDIT : TH_WIRE;
385
386         if (//(scene->obedit == NULL) &&
387             ((G.moving & G_TRANSFORM_OBJ) != 0) &&
388             ((ob->base_flag & BASE_SELECTED) != 0))
389         {
390                 theme_id = TH_TRANSFORM;
391         }
392         else {
393                 /* Sets the 'theme_id' or fallback to wire */
394                 if ((ob->flag & OB_FROMGROUP) != 0) {
395                         if ((ob->base_flag & BASE_SELECTED) != 0) {
396                                 theme_id = TH_GROUP_ACTIVE;
397                         }
398                         else {
399                                 theme_id = TH_GROUP;
400                         }
401                 }
402                 else {
403                         if ((ob->base_flag & BASE_SELECTED) != 0) {
404                                 theme_id = (active) ? TH_ACTIVE : TH_SELECT;
405                         }
406                         else {
407                                 if (ob->type == OB_LAMP) theme_id = TH_LAMP;
408                                 else if (ob->type == OB_SPEAKER) theme_id = TH_SPEAKER;
409                                 else if (ob->type == OB_CAMERA) theme_id = TH_CAMERA;
410                                 else if (ob->type == OB_EMPTY) theme_id = TH_EMPTY;
411                                 /* fallback to TH_WIRE */
412                         }
413                 }
414         }
415
416         if (r_color != NULL) {
417                 switch (theme_id) {
418                         case TH_WIRE_EDIT:    *r_color = ts.colorTransform; break;
419                         case TH_ACTIVE:       *r_color = ts.colorActive; break;
420                         case TH_SELECT:       *r_color = ts.colorSelect; break;
421                         case TH_GROUP:        *r_color = ts.colorGroup; break;
422                         case TH_GROUP_ACTIVE: *r_color = ts.colorGroupActive; break;
423                         case TH_TRANSFORM:    *r_color = ts.colorTransform; break;
424                         case OB_SPEAKER:      *r_color = ts.colorSpeaker; break;
425                         case OB_CAMERA:       *r_color = ts.colorCamera; break;
426                         case OB_EMPTY:        *r_color = ts.colorEmpty; break;
427                         case OB_LAMP:         *r_color = ts.colorLamp; break;
428                         default:              *r_color = ts.colorWire; break;
429                 }
430
431                 /* uses darker active color for non-active + selected */
432                 if ((theme_id == TH_GROUP_ACTIVE) && !active) {
433                         *r_color = ts.colorGroupSelect;
434                 }
435         }
436
437         return theme_id;
438 }
439
440 /* XXX This is utter shit, better find something more general */
441 float *DRW_color_background_blend_get(int theme_id)
442 {
443         static float colors[11][4];
444         float *ret;
445
446         switch (theme_id) {
447                 case TH_WIRE_EDIT:    ret = colors[0]; break;
448                 case TH_ACTIVE:       ret = colors[1]; break;
449                 case TH_SELECT:       ret = colors[2]; break;
450                 case TH_GROUP:        ret = colors[3]; break;
451                 case TH_GROUP_ACTIVE: ret = colors[4]; break;
452                 case TH_TRANSFORM:    ret = colors[5]; break;
453                 case OB_SPEAKER:      ret = colors[6]; break;
454                 case OB_CAMERA:       ret = colors[7]; break;
455                 case OB_EMPTY:        ret = colors[8]; break;
456                 case OB_LAMP:         ret = colors[9]; break;
457                 default:              ret = colors[10]; break;
458         }
459
460         UI_GetThemeColorBlendShade4fv(theme_id, TH_BACK, 0.5, 0, ret);
461
462         return ret;
463 }