23 b.add_input<
decl::Vector>(
"Vector").
min(-10000.0f).max(10000.0f).implicit_field(
26 .default_value({0.8f, 0.8f, 0.8f, 1.0f})
27 .description(
"Color of the first reference brick");
29 .default_value({0.2f, 0.2f, 0.2f, 1.0f})
30 .description(
"Color of the second reference brick");
32 .default_value({0.0f, 0.0f, 0.0f, 1.0f})
40 .description(
"Scale of the texture");
47 "Size of the filling between the bricks (known as \"mortar\"). "
55 "Blurs/softens the edge between the mortar and the bricks. "
56 "This can be useful with a texture and displacement textures");
58 "The color variation between Color1 and Color2. "
59 "Values of -1 and 1 only use one of the two colors. "
60 "Values in between mix the colors");
66 .description(
"Ratio of brick's width relative to the texture scale");
72 .description(
"Ratio of brick's row height relative to the texture scale");
105 tex->offset_freq = 2;
106 tex->squash_freq = 2;
120 float offset_freq =
tex->offset_freq;
121 float squash_freq =
tex->squash_freq;
136 const int offset_freq_;
138 const int squash_freq_;
142 const int offset_freq,
144 const int squash_freq)
145 : offset_(offset), offset_freq_(offset_freq), squash_(squash), squash_freq_(squash_freq)
150 builder.single_input<
float3>(
"Vector");
154 builder.single_input<
float>(
"Scale");
155 builder.single_input<
float>(
"Mortar Size");
156 builder.single_input<
float>(
"Mortar Smooth");
157 builder.single_input<
float>(
"Bias");
158 builder.single_input<
float>(
"Brick Width");
159 builder.single_input<
float>(
"Row Height");
160 builder.single_output<
ColorGeometry4f>(
"Color", mf::ParamFlag::SupportsUnusedOutput);
161 builder.single_output<
float>(
"Fac", mf::ParamFlag::SupportsUnusedOutput);
170 n = (n + 1013) & 0x7fffffff;
172 const uint nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff;
173 return 0.5f * (
float(nn) / 1073741824.0f);
178 const float ff = f * f;
179 return (3.0f * ff - 2.0f * ff * f);
189 int offset_frequency,
191 int squash_frequency)
195 const int rownum =
int(
floorf(p.y / row_height));
197 if (offset_frequency && squash_frequency) {
198 brick_width *= (rownum % squash_frequency) ? 1.0f : squash_amount;
199 offset = (rownum % offset_frequency) ? 0.0f : (brick_width * offset_amount);
202 const int bricknum =
int(
floorf((p.x + offset) / brick_width));
204 const float x = (p.x + offset) - brick_width * bricknum;
205 const float y = p.y - row_height * rownum;
208 brick_noise((rownum << 16) + (bricknum & 0xFFFF)) + bias, 0.0f, 1.0f);
209 float min_dist = std::min(std::min(x, y), std::min(brick_width - x, row_height - y));
212 if (min_dist >= mortar_size) {
215 else if (mortar_smooth == 0.0f) {
219 min_dist = 1.0f - min_dist / mortar_size;
220 mortar = (min_dist < mortar_smooth) ?
smoothstepf(min_dist / mortar_smooth) : 1.0f;
223 return float2(tint, mortar);
237 const VArray<float> &mortar_smooth =
params.readonly_single_input<
float>(6,
"Mortar Smooth");
246 const bool store_fac = !r_fac.is_empty();
247 const bool store_color = !r_color.is_empty();
249 mask.foreach_index([&](
const int64_t i) {
261 float4 color_data, color1, color2, mortar;
266 const float tint = f2.x;
267 const float f = f2.y;
270 const float facm = 1.0f - tint;
271 color_data = color1 * facm + color2 * tint;
275 color_data = color_data * (1.0f - f) + mortar * f;
291 tex->offset,
tex->offset_freq,
tex->squash,
tex->squash_freq);
303 ntype.
declare = file_ns::sh_node_tex_brick_declare;
304 ntype.
draw_buttons = file_ns::node_shader_buts_tex_brick;
306 ntype.
initfunc = file_ns::node_shader_init_tex_brick;
309 ntype.
gpu_fn = file_ns::node_shader_gpu_tex_brick;
#define SH_NODE_TEX_BRICK
#define NODE_CLASS_TEXTURE
void BKE_texture_mapping_default(struct TexMapping *texmap, int type)
void BKE_texture_colormapping_default(struct ColorMapping *colormap)
MINLINE float clamp_f(float value, float min, float max)
MINLINE void copy_v4_v4(float r[4], const float a[4])
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
GPUNodeLink * GPU_constant(const float *num)
GPUNodeLink * GPU_uniform(const float *num)
uiLayout * uiLayoutColumn(uiLayout *layout, bool align)
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
const Signature & signature() const
void set_signature(const Signature *signature)
void construct_and_set_matching_fn(Args &&...args)
static float brick_noise(uint n)
BrickFunction(const float offset, const int offset_freq, const float squash, const int squash_freq)
static float smoothstepf(const float f)
void call(const IndexMask &mask, mf::Params params, mf::Context) const override
static float2 brick(float3 p, float mortar_size, float mortar_smooth, float bias, float brick_width, float row_height, float offset_amount, int offset_frequency, float squash_amount, int squash_frequency)
local_group_size(16, 16) .push_constant(Type b
draw_view in_light_buf[] float
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
void node_type_size_preset(bNodeType *ntype, eNodeSizePreset size)
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)
static void sh_node_brick_build_multi_function(NodeMultiFunctionBuilder &builder)
static void node_shader_buts_tex_brick(uiLayout *layout, bContext *, PointerRNA *ptr)
static void sh_node_tex_brick_declare(NodeDeclarationBuilder &b)
static void node_shader_init_tex_brick(bNodeTree *, bNode *node)
static int node_shader_gpu_tex_brick(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
VecBase< float, 2 > float2
void register_node_type_sh_tex_brick()
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)
void(* initfunc)(bNodeTree *ntree, bNode *node)
NodeGPUExecFunction gpu_fn
NodeMultiFunctionBuildFunction build_multi_function
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeDeclareFunction declare