23 b.add_input<
decl::Vector>(
"Vector").hide_value().implicit_field(
26 b.add_output<
decl::Float>(
"Factor",
"Fac").no_muted_links();
65 static const mf::Signature
signature = []() {
67 mf::SignatureBuilder builder{
"GradientFunction",
signature};
68 builder.single_input<
float3>(
"Vector");
69 builder.single_output<
ColorGeometry4f>(
"Color", mf::ParamFlag::SupportsUnusedOutput);
70 builder.single_output<
float>(
"Fac");
84 const bool compute_color = !r_color.is_empty();
86 switch (gradient_type_) {
94 const float r = std::max(
vector[
i].
x, 0.0f);
101 const float r = std::min(std::max(
vector[
i].
x, 0.0f), 1.0f);
102 const float t = r * r;
103 fac[
i] = (3.0f * t - 2.0f * t * r);
158 const int gradient_type = tex->gradient_type;
159 NodeItem
vector = get_input_link(
"Vector", NodeItem::Type::Vector2);
163 NodeItem res = empty();
165 switch (gradient_type) {
175 res = res * res * (val(3.0f) - val(2.0f) * res);
207 ntype.
ui_name =
"Gradient Texture";
209 "Generate interpolated color and intensity values based on the input vector";
212 ntype.
declare = file_ns::sh_node_tex_gradient_declare;
213 ntype.
draw_buttons = file_ns::node_shader_buts_tex_gradient;
214 ntype.
initfunc = file_ns::node_shader_init_tex_gradient;
217 ntype.
gpu_fn = file_ns::node_shader_gpu_tex_gradient;
#define NODE_CLASS_TEXTURE
#define SH_NODE_TEX_GRADIENT
void BKE_texture_mapping_default(struct TexMapping *texmap, int type)
void BKE_texture_colormapping_default(struct ColorMapping *colormap)
#define BLI_assert_unreachable()
@ NODE_DEFAULT_INPUT_POSITION_FIELD
@ SHD_BLEND_QUADRATIC_SPHERE
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
const Signature & signature() const
void set_signature(const Signature *signature)
void construct_and_set_matching_fn(Args &&...args)
GradientFunction(int gradient_type)
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))
T clamp(const T &a, const T &min, const T &max)
T length(const VecBase< T, Size > &a)
static void node_shader_init_tex_gradient(bNodeTree *, bNode *node)
static void sh_node_tex_gradient_declare(NodeDeclarationBuilder &b)
static int node_shader_gpu_tex_gradient(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void node_shader_buts_tex_gradient(uiLayout *layout, bContext *, PointerRNA *ptr)
static void sh_node_gradient_tex_build_multi_function(NodeMultiFunctionBuilder &builder)
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
VecBase< float, 3 > float3
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_tex_gradient()
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
NodeMaterialXFunction materialx_fn
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)