Blender V5.3
studiolight.cc File Reference
#include "BKE_studiolight.h"
#include "BKE_appdir.hh"
#include "BKE_icons.hh"
#include "BLI_dynstr.hh"
#include "BLI_fileops.hh"
#include "BLI_fileops_types.hh"
#include "BLI_linklist.hh"
#include "BLI_listbase.hh"
#include "BLI_math_color_c.hh"
#include "BLI_math_vector_c.hh"
#include "BLI_path_utils.hh"
#include "BLI_string.hh"
#include "BLI_string_utf8.hh"
#include "CLG_log.h"
#include "DNA_color_types.h"
#include "DNA_listBase.h"
#include "IMB_colormanagement.hh"
#include "IMB_imbuf.hh"
#include "IMB_interp.hh"
#include "IMB_openexr.hh"
#include "GPU_texture.hh"
#include "MEM_guardedalloc.h"
#include <cstring>

Go to the source code of this file.

Namespaces

namespace  blender
 BMesh Iterators.

Macros

#define STUDIOLIGHT_PASSNAME_DIFFUSE   "diffuse"
#define STUDIOLIGHT_PASSNAME_SPECULAR   "specular"
#define ITER_PIXELS(type, src, channels, width, height)
#define ITER_PIXELS_END
#define IMB_SAFE_FREE(p)
#define GPU_TEXTURE_SAFE_FREE(p)
#define STUDIOLIGHT_DELETE_ICON(s)
#define STUDIOLIGHT_FILE_VERSION   1
#define READ_VAL(type, parser, id, val, lines)
#define READ_FVAL(id, val, lines)
#define READ_IVAL(id, val, lines)
#define READ_VEC3(id, val, lines)
#define READ_SOLIDLIGHT(sl, i, lines)
#define WRITE_FVAL(str, id, val)
#define WRITE_IVAL(str, id, val)
#define WRITE_VEC3(str, id, val)
#define WRITE_SOLIDLIGHT(str, sl, i)
#define STUDIOLIGHT_DIAMETER   0.95f
#define RESCALE_COORD(x)

Functions

static void blender::studiolight_free_image_buffers (StudioLight *sl)
static void blender::studiolight_free_gpu_textures (StudioLight *sl)
static void blender::studiolight_free (StudioLight *sl)
static void blender::studiolight_free_temp_resources (StudioLight *sl)
static StudioLight * blender::studiolight_create (int flag)
static void blender::studiolight_load_solid_light (StudioLight *sl)
static void blender::studiolight_write_solid_light (StudioLight *sl)
static void blender::direction_to_equirect (float r[2], const float dir[3])
static ImBuf * blender::studiolight_read_matcap_pass (ExrReadHandle *handle, const char *pass_name, const char *file_colorspace)
static void blender::studiolight_load_equirect_image (StudioLight *sl)
static void blender::studiolight_create_equirect_radiance_gputexture (StudioLight *sl)
static void blender::studiolight_create_matcap_gputexture (StudioLightImage *sli)
static void blender::studiolight_create_matcap_diffuse_gputexture (StudioLight *sl)
static void blender::studiolight_create_matcap_specular_gputexture (StudioLight *sl)
static float4 blender::studiolight_calculate_radiance (const ImBuf *ibuf, const float direction[3])
BLI_INLINE float blender::area_element (float x, float y)
static float blender::brdf_approx (float spec_color, float roughness, float NV)
static float blender::wrapped_lighting (float NL, float w)
static float blender::blinn_specular (const float L[3], const float I[3], const float N[3], const float R[3], float NL, float roughness, float wrap)
static void blender::studiolight_lights_eval (StudioLight *sl, const float normal[3], float r_color[3])
static StudioLight * blender::studiolight_add_file (const char *filepath, int flag)
static void blender::studiolight_add_files_from_datafolder (const int folder_id, const char *subfolder, int flag)
static int blender::studiolight_flag_cmp_order (const StudioLight *sl)
static int blender::studiolight_cmp (const void *a, const void *b)
static uint blender::alpha_circle_mask (float u, float v, float inner_edge, float outer_edge)
static void blender::sphere_normal_from_uv (float normal[3], float u, float v)
static void blender::studiolight_radiance_preview (uint *icon_buffer, StudioLight *sl)
static void blender::studiolight_matcap_preview (uint *icon_buffer, StudioLight *sl, bool flipped)
static void blender::studiolight_irradiance_preview (uint *icon_buffer, StudioLight *sl)
void blender::BKE_studiolight_default (SolidLight lights[4], float light_ambient[3])
void blender::BKE_studiolight_init ()
void blender::BKE_studiolight_free ()
struct StudioLight * blender::BKE_studiolight_find_default (int flag)
struct StudioLight * blender::BKE_studiolight_find (const char *name, int flag)
struct StudioLight * blender::BKE_studiolight_findindex (int index, int flag)
ListBaseT< StudioLight > & blender::BKE_studiolight_listbase ()
void blender::BKE_studiolight_preview (uint *icon_buffer, StudioLight *sl, int icon_id_type)
void blender::BKE_studiolight_ensure_flag (StudioLight *sl, int flag)
void blender::BKE_studiolight_remove (StudioLight *sl)
StudioLight * blender::BKE_studiolight_load (const char *filepath, int type)
StudioLight * blender::BKE_studiolight_create (const char *filepath, const SolidLight light[4], const float light_ambient[3])
StudioLight * blender::BKE_studiolight_studio_edit_get ()
void blender::BKE_studiolight_refresh ()
void blender::BKE_studiolight_set_free_function (StudioLight *sl, StudioLightFreeFunction *free_function, void *data)
void blender::BKE_studiolight_unset_icon_id (StudioLight *sl, int icon_id)

Variables

static ListBaseT< StudioLight > blender::studiolights
static int blender::last_studiolight_id = 0
static const char * blender::STUDIOLIGHT_LIGHTS_FOLDER = "studiolights" SEP_STR "studio" SEP_STR
static const char * blender::STUDIOLIGHT_WORLD_FOLDER = "studiolights" SEP_STR "world" SEP_STR
static const char * blender::STUDIOLIGHT_MATCAP_FOLDER = "studiolights" SEP_STR "matcap" SEP_STR
static const char * blender::STUDIOLIGHT_WORLD_DEFAULT = "forest.exr"
static const char * blender::STUDIOLIGHT_MATCAP_DEFAULT = "basic_1.exr"

Macro Definition Documentation

◆ GPU_TEXTURE_SAFE_FREE

#define GPU_TEXTURE_SAFE_FREE ( p)
Value:
do { \
if (p) { \
GPU_texture_free(p); \
p = nullptr; \
} \
} while (0)

Definition at line 96 of file studiolight.cc.

Referenced by blender::studiolight_free_gpu_textures().

◆ IMB_SAFE_FREE

#define IMB_SAFE_FREE ( p)
Value:
do { \
if (p) { \
IMB_freeImBuf(p); \
p = nullptr; \
} \
} while (0)

Definition at line 88 of file studiolight.cc.

Referenced by blender::studiolight_free_image_buffers().

◆ ITER_PIXELS

#define ITER_PIXELS ( type,
src,
channels,
width,
height )
Value:
{ \
float texel_size[2]; \
texel_size[0] = 1.0f / width; \
texel_size[1] = 1.0f / height; \
type(*pixel_)[channels] = (type(*)[channels])src; \
for (float y = 0.5 * texel_size[1]; y < 1.0; y += texel_size[1]) { \
for (float x = 0.5 * texel_size[0]; x < 1.0; x += texel_size[0], pixel_++) { \
type *pixel = *pixel_;

Iter on all pixel giving texel center position and pixel pointer.

Arguments type : type of src. src : source buffer. channels : number of channels per pixel.

Others x, y : normalized UV coordinate [0..1] of the current pixel center. texel_size[2] : UV size of a pixel in this texture. pixel[] : pointer to the current pixel.

Definition at line 71 of file studiolight.cc.

Referenced by blender::studiolight_irradiance_preview(), blender::studiolight_matcap_preview(), and blender::studiolight_radiance_preview().

◆ ITER_PIXELS_END

#define ITER_PIXELS_END

◆ READ_FVAL

#define READ_FVAL ( id,
val,
lines )
Value:
READ_VAL(float, atof, id, val, lines)
#define READ_VAL(type, parser, id, val, lines)

Definition at line 198 of file studiolight.cc.

◆ READ_IVAL

#define READ_IVAL ( id,
val,
lines )
Value:
READ_VAL(int, atoi, id, val, lines)

Definition at line 199 of file studiolight.cc.

◆ READ_SOLIDLIGHT

#define READ_SOLIDLIGHT ( sl,
i,
lines )
Value:
do { \
READ_IVAL("light[" STRINGIFY(i) "].flag", sl[i].flag, lines); \
READ_FVAL("light[" STRINGIFY(i) "].smooth", sl[i].smooth, lines); \
READ_VEC3("light[" STRINGIFY(i) "].col", sl[i].col, lines); \
READ_VEC3("light[" STRINGIFY(i) "].spec", sl[i].spec, lines); \
READ_VEC3("light[" STRINGIFY(i) "].vec", sl[i].vec, lines); \
} while (0)
#define STRINGIFY(x)
#define smooth

Definition at line 208 of file studiolight.cc.

Referenced by blender::studiolight_load_solid_light().

◆ READ_VAL

#define READ_VAL ( type,
parser,
id,
val,
lines )
Value:
do { \
for (LinkNode *line = lines; line; line = line->next) { \
char *val_str, *str = static_cast<char *>(line->link); \
if ((val_str = strstr(str, id " "))) { \
val_str += sizeof(id); \
val = parser(val_str); \
} \
} \
} while (0)
#define str(s)

Definition at line 187 of file studiolight.cc.

◆ READ_VEC3

#define READ_VEC3 ( id,
val,
lines )
Value:
do { \
READ_FVAL(id ".x", val[0], lines); \
READ_FVAL(id ".y", val[1], lines); \
READ_FVAL(id ".z", val[2], lines); \
} while (0)

Definition at line 201 of file studiolight.cc.

Referenced by blender::studiolight_load_solid_light().

◆ RESCALE_COORD

#define RESCALE_COORD ( x)

◆ STUDIOLIGHT_DELETE_ICON

#define STUDIOLIGHT_DELETE_ICON ( s)
Value:
do { \
if (s != 0) { \
BKE_icon_delete(s); \
s = 0; \
} \
} while (0)

Referenced by blender::studiolight_free().

◆ STUDIOLIGHT_DIAMETER

#define STUDIOLIGHT_DIAMETER   0.95f

Definition at line 645 of file studiolight.cc.

◆ STUDIOLIGHT_FILE_VERSION

#define STUDIOLIGHT_FILE_VERSION   1

Definition at line 185 of file studiolight.cc.

Referenced by blender::studiolight_write_solid_light().

◆ STUDIOLIGHT_PASSNAME_DIFFUSE

#define STUDIOLIGHT_PASSNAME_DIFFUSE   "diffuse"

Definition at line 46 of file studiolight.cc.

Referenced by blender::studiolight_load_equirect_image().

◆ STUDIOLIGHT_PASSNAME_SPECULAR

#define STUDIOLIGHT_PASSNAME_SPECULAR   "specular"

Definition at line 47 of file studiolight.cc.

Referenced by blender::studiolight_load_equirect_image().

◆ WRITE_FVAL

#define WRITE_FVAL ( str,
id,
val )
Value:
BLI_dynstr_appendf(str, id " %f\n", val)

Definition at line 235 of file studiolight.cc.

◆ WRITE_IVAL

#define WRITE_IVAL ( str,
id,
val )
Value:
BLI_dynstr_appendf(str, id " %d\n", val)

Definition at line 236 of file studiolight.cc.

Referenced by blender::studiolight_write_solid_light().

◆ WRITE_SOLIDLIGHT

#define WRITE_SOLIDLIGHT ( str,
sl,
i )
Value:
do { \
WRITE_IVAL(str, "light[" STRINGIFY(i) "].flag", sl[i].flag); \
WRITE_FVAL(str, "light[" STRINGIFY(i) "].smooth", sl[i].smooth); \
WRITE_VEC3(str, "light[" STRINGIFY(i) "].col", sl[i].col); \
WRITE_VEC3(str, "light[" STRINGIFY(i) "].spec", sl[i].spec); \
WRITE_VEC3(str, "light[" STRINGIFY(i) "].vec", sl[i].vec); \
} while (0)

Definition at line 245 of file studiolight.cc.

Referenced by blender::studiolight_write_solid_light().

◆ WRITE_VEC3

#define WRITE_VEC3 ( str,
id,
val )
Value:
do { \
WRITE_FVAL(str, id ".x", val[0]); \
WRITE_FVAL(str, id ".y", val[1]); \
WRITE_FVAL(str, id ".z", val[2]); \
} while (0)

Definition at line 238 of file studiolight.cc.

Referenced by blender::studiolight_write_solid_light().