Blender  V3.3
BKE_shader_fx.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 #pragma once
3 
8 #include "BLI_compiler_attrs.h"
9 #include "DNA_shader_fx_types.h" /* needed for all enum typdefs */
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 struct ARegionType;
16 struct BlendDataReader;
17 struct BlendLibReader;
18 struct BlendWriter;
19 struct ID;
20 struct ListBase;
22 struct Object;
23 struct ShaderFxData;
24 
25 #define SHADER_FX_ACTIVE(_fx, _is_render) \
26  ((((_fx)->mode & eShaderFxMode_Realtime) && (_is_render == false)) || \
27  (((_fx)->mode & eShaderFxMode_Render) && (_is_render == true)))
28 #define SHADER_FX_EDIT(_fx, _is_edit) ((((_fx)->mode & eShaderFxMode_Editmode) == 0) && (_is_edit))
29 
30 typedef enum {
31  /* Should not be used, only for None type */
33 
34  /* grease pencil effects */
37 
38 typedef enum {
40 
41  /* For effects that support editmode this determines if the
42  * effect should be enabled by default in editmode.
43  */
45 
46  /* max one per type */
48 
49  /* can't be added manually by user */
52 
53 typedef void (*ShaderFxIDWalkFunc)(void *userData,
54  struct Object *ob,
55  struct ID **idpoin,
56  int cb_flag);
57 typedef void (*ShaderFxTexWalkFunc)(void *userData,
58  struct Object *ob,
59  struct ShaderFxData *fx,
60  const char *propname);
61 
62 typedef struct ShaderFxTypeInfo {
63  /* The user visible name for this effect */
64  char name[32];
65 
66  /* The DNA struct name for the effect data type, used to
67  * write the DNA data out.
68  */
69  char struct_name[32];
70 
71  /* The size of the effect data type, used by allocation. */
73 
76 
77  /* Copy instance data for this effect type. Should copy all user
78  * level settings to the target effect.
79  */
80  void (*copyData)(const struct ShaderFxData *fx, struct ShaderFxData *target);
81 
82  /* Initialize new instance data for this effect type, this function
83  * should set effect variables to their default values.
84  *
85  * This function is optional.
86  */
87  void (*initData)(struct ShaderFxData *fx);
88 
89  /* Free internal effect data variables, this function should
90  * not free the fx variable itself.
91  *
92  * This function is optional.
93  */
94  void (*freeData)(struct ShaderFxData *fx);
95 
96  /* Return a boolean value indicating if this effect is able to be
97  * calculated based on the effect data. This is *not* regarding the
98  * fx->flag, that is tested by the system, this is just if the data
99  * validates (for example, a lattice will return false if the lattice
100  * object is not defined).
101  *
102  * This function is optional (assumes never disabled if not present).
103  */
104  bool (*isDisabled)(struct ShaderFxData *fx, int userRenderParams);
105 
106  /* Add the appropriate relations to the dependency graph.
107  *
108  * This function is optional.
109  */
111  const struct ModifierUpdateDepsgraphContext *ctx);
112 
113  /* Should return true if the effect needs to be recalculated on time
114  * changes.
115  *
116  * This function is optional (assumes false if not present).
117  */
119 
120  /* Should call the given walk function with a pointer to each ID
121  * pointer (i.e. each data-block pointer) that the effect data
122  * stores. This is used for linking on file load and for
123  * unlinking data-blocks or forwarding data-block references.
124  *
125  * This function is optional.
126  */
128  struct Object *ob,
129  ShaderFxIDWalkFunc walk,
130  void *userData);
131 
132  /* Register the panel types for the effect's UI. */
133  void (*panelRegister)(struct ARegionType *region_type);
135 
136 #define SHADERFX_TYPE_PANEL_PREFIX "FX_PT_"
137 
141 void BKE_shaderfx_init(void);
142 
149 void BKE_shaderfxType_panel_id(ShaderFxType type, char *r_idname);
150 void BKE_shaderfx_panel_expand(struct ShaderFxData *fx);
152 struct ShaderFxData *BKE_shaderfx_new(int type);
153 void BKE_shaderfx_free_ex(struct ShaderFxData *fx, int flag);
154 void BKE_shaderfx_free(struct ShaderFxData *fx);
158 bool BKE_shaderfx_unique_name(struct ListBase *shaderfx, struct ShaderFxData *fx);
167  const struct ShaderFxData *shaderfx);
169 struct ShaderFxData *BKE_shaderfx_findby_name(struct Object *ob, const char *name);
170 void BKE_shaderfx_copydata_generic(const struct ShaderFxData *fx_src, struct ShaderFxData *fx_dst);
171 void BKE_shaderfx_copydata(struct ShaderFxData *fx, struct ShaderFxData *target);
172 void BKE_shaderfx_copydata_ex(struct ShaderFxData *fx, struct ShaderFxData *target, int flag);
173 void BKE_shaderfx_copy(struct ListBase *dst, const struct ListBase *src);
174 void BKE_shaderfx_foreach_ID_link(struct Object *ob, ShaderFxIDWalkFunc walk, void *userData);
175 
179 bool BKE_shaderfx_has_gpencil(const struct Object *ob);
180 
181 void BKE_shaderfx_blend_write(struct BlendWriter *writer, struct ListBase *fxbase);
182 void BKE_shaderfx_blend_read_data(struct BlendDataReader *reader, struct ListBase *lb);
183 void BKE_shaderfx_blend_read_lib(struct BlendLibReader *reader, struct Object *ob);
184 
185 #ifdef __cplusplus
186 }
187 #endif
bool BKE_shaderfx_depends_ontime(struct ShaderFxData *fx)
Definition: shader_fx.c:132
void BKE_shaderfx_foreach_ID_link(struct Object *ob, ShaderFxIDWalkFunc walk, void *userData)
Definition: shader_fx.c:246
ShaderFxTypeType
Definition: BKE_shader_fx.h:30
@ eShaderFxType_NoneType
Definition: BKE_shader_fx.h:32
@ eShaderFxType_GpencilType
Definition: BKE_shader_fx.h:35
void BKE_shaderfx_init(void)
Definition: shader_fx.c:56
void BKE_shaderfx_copy(struct ListBase *dst, const struct ListBase *src)
void(* ShaderFxIDWalkFunc)(void *userData, struct Object *ob, struct ID **idpoin, int cb_flag)
Definition: BKE_shader_fx.h:53
void BKE_shaderfx_free_ex(struct ShaderFxData *fx, int flag)
Definition: shader_fx.c:97
void BKE_shaderfx_blend_write(struct BlendWriter *writer, struct ListBase *fxbase)
Definition: shader_fx.c:264
void BKE_shaderfxType_panel_id(ShaderFxType type, char *r_idname)
Definition: shader_fx.c:155
bool BKE_shaderfx_has_gpencil(const struct Object *ob)
struct ShaderFxData * BKE_shaderfx_findby_type(struct Object *ob, ShaderFxType type)
Definition: shader_fx.c:233
void BKE_shaderfx_free(struct ShaderFxData *fx)
Definition: shader_fx.c:117
void BKE_shaderfx_copydata(struct ShaderFxData *fx, struct ShaderFxData *target)
Definition: shader_fx.c:215
const ShaderFxTypeInfo * BKE_shaderfx_get_info(ShaderFxType type)
Definition: shader_fx.c:139
void BKE_shaderfx_blend_read_lib(struct BlendLibReader *reader, struct Object *ob)
Definition: shader_fx.c:294
struct ShaderFxTypeInfo ShaderFxTypeInfo
struct ShaderFxData * BKE_shaderfx_new(int type)
Definition: shader_fx.c:62
void(* ShaderFxTexWalkFunc)(void *userData, struct Object *ob, struct ShaderFxData *fx, const char *propname)
Definition: BKE_shader_fx.h:57
void BKE_shaderfx_panel_expand(struct ShaderFxData *fx)
Definition: shader_fx.c:163
void BKE_shaderfx_copydata_ex(struct ShaderFxData *fx, struct ShaderFxData *target, int flag)
Definition: shader_fx.c:196
struct ShaderFxData * BKE_shaderfx_findby_name(struct Object *ob, const char *name)
Definition: shader_fx.c:259
bool BKE_shaderfx_is_nonlocal_in_liboverride(const struct Object *ob, const struct ShaderFxData *shaderfx)
void BKE_shaderfx_copydata_generic(const struct ShaderFxData *fx_src, struct ShaderFxData *fx_dst)
ShaderFxTypeFlag
Definition: BKE_shader_fx.h:38
@ eShaderFxTypeFlag_SupportsEditmode
Definition: BKE_shader_fx.h:39
@ eShaderFxTypeFlag_NoUserAdd
Definition: BKE_shader_fx.h:50
@ eShaderFxTypeFlag_EnableInEditmode
Definition: BKE_shader_fx.h:44
@ eShaderFxTypeFlag_Single
Definition: BKE_shader_fx.h:47
bool BKE_shaderfx_unique_name(struct ListBase *shaderfx, struct ShaderFxData *fx)
Definition: shader_fx.c:122
void BKE_shaderfx_blend_read_data(struct BlendDataReader *reader, struct ListBase *lb)
Definition: shader_fx.c:280
ShaderFxType
_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
SyclQueue void void * src
SyclQueue void void size_t num_bytes void
Definition: DNA_ID.h:368
void(* freeData)(struct ShaderFxData *fx)
Definition: BKE_shader_fx.h:94
ShaderFxTypeFlag flags
Definition: BKE_shader_fx.h:75
void(* copyData)(const struct ShaderFxData *fx, struct ShaderFxData *target)
Definition: BKE_shader_fx.h:80
bool(* isDisabled)(struct ShaderFxData *fx, int userRenderParams)
ShaderFxTypeType type
Definition: BKE_shader_fx.h:74
void(* updateDepsgraph)(struct ShaderFxData *fx, const struct ModifierUpdateDepsgraphContext *ctx)
void(* foreachIDLink)(struct ShaderFxData *fx, struct Object *ob, ShaderFxIDWalkFunc walk, void *userData)
bool(* dependsOnTime)(struct ShaderFxData *fx)
char struct_name[32]
Definition: BKE_shader_fx.h:69
void(* initData)(struct ShaderFxData *fx)
Definition: BKE_shader_fx.h:87
void(* panelRegister)(struct ARegionType *region_type)