Workbench: Matcaps T55291
[blender.git] / source / blender / blenkernel / BKE_studiolight.h
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
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  * The Original Code is Copyright (C) 2006-2007 Blender Foundation.
19  * All rights reserved.
20  *
21  * The Original Code is: all of this file.
22  *
23  * Contributor(s): none yet.
24  *
25  * ***** END GPL LICENSE BLOCK *****
26  */
27
28 #ifndef __BKE_STUDIOLIGHT_H__
29 #define __BKE_STUDIOLIGHT_H__
30
31 /** \file BKE_studiolight.h
32  *  \ingroup bke
33  *
34  * Studio lighting for the 3dview
35  */
36
37 #include "BLI_sys_types.h"
38
39 #include "DNA_space_types.h"
40
41 #include "IMB_imbuf_types.h"
42
43 /*
44  * These defines are the indexes in the StudioLight.diffuse_light
45  * X_POS means the light that is traveling towards the positive X
46  * So Light direction.
47  */
48 #define STUDIOLIGHT_X_POS 0
49 #define STUDIOLIGHT_X_NEG 1
50 #define STUDIOLIGHT_Y_POS 2
51 #define STUDIOLIGHT_Y_NEG 3
52 #define STUDIOLIGHT_Z_POS 4
53 #define STUDIOLIGHT_Z_NEG 5
54 #define STUDIOLIGHT_ICON_ID_TYPE_RADIANCE 0
55 #define STUDIOLIGHT_ICON_ID_TYPE_IRRADIANCE 1
56
57 struct GPUTexture;
58
59 enum StudioLightFlag {
60         STUDIOLIGHT_DIFFUSE_LIGHT_CALCULATED                    = (1 << 0),
61         STUDIOLIGHT_LIGHT_DIRECTION_CALCULATED                  = (1 << 1),
62         STUDIOLIGHT_INTERNAL                                    = (1 << 2),
63         STUDIOLIGHT_EXTERNAL_FILE                               = (1 << 3),
64         STUDIOLIGHT_ORIENTATION_CAMERA                          = (1 << 4),
65         STUDIOLIGHT_ORIENTATION_WORLD                           = (1 << 5),
66         STUDIOLIGHT_ORIENTATION_VIEWNORMAL                      = (1 << 6),
67         STUDIOLIGHT_EXTERNAL_IMAGE_LOADED                       = (1 << 7),
68         STUDIOLIGHT_EQUIRECTANGULAR_IRRADIANCE_IMAGE_CALCULATED = (1 << 8),
69         STUDIOLIGHT_EQUIRECTANGULAR_RADIANCE_GPUTEXTURE         = (1 << 9),
70         STUDIOLIGHT_EQUIRECTANGULAR_IRRADIANCE_GPUTEXTURE       = (1 << 10),
71         STUDIOLIGHT_RADIANCE_BUFFERS_CALCULATED                 = (1 << 11),
72 } StudioLightFlag;
73 #define STUDIOLIGHT_FLAG_ALL (STUDIOLIGHT_INTERNAL | STUDIOLIGHT_EXTERNAL_FILE)
74 #define STUDIOLIGHT_FLAG_ORIENTATIONS (STUDIOLIGHT_ORIENTATION_CAMERA | STUDIOLIGHT_ORIENTATION_WORLD | STUDIOLIGHT_ORIENTATION_VIEWNORMAL)
75 #define STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE (STUDIOLIGHT_INTERNAL | STUDIOLIGHT_ORIENTATION_WORLD)
76 #define STUDIOLIGHT_ORIENTATIONS_SOLID (STUDIOLIGHT_ORIENTATION_CAMERA | STUDIOLIGHT_ORIENTATION_WORLD)
77
78 typedef struct StudioLight {
79         struct StudioLight *next, *prev;
80         int flag;
81         char name[FILE_MAXFILE];
82         char path[FILE_MAX];
83         int irradiance_icon_id;
84         int radiance_icon_id;
85         int index;
86         float diffuse_light[6][3];
87         float light_direction[3];
88         ImBuf *equirectangular_radiance_buffer;
89         ImBuf *equirectangular_irradiance_buffer;
90         ImBuf *radiance_cubemap_buffers[6];
91         struct GPUTexture *equirectangular_radiance_gputexture;
92         struct GPUTexture *equirectangular_irradiance_gputexture;
93 } StudioLight;
94
95 void BKE_studiolight_init(void);
96 void BKE_studiolight_free(void);
97 struct StudioLight *BKE_studiolight_find(const char *name, int flag);
98 struct StudioLight *BKE_studiolight_findindex(int index, int flag);
99 struct StudioLight *BKE_studiolight_find_first(int flag);
100 unsigned int *BKE_studiolight_preview(StudioLight *sl, int icon_size, int icon_id_type);
101 const struct ListBase *BKE_studiolight_listbase(void);
102 void BKE_studiolight_ensure_flag(StudioLight *sl, int flag);
103
104 #endif /*  __BKE_STUDIOLIGHT_H__ */