Blender V4.5
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;
19struct ListBase;
21struct Object;
22struct ShaderFxData;
23
24#define SHADER_FX_ACTIVE(_fx, _is_render) \
25 ((((_fx)->mode & eShaderFxMode_Realtime) && (_is_render == false)) || \
26 (((_fx)->mode & eShaderFxMode_Render) && (_is_render == true)))
27#define SHADER_FX_EDIT(_fx, _is_edit) ((((_fx)->mode & eShaderFxMode_Editmode) == 0) && (_is_edit))
28
29typedef enum {
30 /* Should not be used, only for None type */
32
33 /* grease pencil effects */
36
37typedef enum {
39
40 /* For effects that support editmode this determines if the
41 * effect should be enabled by default in editmode.
42 */
44
45 /* max one per type */
47
48 /* can't be added manually by user */
51
52typedef void (*ShaderFxIDWalkFunc)(void *user_data,
53 struct Object *ob,
54 struct ID **idpoin,
56typedef void (*ShaderFxTexWalkFunc)(void *user_data,
57 struct Object *ob,
58 struct ShaderFxData *fx,
59 const char *propname);
60
61typedef struct ShaderFxTypeInfo {
62 /* The user visible name for this effect */
63 char name[32];
64
65 /* The DNA struct name for the effect data type, used to
66 * write the DNA data out.
67 */
68 char struct_name[32];
69
70 /* The size of the effect data type, used by allocation. */
72
75
76 /* Copy instance data for this effect type. Should copy all user
77 * level settings to the target effect.
78 */
79 void (*copy_data)(const struct ShaderFxData *fx, struct ShaderFxData *target);
80
81 /* Initialize new instance data for this effect type, this function
82 * should set effect variables to their default values.
83 *
84 * This function is optional.
85 */
86 void (*init_data)(struct ShaderFxData *fx);
87
88 /* Free internal effect data variables, this function should
89 * not free the fx variable itself.
90 *
91 * This function is optional.
92 */
93 void (*free_data)(struct ShaderFxData *fx);
94
95 /* Return a boolean value indicating if this effect is able to be
96 * calculated based on the effect data. This is *not* regarding the
97 * fx->flag, that is tested by the system, this is just if the data
98 * validates (for example, a lattice will return false if the lattice
99 * object is not defined).
100 *
101 * This function is optional (assumes never disabled if not present).
102 */
103 bool (*is_disabled)(struct ShaderFxData *fx, bool use_render_params);
104
105 /* Add the appropriate relations to the dependency graph.
106 *
107 * This function is optional.
108 */
109 void (*update_depsgraph)(struct ShaderFxData *fx,
110 const struct ModifierUpdateDepsgraphContext *ctx);
111
112 /* Should return true if the effect needs to be recalculated on time
113 * changes.
114 *
115 * This function is optional (assumes false if not present).
116 */
117 bool (*depends_on_time)(struct ShaderFxData *fx);
118
119 /* Should call the given walk function with a pointer to each ID
120 * pointer (i.e. each data-block pointer) that the effect data
121 * stores. This is used for linking on file load and for
122 * unlinking data-blocks or forwarding data-block references.
123 *
124 * This function is optional.
125 */
126 void (*foreach_ID_link)(struct ShaderFxData *fx,
127 struct Object *ob,
129 void *user_data);
130
131 /* Register the panel types for the effect's UI. */
132 void (*panel_register)(struct ARegionType *region_type);
134
135#define SHADERFX_TYPE_PANEL_PREFIX "FX_PT_"
136
140void BKE_shaderfx_init(void);
141
148void BKE_shaderfxType_panel_id(ShaderFxType type, char *r_idname);
152void BKE_shaderfx_free_ex(struct ShaderFxData *fx, int flag);
153void BKE_shaderfx_free(struct ShaderFxData *fx);
157void BKE_shaderfx_unique_name(struct ListBase *shaders, struct ShaderFxData *fx);
166 const struct ShaderFxData *shaderfx);
168struct ShaderFxData *BKE_shaderfx_findby_name(struct Object *ob, const char *name);
169void BKE_shaderfx_copydata_generic(const struct ShaderFxData *fx_src, struct ShaderFxData *fx_dst);
170void BKE_shaderfx_copydata(struct ShaderFxData *fx, struct ShaderFxData *target);
171void BKE_shaderfx_copydata_ex(struct ShaderFxData *fx, struct ShaderFxData *target, int flag);
172void BKE_shaderfx_copy(struct ListBase *dst, const struct ListBase *src);
173void BKE_shaderfx_foreach_ID_link(struct Object *ob, ShaderFxIDWalkFunc walk, void *user_data);
174
178bool BKE_shaderfx_has_gpencil(const struct Object *ob);
179
180void BKE_shaderfx_blend_write(struct BlendWriter *writer, struct ListBase *fxbase);
182 struct ListBase *lb,
183 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
Definition DNA_ID.h:404
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:139