Blender V4.3
BKE_shader_fx.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4#pragma once
5
10#include "BLI_compiler_attrs.h"
11#include "DNA_shader_fx_types.h" /* Needed for all enum type definitions. */
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17struct ARegionType;
18struct BlendDataReader;
19struct BlendWriter;
20struct ID;
21struct ListBase;
23struct Object;
24struct ShaderFxData;
25
26#define SHADER_FX_ACTIVE(_fx, _is_render) \
27 ((((_fx)->mode & eShaderFxMode_Realtime) && (_is_render == false)) || \
28 (((_fx)->mode & eShaderFxMode_Render) && (_is_render == true)))
29#define SHADER_FX_EDIT(_fx, _is_edit) ((((_fx)->mode & eShaderFxMode_Editmode) == 0) && (_is_edit))
30
31typedef enum {
32 /* Should not be used, only for None type */
34
35 /* grease pencil effects */
38
39typedef enum {
41
42 /* For effects that support editmode this determines if the
43 * effect should be enabled by default in editmode.
44 */
46
47 /* max one per type */
49
50 /* can't be added manually by user */
53
54typedef void (*ShaderFxIDWalkFunc)(void *user_data,
55 struct Object *ob,
56 struct ID **idpoin,
57 int cb_flag);
58typedef void (*ShaderFxTexWalkFunc)(void *user_data,
59 struct Object *ob,
60 struct ShaderFxData *fx,
61 const char *propname);
62
63typedef struct ShaderFxTypeInfo {
64 /* The user visible name for this effect */
65 char name[32];
66
67 /* The DNA struct name for the effect data type, used to
68 * write the DNA data out.
69 */
70 char struct_name[32];
71
72 /* The size of the effect data type, used by allocation. */
74
77
78 /* Copy instance data for this effect type. Should copy all user
79 * level settings to the target effect.
80 */
81 void (*copy_data)(const struct ShaderFxData *fx, struct ShaderFxData *target);
82
83 /* Initialize new instance data for this effect type, this function
84 * should set effect variables to their default values.
85 *
86 * This function is optional.
87 */
88 void (*init_data)(struct ShaderFxData *fx);
89
90 /* Free internal effect data variables, this function should
91 * not free the fx variable itself.
92 *
93 * This function is optional.
94 */
95 void (*free_data)(struct ShaderFxData *fx);
96
97 /* Return a boolean value indicating if this effect is able to be
98 * calculated based on the effect data. This is *not* regarding the
99 * fx->flag, that is tested by the system, this is just if the data
100 * validates (for example, a lattice will return false if the lattice
101 * object is not defined).
102 *
103 * This function is optional (assumes never disabled if not present).
104 */
105 bool (*is_disabled)(struct ShaderFxData *fx, bool use_render_params);
106
107 /* Add the appropriate relations to the dependency graph.
108 *
109 * This function is optional.
110 */
111 void (*update_depsgraph)(struct ShaderFxData *fx,
112 const struct ModifierUpdateDepsgraphContext *ctx);
113
114 /* Should return true if the effect needs to be recalculated on time
115 * changes.
116 *
117 * This function is optional (assumes false if not present).
118 */
119 bool (*depends_on_time)(struct ShaderFxData *fx);
120
121 /* Should call the given walk function with a pointer to each ID
122 * pointer (i.e. each data-block pointer) that the effect data
123 * stores. This is used for linking on file load and for
124 * unlinking data-blocks or forwarding data-block references.
125 *
126 * This function is optional.
127 */
128 void (*foreach_ID_link)(struct ShaderFxData *fx,
129 struct Object *ob,
131 void *user_data);
132
133 /* Register the panel types for the effect's UI. */
134 void (*panel_register)(struct ARegionType *region_type);
136
137#define SHADERFX_TYPE_PANEL_PREFIX "FX_PT_"
138
142void BKE_shaderfx_init(void);
143
150void BKE_shaderfxType_panel_id(ShaderFxType type, char *r_idname);
153struct ShaderFxData *BKE_shaderfx_new(int type);
154void BKE_shaderfx_free_ex(struct ShaderFxData *fx, int flag);
155void BKE_shaderfx_free(struct ShaderFxData *fx);
159void BKE_shaderfx_unique_name(struct ListBase *shaders, struct ShaderFxData *fx);
168 const struct ShaderFxData *shaderfx);
170struct ShaderFxData *BKE_shaderfx_findby_name(struct Object *ob, const char *name);
171void BKE_shaderfx_copydata_generic(const struct ShaderFxData *fx_src, struct ShaderFxData *fx_dst);
172void BKE_shaderfx_copydata(struct ShaderFxData *fx, struct ShaderFxData *target);
173void BKE_shaderfx_copydata_ex(struct ShaderFxData *fx, struct ShaderFxData *target, int flag);
174void BKE_shaderfx_copy(struct ListBase *dst, const struct ListBase *src);
175void BKE_shaderfx_foreach_ID_link(struct Object *ob, ShaderFxIDWalkFunc walk, void *user_data);
176
180bool BKE_shaderfx_has_gpencil(const struct Object *ob);
181
182void BKE_shaderfx_blend_write(struct BlendWriter *writer, struct ListBase *fxbase);
184 struct ListBase *lb,
185 struct Object *ob);
186
187#ifdef __cplusplus
188}
189#endif
void BKE_shaderfx_foreach_ID_link(struct Object *ob, ShaderFxIDWalkFunc walk, void *user_data)
Definition shader_fx.cc:240
bool BKE_shaderfx_depends_ontime(struct ShaderFxData *fx)
Definition shader_fx.cc:124
ShaderFxTypeType
@ eShaderFxType_NoneType
@ eShaderFxType_GpencilType
void BKE_shaderfx_init(void)
Definition shader_fx.cc:48
struct ShaderFxData * BKE_shaderfx_findby_type(struct Object *ob, ShaderFxType type)
Definition shader_fx.cc:227
void BKE_shaderfx_copy(struct ListBase *dst, const struct ListBase *src)
void BKE_shaderfx_free_ex(struct ShaderFxData *fx, int flag)
Definition shader_fx.cc:90
void BKE_shaderfx_blend_write(struct BlendWriter *writer, struct ListBase *fxbase)
Definition shader_fx.cc:259
void BKE_shaderfxType_panel_id(ShaderFxType type, char *r_idname)
Definition shader_fx.cc:147
bool BKE_shaderfx_has_gpencil(const struct Object *ob)
struct ShaderFxData * BKE_shaderfx_new(int type)
Definition shader_fx.cc:54
void BKE_shaderfx_free(struct ShaderFxData *fx)
Definition shader_fx.cc:110
void BKE_shaderfx_copydata(struct ShaderFxData *fx, struct ShaderFxData *target)
Definition shader_fx.cc:205
void(* ShaderFxTexWalkFunc)(void *user_data, struct Object *ob, struct ShaderFxData *fx, const char *propname)
void BKE_shaderfx_blend_read_data(struct BlendDataReader *reader, struct ListBase *lb, struct Object *ob)
Definition shader_fx.cc:275
struct ShaderFxTypeInfo ShaderFxTypeInfo
void BKE_shaderfx_panel_expand(struct ShaderFxData *fx)
Definition shader_fx.cc:153
void BKE_shaderfx_copydata_ex(struct ShaderFxData *fx, struct ShaderFxData *target, int flag)
Definition shader_fx.cc:186
bool BKE_shaderfx_is_nonlocal_in_liboverride(const struct Object *ob, const struct ShaderFxData *shaderfx)
const ShaderFxTypeInfo * BKE_shaderfx_get_info(ShaderFxType type)
Definition shader_fx.cc:131
struct ShaderFxData * BKE_shaderfx_findby_name(struct Object *ob, const char *name)
Definition shader_fx.cc:253
void BKE_shaderfx_copydata_generic(const struct ShaderFxData *fx_src, struct ShaderFxData *fx_dst)
void BKE_shaderfx_unique_name(struct ListBase *shaders, struct ShaderFxData *fx)
Definition shader_fx.cc:115
ShaderFxTypeFlag
@ eShaderFxTypeFlag_SupportsEditmode
@ eShaderFxTypeFlag_NoUserAdd
@ eShaderFxTypeFlag_EnableInEditmode
@ eShaderFxTypeFlag_Single
void(* ShaderFxIDWalkFunc)(void *user_data, struct Object *ob, struct ID **idpoin, int cb_flag)
Definition DNA_ID.h:413
void(* copy_data)(const struct ShaderFxData *fx, struct ShaderFxData *target)
ShaderFxTypeFlag flags
void(* update_depsgraph)(struct ShaderFxData *fx, const struct ModifierUpdateDepsgraphContext *ctx)
ShaderFxTypeType type
void(* free_data)(struct ShaderFxData *fx)
void(* init_data)(struct ShaderFxData *fx)
void(* panel_register)(struct ARegionType *region_type)
void(* foreach_ID_link)(struct ShaderFxData *fx, struct Object *ob, ShaderFxIDWalkFunc walk, void *user_data)
bool(* depends_on_time)(struct ShaderFxData *fx)
bool(* is_disabled)(struct ShaderFxData *fx, bool use_render_params)
uint8_t flag
Definition wm_window.cc:138