diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-03-02 10:45:46 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-03-02 10:47:43 +0300 |
commit | 9c183f60e1b0892614cf64db274488ff5bc61620 (patch) | |
tree | 574027e7ebd49fd240fb1a98ac45cbbad0a54df3 /source/blender/render | |
parent | c593b77910cb13cd68fa60ea4a0e7a190f1064aa (diff) |
Fix T47610: Texture node in compositing nodes does not update
The issue was caused by some code accessing R from a functions which
are marked as safe for use from outside of render pipeline.
Now those functions are safe(er) for use.
Diffstat (limited to 'source/blender/render')
4 files changed, 150 insertions, 24 deletions
diff --git a/source/blender/render/extern/include/RE_render_ext.h b/source/blender/render/extern/include/RE_render_ext.h index 075db3a8145..2b5d0ca4e14 100644 --- a/source/blender/render/extern/include/RE_render_ext.h +++ b/source/blender/render/extern/include/RE_render_ext.h @@ -46,7 +46,7 @@ struct Scene; /* used by particle.c, effect.c, editmesh_modes.c and brush.c, returns 1 if rgb, 0 otherwise */ int externtex( struct MTex *mtex, const float vec[3], float *tin, float *tr, float *tg, float *tb, float *ta, - const int thread, struct ImagePool *pool, const bool skip_load_image); + const int thread, struct ImagePool *pool, const bool skip_load_image, const bool texnode_preview); void texture_rgb_blend(float in[3], const float tex[3], const float out[3], float fact, float facg, int blendtype); float texture_value_blend(float tex, float out, float fact, float facg, int blendtype); diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index 3b69c124753..ed83cfec764 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -437,7 +437,7 @@ typedef struct HaloRen { unsigned int lay; struct Material *mat; struct ImagePool *pool; - bool skip_load_image; + bool skip_load_image, texnode_preview; } HaloRen; /* ------------------------------------------------------------------------- */ diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 29d8f17a72b..172fc999897 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -1103,7 +1103,16 @@ static void do_2d_mapping(MTex *mtex, float texvec[3], VlakRen *vlr, const float /* ************************************** */ -static int multitex(Tex *tex, float texvec[3], float dxt[3], float dyt[3], int osatex, TexResult *texres, const short thread, short which_output, struct ImagePool *pool, const bool skip_load_image) +static int multitex(Tex *tex, + float texvec[3], + float dxt[3], float dyt[3], + int osatex, + TexResult *texres, + const short thread, + const short which_output, + struct ImagePool *pool, + const bool skip_load_image, + const bool texnode_preview) { float tmpvec[3]; int retval = 0; /* return value, int:0, col:1, nor:2, everything:3 */ @@ -1112,7 +1121,7 @@ static int multitex(Tex *tex, float texvec[3], float dxt[3], float dyt[3], int o if (tex->use_nodes && tex->nodetree) { retval = ntreeTexExecTree(tex->nodetree, texres, texvec, dxt, dyt, osatex, thread, - tex, which_output, R.r.cfra, (R.r.scemode & R_TEXNODE_PREVIEW) != 0, NULL, NULL); + tex, which_output, R.r.cfra, texnode_preview, NULL, NULL); } else { switch (tex->type) { @@ -1218,9 +1227,19 @@ static int multitex(Tex *tex, float texvec[3], float dxt[3], float dyt[3], int o return retval; } -static int multitex_nodes_intern(Tex *tex, float texvec[3], float dxt[3], float dyt[3], int osatex, TexResult *texres, - const short thread, short which_output, ShadeInput *shi, MTex *mtex, struct ImagePool *pool, - bool scene_color_manage, const bool skip_load_image) +static int multitex_nodes_intern(Tex *tex, + float texvec[3], + float dxt[3], float dyt[3], + int osatex, + TexResult *texres, + const short thread, + short which_output, + ShadeInput *shi, + MTex *mtex, struct + ImagePool *pool, + const bool scene_color_manage, + const bool skip_load_image, + const bool texnode_preview) { if (tex==NULL) { memset(texres, 0, sizeof(TexResult)); @@ -1236,7 +1255,16 @@ static int multitex_nodes_intern(Tex *tex, float texvec[3], float dxt[3], float if (mtex) { /* we have mtex, use it for 2d mapping images only */ do_2d_mapping(mtex, texvec, shi->vlr, shi->facenor, dxt, dyt); - rgbnor = multitex(tex, texvec, dxt, dyt, osatex, texres, thread, which_output, pool, skip_load_image); + rgbnor = multitex(tex, + texvec, + dxt, dyt, + osatex, + texres, + thread, + which_output, + pool, + skip_load_image, + texnode_preview); if (mtex->mapto & (MAP_COL+MAP_COLSPEC+MAP_COLMIR)) { ImBuf *ibuf = BKE_image_pool_acquire_ibuf(tex->ima, &tex->iuser, pool); @@ -1269,7 +1297,16 @@ static int multitex_nodes_intern(Tex *tex, float texvec[3], float dxt[3], float } do_2d_mapping(&localmtex, texvec_l, NULL, NULL, dxt_l, dyt_l); - rgbnor = multitex(tex, texvec_l, dxt_l, dyt_l, osatex, texres, thread, which_output, pool, skip_load_image); + rgbnor = multitex(tex, + texvec_l, + dxt_l, dyt_l, + osatex, + texres, + thread, + which_output, + pool, + skip_load_image, + texnode_preview); { ImBuf *ibuf = BKE_image_pool_acquire_ibuf(tex->ima, &tex->iuser, pool); @@ -1285,7 +1322,16 @@ static int multitex_nodes_intern(Tex *tex, float texvec[3], float dxt[3], float return rgbnor; } else { - return multitex(tex, texvec, dxt, dyt, osatex, texres, thread, which_output, pool, skip_load_image); + return multitex(tex, + texvec, + dxt, dyt, + osatex, + texres, + thread, + which_output, + pool, + skip_load_image, + texnode_preview); } } @@ -1297,14 +1343,15 @@ int multitex_nodes(Tex *tex, float texvec[3], float dxt[3], float dyt[3], int os { return multitex_nodes_intern(tex, texvec, dxt, dyt, osatex, texres, thread, which_output, shi, mtex, pool, R.scene_color_manage, - (R.r.scemode & R_NO_IMAGE_LOAD) != 0); + (R.r.scemode & R_NO_IMAGE_LOAD) != 0, + (R.r.scemode & R_TEXNODE_PREVIEW) != 0); } /* this is called for surface shading */ static int multitex_mtex(ShadeInput *shi, MTex *mtex, float texvec[3], float dxt[3], float dyt[3], TexResult *texres, struct ImagePool *pool, const bool skip_load_image) { Tex *tex = mtex->tex; - + /* TODO(sergey): Texture preview should become an argument? */ if (tex->use_nodes && tex->nodetree) { /* stupid exception here .. but we have to pass shi and mtex to * textures nodes for 2d mapping and color management for images */ @@ -1312,7 +1359,16 @@ static int multitex_mtex(ShadeInput *shi, MTex *mtex, float texvec[3], float dxt tex, mtex->which_output, R.r.cfra, (R.r.scemode & R_TEXNODE_PREVIEW) != 0, shi, mtex); } else { - return multitex(mtex->tex, texvec, dxt, dyt, shi->osatex, texres, shi->thread, mtex->which_output, pool, skip_load_image); + return multitex(mtex->tex, + texvec, + dxt, dyt, + shi->osatex, + texres, + shi->thread, + mtex->which_output, + pool, + skip_load_image, + (R.r.scemode & R_TEXNODE_PREVIEW) != 0); } } @@ -1323,7 +1379,7 @@ static int multitex_mtex(ShadeInput *shi, MTex *mtex, float texvec[3], float dxt */ int multitex_ext(Tex *tex, float texvec[3], float dxt[3], float dyt[3], int osatex, TexResult *texres, struct ImagePool *pool, bool scene_color_manage, const bool skip_load_image) { - return multitex_nodes_intern(tex, texvec, dxt, dyt, osatex, texres, 0, 0, NULL, NULL, pool, scene_color_manage, skip_load_image); + return multitex_nodes_intern(tex, texvec, dxt, dyt, osatex, texres, 0, 0, NULL, NULL, pool, scene_color_manage, skip_load_image, false); } /* extern-tex doesn't support nodes (ntreeBeginExec() can't be called when rendering is going on)\ @@ -1335,7 +1391,7 @@ int multitex_ext_safe(Tex *tex, float texvec[3], TexResult *texres, struct Image int use_nodes= tex->use_nodes, retval; tex->use_nodes = false; - retval= multitex_nodes_intern(tex, texvec, NULL, NULL, 0, texres, 0, 0, NULL, NULL, pool, scene_color_manage, skip_load_image); + retval= multitex_nodes_intern(tex, texvec, NULL, NULL, 0, texres, 0, 0, NULL, NULL, pool, scene_color_manage, skip_load_image, false); tex->use_nodes= use_nodes; return retval; @@ -2672,6 +2728,7 @@ void do_material_tex(ShadeInput *shi, Render *re) void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float col_r[3], float *val, Render *re) { const bool skip_load_image = (re->r.scemode & R_NO_IMAGE_LOAD) != 0; + const bool texnode_preview = (re->r.scemode & R_TEXNODE_PREVIEW) != 0; MTex *mtex; Tex *tex; TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL}; @@ -2759,7 +2816,16 @@ void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float col_ else texvec[2]= mtex->size[2]*(mtex->ofs[2]); } - rgbnor = multitex(tex, texvec, NULL, NULL, 0, &texres, shi->thread, mtex->which_output, re->pool, skip_load_image); /* NULL = dxt/dyt, 0 = shi->osatex - not supported */ + rgbnor = multitex(tex, + texvec, + NULL, NULL, + 0, + &texres, + shi->thread, + mtex->which_output, + re->pool, + skip_load_image, + texnode_preview); /* NULL = dxt/dyt, 0 = shi->osatex - not supported */ /* texture output */ @@ -2871,6 +2937,7 @@ void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float col_ void do_halo_tex(HaloRen *har, float xn, float yn, float col_r[4]) { const bool skip_load_image = har->skip_load_image; + const bool texnode_preview = har->texnode_preview; MTex *mtex; TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL}; float texvec[3], dxt[3], dyt[3], fact, facm, dx; @@ -2927,7 +2994,16 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float col_r[4]) if (mtex->tex->type==TEX_IMAGE) do_2d_mapping(mtex, texvec, NULL, NULL, dxt, dyt); - rgb = multitex(mtex->tex, texvec, dxt, dyt, osatex, &texres, 0, mtex->which_output, har->pool, skip_load_image); + rgb = multitex(mtex->tex, + texvec, + dxt, dyt, + osatex, + &texres, + 0, + mtex->which_output, + har->pool, + skip_load_image, + texnode_preview); /* texture output */ if (rgb && (mtex->texflag & MTEX_RGBTOINT)) { @@ -3017,6 +3093,7 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float col_r[4]) void do_sky_tex(const float rco[3], const float lo[3], const float dxyview[2], float hor[3], float zen[3], float *blend, int skyflag, short thread) { const bool skip_load_image = (R.r.scemode & R_NO_IMAGE_LOAD) != 0; + const bool texnode_preview = (R.r.scemode & R_TEXNODE_PREVIEW) != 0; MTex *mtex; Tex *tex; TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL}; @@ -3134,7 +3211,16 @@ void do_sky_tex(const float rco[3], const float lo[3], const float dxyview[2], f /* texture */ if (tex->type==TEX_IMAGE) do_2d_mapping(mtex, texvec, NULL, NULL, dxt, dyt); - rgb = multitex(mtex->tex, texvec, dxt, dyt, R.osa, &texres, thread, mtex->which_output, R.pool, skip_load_image); + rgb = multitex(mtex->tex, + texvec, + dxt, dyt, + R.osa, + &texres, + thread, + mtex->which_output, + R.pool, + skip_load_image, + texnode_preview); /* texture output */ if (rgb && (mtex->texflag & MTEX_RGBTOINT)) { @@ -3227,6 +3313,7 @@ void do_sky_tex(const float rco[3], const float lo[3], const float dxyview[2], f void do_lamp_tex(LampRen *la, const float lavec[3], ShadeInput *shi, float col_r[3], int effect) { const bool skip_load_image = (R.r.scemode & R_NO_IMAGE_LOAD) != 0; + const bool texnode_preview = (R.r.scemode & R_TEXNODE_PREVIEW) != 0; Object *ob; MTex *mtex; Tex *tex; @@ -3350,7 +3437,16 @@ void do_lamp_tex(LampRen *la, const float lavec[3], ShadeInput *shi, float col_r do_2d_mapping(mtex, texvec, NULL, NULL, dxt, dyt); } - rgb = multitex(tex, texvec, dxt, dyt, shi->osatex, &texres, shi->thread, mtex->which_output, R.pool, skip_load_image); + rgb = multitex(tex, + texvec, + dxt, dyt, + shi->osatex, + &texres, + shi->thread, + mtex->which_output, + R.pool, + skip_load_image, + texnode_preview); /* texture output */ if (rgb && (mtex->texflag & MTEX_RGBTOINT)) { @@ -3424,7 +3520,13 @@ void do_lamp_tex(LampRen *la, const float lavec[3], ShadeInput *shi, float col_r /* ------------------------------------------------------------------------- */ -int externtex(MTex *mtex, const float vec[3], float *tin, float *tr, float *tg, float *tb, float *ta, const int thread, struct ImagePool *pool, const bool skip_load_image) +int externtex(MTex *mtex, + const float vec[3], + float *tin, float *tr, float *tg, float *tb, float *ta, + const int thread, + struct ImagePool *pool, + const bool skip_load_image, + const bool texnode_preview) { Tex *tex; TexResult texr; @@ -3450,7 +3552,15 @@ int externtex(MTex *mtex, const float vec[3], float *tin, float *tr, float *tg, do_2d_mapping(mtex, texvec, NULL, NULL, dxt, dyt); } - rgb = multitex(tex, texvec, dxt, dyt, 0, &texr, thread, mtex->which_output, pool, skip_load_image); + rgb = multitex(tex, + texvec, + dxt, dyt, + 0, &texr, + thread, + mtex->which_output, + pool, + skip_load_image, + texnode_preview); if (rgb) { texr.tin = IMB_colormanagement_get_luminance(&texr.tr); diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c index 560627b1be1..e8db096c9a5 100644 --- a/source/blender/render/intern/source/renderdatabase.c +++ b/source/blender/render/intern/source/renderdatabase.c @@ -956,6 +956,7 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, const float *orco, float hasize, float vectsize, int seed) { const bool skip_load_image = (re->r.scemode & R_NO_IMAGE_LOAD) != 0; + const bool texnode_preview = (re->r.scemode & R_TEXNODE_PREVIEW) != 0; HaloRen *har; MTex *mtex; float tin, tr, tg, tb, ta; @@ -1047,7 +1048,13 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, } } - externtex(mtex, texvec, &tin, &tr, &tg, &tb, &ta, 0, re->pool, skip_load_image); + externtex(mtex, + texvec, + &tin, &tr, &tg, &tb, &ta, + 0, + re->pool, + skip_load_image, + texnode_preview); yn= tin*mtex->colfac; //zn= tin*mtex->alphafac; @@ -1067,7 +1074,8 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, } har->pool = re->pool; - har->skip_load_image = (re->r.scemode & R_NO_IMAGE_LOAD) != 0; + har->skip_load_image = skip_load_image; + har->texnode_preview = texnode_preview; return har; } @@ -1077,6 +1085,7 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater const float *orco, const float *uvco, float hasize, float vectsize, int seed, const float pa_co[3]) { const bool skip_load_image = (re->r.scemode & R_NO_IMAGE_LOAD) != 0; + const bool texnode_preview = (re->r.scemode & R_TEXNODE_PREVIEW) != 0; HaloRen *har; MTex *mtex; float tin, tr, tg, tb, ta; @@ -1180,7 +1189,13 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater copy_v3_v3(texvec, orco); } - hasrgb = externtex(mtex, texvec, &tin, &tr, &tg, &tb, &ta, 0, re->pool, skip_load_image); + hasrgb = externtex(mtex, + texvec, + &tin, &tr, &tg, &tb, &ta, + 0, + re->pool, + skip_load_image, + texnode_preview); //yn= tin*mtex->colfac; //zn= tin*mtex->alphafac; @@ -1225,6 +1240,7 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater har->pool = re->pool; har->skip_load_image = (re->r.scemode & R_NO_IMAGE_LOAD) != 0; + har->texnode_preview = (re->r.scemode & R_TEXNODE_PREVIEW) != 0; return har; } |