diff options
author | Miika Hamalainen <blender@miikah.org> | 2011-06-16 16:00:03 +0400 |
---|---|---|
committer | Miika Hamalainen <blender@miikah.org> | 2011-06-16 16:00:03 +0400 |
commit | b937a4f5b6adc6bc0dca62cb5c87db08c873cfba (patch) | |
tree | f489aca8e10e2a686fc1d1397397f99e1e1f2077 /source/blender/render | |
parent | 3de22dec26606c2c526f7193db038fa5125f9b03 (diff) | |
parent | f227c4a064d96909243b4a60a7f6c544f521817a (diff) |
Merge with trunk r37546
Diffstat (limited to 'source/blender/render')
-rw-r--r-- | source/blender/render/CMakeLists.txt | 9 | ||||
-rw-r--r-- | source/blender/render/extern/include/RE_pipeline.h | 2 | ||||
-rw-r--r-- | source/blender/render/extern/include/RE_shader_ext.h | 5 | ||||
-rw-r--r-- | source/blender/render/intern/include/render_types.h | 2 | ||||
-rw-r--r-- | source/blender/render/intern/source/convertblender.c | 1 | ||||
-rw-r--r-- | source/blender/render/intern/source/envmap.c | 1 | ||||
-rw-r--r-- | source/blender/render/intern/source/imagetexture.c | 13 | ||||
-rw-r--r-- | source/blender/render/intern/source/pipeline.c | 135 | ||||
-rw-r--r-- | source/blender/render/intern/source/pixelshading.c | 25 | ||||
-rw-r--r-- | source/blender/render/intern/source/pointdensity.c | 16 | ||||
-rw-r--r-- | source/blender/render/intern/source/render_texture.c | 4 | ||||
-rw-r--r-- | source/blender/render/intern/source/rendercore.c | 184 | ||||
-rw-r--r-- | source/blender/render/intern/source/shadeinput.c | 14 | ||||
-rw-r--r-- | source/blender/render/intern/source/sunsky.c | 2 | ||||
-rw-r--r-- | source/blender/render/intern/source/volumetric.c | 2 |
15 files changed, 160 insertions, 255 deletions
diff --git a/source/blender/render/CMakeLists.txt b/source/blender/render/CMakeLists.txt index bcb427abd6c..aea377a35bb 100644 --- a/source/blender/render/CMakeLists.txt +++ b/source/blender/render/CMakeLists.txt @@ -41,6 +41,10 @@ set(INC ../../../intern/guardedalloc ) +set(INC_SYS + +) + set(SRC intern/raytrace/rayobject.cpp intern/raytrace/rayobject_empty.cpp @@ -119,7 +123,8 @@ if(WITH_IMAGE_OPENEXR) endif() if(WITH_CODEC_QUICKTIME) - list(APPEND INC ../quicktime ${QUICKTIME_INC}) + list(APPEND INC ../quicktime) + list(APPEND INC_SYS ${QUICKTIME_INC}) add_definitions(-DWITH_QUICKTIME) endif() @@ -130,4 +135,4 @@ if(APPLE) endif() endif() -blender_add_lib_nolist(bf_render "${SRC}" "${INC}") +blender_add_lib_nolist(bf_render "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index 47230ab3089..23f301249ba 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -146,7 +146,7 @@ typedef struct RenderResult { typedef struct RenderStats { int cfra; int totface, totvert, totstrand, tothalo, totlamp, totpart; - short curfield, curblur, curpart, partsdone, convertdone; + short curfield, curblur, curpart, partsdone, convertdone, curfsa; double starttime, lastframetime; const char *infostr, *statstr; char scenename[32]; diff --git a/source/blender/render/extern/include/RE_shader_ext.h b/source/blender/render/extern/include/RE_shader_ext.h index 74fc161f262..ecfc54bc487 100644 --- a/source/blender/render/extern/include/RE_shader_ext.h +++ b/source/blender/render/extern/include/RE_shader_ext.h @@ -193,6 +193,8 @@ typedef struct ShadeInput /* node shaders... */ struct Tex; struct MTex; +struct ImBuf; + /* this one uses nodes */ int multitex_ext(struct Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, struct TexResult *texres); /* nodes disabled */ @@ -208,9 +210,8 @@ struct Render; struct Image; struct Object; -void RE_shade_external(struct Render *re, struct ShadeInput *shi, struct ShadeResult *shr); int RE_bake_shade_all_selected(struct Render *re, int type, struct Object *actob, short *do_update, float *progress); struct Image *RE_bake_shade_get_image(void); +void RE_bake_ibuf_filter(struct ImBuf *ibuf, unsigned char *mask, const int filter); #endif /* RE_SHADER_EXT_H */ - diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index cf16211b6d1..b2535ebc9ea 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -214,7 +214,7 @@ struct Render ListBase instancetable; int totinstance; - struct Image *backbuf, *bakebuf; + struct Image *bakebuf; struct GHash *orco_hash; diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index c1c2fb60abd..15fc9d38c01 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -4665,7 +4665,6 @@ void RE_Database_Free(Render *re) re->totvlak=re->totvert=re->totstrand=re->totlamp=re->tothalo= 0; re->i.convertdone= 0; - re->backbuf= NULL; re->bakebuf= NULL; if(re->scene) diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index 1e40ab886ae..e2ab21ef877 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -149,7 +149,6 @@ static Render *envmap_render_copy(Render *re, EnvMap *env) envre->r.layers.first= envre->r.layers.last= NULL; envre->r.filtertype= 0; envre->r.xparts= envre->r.yparts= 2; - envre->r.bufflag= 0; envre->r.size= 100; envre->r.yasp= envre->r.xasp= 1; diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index 7d2c7b35247..cb08ae96bf7 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -76,6 +76,8 @@ extern struct Render R; /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float maxy, TexResult *texres, int imaprepeat, int imapextend); + /* *********** IMAGEWRAPPING ****************** */ @@ -201,7 +203,16 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, float *texvec, TexResult *texre ibuf->rect+= (ibuf->x*ibuf->y); } - ibuf_get_color(&texres->tr, ibuf, x, y); + /* interpolate */ + if (tex->imaflag & TEX_INTERPOL) { + float filterx, filtery; + filterx = (0.5f * tex->filtersize) / ibuf->x; + filtery = (0.5f * tex->filtersize) / ibuf->y; + + boxsample(ibuf, fx-filterx, fy-filtery, fx+filterx, fy+filtery, texres, (tex->extend==TEX_REPEAT), (tex->extend==TEX_EXTEND)); + } + else /* no filtering */ + ibuf_get_color(&texres->tr, ibuf, x, y); if( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) { ibuf->rect-= (ibuf->x*ibuf->y); diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 436f0ecd997..90f07586786 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -2065,36 +2065,6 @@ static void do_render_fields_3d(Render *re) re->display_draw(re->ddh, re->result, NULL); } -static void load_backbuffer(Render *re) -{ - if(re->r.alphamode == R_ADDSKY) { - ImBuf *ibuf; - char name[256]; - - BLI_strncpy(name, re->r.backbuf, sizeof(name)); - BLI_path_abs(name, re->main->name); - BLI_path_frame(name, re->r.cfra, 0); - - if(re->backbuf) { - re->backbuf->id.us--; - if(re->backbuf->id.us<1) - BKE_image_signal(re->backbuf, NULL, IMA_SIGNAL_RELOAD); - } - - re->backbuf= BKE_add_image_file(name); - ibuf= BKE_image_get_ibuf(re->backbuf, NULL); - if(ibuf==NULL) { - // error() doesnt work with render window open - //error("No backbuf there!"); - printf("Error: No backbuf %s\n", name); - } - else { - if (re->r.mode & R_FIELDS) - image_de_interlace(re->backbuf, re->r.mode & R_ODDFIELD); - } - } -} - /* main render routine, no compositing */ static void do_render_fields_blur_3d(Render *re) { @@ -2105,10 +2075,6 @@ static void do_render_fields_blur_3d(Render *re) G.afbreek= 1; return; } - - /* backbuffer initialize */ - if(re->r.bufflag & 1) - load_backbuffer(re); /* now use renderdata and camera to set viewplane */ RE_SetCamera(re, camera); @@ -2203,6 +2169,24 @@ static void render_scene(Render *re, Scene *sce, int cfra) do_render_fields_blur_3d(resc); } +/* helper call to detect if this scene needs a render, or if there's a any render layer to render */ +static int composite_needs_render(Scene *sce, int this_scene) +{ + bNodeTree *ntree= sce->nodetree; + bNode *node; + + if(ntree==NULL) return 1; + if(sce->use_nodes==0) return 1; + if((sce->r.scemode & R_DOCOMP)==0) return 1; + + for(node= ntree->nodes.first; node; node= node->next) { + if(node->type==CMP_NODE_R_LAYERS) + if(this_scene==0 || node->id==NULL || node->id==&sce->id) + return 1; + } + return 0; +} + static void tag_scenes_for_render(Render *re) { bNode *node; @@ -2211,7 +2195,8 @@ static void tag_scenes_for_render(Render *re) for(sce= re->main->scene.first; sce; sce= sce->id.next) sce->id.flag &= ~LIB_DOIT; - re->scene->id.flag |= LIB_DOIT; + if(RE_GetCamera(re) && composite_needs_render(re->scene, 1)) + re->scene->id.flag |= LIB_DOIT; if(re->scene->nodetree==NULL) return; @@ -2258,24 +2243,6 @@ static void ntree_render_scenes(Render *re) set_scene_bg(re->main, re->scene); } -/* helper call to detect if theres a composite with render-result node */ -static int composite_needs_render(Scene *sce) -{ - bNodeTree *ntree= sce->nodetree; - bNode *node; - - if(ntree==NULL) return 1; - if(sce->use_nodes==0) return 1; - if((sce->r.scemode & R_DOCOMP)==0) return 1; - - for(node= ntree->nodes.first; node; node= node->next) { - if(node->type==CMP_NODE_R_LAYERS) - if(node->id==NULL || node->id==&sce->id) - return 1; - } - return 0; -} - /* bad call... need to think over proper method still */ static void render_composit_stats(void *UNUSED(arg), char *str) { @@ -2291,6 +2258,16 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree) float *rectf, filt[3][3]; int sample; + /* interaction callbacks */ + if(ntree) { + ntree->stats_draw= render_composit_stats; + ntree->test_break= re->test_break; + ntree->progress= re->progress; + ntree->sdh= re->sdh; + ntree->tbh= re->tbh; + ntree->prh= re->prh; + } + /* filtmask needs it */ R= *re; @@ -2298,25 +2275,27 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree) rectf= MEM_mapallocN(re->rectx*re->recty*sizeof(float)*4, "fullsample rgba"); for(sample=0; sample<re->r.osa; sample++) { + Render *re1; RenderResult rres; int x, y, mask; - /* set all involved renders on the samplebuffers (first was done by render itself) */ + /* enable full sample print */ + R.i.curfsa= sample+1; + + /* set all involved renders on the samplebuffers (first was done by render itself, but needs tagged) */ /* also function below assumes this */ - if(sample) { - Render *re1; - tag_scenes_for_render(re); - for(re1= RenderGlobal.renderlist.first; re1; re1= re1->next) { - if(re1->scene->id.flag & LIB_DOIT) { - if(re1->r.scemode & R_FULL_SAMPLE) { + tag_scenes_for_render(re); + for(re1= RenderGlobal.renderlist.first; re1; re1= re1->next) { + if(re1->scene->id.flag & LIB_DOIT) { + if(re1->r.scemode & R_FULL_SAMPLE) { + if(sample) read_render_result(re1, sample); - ntreeCompositTagRender(re1->scene); /* ensure node gets exec to put buffers on stack */ - } + ntreeCompositTagRender(re1->scene); /* ensure node gets exec to put buffers on stack */ } } } - + /* composite */ if(ntree) { ntreeCompositTagRender(re->scene); @@ -2359,6 +2338,17 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree) break; } + /* clear interaction callbacks */ + if(ntree) { + ntree->stats_draw= NULL; + ntree->test_break= NULL; + ntree->progress= NULL; + ntree->tbh= ntree->sdh= ntree->prh= NULL; + } + + /* disable full sample print */ + R.i.curfsa= 0; + BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); if(re->result->rectf) MEM_freeN(re->result->rectf); @@ -2398,8 +2388,10 @@ void RE_MergeFullSample(Render *re, Main *bmain, Scene *sce, bNodeTree *ntree) } /* own render result should be read/allocated */ - if(re->scene->id.flag & LIB_DOIT) + if(re->scene->id.flag & LIB_DOIT) { RE_ReadRenderResult(re->scene, re->scene); + re->scene->id.flag &= ~LIB_DOIT; + } /* and now we can draw (result is there) */ re->display_init(re->dih, re->result); @@ -2417,12 +2409,21 @@ static void do_render_composite_fields_blur_3d(Render *re) /* INIT seeding, compositor can use random texture */ BLI_srandom(re->r.cfra); - if(composite_needs_render(re->scene)) { + if(composite_needs_render(re->scene, 1)) { /* save memory... free all cached images */ ntreeFreeCache(ntree); do_render_fields_blur_3d(re); - } else { + } + else { + /* ensure new result gets added, like for regular renders */ + BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); + + RE_FreeRenderResult(re->result); + re->result= new_render_result(re, &re->disprect, 0, RR_USEMEM); + + BLI_rw_mutex_unlock(&re->resultmutex); + /* scene render process already updates animsys */ update_newframe = 1; } @@ -2758,7 +2759,7 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, void *erh, vo } if(scene->r.scemode & R_FULL_SAMPLE) { - if(composite_needs_render(scene)==0) { + if(composite_needs_render(scene, 0)==0) { error(erh, "Full Sample AA not supported without 3d rendering"); return 0; } diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c index 2d42938f6ac..56a1c870904 100644 --- a/source/blender/render/intern/source/pixelshading.c +++ b/source/blender/render/intern/source/pixelshading.c @@ -502,21 +502,6 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz, /* ------------------------------------------------------------------------- */ -static void fillBackgroundImage(float *collector, float fx, float fy) -{ - collector[0] = 0.0; - collector[1] = 0.0; - collector[2] = 0.0; - collector[3] = 0.0; - - if(R.backbuf) { - float dx= 1.0f/(float)R.winx; - float dy= 1.0f/(float)R.winy; - - image_sample(R.backbuf, fx*dx, fy*dy, dx, dy, collector); - } -} - /* Only view vector is important here. Result goes to colf[3] */ void shadeSkyView(float *colf, float *rco, float *view, float *dxyview, short thread) { @@ -626,18 +611,14 @@ void shadeSkyPixel(float *collector, float fx, float fy, short thread) float fac; - /* 1. Do a backbuffer image: */ - if(R.r.bufflag & 1) { - fillBackgroundImage(collector, fx, fy); - } - else if((R.wrld.skytype & (WO_SKYBLEND+WO_SKYTEX))==0) { - /* 2. solid color */ + if((R.wrld.skytype & (WO_SKYBLEND+WO_SKYTEX))==0) { + /* 1. solid color */ VECCOPY(collector, &R.wrld.horr); collector[3] = 0.0f; } else { - /* 3. */ + /* 2. */ /* This one true because of the context of this routine */ if(R.wrld.skytype & WO_SKYPAPER) { diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index d3d3e4d261c..b45528b96d9 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -362,10 +362,18 @@ static void accum_density(void *userdata, int index, float squared_dist) density = pdr->squared_radius; else if (pdr->falloff_type == TEX_PD_FALLOFF_ROOT) density = sqrt(dist); - else if (pdr->falloff_type == TEX_PD_FALLOFF_PARTICLE_AGE) - density = dist*MIN2(pdr->point_data[pdr->offset + index], 1.0f); - else if (pdr->falloff_type == TEX_PD_FALLOFF_PARTICLE_VEL) - density = dist*len_v3(pdr->point_data + index*3)*pdr->velscale; + else if (pdr->falloff_type == TEX_PD_FALLOFF_PARTICLE_AGE) { + if (pdr->point_data_used & POINT_DATA_LIFE) + density = dist*MIN2(pdr->point_data[pdr->offset + index], 1.0f); + else + density = dist; + } + else if (pdr->falloff_type == TEX_PD_FALLOFF_PARTICLE_VEL) { + if (pdr->point_data_used & POINT_DATA_VEL) + density = dist*len_v3(pdr->point_data + index*3)*pdr->velscale; + else + density = dist; + } if (pdr->density_curve && dist != 0.0f) { density = curvemapping_evaluateF(pdr->density_curve, 0, density/dist)*dist; diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 1c84f9f0e01..72ed7165d5e 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -2207,6 +2207,7 @@ void do_material_tex(ShadeInput *shi) } } else if(mtex->texco==TEXCO_REFL) { + calc_R_ref(shi); co= shi->ref; dx= shi->dxref; dy= shi->dyref; } else if(mtex->texco==TEXCO_NORM) { @@ -2524,9 +2525,6 @@ void do_material_tex(ShadeInput *shi) shi->orn[0]= -shi->vn[0]; shi->orn[1]= -shi->vn[1]; shi->orn[2]= -shi->vn[2]; - - /* reflection vector */ - calc_R_ref(shi); } } diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index bc6c4795f5c..7c197bb440e 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -1956,40 +1956,6 @@ void add_halo_flare(Render *re) R.r.mode= mode; } -/* ************************* used for shaded view ************************ */ - -/* if *re, then initialize, otherwise execute */ -void RE_shade_external(Render *re, ShadeInput *shi, ShadeResult *shr) -{ - static VlakRen vlr; - static ObjectRen obr; - static ObjectInstanceRen obi; - - /* init */ - if(re) { - R= *re; - - /* fake render face */ - memset(&vlr, 0, sizeof(VlakRen)); - memset(&obr, 0, sizeof(ObjectRen)); - memset(&obi, 0, sizeof(ObjectInstanceRen)); - obr.lay= -1; - obi.obr= &obr; - - return; - } - shi->vlr= &vlr; - shi->obr= &obr; - shi->obi= &obi; - - if(shi->mat->nodetree && shi->mat->use_nodes) - ntreeShaderExecTree(shi->mat->nodetree, shi, shr); - else { - shade_input_init_material(shi); - shade_material_loop(shi, shr); - } -} - /* ************************* bake ************************ */ @@ -2018,74 +1984,6 @@ typedef struct BakeShade { short *do_update; } BakeShade; -/* bake uses a char mask to know what has been baked */ -#define BAKE_MASK_NULL 0 -#define BAKE_MASK_MARGIN 1 -#define BAKE_MASK_BAKED 2 -static void bake_mask_filter_extend( char *mask, int width, int height ) -{ - char *row1, *row2, *row3; - int rowlen, x, y; - char *temprect; - - rowlen= width; - - /* make a copy, to prevent flooding */ - temprect= MEM_dupallocN(mask); - - for(y=1; y<=height; y++) { - /* setup rows */ - row1= (char *)(temprect + (y-2)*rowlen); - row2= row1 + rowlen; - row3= row2 + rowlen; - if(y==1) - row1= row2; - else if(y==height) - row3= row2; - - for(x=0; x<rowlen; x++) { - if (mask[((y-1)*rowlen)+x]==0) { - if (*row1 || *row2 || *row3 || *(row1+1) || *(row3+1) ) { - mask[((y-1)*rowlen)+x] = BAKE_MASK_MARGIN; - } else if((x!=rowlen-1) && (*(row1+2) || *(row2+2) || *(row3+2)) ) { - mask[((y-1)*rowlen)+x] = BAKE_MASK_MARGIN; - } - } - - if(x!=0) { - row1++; row2++; row3++; - } - } - } - MEM_freeN(temprect); -} - -static void bake_mask_clear( ImBuf *ibuf, char *mask, char val ) -{ - int x,y; - if (ibuf->rect_float) { - for(x=0; x<ibuf->x; x++) { - for(y=0; y<ibuf->y; y++) { - if (mask[ibuf->x*y + x] == val) { - float *col= ibuf->rect_float + 4*(ibuf->x*y + x); - col[0] = col[1] = col[2] = col[3] = 0.0f; - } - } - } - - } else { - /* char buffer */ - for(x=0; x<ibuf->x; x++) { - for(y=0; y<ibuf->y; y++) { - if (mask[ibuf->x*y + x] == val) { - char *col= (char *)(ibuf->rect + ibuf->x*y + x); - col[0] = col[1] = col[2] = col[3] = 0; - } - } - } - } -} - static void bake_set_shade_input(ObjectInstanceRen *obi, VlakRen *vlr, ShadeInput *shi, int quad, int isect, int x, int y, float u, float v) { if(quad) @@ -2281,7 +2179,7 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int quad, int } if (bs->rect_mask) { - bs->rect_mask[bs->rectx*y + x] = BAKE_MASK_BAKED; + bs->rect_mask[bs->rectx*y + x] = FILTER_MASK_USED; } } @@ -2308,7 +2206,7 @@ static void bake_displacement(void *handle, ShadeInput *shi, float dist, int x, col[3]= 255; } if (bs->rect_mask) { - bs->rect_mask[bs->rectx*y + x] = BAKE_MASK_BAKED; + bs->rect_mask[bs->rectx*y + x] = FILTER_MASK_USED; } } @@ -2532,7 +2430,8 @@ static int get_next_bake_face(BakeShade *bs) if(tface && tface->tpage) { Image *ima= tface->tpage; ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - float vec[4]= {0.0f, 0.0f, 0.0f, 0.0f}; + const float vec_alpha[4]= {0.0f, 0.0f, 0.0f, 0.0f}; + const float vec_solid[4]= {0.0f, 0.0f, 0.0f, 1.0f}; if(ibuf==NULL) continue; @@ -2552,7 +2451,7 @@ static int get_next_bake_face(BakeShade *bs) imb_freerectImBuf(ibuf); /* clear image */ if(R.r.bake_flag & R_BAKE_CLEAR) - IMB_rectfill(ibuf, vec); + IMB_rectfill(ibuf, (ibuf->depth == 32) ? vec_alpha : vec_solid); /* might be read by UI to set active image for display */ R.bakebuf= ima; @@ -2657,6 +2556,48 @@ static void *do_bake_thread(void *bs_v) return NULL; } +void RE_bake_ibuf_filter(ImBuf *ibuf, unsigned char *mask, const int filter) +{ + /* must check before filtering */ + const short is_new_alpha= (ibuf->depth != 32) && BKE_alphatest_ibuf(ibuf); + + /* Margin */ + if(filter) { + char *temprect; + int i; + + /* extend the mask +2 pixels from the image, + * this is so colors dont blend in from outside */ + + for(i=0; i< filter; i++) + IMB_mask_filter_extend((char *)ibuf->userdata, ibuf->x, ibuf->y); + + temprect = MEM_dupallocN(ibuf->userdata); + + /* expand twice to clear this many pixels, so they blend back in */ + IMB_mask_filter_extend(temprect, ibuf->x, ibuf->y); + IMB_mask_filter_extend(temprect, ibuf->x, ibuf->y); + + /* clear all pixels in the margin */ + IMB_mask_clear(ibuf, temprect, FILTER_MASK_MARGIN); + MEM_freeN(temprect); + + for(i= 0; i < filter; i++) + IMB_filter_extend(ibuf, (char *)ibuf->userdata); + } + + /* if the bake results in new alpha then change the image setting */ + if(is_new_alpha) { + ibuf->depth= 32; + } + else { + if(filter && ibuf->depth != 32) { + /* clear alpha added by filtering */ + IMB_rectfill_alpha(ibuf, 1.0f); + } + } +} + /* using object selection tags, the faces with UV maps get baked */ /* render should have been setup */ /* returns 0 if nothing was handled */ @@ -2743,36 +2684,7 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up if(!ibuf) continue; - if(re->r.bake_filter) { - if (usemask) { - /* extend the mask +2 pixels from the image, - * this is so colors dont blend in from outside */ - char *temprect; - - for(a=0; a<re->r.bake_filter; a++) - bake_mask_filter_extend((char *)ibuf->userdata, ibuf->x, ibuf->y); - - temprect = MEM_dupallocN(ibuf->userdata); - - /* expand twice to clear this many pixels, so they blend back in */ - bake_mask_filter_extend(temprect, ibuf->x, ibuf->y); - bake_mask_filter_extend(temprect, ibuf->x, ibuf->y); - - /* clear all pixels in the margin*/ - bake_mask_clear(ibuf, temprect, BAKE_MASK_MARGIN); - MEM_freeN(temprect); - } - - for(a=0; a<re->r.bake_filter; a++) { - /*the mask, ibuf->userdata - can be null, in this case only zero alpha is used */ - IMB_filter_extend(ibuf, (char *)ibuf->userdata); - } - - if (ibuf->userdata) { - MEM_freeN(ibuf->userdata); - ibuf->userdata= NULL; - } - } + RE_bake_ibuf_filter(ibuf, (unsigned char *)ibuf->userdata, re->r.bake_filter); ibuf->userflags |= IB_BITMAPDIRTY; if (ibuf->rect_float) IMB_rect_from_float(ibuf); diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index e575776ec79..e22ddd28dda 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -543,11 +543,6 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert shi->orn[2]= -shi->vn[2]; } - if(texco & TEXCO_REFL) { - /* mirror reflection color textures (and envmap) */ - calc_R_ref(shi); /* wrong location for normal maps! XXXXXXXXXXXXXX */ - } - if(texco & TEXCO_STRESS) { /* not supported */ } @@ -633,14 +628,14 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float * dxco[0]= fx; dxco[1]= 0.0f; if(shi->facenor[2]!=0.0f) - dxco[2]= (shi->facenor[0]*fx)/shi->facenor[2]; + dxco[2]= -(shi->facenor[0]*fx)/shi->facenor[2]; else dxco[2]= 0.0f; dyco[0]= 0.0f; dyco[1]= fy; if(shi->facenor[2]!=0.0f) - dyco[2]= (shi->facenor[1]*fy)/shi->facenor[2]; + dyco[2]= -(shi->facenor[1]*fy)/shi->facenor[2]; else dyco[2]= 0.0f; @@ -1205,11 +1200,6 @@ void shade_input_set_shade_texco(ShadeInput *shi) shi->orn[2]= -shi->vn[2]; } - if(texco & TEXCO_REFL) { - /* mirror reflection color textures (and envmap) */ - calc_R_ref(shi); /* wrong location for normal maps! XXXXXXXXXXXXXX */ - } - if(texco & TEXCO_STRESS) { float *s1, *s2, *s3; diff --git a/source/blender/render/intern/source/sunsky.c b/source/blender/render/intern/source/sunsky.c index f645c29a7a5..5877fa42292 100644 --- a/source/blender/render/intern/source/sunsky.c +++ b/source/blender/render/intern/source/sunsky.c @@ -460,7 +460,7 @@ void AtmospherePixleShader( struct SunSky* sunSky, float view[3], float s, float vec3opv(sunSky->atm_BetaRM, sunSky->atm_BetaRay, +, sunSky->atm_BetaMie); //e^(-(beta_1 + beta_2) * s) = E1 - vec3opf(E1, sunSky->atm_BetaRM, *, -s/log(2)); + vec3opf(E1, sunSky->atm_BetaRM, *, -s/M_LN2); E1[0] = exp(E1[0]); E1[1] = exp(E1[1]); E1[2] = exp(E1[2]); diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c index 09422af7c79..c4e741b6c61 100644 --- a/source/blender/render/intern/source/volumetric.c +++ b/source/blender/render/intern/source/volumetric.c @@ -605,7 +605,7 @@ static void volumeintegrate(struct ShadeInput *shi, float *col, float *co, float for (; t0 < t1; pt0 = t0, t0 += stepsize) { const float density = vol_get_density(shi, p); - if (density > 0.01f) { + if (density > 0.00001f) { float scatter_col[3] = {0.f, 0.f, 0.f}, emit_col[3]; const float stepd = (t0 - pt0) * density; |