22 "Scale of the texture");
27 .description(
"Amount of distortion");
29 b.add_output<
decl::Float>(
"Factor",
"Fac").no_muted_links();
54 float depth = tex->
depth;
69 static const mf::Signature
signature = []() {
71 mf::SignatureBuilder builder{
"MagicFunction",
signature};
72 builder.single_input<
float3>(
"Vector");
73 builder.single_input<
float>(
"Scale");
74 builder.single_input<
float>(
"Distortion");
76 builder.single_output<
float>(
"Fac", mf::ParamFlag::SupportsUnusedOutput);
92 const bool compute_factor = !r_fac.is_empty();
96 const float distort = distortion[
i];
97 float x =
sinf((co[0] + co[1] + co[2]) * 5.0f);
98 float y =
cosf((-co[0] + co[1] - co[2]) * 5.0f);
99 float z = -
cosf((-co[0] - co[1] + co[2]) * 5.0f);
154 if (distort != 0.0f) {
155 const float d = distort * 2.0f;
163 if (compute_factor) {
165 r_fac[
i] = (r_color[
i].r + r_color[
i].g + r_color[
i].b) * (1.0f / 3.0f);
187 ntype.
ui_name =
"Magic Texture";
191 ntype.
declare = file_ns::sh_node_tex_magic_declare;
192 ntype.
draw_buttons = file_ns::node_shader_buts_tex_magic;
193 ntype.
initfunc = file_ns::node_shader_init_tex_magic;
196 ntype.
gpu_fn = file_ns::node_shader_gpu_tex_magic;
#define NODE_CLASS_TEXTURE
#define SH_NODE_TEX_MAGIC
void BKE_texture_mapping_default(struct TexMapping *texmap, int type)
void BKE_texture_colormapping_default(struct ColorMapping *colormap)
@ NODE_DEFAULT_INPUT_POSITION_FIELD
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
GPUNodeLink * GPU_constant(const float *num)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
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 * MEM_callocN(size_t len, const char *str)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
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(uiLayout *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)
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
VecBase< float, 3 > float3
void register_node_type_sh_tex_magic()
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 common_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
void node_free_standard_storage(bNode *node)
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
ColorMapping color_mapping
std::string ui_description
void(* initfunc)(bNodeTree *ntree, bNode *node)
NodeGPUExecFunction gpu_fn
NodeMultiFunctionBuildFunction build_multi_function
const char * enum_name_legacy
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeDeclareFunction declare
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)