21 b.add_input<
decl::Vector>(
"Vector").
min(-10000.0f).max(10000.0f).implicit_field(
30 .description(
"Value used as seed in 1D and 4D dimensions");
47 BLI_assert(dimensions >= 1 && dimensions <= 4);
48 return std::array{
"node_white_noise_1d",
49 "node_white_noise_2d",
50 "node_white_noise_3d",
51 "node_white_noise_4d"}[dimensions - 1];
80 BLI_assert(dimensions >= 1 && dimensions <= 4);
81 static std::array<mf::Signature, 4> signatures{
93 mf::SignatureBuilder builder{
"WhiteNoise",
signature};
95 if (
ELEM(dimensions, 2, 3, 4)) {
96 builder.single_input<
float3>(
"Vector");
98 if (
ELEM(dimensions, 1, 4)) {
99 builder.single_input<
float>(
"W");
102 builder.single_output<
float>(
"Value", mf::ParamFlag::SupportsUnusedOutput);
103 builder.single_output<
ColorGeometry4f>(
"Color", mf::ParamFlag::SupportsUnusedOutput);
110 int param =
ELEM(dimensions_, 2, 3, 4) +
ELEM(dimensions_, 1, 4);
117 const bool compute_value = !r_value.
is_empty();
118 const bool compute_color = !r_color.is_empty();
120 switch (dimensions_) {
198 const float LARGE_NUMBER = 10000.0f;
200 NodeItem
noise = empty();
201 NodeItem
vector = empty();
202 NodeItem
w = empty();
204 int dimension = node_->custom1;
207 w = get_input_value(
"W", NodeItem::Type::Vector2);
209 "cellnoise2d", NodeItem::Type::Float, {{
"texcoord",
w * val(LARGE_NUMBER)}});
212 vector = get_input_link(
"Vector", NodeItem::Type::Vector2);
217 "cellnoise2d", NodeItem::Type::Float, {{
"texcoord",
vector * val(LARGE_NUMBER)}});
220 vector = get_input_link(
"Vector", NodeItem::Type::Vector3);
222 vector = texcoord_node(NodeItem::Type::Vector3);
225 "cellnoise3d", NodeItem::Type::Float, {{
"position",
vector * val(LARGE_NUMBER)}});
228 vector = get_input_link(
"Vector", NodeItem::Type::Vector3);
230 vector = texcoord_node(NodeItem::Type::Vector3);
232 w = get_input_value(
"W", NodeItem::Type::Float);
234 "cellnoise3d", NodeItem::Type::Float, {{
"position", (
vector +
w) * val(LARGE_NUMBER)}});
241 if (
STREQ(socket_out_->name,
"Value")) {
247 NodeItem combine = create_node(
"combine3",
248 NodeItem::Type::Color3,
249 {{
"in1",
noise}, {
"in2", val(1.0f)}, {
"in3", val(0.5f)}});
250 return create_node(
"hsvtorgb", NodeItem::Type::Color3, {{
"in", combine}});
264 ntype.
declare = file_ns::sh_node_tex_white_noise_declare;
265 ntype.
draw_buttons = file_ns::node_shader_buts_white_noise;
266 ntype.
initfunc = file_ns::node_shader_init_tex_white_noise;
267 ntype.
gpu_fn = file_ns::gpu_shader_tex_white_noise;
268 ntype.
updatefunc = file_ns::node_shader_update_tex_white_noise;
#define NODE_CLASS_TEXTURE
#define SH_NODE_TEX_WHITE_NOISE
#define BLI_assert_unreachable()
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a vector
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 & z() const
Return the z value.
SIMD_FORCE_INLINE const btScalar & w() const
Return the w 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 make_available(bNode &node) const
void call(const IndexMask &mask, mf::Params params, mf::Context) const override
static mf::Signature create_signature(int dimensions)
WhiteNoiseFunction(int dimensions)
local_group_size(16, 16) .push_constant(Type b
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
ccl_device_inline float4 mask(const int4 mask, const float4 a)
void node_set_socket_availability(bNodeTree *ntree, bNodeSocket *sock, bool is_available)
void node_register_type(bNodeType *ntype)
bNodeSocket * node_find_socket(bNode *node, eNodeSocketInOut in_out, StringRef identifier)
static const char * gpu_shader_get_name(const int dimensions)
static void sh_node_tex_white_noise_declare(NodeDeclarationBuilder &b)
static void node_shader_buts_white_noise(uiLayout *layout, bContext *, PointerRNA *ptr)
static void node_shader_update_tex_white_noise(bNodeTree *ntree, bNode *node)
static int gpu_shader_tex_white_noise(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void sh_node_noise_build_multi_function(NodeMultiFunctionBuilder &builder)
static void node_shader_init_tex_white_noise(bNodeTree *, bNode *node)
float hash_float_to_float(float k)
float3 hash_float_to_float3(float k)
VecBase< float, 4 > float4
VecBase< float, 2 > float2
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
VecBase< float, 3 > float3
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_tex_white_noise()
void sh_fn_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
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)