Blender V5.0
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
9
10#include "BLI_compiler_attrs.h"
11#include "DNA_shader_fx_types.h" /* Needed for all enum type definitions. */
12
13#include "BKE_lib_query.hh" /* For LibraryForeachIDCallbackFlag enum. */
14
15struct ARegionType;
16struct BlendDataReader;
17struct BlendWriter;
18struct ID;
20struct ListBase;
22struct Object;
23struct 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
30typedef enum {
31 /* Should not be used, only for None type */
33
34 /* grease pencil effects */
37
38typedef 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
53typedef void (*ShaderFxIDWalkFunc)(void *user_data,
54 struct Object *ob,
55 struct ID **idpoin,
57typedef void (*ShaderFxTexWalkFunc)(void *user_data,
58 struct Object *ob,
59 struct ShaderFxData *fx,
60 const char *propname);
61
62typedef 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 (*copy_data)(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 (*init_data)(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 (*free_data)(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 (*is_disabled)(struct ShaderFxData *fx, bool use_render_params);
105
106 /* Add the appropriate relations to the dependency graph.
107 *
108 * This function is optional.
109 */
110 void (*update_depsgraph)(struct ShaderFxData *fx,
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 */
118 bool (*depends_on_time)(struct ShaderFxData *fx);
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 */
127 void (*foreach_ID_link)(struct ShaderFxData *fx,
128 struct Object *ob,
130 void *user_data);
131
132 /* Should iterate over every working space color. */
135
136 /* Register the panel types for the effect's UI. */
137 void (*panel_register)(struct ARegionType *region_type);
139
140#define SHADERFX_TYPE_PANEL_PREFIX "FX_PT_"
141
145void BKE_shaderfx_init(void);
146
153void BKE_shaderfxType_panel_id(ShaderFxType type, char *r_idname);
157void BKE_shaderfx_free_ex(struct ShaderFxData *fx, int flag);
158void BKE_shaderfx_free(struct ShaderFxData *fx);
162void BKE_shaderfx_unique_name(struct ListBase *shaders, struct ShaderFxData *fx);
171 const struct ShaderFxData *shaderfx);
173struct ShaderFxData *BKE_shaderfx_findby_name(struct Object *ob, const char *name);
174void BKE_shaderfx_copydata_generic(const struct ShaderFxData *fx_src, struct ShaderFxData *fx_dst);
175void BKE_shaderfx_copydata(struct ShaderFxData *fx, struct ShaderFxData *target);
176void BKE_shaderfx_copydata_ex(struct ShaderFxData *fx, struct ShaderFxData *target, int flag);
177void BKE_shaderfx_copy(struct ListBase *dst, const struct ListBase *src);
178void BKE_shaderfx_foreach_ID_link(struct Object *ob, ShaderFxIDWalkFunc walk, void *user_data);
179
183bool BKE_shaderfx_has_gpencil(const struct Object *ob);
184
185void BKE_shaderfx_blend_write(struct BlendWriter *writer, struct ListBase *fxbase);
187 struct ListBase *lb,
188 struct Object *ob);
LibraryForeachIDCallbackFlag
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
void(* ShaderFxIDWalkFunc)(void *user_data, struct Object *ob, struct ID **idpoin, LibraryForeachIDCallbackFlag cb_flag)
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
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
const char * name
Definition DNA_ID.h:414
void(* copy_data)(const struct ShaderFxData *fx, struct ShaderFxData *target)
void(* foreach_working_space_color)(ShaderFxData *fx, const IDTypeForeachColorFunctionCallback &func)
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:145