diff options
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 3 | ||||
-rw-r--r-- | source/blender/render/intern/include/texture.h | 1 | ||||
-rw-r--r-- | source/blender/render/intern/source/imagetexture.c | 44 | ||||
-rw-r--r-- | source/blender/render/intern/source/render_texture.c | 2 |
4 files changed, 30 insertions, 20 deletions
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index fca81acf038..6d6e5166e1c 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -4652,6 +4652,9 @@ static void image_get_entry_and_index(Image *ima, ImageUser *iuser, int *r_entry frame = iuser ? iuser->framenr : ima->lastframe; } } + else if (ima->source == IMA_SRC_TILED) { + frame = (iuser && iuser->tile) ? iuser->tile : 1001; + } *r_entry = frame; *r_index = index; diff --git a/source/blender/render/intern/include/texture.h b/source/blender/render/intern/include/texture.h index d47413717d4..f051d3ed318 100644 --- a/source/blender/render/intern/include/texture.h +++ b/source/blender/render/intern/include/texture.h @@ -83,7 +83,6 @@ int imagewraposa(struct Tex *tex, const bool skip_load_image); int imagewrap(struct Tex *tex, struct Image *ima, - struct ImBuf *ibuf, const float texvec[3], struct TexResult *texres, struct ImagePool *pool, diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index dc7288234b3..47d0986fabd 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -100,7 +100,6 @@ static void ibuf_get_color(float col[4], struct ImBuf *ibuf, int x, int y) int imagewrap(Tex *tex, Image *ima, - ImBuf *ibuf, const float texvec[3], TexResult *texres, struct ImagePool *pool, @@ -116,35 +115,44 @@ int imagewrap(Tex *tex, retval = texres->nor ? 3 : 1; /* quick tests */ - if (ibuf == NULL && ima == NULL) { + if (ima == NULL) { return retval; } - if (ima) { - /* hack for icon render */ - if (skip_load_image && !BKE_image_has_loaded_ibuf(ima)) { - return retval; - } + /* hack for icon render */ + if (skip_load_image && !BKE_image_has_loaded_ibuf(ima)) { + return retval; + } - ibuf = BKE_image_pool_acquire_ibuf(ima, &tex->iuser, pool); + ImageUser *iuser = &tex->iuser; + ImageUser local_iuser; + if (ima->source == IMA_SRC_TILED) { + /* tex->iuser might be shared by threads, so create a local copy. */ + local_iuser = tex->iuser; + iuser = &local_iuser; - ima->flag |= IMA_USED_FOR_RENDER; + float new_uv[2]; + iuser->tile = BKE_image_get_tile_from_pos(ima, texvec, new_uv, NULL); + fx = new_uv[0]; + fy = new_uv[1]; + } + else { + fx = texvec[0]; + fy = texvec[1]; } + + ImBuf *ibuf = BKE_image_pool_acquire_ibuf(ima, iuser, pool); + + ima->flag |= IMA_USED_FOR_RENDER; + if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL)) { - if (ima) { - BKE_image_pool_release_ibuf(ima, ibuf, pool); - } + BKE_image_pool_release_ibuf(ima, ibuf, pool); return retval; } /* setup mapping */ if (tex->imaflag & TEX_IMAROT) { - fy = texvec[0]; - fx = texvec[1]; - } - else { - fx = texvec[0]; - fy = texvec[1]; + SWAP(float, fx, fy); } if (tex->extend == TEX_CHECKER) { diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 3f3dc9842a5..fe162212b9c 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -1219,7 +1219,7 @@ static int multitex(Tex *tex, tex, tex->ima, NULL, texvec, dxt, dyt, texres, pool, skip_load_image); } else { - retval = imagewrap(tex, tex->ima, NULL, texvec, texres, pool, skip_load_image); + retval = imagewrap(tex, tex->ima, texvec, texres, pool, skip_load_image); } if (tex->ima) { BKE_image_tag_time(tex->ima); |