45 const short imaprepeat,
46 const short imapextend);
57 const float *fp = ibuf->
float_data() + 4 * ofs;
61 const float *fp = ibuf->
float_data() + 3 * ofs;
67 col[0] = col[1] = col[2] = col[3] = *fp;
73 col[0] =
float(rect[0]) * (1.0f / 255.0f);
74 col[1] =
float(rect[1]) * (1.0f / 255.0f);
75 col[2] =
float(rect[2]) * (1.0f / 255.0f);
76 col[3] =
float(rect[3]) * (1.0f / 255.0f);
87 const float texvec[3],
90 const bool skip_load_image)
101 if (ima ==
nullptr) {
114 local_iuser = tex->
iuser;
115 iuser = &local_iuser;
170 fx = (fx - 0.5f) / (1.0f - tex->
checkerdist) + 0.5f;
171 fy = (fy - 0.5f) / (1.0f - tex->
checkerdist) + 0.5f;
179 if (
x < 0 ||
y < 0 || x >= ibuf->
x ||
y >= ibuf->
y || texvec[2] < -1.0f || texvec[2] > 1.0f) {
236 float filterx, filtery;
242 CLAMP(fx, 0.0f, 1.0f);
243 CLAMP(fy, 0.0f, 1.0f);
268 texres->
trgba[3] = texres->
tin = std::max(
272 texres->
trgba[3] = texres->
tin = 1.0;
282 fx = 1.0f / texres->
trgba[3];
283 texres->
trgba[0] *= fx;
284 texres->
trgba[1] *= fx;
285 texres->
trgba[2] *= fx;
307 rf->
xmin += (x2 - x1);
308 rf->
xmax += (x2 - x1);
312 newrct = stack + *count;
316 newrct->
xmin = rf->
xmin + (x2 - x1);
327 else if (rf->
xmax > x2) {
329 rf->
xmin -= (x2 - x1);
330 rf->
xmax -= (x2 - x1);
334 newrct = stack + *count;
338 newrct->
xmax = rf->
xmax - (x2 - x1);
363 rf->
ymin += (y2 - y1);
364 rf->
ymax += (y2 - y1);
368 newrct = stack + *count;
372 newrct->
ymin = rf->
ymin + (y2 - y1);
383 else if (rf->
ymax > y2) {
385 rf->
ymin -= (y2 - y1);
386 rf->
ymax -= (y2 - y1);
390 newrct = stack + *count;
394 newrct->
ymax = rf->
ymax - (y2 - y1);
460 float muly, mulx, div, col[4];
461 int x,
y, startx, endx, starty, endy;
468 startx = std::max(startx, 0);
469 starty = std::max(starty, 0);
470 if (endx >= ibuf->
x) {
473 if (endy >= ibuf->
y) {
477 if (starty == endy && startx == endx) {
482 for (
y = starty;
y <= endy;
y++) {
486 if (starty == endy) {
491 muly = 1.0f - (rf->
ymin -
y);
494 muly = (rf->
ymax -
y);
498 if (startx == endx) {
506 for (
x = startx;
x <= endx;
x++) {
509 mulx *= 1.0f - (rf->
xmin -
x);
512 mulx *= (rf->
xmax -
x);
546 const short imaprepeat,
547 const short imapextend)
561 float opp, tot, alphaclip = 1.0;
565 rf->
xmin = minx * (ibuf->
x);
566 rf->
xmax = maxx * (ibuf->
x);
567 rf->
ymin = miny * (ibuf->
y);
568 rf->
ymax = maxy * (ibuf->
y);
576 else if (imaprepeat) {
582 if (alphaclip <= 0.0f) {
592 else if (imaprepeat) {
598 if (alphaclip <= 0.0f) {
621 texres->
trgba[0] /= tot;
622 texres->
trgba[1] /= tot;
623 texres->
trgba[2] /= tot;
625 texres->
trgba[3] /= tot;
633 if (texres->
talpha == 0) {
634 texres->
trgba[3] = 1.0;
637 if (alphaclip != 1.0f) {
639 texres->
trgba[0] *= alphaclip;
640 texres->
trgba[1] *= alphaclip;
641 texres->
trgba[2] *= alphaclip;
642 texres->
trgba[3] *= alphaclip;
652 if (ibuf ==
nullptr) [[unlikely]] {
658 boxsample(ibuf, fx, fy, fx + dx, fy + dy, &texres, 0, 1);
int BKE_image_get_tile_from_pos(Image *ima, const float uv[2], float r_uv[2], float r_ofs[2])
MINLINE void madd_v4_v4fl(float r[4], const float a[4], float f)
static void clipx_rctf_swap(rctf *stack, short *count, float x1, float x2)
void image_sample(struct Image *ima, float fx, float fy, float dx, float dy, float result[4], struct ImagePool *pool)
MINLINE void copy_v3_v3(float r[3], const float a[3])
bool BKE_image_has_loaded_ibuf(Image *image)
static float square_rctf(const rctf *rf)
MINLINE void zero_v4(float r[4])
static void boxsampleclip(ImBuf *ibuf, const rctf *rf, TexResult *texres)
MINLINE void add_v4_v4(float r[4], const float a[4])
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
static float clipx_rctf(rctf *rf, float x1, float x2)
static void ibuf_get_color(float col[4], const ImBuf *ibuf, int x, int y)
static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float maxy, TexResult *texres, const short imaprepeat, const short imapextend)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
MINLINE void copy_v4_v4(float r[4], const float a[4])
static void clipy_rctf_swap(rctf *stack, short *count, float y1, float y2)
MINLINE void mul_v4_fl(float r[4], float f)
ImBuf * BKE_image_pool_acquire_ibuf(Image *ima, ImageUser *iuser, ImagePool *pool)
static float clipy_rctf(rctf *rf, float y1, float y2)
void BKE_image_pool_release_ibuf(Image *ima, ImBuf *ibuf, ImagePool *pool)
int imagewrap(struct Tex *tex, struct Image *ima, const float texvec[3], struct TexResult *texres, struct ImagePool *pool, bool skip_load_image)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
const uint8_t * byte_data() const
const float * float_data() const