Blender  V2.93
BKE_studiolight.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2006-2007 Blender Foundation.
17  * All rights reserved.
18  */
19 
20 #pragma once
21 
28 #include "BLI_sys_types.h"
29 
30 #include "BLI_path_util.h"
31 
32 #include "DNA_userdef_types.h" /* for #SolidLight */
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 struct ImBuf;
39 
40 /*
41  * These defines are the indexes in the StudioLight.diffuse_light
42  * X_POS means the light that is traveling towards the positive X
43  * So Light direction.
44  */
45 #define STUDIOLIGHT_X_POS 0
46 #define STUDIOLIGHT_X_NEG 1
47 #define STUDIOLIGHT_Y_POS 2
48 #define STUDIOLIGHT_Y_NEG 3
49 #define STUDIOLIGHT_Z_POS 4
50 #define STUDIOLIGHT_Z_NEG 5
51 
52 #define STUDIOLIGHT_ICON_ID_TYPE_RADIANCE (1 << 0)
53 #define STUDIOLIGHT_ICON_ID_TYPE_IRRADIANCE (1 << 1)
54 #define STUDIOLIGHT_ICON_ID_TYPE_MATCAP (1 << 2)
55 #define STUDIOLIGHT_ICON_ID_TYPE_MATCAP_FLIPPED (1 << 3)
56 
57 #define STUDIOLIGHT_MAX_LIGHT 4
58 
59 #define STUDIOLIGHT_ICON_SIZE 96
60 
61 /* Only 1 - 5 is supported */
62 #define STUDIOLIGHT_SH_BANDS 2
63 
64 #define STUDIOLIGHT_SH_COEFS_LEN (STUDIOLIGHT_SH_BANDS * STUDIOLIGHT_SH_BANDS)
65 
66 #if STUDIOLIGHT_SH_BANDS > 3
67 /* Bypass L3 */
68 # define STUDIOLIGHT_SH_EFFECTIVE_COEFS_LEN (STUDIOLIGHT_SH_COEFS_LEN - 7)
69 #else
70 # define STUDIOLIGHT_SH_EFFECTIVE_COEFS_LEN STUDIOLIGHT_SH_COEFS_LEN
71 #endif
72 
73 struct GPUTexture;
74 struct StudioLight;
75 
76 /* StudioLight.flag */
79  /* STUDIOLIGHT_LIGHT_DIRECTION_CALCULATED = (1 << 1), */
92 
95  /* Is set for studio lights and matcaps with specular highlight pass. */
97 };
98 
99 #define STUDIOLIGHT_FLAG_ALL (STUDIOLIGHT_INTERNAL | STUDIOLIGHT_EXTERNAL_FILE)
100 #define STUDIOLIGHT_FLAG_ORIENTATIONS \
101  (STUDIOLIGHT_TYPE_STUDIO | STUDIOLIGHT_TYPE_WORLD | STUDIOLIGHT_TYPE_MATCAP)
102 #define STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE (STUDIOLIGHT_TYPE_WORLD)
103 #define STUDIOLIGHT_ORIENTATIONS_SOLID (STUDIOLIGHT_INTERNAL | STUDIOLIGHT_TYPE_STUDIO)
104 
105 typedef void StudioLightFreeFunction(struct StudioLight *, void *data);
106 
107 typedef struct StudioLightImage {
108  struct ImBuf *ibuf;
111 
112 typedef struct StudioLight {
113  struct StudioLight *next, *prev;
114 
115  int index;
116  int flag;
118  char path[FILE_MAX];
126  float light_direction[3];
135  float light_ambient[3];
136 
137  /*
138  * Free function to clean up the running icons previews (wmJob) the usage is in
139  * interface_icons. Please be aware that this was build to handle only one free function
140  * that cleans up all icons. just to keep the code simple.
141  */
145 
146 void BKE_studiolight_init(void);
147 void BKE_studiolight_free(void);
148 void BKE_studiolight_default(SolidLight lights[4], float light_ambient[4]);
149 struct StudioLight *BKE_studiolight_find(const char *name, int flag);
152 void BKE_studiolight_preview(uint *icon_buffer, StudioLight *sl, int icon_id_type);
153 struct ListBase *BKE_studiolight_listbase(void);
154 void BKE_studiolight_ensure_flag(StudioLight *sl, int flag);
155 void BKE_studiolight_refresh(void);
156 StudioLight *BKE_studiolight_load(const char *path, int type);
157 StudioLight *BKE_studiolight_create(const char *path,
158  const SolidLight light[4],
159  const float light_ambient[3]);
163  StudioLightFreeFunction *free_function,
164  void *data);
165 void BKE_studiolight_unset_icon_id(StudioLight *sl, int icon_id);
166 
167 #ifdef __cplusplus
168 }
169 #endif
void BKE_studiolight_remove(StudioLight *sl)
Definition: studiolight.c:1578
struct StudioLight * BKE_studiolight_findindex(int index, int flag)
Definition: studiolight.c:1499
StudioLightFlag
@ STUDIOLIGHT_EXTERNAL_IMAGE_LOADED
@ STUDIOLIGHT_EQUIRECT_RADIANCE_GPUTEXTURE
@ STUDIOLIGHT_MATCAP_SPECULAR_GPUTEXTURE
@ STUDIOLIGHT_USER_DEFINED
@ STUDIOLIGHT_EQUIRECT_IRRADIANCE_IMAGE_CALCULATED
@ STUDIOLIGHT_INTERNAL
@ STUDIOLIGHT_UI_EXPANDED
@ STUDIOLIGHT_SPHERICAL_HARMONICS_COEFFICIENTS_CALCULATED
@ STUDIOLIGHT_MATCAP_DIFFUSE_GPUTEXTURE
@ STUDIOLIGHT_TYPE_MATCAP
@ STUDIOLIGHT_TYPE_WORLD
@ STUDIOLIGHT_RADIANCE_BUFFERS_CALCULATED
@ STUDIOLIGHT_SPECULAR_HIGHLIGHT_PASS
@ STUDIOLIGHT_EQUIRECT_IRRADIANCE_GPUTEXTURE
@ STUDIOLIGHT_TYPE_STUDIO
@ STUDIOLIGHT_EXTERNAL_FILE
void BKE_studiolight_default(SolidLight lights[4], float light_ambient[4])
Definition: studiolight.c:1355
struct StudioLight StudioLight
void StudioLightFreeFunction(struct StudioLight *, void *data)
struct ListBase * BKE_studiolight_listbase(void)
Definition: studiolight.c:1510
StudioLight * BKE_studiolight_load(const char *path, int type)
Definition: studiolight.c:1586
StudioLight * BKE_studiolight_create(const char *path, const SolidLight light[4], const float light_ambient[3])
Definition: studiolight.c:1592
struct StudioLightImage StudioLightImage
void BKE_studiolight_unset_icon_id(StudioLight *sl, int icon_id)
Definition: studiolight.c:1640
void BKE_studiolight_set_free_function(StudioLight *sl, StudioLightFreeFunction *free_function, void *data)
Definition: studiolight.c:1632
void BKE_studiolight_init(void)
Definition: studiolight.c:1409
struct StudioLight * BKE_studiolight_find(const char *name, int flag)
Definition: studiolight.c:1483
void BKE_studiolight_ensure_flag(StudioLight *sl, int flag)
Definition: studiolight.c:1539
#define STUDIOLIGHT_SH_EFFECTIVE_COEFS_LEN
struct StudioLight * BKE_studiolight_find_default(int flag)
Definition: studiolight.c:1458
#define STUDIOLIGHT_MAX_LIGHT
StudioLight * BKE_studiolight_studio_edit_get(void)
Definition: studiolight.c:1615
void BKE_studiolight_free(void)
Definition: studiolight.c:1450
void BKE_studiolight_refresh(void)
Definition: studiolight.c:1626
void BKE_studiolight_preview(uint *icon_buffer, StudioLight *sl, int icon_id_type)
Definition: studiolight.c:1515
#define FILE_MAXFILE
#define FILE_MAX
unsigned int uint
Definition: BLI_sys_types.h:83
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
struct GPUTexture GPUTexture
Definition: GPU_texture.h:33
struct GPUTexture * gputexture
struct ImBuf * ibuf
StudioLightImage matcap_specular
struct StudioLight * prev
SolidLight light[STUDIOLIGHT_MAX_LIGHT]
void * free_function_data
struct StudioLight * next
float light_direction[3]
struct GPUTexture * equirect_radiance_gputexture
char path[FILE_MAX]
float spherical_harmonics_coefs[STUDIOLIGHT_SH_EFFECTIVE_COEFS_LEN][3]
struct ImBuf * equirect_irradiance_buffer
StudioLightFreeFunction * free_function
char * path_sh_cache
struct ImBuf * equirect_radiance_buffer
int icon_id_matcap_flipped
char name[FILE_MAXFILE]
char * path_irr_cache
StudioLightImage matcap_diffuse
struct ImBuf * radiance_cubemap_buffers[6]
float light_ambient[3]
struct GPUTexture * equirect_irradiance_gputexture