2023-08-15 16:20:26 +02:00
|
|
|
/* SPDX-FileCopyrightText: 2006-2007 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2018-05-11 16:55:14 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-02-17 22:08:12 +01:00
|
|
|
/** \file
|
|
|
|
* \ingroup bke
|
2018-05-11 16:55:14 +02:00
|
|
|
*
|
|
|
|
* Studio lighting for the 3dview
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "BLI_sys_types.h"
|
|
|
|
|
2019-09-07 15:17:40 +02:00
|
|
|
#include "BLI_path_util.h"
|
|
|
|
|
2020-12-15 00:47:58 +01:00
|
|
|
#include "DNA_userdef_types.h" /* for #SolidLight */
|
2018-05-11 16:55:14 +02:00
|
|
|
|
2020-03-02 15:07:49 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2019-09-07 15:17:40 +02:00
|
|
|
struct ImBuf;
|
2018-05-17 15:23:21 +02:00
|
|
|
|
2018-06-19 14:00:34 +02:00
|
|
|
#define STUDIOLIGHT_ICON_ID_TYPE_RADIANCE (1 << 0)
|
|
|
|
#define STUDIOLIGHT_ICON_ID_TYPE_IRRADIANCE (1 << 1)
|
|
|
|
#define STUDIOLIGHT_ICON_ID_TYPE_MATCAP (1 << 2)
|
|
|
|
#define STUDIOLIGHT_ICON_ID_TYPE_MATCAP_FLIPPED (1 << 3)
|
|
|
|
|
2018-11-29 19:54:23 +01:00
|
|
|
#define STUDIOLIGHT_MAX_LIGHT 4
|
|
|
|
|
2018-06-19 14:00:34 +02:00
|
|
|
#define STUDIOLIGHT_ICON_SIZE 96
|
2018-05-25 08:06:36 +02:00
|
|
|
|
|
|
|
struct GPUTexture;
|
2018-06-20 09:29:40 +02:00
|
|
|
struct StudioLight;
|
2018-05-11 16:55:14 +02:00
|
|
|
|
2022-04-05 00:00:20 +02:00
|
|
|
/** #StudioLight.flag */
|
2018-05-17 15:23:21 +02:00
|
|
|
enum StudioLightFlag {
|
2023-12-14 14:29:28 +01:00
|
|
|
STUDIOLIGHT_INTERNAL = (1 << 0),
|
|
|
|
STUDIOLIGHT_EXTERNAL_FILE = (1 << 1),
|
|
|
|
STUDIOLIGHT_TYPE_STUDIO = (1 << 2),
|
|
|
|
STUDIOLIGHT_TYPE_WORLD = (1 << 3),
|
|
|
|
STUDIOLIGHT_TYPE_MATCAP = (1 << 4),
|
|
|
|
STUDIOLIGHT_EXTERNAL_IMAGE_LOADED = (1 << 5),
|
|
|
|
/** GPU Texture used for lookdev mode. */
|
|
|
|
STUDIOLIGHT_EQUIRECT_RADIANCE_GPUTEXTURE = (1 << 6),
|
|
|
|
STUDIOLIGHT_USER_DEFINED = (1 << 7),
|
|
|
|
|
|
|
|
STUDIOLIGHT_MATCAP_DIFFUSE_GPUTEXTURE = (1 << 8),
|
|
|
|
STUDIOLIGHT_MATCAP_SPECULAR_GPUTEXTURE = (1 << 9),
|
2019-08-27 08:42:50 +02:00
|
|
|
/* Is set for studio lights and matcaps with specular highlight pass. */
|
2023-12-14 14:29:28 +01:00
|
|
|
STUDIOLIGHT_SPECULAR_HIGHLIGHT_PASS = (1 << 10),
|
2018-07-31 12:44:49 +02:00
|
|
|
};
|
2018-06-19 14:00:34 +02:00
|
|
|
|
2018-06-05 08:15:30 +02:00
|
|
|
#define STUDIOLIGHT_FLAG_ALL (STUDIOLIGHT_INTERNAL | STUDIOLIGHT_EXTERNAL_FILE)
|
2018-11-28 22:16:56 +01:00
|
|
|
#define STUDIOLIGHT_FLAG_ORIENTATIONS \
|
|
|
|
(STUDIOLIGHT_TYPE_STUDIO | STUDIOLIGHT_TYPE_WORLD | STUDIOLIGHT_TYPE_MATCAP)
|
|
|
|
#define STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE (STUDIOLIGHT_TYPE_WORLD)
|
2018-11-29 19:54:23 +01:00
|
|
|
#define STUDIOLIGHT_ORIENTATIONS_SOLID (STUDIOLIGHT_INTERNAL | STUDIOLIGHT_TYPE_STUDIO)
|
2018-05-11 16:55:14 +02:00
|
|
|
|
2018-06-20 09:29:40 +02:00
|
|
|
typedef void StudioLightFreeFunction(struct StudioLight *, void *data);
|
|
|
|
|
2019-08-27 08:42:50 +02:00
|
|
|
typedef struct StudioLightImage {
|
2019-09-07 15:17:40 +02:00
|
|
|
struct ImBuf *ibuf;
|
2019-08-27 08:42:50 +02:00
|
|
|
struct GPUTexture *gputexture;
|
|
|
|
} StudioLightImage;
|
|
|
|
|
2018-05-17 15:23:21 +02:00
|
|
|
typedef struct StudioLight {
|
2018-05-11 16:55:14 +02:00
|
|
|
struct StudioLight *next, *prev;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-19 14:00:34 +02:00
|
|
|
int index;
|
2018-05-11 16:55:14 +02:00
|
|
|
int flag;
|
|
|
|
char name[FILE_MAXFILE];
|
2023-05-03 06:13:27 +02:00
|
|
|
char filepath[FILE_MAX];
|
2018-06-14 10:38:17 +02:00
|
|
|
int icon_id_irradiance;
|
|
|
|
int icon_id_radiance;
|
|
|
|
int icon_id_matcap;
|
|
|
|
int icon_id_matcap_flipped;
|
2019-08-27 08:42:50 +02:00
|
|
|
StudioLightImage matcap_diffuse;
|
|
|
|
StudioLightImage matcap_specular;
|
2019-09-07 15:17:40 +02:00
|
|
|
struct ImBuf *equirect_radiance_buffer;
|
2018-11-19 01:01:43 +01:00
|
|
|
struct GPUTexture *equirect_radiance_gputexture;
|
2018-11-29 19:54:23 +01:00
|
|
|
SolidLight light[STUDIOLIGHT_MAX_LIGHT];
|
|
|
|
float light_ambient[3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-20 09:29:40 +02:00
|
|
|
/*
|
2018-06-21 09:22:34 +02:00
|
|
|
* Free function to clean up the running icons previews (wmJob) the usage is in
|
|
|
|
* interface_icons. Please be aware that this was build to handle only one free function
|
|
|
|
* that cleans up all icons. just to keep the code simple.
|
|
|
|
*/
|
2018-06-20 09:29:40 +02:00
|
|
|
StudioLightFreeFunction *free_function;
|
2018-06-25 12:02:57 +02:00
|
|
|
void *free_function_data;
|
2018-05-11 16:55:14 +02:00
|
|
|
} StudioLight;
|
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/* API */
|
|
|
|
|
2018-05-11 16:55:14 +02:00
|
|
|
void BKE_studiolight_init(void);
|
|
|
|
void BKE_studiolight_free(void);
|
2021-07-13 08:53:46 +02:00
|
|
|
void BKE_studiolight_default(SolidLight lights[4], float light_ambient[3]);
|
2018-05-25 08:06:36 +02:00
|
|
|
struct StudioLight *BKE_studiolight_find(const char *name, int flag);
|
2018-06-05 08:15:30 +02:00
|
|
|
struct StudioLight *BKE_studiolight_findindex(int index, int flag);
|
2018-12-31 15:36:09 +01:00
|
|
|
struct StudioLight *BKE_studiolight_find_default(int flag);
|
2018-06-25 12:02:57 +02:00
|
|
|
void BKE_studiolight_preview(uint *icon_buffer, StudioLight *sl, int icon_id_type);
|
2018-06-07 16:01:57 +02:00
|
|
|
struct ListBase *BKE_studiolight_listbase(void);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Ensure state of studio-lights.
|
|
|
|
*/
|
2018-05-11 16:55:14 +02:00
|
|
|
void BKE_studiolight_ensure_flag(StudioLight *sl, int flag);
|
2018-06-07 16:01:57 +02:00
|
|
|
void BKE_studiolight_refresh(void);
|
2023-05-03 06:13:27 +02:00
|
|
|
StudioLight *BKE_studiolight_load(const char *filepath, int type);
|
|
|
|
StudioLight *BKE_studiolight_create(const char *filepath,
|
2018-11-29 19:54:23 +01:00
|
|
|
const SolidLight light[4],
|
|
|
|
const float light_ambient[3]);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Only useful for workbench while editing the user-preferences.
|
|
|
|
*/
|
2018-11-29 19:54:23 +01:00
|
|
|
StudioLight *BKE_studiolight_studio_edit_get(void);
|
2018-06-22 14:48:23 +02:00
|
|
|
void BKE_studiolight_remove(StudioLight *sl);
|
2018-06-20 09:29:40 +02:00
|
|
|
void BKE_studiolight_set_free_function(StudioLight *sl,
|
|
|
|
StudioLightFreeFunction *free_function,
|
|
|
|
void *data);
|
|
|
|
void BKE_studiolight_unset_icon_id(StudioLight *sl, int icon_id);
|
2018-05-11 16:55:14 +02:00
|
|
|
|
2020-03-02 15:07:49 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|