27 const bool is_compositor =
b.tree_or_null() &&
b.tree_or_null()->type ==
NTREE_COMPOSIT;
31 b.add_input<
decl::Vector>(
"Vector"_ustr).default_input_type(default_input_type);
37 .description(
"Scale of the texture");
42 .description(
"Amount of distortion");
43 b.add_output<
decl::Color>(
"Color"_ustr).no_muted_links();
44 b.add_output<
decl::Float>(
"Factor"_ustr,
"Fac"_ustr).no_muted_links();
69 float depth = tex->
depth;
84 static const mf::Signature
signature = []() {
86 mf::SignatureBuilder builder{
"MagicFunction",
signature};
87 builder.single_input<
float3>(
"Vector");
88 builder.single_input<
float>(
"Scale");
89 builder.single_input<
float>(
"Distortion");
91 builder.single_output<
float>(
"Fac", mf::ParamFlag::SupportsUnusedOutput);
101 const VArray<float> &distortion = params.readonly_single_input<
float>(2,
"Distortion");
105 MutableSpan<float> r_fac = params.uninitialized_single_output_if_required<
float>(4,
"Fac");
107 const bool compute_factor = !r_fac.
is_empty();
111 const float distort = distortion[i];
112 float x =
sinf((co[0] + co[1] + co[2]) * 5.0f);
113 float y =
cosf((-co[0] + co[1] - co[2]) * 5.0f);
114 float z = -
cosf((-co[0] - co[1] + co[2]) * 5.0f);
169 if (distort != 0.0f) {
170 const float d = distort * 2.0f;
178 if (compute_factor) {
180 r_fac[i] = (r_color[i].r + r_color[i].g + r_color[i].b) * (1.0f / 3.0f);
187 static constexpr int8_t id = 0;
209 ntype.
ui_name =
"Magic Texture";
213 ntype.
declare = file_ns::sh_node_tex_magic_declare;
214 ntype.
draw_buttons = file_ns::node_shader_buts_tex_magic;
215 ntype.
initfunc = file_ns::node_shader_init_tex_magic;
218 ntype.
gpu_fn = file_ns::node_shader_gpu_tex_magic;
#define NODE_CLASS_TEXTURE
#define SH_NODE_TEX_MAGIC
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
constexpr bool is_empty() const
const Signature & signature() const
void set_signature(const Signature *signature)
void construct_and_set_matching_fn(Args &&...args)
void call(const IndexMask &mask, mf::Params params, mf::Context) const override
void hash_unique(UniqueHashBytes &hash) const override
float3x3 scale(float3x3 mat, float2 scale)
void node_register_type(bNodeType &ntype)
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
static void node_shader_buts_tex_magic(ui::Layout &layout, bContext *, PointerRNA *ptr)
static void sh_node_tex_magic_declare(NodeDeclarationBuilder &b)
static void node_shader_init_tex_magic(bNodeTree *, bNode *node)
static void sh_node_magic_tex_build_multi_function(NodeMultiFunctionBuilder &builder)
static int node_shader_gpu_tex_magic(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
@ ITEM_R_SPLIT_EMPTY_NAME
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
void register_node_type_sh_tex_magic()
GPUNodeLink * GPU_constant(const float *num)
void node_shader_gpu_tex_mapping(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *)
void node_shader_gpu_default_tex_coord(GPUMaterial *mat, bNode *node, GPUNodeLink **link)
void BKE_texture_mapping_default(struct TexMapping *texmap, int type)
@ NODE_DEFAULT_INPUT_POSITION_FIELD
@ NODE_DEFAULT_INPUT_UNIFORM_IMAGE_COORDINATES
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
void node_free_standard_storage(bNode *node)
VecBase< float, 3 > float3
void BKE_texture_colormapping_default(struct ColorMapping *colormap)
void common_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
ColorMapping color_mapping
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
std::string ui_description
NodeGPUExecFunction gpu_fn
NodeMultiFunctionBuildFunction build_multi_function
void(*) initfunc(bNodeTree *ntree, bNode *node)
const char * enum_name_legacy
NodeDeclareFunction declare
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)