30 b.add_output<
decl::Color>(
"Color").no_muted_links().dependent_field().reference_pass_all();
31 b.add_output<
decl::Float>(
"Alpha").no_muted_links().dependent_field().reference_pass_all();
50 const int8_t interpolation_;
62 : interpolation_(interpolation),
63 extension_(extension),
65 image_user_(image_user)
70 builder.single_input<
float3>(
"Vector");
72 builder.single_output<
float>(
"Alpha", mf::ParamFlag::SupportsUnusedOutput);
78 if (image_buffer_ ==
nullptr) {
79 throw std::runtime_error(
"cannot acquire image buffer");
92 throw std::runtime_error(
"cannot get float buffer");
112 return std::clamp(x, 0, width - 1);
117 const int m = std::abs(x + (x < 0)) % (2 * width);
119 return 2 * width - m - 1;
126 if (px < 0 || py < 0 || px >= ibuf.
x || py >= ibuf.
y) {
127 return float4(0.0f, 0.0f, 0.0f, 0.0f);
132 static float frac(
const float x,
int *ix)
134 const int i =
int(x) - ((x < 0.0f) ? 1 : 0);
144 const int width = ibuf.
x;
145 const int height = ibuf.
y;
146 int pix, piy, nix, niy;
147 const float tx =
frac(px *
float(width) - 0.5f, &pix);
148 const float ty =
frac(py *
float(height) - 0.5f, &piy);
149 int ppix, ppiy, nnix, nniy;
195 return float4(0.0f, 0.0f, 0.0f, 0.0f);
198 const int xc[4] = {ppix, pix, nix, nnix};
199 const int yc[4] = {ppiy, piy, niy, nniy};
202 u[0] = (((-1.0f / 6.0f) * tx + 0.5f) * tx - 0.5f) * tx + (1.0f / 6.0f);
203 u[1] = ((0.5f * tx - 1.0f) * tx) * tx + (2.0f / 3.0f);
204 u[2] = ((-0.5f * tx + 0.5f) * tx + 0.5f) * tx + (1.0f / 6.0f);
205 u[3] = (1.0f / 6.0f) * tx * tx * tx;
207 v[0] = (((-1.0f / 6.0f) * ty + 0.5f) * ty - 0.5f) * ty + (1.0f / 6.0f);
208 v[1] = ((0.5f * ty - 1.0f) * ty) * ty + (2.0f / 3.0f);
209 v[2] = ((-0.5f * ty + 0.5f) * ty + 0.5f) * ty + (1.0f / 6.0f);
210 v[3] = (1.0f / 6.0f) * ty * ty * ty;
235 const int width = ibuf.
x;
236 const int height = ibuf.
y;
237 int pix, piy, nix, niy;
238 const float nfx =
frac(px *
float(width) - 0.5f, &pix);
239 const float nfy =
frac(py *
float(height) - 0.5f, &piy);
269 const float ptx = 1.0f - nfx;
270 const float pty = 1.0f - nfy;
283 const int width = ibuf.
x;
284 const int height = ibuf.
y;
286 const float tx =
frac(px *
float(width), &ix);
287 const float ty =
frac(py *
float(height), &iy);
296 if (tx < 0.0f || ty < 0.0f || tx > 1.0f || ty > 1.0f) {
297 return float4(0.0f, 0.0f, 0.0f, 0.0f);
299 if (ix < 0 || iy < 0 || ix > width || iy > height) {
300 return float4(0.0f, 0.0f, 0.0f, 0.0f);
315 return float4(0.0f, 0.0f, 0.0f, 0.0f);
329 switch (interpolation_) {
331 mask.foreach_index([&](
const int64_t i) {
332 const float3 p = vectors[i];
337 mask.foreach_index([&](
const int64_t i) {
338 const float3 p = vectors[i];
344 mask.foreach_index([&](
const int64_t i) {
345 const float3 p = vectors[i];
356 switch (alpha_mode) {
372 mask.foreach_index([&](
const int64_t i) { color_data[i].w = 1.0f; });
377 if (!r_alpha.is_empty()) {
378 mask.foreach_index([&](
const int64_t i) { r_alpha[i] = r_color[i].a; });
386 if (image ==
nullptr) {
387 params.set_default_remaining_outputs();
395 image_user.
cycl =
false;
396 image_user.
frames = INT_MAX;
400 std::unique_ptr<ImageFieldsFunction> image_fn;
402 image_fn = std::make_unique<ImageFieldsFunction>(
405 catch (
const std::runtime_error &) {
406 params.set_default_remaining_outputs();
ImBuf * BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
void BKE_imageuser_default(ImageUser *iuser)
bool BKE_image_is_animated(Image *image)
#define NODE_STORAGE_FUNCS(StorageT)
#define NODE_CLASS_TEXTURE
MINLINE void straight_to_premul_v4(float color[4])
void BLI_thread_unlock(int type)
void BLI_thread_lock(int type)
@ IMA_ALPHA_CHANNEL_PACKED
@ SHD_IMAGE_EXTENSION_MIRROR
@ SHD_IMAGE_EXTENSION_CLIP
@ SHD_IMAGE_EXTENSION_REPEAT
@ SHD_IMAGE_EXTENSION_EXTEND
bool IMB_colormanagement_space_name_is_data(const char *name)
void IMB_float_from_rect(ImBuf *ibuf)
Contains defines and structs used throughout the imbuf module.
#define NOD_REGISTER_NODE(REGISTER_FUNC)
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
ATTR_WARN_UNUSED_RESULT const BMVert * v
static std::shared_ptr< FieldOperation > Create(std::shared_ptr< const mf::MultiFunction > function, Vector< GField > inputs={})
const Signature & signature() const
void set_signature(const Signature *signature)
~ImageFieldsFunction() override
static float4 image_cubic_texture_lookup(const ImBuf &ibuf, const float px, const float py, const int extension)
static float frac(const float x, int *ix)
static int wrap_clamp(const int x, const int width)
void call(const IndexMask &mask, mf::Params params, mf::Context) const override
static float4 image_closest_texture_lookup(const ImBuf &ibuf, const float px, const float py, const int extension)
static float4 image_pixel_lookup(const ImBuf &ibuf, const int px, const int py)
static int wrap_periodic(int x, const int width)
ImageFieldsFunction(const int8_t interpolation, const int8_t extension, Image &image, ImageUser image_user)
static float4 image_linear_texture_lookup(const ImBuf &ibuf, const float px, const float py, const int8_t extension)
static int wrap_mirror(const int x, const int width)
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 node_geo_exec(GeoNodeExecParams params)
static void node_register()
static void node_layout(uiLayout *layout, bContext *, PointerRNA *ptr)
static void node_declare(NodeDeclarationBuilder &b)
static void node_init(bNodeTree *, bNode *node)
VecBase< float, 4 > float4
void geo_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)
ImBufFloatBuffer float_buffer
ColorManagedColorspaceSettings colorspace_settings
void(* initfunc)(bNodeTree *ntree, bNode *node)
NodeGeometryExecFunction geometry_node_execute
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeDeclareFunction declare