Blender  V3.3
BKE_studiolight.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2006-2007 Blender Foundation. All rights reserved. */
3 
4 #pragma once
5 
12 #include "BLI_sys_types.h"
13 
14 #include "BLI_path_util.h"
15 
16 #include "DNA_userdef_types.h" /* for #SolidLight */
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 struct ImBuf;
23 
24 /*
25  * These defines are the indexes in the StudioLight.diffuse_light
26  * X_POS means the light that is traveling towards the positive X
27  * So Light direction.
28  */
29 #define STUDIOLIGHT_X_POS 0
30 #define STUDIOLIGHT_X_NEG 1
31 #define STUDIOLIGHT_Y_POS 2
32 #define STUDIOLIGHT_Y_NEG 3
33 #define STUDIOLIGHT_Z_POS 4
34 #define STUDIOLIGHT_Z_NEG 5
35 
36 #define STUDIOLIGHT_ICON_ID_TYPE_RADIANCE (1 << 0)
37 #define STUDIOLIGHT_ICON_ID_TYPE_IRRADIANCE (1 << 1)
38 #define STUDIOLIGHT_ICON_ID_TYPE_MATCAP (1 << 2)
39 #define STUDIOLIGHT_ICON_ID_TYPE_MATCAP_FLIPPED (1 << 3)
40 
41 #define STUDIOLIGHT_MAX_LIGHT 4
42 
43 #define STUDIOLIGHT_ICON_SIZE 96
44 
45 /* Only 1 - 5 is supported */
46 #define STUDIOLIGHT_SH_BANDS 2
47 
48 #define STUDIOLIGHT_SH_COEFS_LEN (STUDIOLIGHT_SH_BANDS * STUDIOLIGHT_SH_BANDS)
49 
50 #if STUDIOLIGHT_SH_BANDS > 3
51 /* Bypass L3 */
52 # define STUDIOLIGHT_SH_EFFECTIVE_COEFS_LEN (STUDIOLIGHT_SH_COEFS_LEN - 7)
53 #else
54 # define STUDIOLIGHT_SH_EFFECTIVE_COEFS_LEN STUDIOLIGHT_SH_COEFS_LEN
55 #endif
56 
57 struct GPUTexture;
58 struct StudioLight;
59 
63  /* STUDIOLIGHT_LIGHT_DIRECTION_CALCULATED = (1 << 1), */
76 
79  /* Is set for studio lights and matcaps with specular highlight pass. */
81 };
82 
83 #define STUDIOLIGHT_FLAG_ALL (STUDIOLIGHT_INTERNAL | STUDIOLIGHT_EXTERNAL_FILE)
84 #define STUDIOLIGHT_FLAG_ORIENTATIONS \
85  (STUDIOLIGHT_TYPE_STUDIO | STUDIOLIGHT_TYPE_WORLD | STUDIOLIGHT_TYPE_MATCAP)
86 #define STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE (STUDIOLIGHT_TYPE_WORLD)
87 #define STUDIOLIGHT_ORIENTATIONS_SOLID (STUDIOLIGHT_INTERNAL | STUDIOLIGHT_TYPE_STUDIO)
88 
89 typedef void StudioLightFreeFunction(struct StudioLight *, void *data);
90 
91 typedef struct StudioLightImage {
92  struct ImBuf *ibuf;
95 
96 typedef struct StudioLight {
97  struct StudioLight *next, *prev;
98 
99  int index;
100  int flag;
102  char path[FILE_MAX];
110  float light_direction[3];
119  float light_ambient[3];
120 
121  /*
122  * Free function to clean up the running icons previews (wmJob) the usage is in
123  * interface_icons. Please be aware that this was build to handle only one free function
124  * that cleans up all icons. just to keep the code simple.
125  */
129 
130 /* API */
131 
132 void BKE_studiolight_init(void);
133 void BKE_studiolight_free(void);
134 void BKE_studiolight_default(SolidLight lights[4], float light_ambient[3]);
135 struct StudioLight *BKE_studiolight_find(const char *name, int flag);
138 void BKE_studiolight_preview(uint *icon_buffer, StudioLight *sl, int icon_id_type);
139 struct ListBase *BKE_studiolight_listbase(void);
143 void BKE_studiolight_ensure_flag(StudioLight *sl, int flag);
144 void BKE_studiolight_refresh(void);
145 StudioLight *BKE_studiolight_load(const char *path, int type);
146 StudioLight *BKE_studiolight_create(const char *path,
147  const SolidLight light[4],
148  const float light_ambient[3]);
155  StudioLightFreeFunction *free_function,
156  void *data);
157 void BKE_studiolight_unset_icon_id(StudioLight *sl, int icon_id);
158 
159 #ifdef __cplusplus
160 }
161 #endif
void BKE_studiolight_remove(StudioLight *sl)
Definition: studiolight.c:1557
struct StudioLight * BKE_studiolight_findindex(int index, int flag)
Definition: studiolight.c:1478
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
struct StudioLight StudioLight
void StudioLightFreeFunction(struct StudioLight *, void *data)
struct ListBase * BKE_studiolight_listbase(void)
Definition: studiolight.c:1489
StudioLight * BKE_studiolight_load(const char *path, int type)
Definition: studiolight.c:1565
StudioLight * BKE_studiolight_create(const char *path, const SolidLight light[4], const float light_ambient[3])
Definition: studiolight.c:1571
struct StudioLightImage StudioLightImage
void BKE_studiolight_unset_icon_id(StudioLight *sl, int icon_id)
Definition: studiolight.c:1618
void BKE_studiolight_set_free_function(StudioLight *sl, StudioLightFreeFunction *free_function, void *data)
Definition: studiolight.c:1610
void BKE_studiolight_default(SolidLight lights[4], float light_ambient[3])
Definition: studiolight.c:1335
void BKE_studiolight_init(void)
Definition: studiolight.c:1388
struct StudioLight * BKE_studiolight_find(const char *name, int flag)
Definition: studiolight.c:1462
void BKE_studiolight_ensure_flag(StudioLight *sl, int flag)
Definition: studiolight.c:1517
#define STUDIOLIGHT_SH_EFFECTIVE_COEFS_LEN
struct StudioLight * BKE_studiolight_find_default(int flag)
Definition: studiolight.c:1437
#define STUDIOLIGHT_MAX_LIGHT
StudioLight * BKE_studiolight_studio_edit_get(void)
Definition: studiolight.c:1593
void BKE_studiolight_free(void)
Definition: studiolight.c:1429
void BKE_studiolight_refresh(void)
Definition: studiolight.c:1604
void BKE_studiolight_preview(uint *icon_buffer, StudioLight *sl, int icon_id_type)
Definition: studiolight.c:1494
#define FILE_MAXFILE
#define FILE_MAX
unsigned int uint
Definition: BLI_sys_types.h:67
_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:17
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