29 node_storage(node).dimensions = 1;
32 "Scale of the base noise octave");
34 "The number of noise octaves. Higher values give more detailed noise but increase render "
42 "Blend factor between an octave and its previous one. A value of zero corresponds to "
49 "The difference between the scale of each two consecutive octaves. Larger values "
50 "corresponds to larger scale for higher octaves");
57 "An added offset to each octave, determines the level where the highest octave will "
64 .description(
"An extra multiplier to tune the magnitude of octaves");
69 .description(
"Amount of distortion");
90 tex->normalize =
true;
102 return std::array{
"node_noise_tex_multi_fractal_1d",
103 "node_noise_tex_multi_fractal_2d",
104 "node_noise_tex_multi_fractal_3d",
105 "node_noise_tex_multi_fractal_4d"}[dimensions - 1];
107 return std::array{
"node_noise_tex_fbm_1d",
108 "node_noise_tex_fbm_2d",
109 "node_noise_tex_fbm_3d",
110 "node_noise_tex_fbm_4d"}[dimensions - 1];
112 return std::array{
"node_noise_tex_hybrid_multi_fractal_1d",
113 "node_noise_tex_hybrid_multi_fractal_2d",
114 "node_noise_tex_hybrid_multi_fractal_3d",
115 "node_noise_tex_hybrid_multi_fractal_4d"}[dimensions - 1];
117 return std::array{
"node_noise_tex_ridged_multi_fractal_1d",
118 "node_noise_tex_ridged_multi_fractal_2d",
119 "node_noise_tex_ridged_multi_fractal_3d",
120 "node_noise_tex_ridged_multi_fractal_4d"}[dimensions - 1];
122 return std::array{
"node_noise_tex_hetero_terrain_1d",
123 "node_noise_tex_hetero_terrain_2d",
124 "node_noise_tex_hetero_terrain_3d",
125 "node_noise_tex_hetero_terrain_4d"}[dimensions - 1];
175 : dimensions_(dimensions), type_(type), normalize_(
normalize)
177 BLI_assert(dimensions >= 1 && dimensions <= 4);
179 static std::array<mf::Signature, 20> signatures{
213 if (
ELEM(dimensions, 2, 3, 4)) {
214 builder.single_input<
float3>(
"Vector");
216 if (
ELEM(dimensions, 1, 4)) {
217 builder.single_input<
float>(
"W");
220 builder.single_input<
float>(
"Scale");
221 builder.single_input<
float>(
"Detail");
222 builder.single_input<
float>(
"Roughness");
223 builder.single_input<
float>(
"Lacunarity");
229 builder.single_input<
float>(
"Offset");
232 builder.single_input<
float>(
"Gain");
234 builder.single_input<
float>(
"Distortion");
236 builder.single_output<
float>(
"Fac", mf::ParamFlag::SupportsUnusedOutput);
237 builder.single_output<
ColorGeometry4f>(
"Color", mf::ParamFlag::SupportsUnusedOutput);
244 int param =
ELEM(dimensions_, 2, 3, 4) +
ELEM(dimensions_, 1, 4);
247 const VArray<float> &roughness =
params.readonly_single_input<
float>(param++,
"Roughness");
248 const VArray<float> &lacunarity =
params.readonly_single_input<
float>(param++,
"Lacunarity");
254 params.readonly_single_input<
float>(param++,
"Offset") :
260 params.readonly_single_input<
float>(param++,
"Gain") :
262 const VArray<float> &distortion =
params.readonly_single_input<
float>(param++,
"Distortion");
269 const bool compute_factor = !r_factor.is_empty();
270 const bool compute_color = !r_color.is_empty();
272 switch (dimensions_) {
275 if (compute_factor) {
276 mask.foreach_index([&](
const int64_t i) {
277 const float position =
w[i] * scale[i];
290 mask.foreach_index([&](
const int64_t i) {
291 const float position =
w[i] * scale[i];
309 if (compute_factor) {
310 mask.foreach_index([&](
const int64_t i) {
324 mask.foreach_index([&](
const int64_t i) {
343 if (compute_factor) {
344 mask.foreach_index([&](
const int64_t i) {
358 mask.foreach_index([&](
const int64_t i) {
378 if (compute_factor) {
379 mask.foreach_index([&](
const int64_t i) {
381 const float position_w =
w[i] * scale[i];
383 position_vector[0], position_vector[1], position_vector[2], position_w};
396 mask.foreach_index([&](
const int64_t i) {
398 const float position_w =
w[i] * scale[i];
400 position_vector[0], position_vector[1], position_vector[2], position_w};
439 NodeItem scale = get_input_value(
"Scale", NodeItem::Type::Float);
440 NodeItem detail = get_input_default(
"Detail", NodeItem::Type::Float);
441 NodeItem lacunarity = get_input_value(
"Lacunarity", NodeItem::Type::Float);
443 NodeItem position = create_node(
"position", NodeItem::Type::Vector3);
444 position = position * scale;
446 return create_node(
"fractal3d",
447 STREQ(socket_out_->identifier,
"Fac") ? NodeItem::Type::Float :
448 NodeItem::
Type::Color3,
449 {{
"position", position},
450 {
"octaves", val(
int(detail.value->asA<
float>()))},
451 {
"lacunarity", lacunarity}});
465 ntype.
declare = file_ns::sh_node_tex_noise_declare;
466 ntype.
draw_buttons = file_ns::node_shader_buts_tex_noise;
467 ntype.
initfunc = file_ns::node_shader_init_tex_noise;
470 ntype.
gpu_fn = file_ns::node_shader_gpu_tex_noise;
471 ntype.
updatefunc = file_ns::node_shader_update_tex_noise;
#define SH_NODE_TEX_NOISE
#define NODE_STORAGE_FUNCS(StorageT)
#define NODE_CLASS_TEXTURE
void BKE_texture_mapping_default(struct TexMapping *texmap, int type)
void BKE_texture_colormapping_default(struct ColorMapping *colormap)
@ SHD_NOISE_HYBRID_MULTIFRACTAL
@ SHD_NOISE_RIDGED_MULTIFRACTAL
@ SHD_NOISE_HETERO_TERRAIN
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
GPUNodeLink * GPU_constant(const float *num)
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
SIMD_FORCE_INLINE btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
const Signature & signature() const
void set_signature(const Signature *signature)
void construct_and_set_matching_fn(Args &&...args)
void make_available(bNode &node) const
static mf::Signature create_signature(int dimensions, int type)
NoiseFunction(int dimensions, int type, bool normalize)
ExecutionHints get_execution_hints() const override
void call(const IndexMask &mask, mf::Params params, mf::Context) const override
local_group_size(16, 16) .push_constant(Type b
void node_set_socket_availability(bNodeTree *ntree, bNodeSocket *sock, bool is_available)
void node_type_storage(bNodeType *ntype, const char *storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
void node_register_type(bNodeType *ntype)
bNodeSocket * node_find_socket(bNode *node, eNodeSocketInOut in_out, StringRef identifier)
T clamp(const T &a, const T &min, const T &max)
T max(const T &a, const T &b)
static const char * gpu_shader_get_name(const int dimensions, const int type)
static void sh_node_noise_build_multi_function(NodeMultiFunctionBuilder &builder)
static void node_shader_buts_tex_noise(uiLayout *layout, bContext *, PointerRNA *ptr)
static void node_shader_init_tex_noise(bNodeTree *, bNode *node)
static void node_shader_update_tex_noise(bNodeTree *ntree, bNode *node)
static int node_shader_gpu_tex_noise(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void sh_node_tex_noise_declare(NodeDeclarationBuilder &b)
float3 perlin_float3_fractal_distorted(float position, float detail, float roughness, float lacunarity, float offset, float gain, float distortion, int type, bool normalize)
float perlin_fractal_distorted(T position, float detail, float roughness, float lacunarity, float offset, float gain, float distortion, int type, bool normalize)
VecBase< float, 2 > float2
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_tex_noise()
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 sh_fn_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
void node_free_standard_storage(bNode *node)
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
int RNA_enum_get(PointerRNA *ptr, const char *name)
NodeMaterialXFunction materialx_fn
void(* initfunc)(bNodeTree *ntree, bNode *node)
NodeGPUExecFunction gpu_fn
NodeMultiFunctionBuildFunction build_multi_function
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeDeclareFunction declare
void(* updatefunc)(bNodeTree *ntree, bNode *node)