Blender  V2.93
BKE_shader_fx.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 #pragma once
17 
22 #include "BLI_compiler_attrs.h"
23 #include "DNA_shader_fx_types.h" /* needed for all enum typdefs */
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 struct ARegionType;
30 struct BlendDataReader;
31 struct BlendLibReader;
32 struct BlendWriter;
33 struct ID;
34 struct ListBase;
36 struct Object;
37 struct ShaderFxData;
38 
39 #define SHADER_FX_ACTIVE(_fx, _is_render) \
40  ((((_fx)->mode & eShaderFxMode_Realtime) && (_is_render == false)) || \
41  (((_fx)->mode & eShaderFxMode_Render) && (_is_render == true)))
42 #define SHADER_FX_EDIT(_fx, _is_edit) ((((_fx)->mode & eShaderFxMode_Editmode) == 0) && (_is_edit))
43 
44 typedef enum {
45  /* Should not be used, only for None type */
47 
48  /* grease pencil effects */
51 
52 typedef enum {
54 
55  /* For effects that support editmode this determines if the
56  * effect should be enabled by default in editmode.
57  */
59 
60  /* max one per type */
62 
63  /* can't be added manually by user */
66 
67 typedef void (*ShaderFxIDWalkFunc)(void *userData,
68  struct Object *ob,
69  struct ID **idpoin,
70  int cb_flag);
71 typedef void (*ShaderFxTexWalkFunc)(void *userData,
72  struct Object *ob,
73  struct ShaderFxData *fx,
74  const char *propname);
75 
76 typedef struct ShaderFxTypeInfo {
77  /* The user visible name for this effect */
78  char name[32];
79 
80  /* The DNA struct name for the effect data type, used to
81  * write the DNA data out.
82  */
83  char struct_name[32];
84 
85  /* The size of the effect data type, used by allocation. */
87 
90 
91  /* Copy instance data for this effect type. Should copy all user
92  * level settings to the target effect.
93  */
94  void (*copyData)(const struct ShaderFxData *fx, struct ShaderFxData *target);
95 
96  /* Initialize new instance data for this effect type, this function
97  * should set effect variables to their default values.
98  *
99  * This function is optional.
100  */
101  void (*initData)(struct ShaderFxData *fx);
102 
103  /* Free internal effect data variables, this function should
104  * not free the fx variable itself.
105  *
106  * This function is optional.
107  */
108  void (*freeData)(struct ShaderFxData *fx);
109 
110  /* Return a boolean value indicating if this effect is able to be
111  * calculated based on the effect data. This is *not* regarding the
112  * fx->flag, that is tested by the system, this is just if the data
113  * validates (for example, a lattice will return false if the lattice
114  * object is not defined).
115  *
116  * This function is optional (assumes never disabled if not present).
117  */
118  bool (*isDisabled)(struct ShaderFxData *fx, int userRenderParams);
119 
120  /* Add the appropriate relations to the dependency graph.
121  *
122  * This function is optional.
123  */
124  void (*updateDepsgraph)(struct ShaderFxData *fx,
125  const struct ModifierUpdateDepsgraphContext *ctx);
126 
127  /* Should return true if the effect needs to be recalculated on time
128  * changes.
129  *
130  * This function is optional (assumes false if not present).
131  */
132  bool (*dependsOnTime)(struct ShaderFxData *fx);
133 
134  /* Should call the given walk function with a pointer to each ID
135  * pointer (i.e. each data-block pointer) that the effect data
136  * stores. This is used for linking on file load and for
137  * unlinking data-blocks or forwarding data-block references.
138  *
139  * This function is optional.
140  */
141  void (*foreachIDLink)(struct ShaderFxData *fx,
142  struct Object *ob,
143  ShaderFxIDWalkFunc walk,
144  void *userData);
145 
146  /* Register the panel types for the effect's UI. */
147  void (*panelRegister)(struct ARegionType *region_type);
149 
150 #define SHADERFX_TYPE_PANEL_PREFIX "FX_PT_"
151 
152 /* Initialize global data (type info and some common global storage). */
153 void BKE_shaderfx_init(void);
154 
155 void BKE_shaderfxType_panel_id(ShaderFxType type, char *r_idname);
156 void BKE_shaderfx_panel_expand(struct ShaderFxData *fx);
158 struct ShaderFxData *BKE_shaderfx_new(int type);
159 void BKE_shaderfx_free_ex(struct ShaderFxData *fx, const int flag);
160 void BKE_shaderfx_free(struct ShaderFxData *fx);
161 bool BKE_shaderfx_unique_name(struct ListBase *shaderfx, struct ShaderFxData *fx);
164 struct ShaderFxData *BKE_shaderfx_findby_name(struct Object *ob, const char *name);
165 void BKE_shaderfx_copydata_generic(const struct ShaderFxData *fx_src, struct ShaderFxData *fx_dst);
166 void BKE_shaderfx_copydata(struct ShaderFxData *fx, struct ShaderFxData *target);
167 void BKE_shaderfx_copydata_ex(struct ShaderFxData *fx,
168  struct ShaderFxData *target,
169  const int flag);
170 void BKE_shaderfx_copy(struct ListBase *dst, const struct ListBase *src);
171 void BKE_shaderfx_foreach_ID_link(struct Object *ob, ShaderFxIDWalkFunc walk, void *userData);
172 
173 bool BKE_shaderfx_has_gpencil(struct Object *ob);
174 
175 void BKE_shaderfx_blend_write(struct BlendWriter *writer, struct ListBase *fxbase);
176 void BKE_shaderfx_blend_read_data(struct BlendDataReader *reader, struct ListBase *lb);
177 void BKE_shaderfx_blend_read_lib(struct BlendLibReader *reader, struct Object *ob);
178 
179 #ifdef __cplusplus
180 }
181 #endif
bool BKE_shaderfx_depends_ontime(struct ShaderFxData *fx)
Definition: shader_fx.c:150
void BKE_shaderfx_foreach_ID_link(struct Object *ob, ShaderFxIDWalkFunc walk, void *userData)
Definition: shader_fx.c:264
ShaderFxTypeType
Definition: BKE_shader_fx.h:44
@ eShaderFxType_NoneType
Definition: BKE_shader_fx.h:46
@ eShaderFxType_GpencilType
Definition: BKE_shader_fx.h:49
void BKE_shaderfx_init(void)
Definition: shader_fx.c:73
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:67
void BKE_shaderfx_blend_write(struct BlendWriter *writer, struct ListBase *fxbase)
Definition: shader_fx.c:282
void BKE_shaderfxType_panel_id(ShaderFxType type, char *r_idname)
Definition: shader_fx.c:173
struct ShaderFxData * BKE_shaderfx_findby_type(struct Object *ob, ShaderFxType type)
Definition: shader_fx.c:251
void BKE_shaderfx_free_ex(struct ShaderFxData *fx, const int flag)
Definition: shader_fx.c:114
void BKE_shaderfx_free(struct ShaderFxData *fx)
Definition: shader_fx.c:134
void BKE_shaderfx_copydata(struct ShaderFxData *fx, struct ShaderFxData *target)
Definition: shader_fx.c:233
const ShaderFxTypeInfo * BKE_shaderfx_get_info(ShaderFxType type)
Definition: shader_fx.c:157
void BKE_shaderfx_blend_read_lib(struct BlendLibReader *reader, struct Object *ob)
Definition: shader_fx.c:312
struct ShaderFxTypeInfo ShaderFxTypeInfo
struct ShaderFxData * BKE_shaderfx_new(int type)
Definition: shader_fx.c:79
void BKE_shaderfx_copydata_ex(struct ShaderFxData *fx, struct ShaderFxData *target, const int flag)
Definition: shader_fx.c:214
void(* ShaderFxTexWalkFunc)(void *userData, struct Object *ob, struct ShaderFxData *fx, const char *propname)
Definition: BKE_shader_fx.h:71
void BKE_shaderfx_panel_expand(struct ShaderFxData *fx)
Definition: shader_fx.c:181
bool BKE_shaderfx_has_gpencil(struct Object *ob)
Definition: shader_fx.c:61
struct ShaderFxData * BKE_shaderfx_findby_name(struct Object *ob, const char *name)
Definition: shader_fx.c:277
void BKE_shaderfx_copydata_generic(const struct ShaderFxData *fx_src, struct ShaderFxData *fx_dst)
ShaderFxTypeFlag
Definition: BKE_shader_fx.h:52
@ eShaderFxTypeFlag_SupportsEditmode
Definition: BKE_shader_fx.h:53
@ eShaderFxTypeFlag_NoUserAdd
Definition: BKE_shader_fx.h:64
@ eShaderFxTypeFlag_EnableInEditmode
Definition: BKE_shader_fx.h:58
@ eShaderFxTypeFlag_Single
Definition: BKE_shader_fx.h:61
bool BKE_shaderfx_unique_name(struct ListBase *shaderfx, struct ShaderFxData *fx)
Definition: shader_fx.c:140
void BKE_shaderfx_blend_read_data(struct BlendDataReader *reader, struct ListBase *lb)
Definition: shader_fx.c:298
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
Definition: DNA_ID.h:273
void(* freeData)(struct ShaderFxData *fx)
ShaderFxTypeFlag flags
Definition: BKE_shader_fx.h:89
void(* copyData)(const struct ShaderFxData *fx, struct ShaderFxData *target)
Definition: BKE_shader_fx.h:94
bool(* isDisabled)(struct ShaderFxData *fx, int userRenderParams)
ShaderFxTypeType type
Definition: BKE_shader_fx.h:88
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:83
void(* initData)(struct ShaderFxData *fx)
void(* panelRegister)(struct ARegionType *region_type)