diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-11-15 06:05:32 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-11-15 06:05:32 +0400 |
commit | e59ab6486f9e7285815671044b785c28365d5165 (patch) | |
tree | 4a9406c8181a817a8b96243ae167acc740ed20f7 /source/blender/render | |
parent | 35ab6cabbf62187290e417dba6d8b18cd4fe18de (diff) | |
parent | b1019a56b54294fc91293c5c43ef46d54950ae84 (diff) |
svn merge -r41751:41779 ^/trunk/blender
Diffstat (limited to 'source/blender/render')
-rw-r--r-- | source/blender/render/extern/include/RE_pipeline.h | 2 | ||||
-rw-r--r-- | source/blender/render/intern/source/convertblender.c | 18 | ||||
-rw-r--r-- | source/blender/render/intern/source/envmap.c | 10 | ||||
-rw-r--r-- | source/blender/render/intern/source/imagetexture.c | 2 | ||||
-rw-r--r-- | source/blender/render/intern/source/occlusion.c | 4 | ||||
-rw-r--r-- | source/blender/render/intern/source/pipeline.c | 4 | ||||
-rw-r--r-- | source/blender/render/intern/source/pixelshading.c | 14 | ||||
-rw-r--r-- | source/blender/render/intern/source/render_texture.c | 37 | ||||
-rw-r--r-- | source/blender/render/intern/source/shadbuf.c | 4 | ||||
-rw-r--r-- | source/blender/render/intern/source/shadeoutput.c | 20 | ||||
-rw-r--r-- | source/blender/render/intern/source/volume_precache.c | 35 |
11 files changed, 82 insertions, 68 deletions
diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index fac3329bae0..c00df7db87e 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -233,7 +233,7 @@ void RE_MergeFullSample(struct Render *re, struct Main *bmain, struct Scene *sce /* ancient stars function... go away! */ void RE_make_stars(struct Render *re, struct Scene *scenev3d, void (*initfunc)(void), - void (*vertexfunc)(float*), void (*termfunc)(void)); + void (*vertexfunc)(float*), void (*termfunc)(void)); /* display and event callbacks */ void RE_display_init_cb (struct Render *re, void *handle, void (*f)(void *handle, RenderResult *rr)); diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 66dc0b95a60..7d301389eed 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -3621,7 +3621,7 @@ static void area_lamp_vectors(LampRen *lar) float xsize= 0.5f*lar->area_size, ysize= 0.5f*lar->area_sizey, multifac; /* make it smaller, so area light can be multisampled */ - multifac= 1.0f/sqrt((float)lar->ray_totsamp); + multifac= 1.0f/sqrtf((float)lar->ray_totsamp); xsize *= multifac; ysize *= multifac; @@ -3801,7 +3801,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) if(lar->mode & LA_HALO) { if(lar->spotsi>170.0f) lar->spotsi= 170.0f; } - lar->spotsi= cos( M_PI*lar->spotsi/360.0f ); + lar->spotsi= cosf( (float)M_PI*lar->spotsi/360.0f ); lar->spotbl= (1.0f-lar->spotsi)*la->spotblend; memcpy(lar->mtex, la->mtex, MAX_MTEX*sizeof(void *)); @@ -4028,8 +4028,8 @@ void init_render_world(Render *re) re->wrld.misi= 1.0f; } - re->wrld.linfac= 1.0 + pow((2.0*re->wrld.exp + 0.5), -10); - re->wrld.logfac= log( (re->wrld.linfac-1.0)/re->wrld.linfac )/re->wrld.range; + re->wrld.linfac= 1.0f + powf((2.0f*re->wrld.exp + 0.5f), -10); + re->wrld.logfac= logf((re->wrld.linfac-1.0f)/re->wrld.linfac) / re->wrld.range; } @@ -4082,7 +4082,7 @@ static void set_phong_threshold(ObjectRen *obr) if(tot) { thresh/= (float)tot; - obr->ob->smoothresh= cos(0.5*M_PI-saacos(thresh)); + obr->ob->smoothresh= cosf(0.5f*(float)M_PI-saacos(thresh)); } } @@ -5260,11 +5260,11 @@ static void speedvector_project(Render *re, float zco[2], const float co[3], con /* angle between (0,0,-1) and (co) */ copy_v3_v3(vec, co); - ang= saacos(-vec[2]/sqrt(vec[0]*vec[0] + vec[2]*vec[2])); + ang= saacos(-vec[2]/sqrtf(vec[0]*vec[0] + vec[2]*vec[2])); if(vec[0]<0.0f) ang= -ang; zco[0]= ang/pixelphix + zmulx; - ang= 0.5f*M_PI - saacos(vec[1]/sqrt(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2])); + ang= 0.5f*M_PI - saacos(vec[1]/sqrtf(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2])); zco[1]= ang/pixelphiy + zmuly; } @@ -5292,7 +5292,7 @@ static void calculate_speedvector(const float vectors[2], int step, float winsq, /* maximize speed for image width, otherwise it never looks good */ len= zco[0]*zco[0] + zco[1]*zco[1]; if(len > winsq) { - len= winroot/sqrt(len); + len= winroot/sqrtf(len); zco[0]*= len; zco[1]*= len; } @@ -5502,7 +5502,7 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float * // maximize speed as usual len= zco[0]*zco[0] + zco[1]*zco[1]; if(len > winsq) { - len= winroot/sqrt(len); + len= winroot/sqrtf(len); zco[0]*= len; zco[1]*= len; } diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index 6ea62828601..62cb29c3d5f 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -601,31 +601,31 @@ static int envcube_isect(EnvMap *env, float *vec, float *answ) } else { /* which face */ - if( vec[2]<=-fabs(vec[0]) && vec[2]<=-fabs(vec[1]) ) { + if( vec[2] <= -fabsf(vec[0]) && vec[2] <= -fabsf(vec[1]) ) { face= 0; labda= -1.0f/vec[2]; answ[0]= labda*vec[0]; answ[1]= labda*vec[1]; } - else if( vec[2]>=fabs(vec[0]) && vec[2]>=fabs(vec[1]) ) { + else if (vec[2] >= fabsf(vec[0]) && vec[2] >= fabsf(vec[1])) { face= 1; labda= 1.0f/vec[2]; answ[0]= labda*vec[0]; answ[1]= -labda*vec[1]; } - else if( vec[1]>=fabs(vec[0]) ) { + else if (vec[1] >= fabsf(vec[0])) { face= 2; labda= 1.0f/vec[1]; answ[0]= labda*vec[0]; answ[1]= labda*vec[2]; } - else if( vec[0]<=-fabs(vec[1]) ) { + else if (vec[0] <= -fabsf(vec[1])) { face= 3; labda= -1.0f/vec[0]; answ[0]= labda*vec[1]; answ[1]= labda*vec[2]; } - else if( vec[1]<=-fabs(vec[0]) ) { + else if (vec[1] <= -fabsf(vec[0])) { face= 4; labda= -1.0f/vec[1]; answ[0]= -labda*vec[0]; diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index d1f7059416d..785d9ac69d8 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -1092,7 +1092,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex if (tex->imaflag & TEX_FILTER_MIN) { // make sure the filtersize is minimal in pixels (normal, ref map can have miniature pixel dx/dy) - const float addval = (0.5f * tex->filtersize) / (float)MIN2(ibuf->x, ibuf->y); + const float addval = (0.5f * tex->filtersize) / (float)MIN2(ibuf->x, ibuf->y); if (addval > minx) minx = addval; if (addval > miny) miny = addval; } diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c index 0984c9e784f..e20fd85d0f0 100644 --- a/source/blender/render/intern/source/occlusion.c +++ b/source/blender/render/intern/source/occlusion.c @@ -1034,8 +1034,8 @@ static float occ_quad_form_factor(float *p, float *n, float *q0, float *q1, floa /* dot */ vresult.v = (vec_splat_float(n[0])*gx + - vec_splat_float(n[1])*gy + - vec_splat_float(n[2])*gz)*vangle; + vec_splat_float(n[1])*gy + + vec_splat_float(n[2])*gz)*vangle; result= (vresult.f[0] + vresult.f[1] + vresult.f[2] + vresult.f[3])*(0.5f/(float)M_PI); result= MAX2(result, 0.0f); diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index d4bd8f8a693..d7045c0b322 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -159,7 +159,7 @@ static void stats_background(void *UNUSED(arg), RenderStats *rs) megs_peak_memory = (peak_memory)/(1024.0*1024.0); fprintf(stdout, "Fra:%d Mem:%.2fM (%.2fM, peak %.2fM) ", rs->cfra, - megs_used_memory, mmap_used_memory, megs_peak_memory); + megs_used_memory, mmap_used_memory, megs_peak_memory); if(rs->curfield) fprintf(stdout, "Field %d ", rs->curfield); @@ -1831,7 +1831,7 @@ static void do_render_3d(Render *re) if(render_scene_needs_vector(re)) RE_Database_FromScene_Vectors(re, re->main, re->scene, re->lay); else - RE_Database_FromScene(re, re->main, re->scene, re->lay, 1); + RE_Database_FromScene(re, re->main, re->scene, re->lay, 1); /* clear UI drawing locks */ if(re->draw_lock) diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c index 36709408496..a78cc3e2288 100644 --- a/source/blender/render/intern/source/pixelshading.c +++ b/source/blender/render/intern/source/pixelshading.c @@ -331,7 +331,7 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz, /* halo being intersected? */ if(har->zs> zz-har->zd) { t= ((float)(zz-har->zs))/(float)har->zd; - alpha*= sqrt(sqrt(t)); + alpha*= sqrtf(sqrtf(t)); } } @@ -351,7 +351,7 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz, rc= hashvectf + (ofs % 768); - fac= fabs( rc[1]*(har->rad*fabs(rc[0]) - radist) ); + fac= fabsf( rc[1]*(har->rad*fabsf(rc[0]) - radist) ); if(fac< 1.0f) { ringf+= (1.0f-fac); @@ -360,7 +360,7 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz, } if(har->type & HA_VECT) { - dist= fabs( har->cos*(yn) - har->sin*(xn) )/har->rad; + dist= fabsf( har->cos*(yn) - har->sin*(xn) )/har->rad; if(dist>1.0f) dist= 1.0f; if(har->tex) { zn= har->sin*xn - har->cos*yn; @@ -379,7 +379,7 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz, if(har->hard>=30) { dist= sqrt(dist); if(har->hard>=40) { - dist= sin(dist*M_PI_2); + dist= sinf(dist*(float)M_PI_2); if(har->hard>=50) { dist= sqrt(dist); } @@ -418,8 +418,8 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz, angle= atan2(yn, xn); angle*= (1.0f+0.25f*har->starpoints); - co= cos(angle); - si= sin(angle); + co= cosf(angle); + si= sinf(angle); angle= (co*xn+si*yn)*(co*yn-si*xn); @@ -427,7 +427,7 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz, if(ster>1.0f) { ster= (har->rad)/(ster); - if(ster<1.0f) dist*= sqrt(ster); + if(ster<1.0f) dist*= sqrtf(ster); } } diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 8062dd7e93e..7ed6050d7d3 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -325,7 +325,7 @@ static float wood_int(Tex *tex, float x, float y, float z) wi = waveform[wf]((x + y + z)*10.0f); } else if (wt==TEX_RING) { - wi = waveform[wf](sqrt(x*x + y*y + z*z)*20.0f); + wi = waveform[wf](sqrtf(x*x + y*y + z*z)*20.0f); } else if (wt==TEX_BANDNOISE) { wi = tex->turbul*BLI_gNoise(tex->noisesize, x, y, z, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); @@ -333,7 +333,7 @@ static float wood_int(Tex *tex, float x, float y, float z) } else if (wt==TEX_RINGNOISE) { wi = tex->turbul*BLI_gNoise(tex->noisesize, x, y, z, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); - wi = waveform[wf](sqrt(x*x + y*y + z*z)*20.0f + wi); + wi = waveform[wf](sqrtf(x*x + y*y + z*z)*20.0f + wi); } return wi; @@ -659,7 +659,7 @@ static float voronoiTex(Tex *tex, float *texvec, TexResult *texres) if (sc!=0.f) sc = tex->ns_outscale/sc; voronoi(texvec[0], texvec[1], texvec[2], da, pa, tex->vn_mexp, tex->vn_distm); - texres->tin = sc * fabs(tex->vn_w1*da[0] + tex->vn_w2*da[1] + tex->vn_w3*da[2] + tex->vn_w4*da[3]); + texres->tin = sc * fabsf(tex->vn_w1*da[0] + tex->vn_w2*da[1] + tex->vn_w3*da[2] + tex->vn_w4*da[3]); if (tex->vn_coltype) { float ca[3]; /* cell color */ @@ -699,11 +699,11 @@ static float voronoiTex(Tex *tex, float *texvec, TexResult *texres) /* calculate bumpnormal */ voronoi(texvec[0] + offs, texvec[1], texvec[2], da, pa, tex->vn_mexp, tex->vn_distm); - texres->nor[0] = sc * fabs(tex->vn_w1*da[0] + tex->vn_w2*da[1] + tex->vn_w3*da[2] + tex->vn_w4*da[3]); + texres->nor[0] = sc * fabsf(tex->vn_w1*da[0] + tex->vn_w2*da[1] + tex->vn_w3*da[2] + tex->vn_w4*da[3]); voronoi(texvec[0], texvec[1] + offs, texvec[2], da, pa, tex->vn_mexp, tex->vn_distm); - texres->nor[1] = sc * fabs(tex->vn_w1*da[0] + tex->vn_w2*da[1] + tex->vn_w3*da[2] + tex->vn_w4*da[3]); + texres->nor[1] = sc * fabsf(tex->vn_w1*da[0] + tex->vn_w2*da[1] + tex->vn_w3*da[2] + tex->vn_w4*da[3]); voronoi(texvec[0], texvec[1], texvec[2] + offs, da, pa, tex->vn_mexp, tex->vn_distm); - texres->nor[2] = sc * fabs(tex->vn_w1*da[0] + tex->vn_w2*da[1] + tex->vn_w3*da[2] + tex->vn_w4*da[3]); + texres->nor[2] = sc * fabsf(tex->vn_w1*da[0] + tex->vn_w2*da[1] + tex->vn_w3*da[2] + tex->vn_w4*da[3]); tex_normal_derivate(tex, texres); rv |= TEX_NOR; @@ -1450,9 +1450,9 @@ void texture_rgb_blend(float in[3], const float tex[3], const float out[3], floa case MTEX_DIFF: fact*= facg; facm= 1.0f-fact; - in[0]= facm*out[0] + fact*fabs(tex[0]-out[0]); - in[1]= facm*out[1] + fact*fabs(tex[1]-out[1]); - in[2]= facm*out[2] + fact*fabs(tex[2]-out[2]); + in[0]= facm*out[0] + fact*fabsf(tex[0]-out[0]); + in[1]= facm*out[1] + fact*fabsf(tex[1]-out[1]); + in[2]= facm*out[2] + fact*fabsf(tex[2]-out[2]); break; case MTEX_DARK: @@ -1557,7 +1557,7 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen break; case MTEX_DIFF: - in= facm*out + fact*fabs(tex-out); + in= facm*out + fact*fabsf(tex-out); break; case MTEX_DARK: @@ -2478,7 +2478,7 @@ void do_material_tex(ShadeInput *shi, Render *re) texres.nor[0] = -texres.nor[0]; texres.nor[1] = -texres.nor[1]; } - fact = Tnor*fabs(norfac); + fact = Tnor*fabsf(norfac); if (fact>1.f) fact = 1.f; facm = 1.f-fact; if(mtex->normapspace == MTEX_NSPACE_TANGENT) { @@ -2721,9 +2721,9 @@ void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float *col mul_m4_v3(ob->imat_ren, co); } } - else if(mtex->texco==TEXCO_GLOB) { - copy_v3_v3(co, xyz); - mul_m4_v3(re->viewinv, co); + else if(mtex->texco==TEXCO_GLOB) { + copy_v3_v3(co, xyz); + mul_m4_v3(re->viewinv, co); } else continue; // can happen when texco defines disappear and it renders old files @@ -3031,7 +3031,7 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h /* only works with texture being "real" */ /* use saacos(), fixes bug [#22398], float precision caused lo[2] to be slightly less then -1.0 */ if(lo[0] || lo[1]) { /* check for zero case [#24807] */ - fact= (1.0f/(float)M_PI)*saacos(lo[2])/(sqrt(lo[0]*lo[0] + lo[1]*lo[1])); + fact= (1.0f/(float)M_PI)*saacos(lo[2])/(sqrtf(lo[0]*lo[0] + lo[1]*lo[1])); tempvec[0]= lo[0]*fact; tempvec[1]= lo[1]*fact; tempvec[2]= 0.0; @@ -3721,15 +3721,12 @@ void RE_sample_material_color(Material *mat, float color[3], float *alpha, const obi.ob = ob; shi.obi = &obi; unit_m4(re.viewinv); - - color[0] = mat->vol.reflection_col[0]; - color[1] = mat->vol.reflection_col[1]; - color[2] = mat->vol.reflection_col[2]; + copy_v3_v3(color, mat->vol.reflection_col); *alpha = mat->vol.density; /* do texture */ do_volume_tex(&shi, volume_co, (MAP_TRANSMISSION_COL | MAP_REFLECTION_COL | MAP_DENSITY), - color, alpha, &re); + color, alpha, &re); } } diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c index f3eb2234778..8cb7009f756 100644 --- a/source/blender/render/intern/source/shadbuf.c +++ b/source/blender/render/intern/source/shadbuf.c @@ -1083,7 +1083,7 @@ static float readshadowbuf(ShadBuf *shb, ShadSampleBuf *shsample, int bias, int else { /* got warning on this for 64 bits.... */ /* but it's working code! in this case rz is not a pointer but zvalue (ton) */ - zsamp= GET_INT_FROM_POINTER(rz); + zsamp= GET_INT_FROM_POINTER(rz); } /* tricky stuff here; we use ints which can overflow easily with bias values */ @@ -1267,7 +1267,7 @@ static float readshadowbuf_halo(ShadBuf *shb, ShadSampleBuf *shsample, int xs, i else { /* same as before */ /* still working code! (ton) */ - zsamp= GET_INT_FROM_POINTER(rz); + zsamp= GET_INT_FROM_POINTER(rz); } /* NO schadow when sampled at 'eternal' distance */ diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index fde4eab37b0..e1f521db066 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -174,7 +174,7 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens) VECCOPY(npos, p1); // npos is double! /* pre-scale */ - npos[2]*= lar->sh_zfac; + npos[2] *= (double)lar->sh_zfac; } else { VECCOPY(npos, lar->sh_invcampos); /* in initlamp calculated */ @@ -204,11 +204,11 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens) maxz*= lar->sh_zfac; maxy= lar->imat[0][1]*p1[0]+lar->imat[1][1]*p1[1]+lar->imat[2][1]*p1[2]; - if( fabs(nray[2]) < FLT_EPSILON ) use_yco= 1; + if( fabsf(nray[2]) < FLT_EPSILON ) use_yco= 1; } /* scale z to make sure volume is normalized */ - nray[2]*= lar->sh_zfac; + nray[2] *= (double)lar->sh_zfac; /* nray does not need normalization */ ladist= lar->sh_zfac*lar->dist; @@ -260,7 +260,7 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens) /* intersction point with -ladist, the bottom of the cone */ if(use_yco==0) { - t3= (-ladist-npos[2])/nray[2]; + t3= ((double)(-ladist)-npos[2])/nray[2]; /* de we have to replace one of the intersection points? */ if(ok1) { @@ -413,7 +413,7 @@ float fresnel_fac(float *view, float *vn, float grad, float fac) if(t1>0.0f) t2= 1.0f+t1; else t2= 1.0f-t1; - t2= grad + (1.0f-grad)*pow(t2, fac); + t2= grad + (1.0f-grad)*powf(t2, fac); if(t2<0.0f) return 0.0f; else if(t2>1.0f) return 1.0f; @@ -698,7 +698,7 @@ static float WardIso_Spec( float *n, float *l, float *v, float rms, int tangent) angle = tan(saacos(nh)); alpha = MAX2(rms, 0.001f); - i= nl * (1.0f/(4.0f*M_PI*alpha*alpha)) * (exp( -(angle*angle)/(alpha*alpha))/(sqrt(nv*nl))); + i= nl * (1.0f/(4.0f*(float)M_PI*alpha*alpha)) * (expf( -(angle*angle)/(alpha*alpha))/(sqrtf(nv*nl))); return i; } @@ -777,7 +777,7 @@ static float OrenNayar_Diff(float nl, float *n, float *l, float *v, float rough b*= 0.95f; /* prevent tangens from shooting to inf, 'nl' can be not a dot product here. */ /* overflow only happens with extreme size area light, and higher roughness */ - i = nl * ( A + ( B * t * sin(a) * tan(b) ) ); + i = nl * ( A + ( B * t * sinf(a) * tanf(b) ) ); return i; } @@ -1636,9 +1636,9 @@ static void shade_lamp_loop_only_shadow(ShadeInput *shi, ShadeResult *shr) static void wrld_exposure_correct(float diff[3]) { - diff[0]= R.wrld.linfac*(1.0f-exp( diff[0]*R.wrld.logfac) ); - diff[1]= R.wrld.linfac*(1.0f-exp( diff[1]*R.wrld.logfac) ); - diff[2]= R.wrld.linfac*(1.0f-exp( diff[2]*R.wrld.logfac) ); + diff[0]= R.wrld.linfac*(1.0f-expf( diff[0]*R.wrld.logfac) ); + diff[1]= R.wrld.linfac*(1.0f-expf( diff[1]*R.wrld.logfac) ); + diff[2]= R.wrld.linfac*(1.0f-expf( diff[2]*R.wrld.logfac) ); } void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) diff --git a/source/blender/render/intern/source/volume_precache.c b/source/blender/render/intern/source/volume_precache.c index 29eea081672..8b3c3ec5c3d 100644 --- a/source/blender/render/intern/source/volume_precache.c +++ b/source/blender/render/intern/source/volume_precache.c @@ -285,7 +285,7 @@ static inline int lc_to_ms_I(int x, int y, int z, int *n) /* *** multiple scattering approximation *** */ /* get the total amount of light energy in the light cache. used to normalise after multiple scattering */ -static float total_ss_energy(VolumePrecache *vp) +static float total_ss_energy(Render *re, int do_test_break, VolumePrecache *vp) { int x, y, z; int *res = vp->res; @@ -301,12 +301,14 @@ static float total_ss_energy(VolumePrecache *vp) if (vp->data_b[i] > 0.f) energy += vp->data_b[i]; } } + + if (do_test_break && re->test_break(re->tbh)) break; } return energy; } -static float total_ms_energy(float *sr, float *sg, float *sb, int *res) +static float total_ms_energy(Render *re, int do_test_break, float *sr, float *sg, float *sb, int *res) { int x, y, z; float energy=0.f; @@ -321,16 +323,19 @@ static float total_ms_energy(float *sr, float *sg, float *sb, int *res) if (sb[i] > 0.f) energy += sb[i]; } } + + if (do_test_break && re->test_break(re->tbh)) break; } return energy; } -static void ms_diffuse(float *x0, float *x, float diff, int *n) //n is the unpadded resolution +static void ms_diffuse(Render *re, int do_test_break, float *x0, float *x, float diff, int *n) //n is the unpadded resolution { int i, j, k, l; const float dt = VOL_MS_TIMESTEP; - const float a = dt*diff*n[0]*n[1]*n[2]; + size_t size = n[0]*n[1]*n[2]; + const float a = dt*diff*size; for (l=0; l<20; l++) { @@ -345,7 +350,11 @@ static void ms_diffuse(float *x0, float *x, float diff, int *n) //n is the unpad ) / (1+6*a); } } + + if (do_test_break && re->test_break(re->tbh)) break; } + + if (re->test_break(re->tbh)) break; } } @@ -359,6 +368,7 @@ static void multiple_scattering_diffusion(Render *re, VolumePrecache *vp, Materi int x, y, z, m; int *n = vp->res; const int size = (n[0]+2)*(n[1]+2)*(n[2]+2); + const int do_test_break = (size > 100000); double time, lasttime= PIL_check_seconds_timer(); float total; float c=1.0f; @@ -374,7 +384,7 @@ static void multiple_scattering_diffusion(Render *re, VolumePrecache *vp, Materi total = (float)(n[0]*n[1]*n[2]*simframes); - energy_ss = total_ss_energy(vp); + energy_ss = total_ss_energy(re, do_test_break, vp); /* Scattering as diffusion pass */ for (m=0; m<simframes; m++) @@ -409,21 +419,26 @@ static void multiple_scattering_diffusion(Render *re, VolumePrecache *vp, Materi } } } + + if (do_test_break && re->test_break(re->tbh)) break; } + + if (re->test_break(re->tbh)) break; + SWAP(float *,sr,sr0); SWAP(float *,sg,sg0); SWAP(float *,sb,sb0); /* main diffusion simulation */ - ms_diffuse(sr0, sr, diff, n); - ms_diffuse(sg0, sg, diff, n); - ms_diffuse(sb0, sb, diff, n); + ms_diffuse(re, do_test_break, sr0, sr, diff, n); + ms_diffuse(re, do_test_break, sg0, sg, diff, n); + ms_diffuse(re, do_test_break, sb0, sb, diff, n); if (re->test_break(re->tbh)) break; } /* normalisation factor to conserve energy */ - energy_ms = total_ms_energy(sr, sg, sb, n); + energy_ms = total_ms_energy(re, do_test_break, sr, sg, sb, n); fac *= (energy_ss / energy_ms); /* blend multiple scattering back in the light cache */ @@ -449,6 +464,8 @@ static void multiple_scattering_diffusion(Render *re, VolumePrecache *vp, Materi vp->data_b[i] = origf * vp->data_b[i] + fac * sb[j]; } } + + if (do_test_break && re->test_break(re->tbh)) break; } MEM_freeN(sr0); |