Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoerg Mueller <nexyon@gmail.com>2011-08-23 00:31:46 +0400
committerJoerg Mueller <nexyon@gmail.com>2011-08-23 00:31:46 +0400
commitf0d5abfcb2b54f6fd7a24220e81e0c88a914d87f (patch)
tree328a631d447ea7c7be2a757d092065c721090f82 /source/blender/render
parent1d529d83a0693693878749110a05d8b0fa929d0f (diff)
parent6a374d266d8213629f74a9f4c9a4984ddf59ef4c (diff)
Merging trunk up to r39637.
Diffstat (limited to 'source/blender/render')
-rw-r--r--source/blender/render/SConscript2
-rw-r--r--source/blender/render/intern/source/convertblender.c66
-rw-r--r--source/blender/render/intern/source/envmap.c24
-rw-r--r--source/blender/render/intern/source/gammaCorrectionTables.c2
-rw-r--r--source/blender/render/intern/source/initrender.c52
-rw-r--r--source/blender/render/intern/source/occlusion.c2
-rw-r--r--source/blender/render/intern/source/pixelblending.c24
-rw-r--r--source/blender/render/intern/source/pixelshading.c72
-rw-r--r--source/blender/render/intern/source/rayshade.c118
-rw-r--r--source/blender/render/intern/source/render_texture.c392
-rw-r--r--source/blender/render/intern/source/rendercore.c36
-rw-r--r--source/blender/render/intern/source/renderdatabase.c70
-rw-r--r--source/blender/render/intern/source/shadbuf.c49
-rw-r--r--source/blender/render/intern/source/sss.c52
-rw-r--r--source/blender/render/intern/source/strand.c8
-rw-r--r--source/blender/render/intern/source/sunsky.c116
-rw-r--r--source/blender/render/intern/source/volume_precache.c4
-rw-r--r--source/blender/render/intern/source/volumetric.c18
-rw-r--r--source/blender/render/intern/source/voxeldata.c6
-rw-r--r--source/blender/render/intern/source/zbuf.c78
20 files changed, 605 insertions, 586 deletions
diff --git a/source/blender/render/SConscript b/source/blender/render/SConscript
index bff7797e0c7..4ec1ce3de6b 100644
--- a/source/blender/render/SConscript
+++ b/source/blender/render/SConscript
@@ -31,7 +31,7 @@ if env['OURPLATFORM'] == 'darwin':
cflags_raytrace = env['CFLAGS'] + env['BF_RAYOPTIMIZATION_SSE_FLAGS']
cxxflags_raytrace = env['CXXFLAGS'] + env['BF_RAYOPTIMIZATION_SSE_FLAGS']
-if env['OURPLATFORM'] == 'linux2':
+if env['OURPLATFORM'] == 'linux':
if env['WITH_BF_RAYOPTIMIZATION']:
cflags_raytrace = env['CCFLAGS'] + env['BF_RAYOPTIMIZATION_SSE_FLAGS']
cxxflags_raytrace = env['CXXFLAGS'] + env['BF_RAYOPTIMIZATION_SSE_FLAGS']
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
index b385b507707..7033ec27fc0 100644
--- a/source/blender/render/intern/source/convertblender.c
+++ b/source/blender/render/intern/source/convertblender.c
@@ -192,10 +192,10 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void),
/* minimal free space (starting at camera) */
starmindist= wrld->starmindist;
- if (stargrid <= 0.10) return;
+ if (stargrid <= 0.10f) return;
if (re) re->flag |= R_HALO;
- else stargrid *= 1.0; /* then it draws fewer */
+ else stargrid *= 1.0f; /* then it draws fewer */
if(re) invert_m4_m4(mat, re->viewmat);
else unit_m4(mat);
@@ -267,17 +267,17 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void),
if (alpha >= clipend) alpha = 0.0;
else if (alpha <= starmindist) alpha = 0.0;
- else if (alpha <= 2.0 * starmindist) {
+ else if (alpha <= 2.0f * starmindist) {
alpha = (alpha - starmindist) / starmindist;
} else {
- alpha -= 2.0 * starmindist;
- alpha /= (clipend - 2.0 * starmindist);
- alpha = 1.0 - alpha;
+ alpha -= 2.0f * starmindist;
+ alpha /= (clipend - 2.0f * starmindist);
+ alpha = 1.0f - alpha;
}
}
- if (alpha != 0.0) {
+ if (alpha != 0.0f) {
fac = force * BLI_drand();
har = initstar(re, obr, vec, fac);
@@ -822,7 +822,7 @@ static void autosmooth(Render *UNUSED(re), ObjectRen *obr, float mat[][4], int d
if(obr->totvert==0) return;
asverts= MEM_callocN(sizeof(ASvert)*obr->totvert, "all smooth verts");
- thresh= cos( M_PI*(0.5f+(float)degr)/180.0 );
+ thresh= cosf((float)M_PI*(0.5f+(float)degr)/180.0f );
/* step zero: give faces normals of original mesh, if this is provided */
@@ -1046,9 +1046,9 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par
float fac;
if(ma->strand_ease!=0.0f) {
if(ma->strand_ease<0.0f)
- fac= pow(sd->time, 1.0+ma->strand_ease);
+ fac= pow(sd->time, 1.0f+ma->strand_ease);
else
- fac= pow(sd->time, 1.0/(1.0f-ma->strand_ease));
+ fac= pow(sd->time, 1.0f/(1.0f-ma->strand_ease));
}
else fac= sd->time;
@@ -1063,7 +1063,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par
width= w;
/*cross is the radius of the strand so we want it to be half of full width */
- mul_v3_fl(cross,0.5/crosslen);
+ mul_v3_fl(cross,0.5f/crosslen);
}
else
width/=w;
@@ -1984,8 +1984,8 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
else {
/* render normal particles */
if(part->trail_count > 1) {
- float length = part->path_end * (1.0 - part->randlength * r_length);
- int trail_count = part->trail_count * (1.0 - part->randlength * r_length);
+ float length = part->path_end * (1.0f - part->randlength * r_length);
+ int trail_count = part->trail_count * (1.0f - part->randlength * r_length);
float ct = (part->draw & PART_ABS_PATH_TIME) ? cfra : pa_time;
float dt = length / (trail_count ? (float)trail_count : 1.0f);
@@ -2159,7 +2159,7 @@ static void make_render_halos(Render *re, ObjectRen *obr, Mesh *UNUSED(me), int
normalize_v3(view);
zn= nor[0]*view[0]+nor[1]*view[1]+nor[2]*view[2];
- if(zn>=0.0) hasize= 0.0;
+ if(zn>=0.0f) hasize= 0.0f;
else hasize*= zn*zn*zn*zn;
}
@@ -3599,7 +3599,7 @@ static void initshadowbuf(Render *re, LampRen *lar, float mat[][4])
/* bias is percentage, made 2x larger because of correction for angle of incidence */
/* when a ray is closer to parallel of a face, bias value is increased during render */
- shb->bias= (0.02*lar->bias)*0x7FFFFFFF;
+ shb->bias= (0.02f*lar->bias)*0x7FFFFFFF;
/* halfway method (average of first and 2nd z) reduces bias issues */
if(ELEM(lar->buftype, LA_SHADBUF_HALFWAY, LA_SHADBUF_DEEP))
@@ -3610,7 +3610,7 @@ static void initshadowbuf(Render *re, LampRen *lar, float mat[][4])
static void area_lamp_vectors(LampRen *lar)
{
- float xsize= 0.5*lar->area_size, ysize= 0.5*lar->area_sizey, multifac;
+ 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);
@@ -3637,7 +3637,7 @@ static void area_lamp_vectors(LampRen *lar)
lar->area[3][1]= lar->co[1] + xsize*lar->mat[0][1] - ysize*lar->mat[1][1];
lar->area[3][2]= lar->co[2] + xsize*lar->mat[0][2] - ysize*lar->mat[1][2];
/* only for correction button size, matrix size works on energy */
- lar->areasize= lar->dist*lar->dist/(4.0*xsize*ysize);
+ lar->areasize= lar->dist*lar->dist/(4.0f*xsize*ysize);
}
/* If lar takes more lamp data, the decoupling will be better. */
@@ -3791,10 +3791,10 @@ static GroupObject *add_render_lamp(Render *re, Object *ob)
lar->spotsi= la->spotsize;
if(lar->mode & LA_HALO) {
- if(lar->spotsi>170.0) lar->spotsi= 170.0;
+ if(lar->spotsi>170.0f) lar->spotsi= 170.0f;
}
- lar->spotsi= cos( M_PI*lar->spotsi/360.0 );
- lar->spotbl= (1.0-lar->spotsi)*la->spotblend;
+ lar->spotsi= cos( M_PI*lar->spotsi/360.0f );
+ lar->spotbl= (1.0f-lar->spotsi)*la->spotblend;
memcpy(lar->mtex, la->mtex, MAX_MTEX*sizeof(void *));
@@ -3813,7 +3813,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob)
xn= saacos(lar->spotsi);
xn= sin(xn)/cos(xn);
- lar->spottexfac= 1.0/(xn);
+ lar->spottexfac= 1.0f/(xn);
if(lar->mode & LA_ONLYSHADOW) {
if((lar->mode & (LA_SHAD_BUF|LA_SHAD_RAY))==0) lar->mode -= LA_ONLYSHADOW;
@@ -3823,7 +3823,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob)
/* set flag for spothalo en initvars */
if(la->type==LA_SPOT && (la->mode & LA_HALO) && (la->buftype != LA_SHADBUF_DEEP)) {
- if(la->haint>0.0) {
+ if(la->haint>0.0f) {
re->flag |= R_LAMPHALO;
/* camera position (0,0,0) rotate around lamp */
@@ -3990,9 +3990,9 @@ void init_render_world(Render *re)
cp= (char *)&re->wrld.fastcol;
- cp[0]= 255.0*re->wrld.horr;
- cp[1]= 255.0*re->wrld.horg;
- cp[2]= 255.0*re->wrld.horb;
+ cp[0]= 255.0f*re->wrld.horr;
+ cp[1]= 255.0f*re->wrld.horg;
+ cp[2]= 255.0f*re->wrld.horb;
cp[3]= 1;
VECCOPY(re->grvec, re->viewmat[2]);
@@ -4047,25 +4047,25 @@ static void set_phong_threshold(ObjectRen *obr)
if(vlr->flag & R_SMOOTH) {
dot= INPR(vlr->n, vlr->v1->n);
dot= ABS(dot);
- if(dot>0.9) {
+ if(dot>0.9f) {
thresh+= dot; tot++;
}
dot= INPR(vlr->n, vlr->v2->n);
dot= ABS(dot);
- if(dot>0.9) {
+ if(dot>0.9f) {
thresh+= dot; tot++;
}
dot= INPR(vlr->n, vlr->v3->n);
dot= ABS(dot);
- if(dot>0.9) {
+ if(dot>0.9f) {
thresh+= dot; tot++;
}
if(vlr->v4) {
dot= INPR(vlr->n, vlr->v4->n);
dot= ABS(dot);
- if(dot>0.9) {
+ if(dot>0.9f) {
thresh+= dot; tot++;
}
}
@@ -4105,7 +4105,7 @@ static void set_fullsample_trace_flag(Render *re, ObjectRen *obr)
else if((mode & MA_RAYMIRROR) || ((mode & MA_TRANSP) && (mode & MA_RAYTRANSP))) {
/* for blurry reflect/refract, better to take more samples
* inside the raytrace than as OSA samples */
- if ((vlr->mat->gloss_mir == 1.0) && (vlr->mat->gloss_tra == 1.0))
+ if ((vlr->mat->gloss_mir == 1.0f) && (vlr->mat->gloss_tra == 1.0f))
vlr->flag |= R_FULL_OSA;
}
}
@@ -4221,11 +4221,11 @@ static void check_non_flat_quads(ObjectRen *obr)
/* render normals are inverted in render! we calculate normal of single tria here */
flen= normal_tri_v3( nor,vlr->v4->co, vlr->v3->co, vlr->v1->co);
- if(flen==0.0) normal_tri_v3( nor,vlr->v4->co, vlr->v2->co, vlr->v1->co);
+ if(flen==0.0f) normal_tri_v3( nor,vlr->v4->co, vlr->v2->co, vlr->v1->co);
xn= nor[0]*vlr->n[0] + nor[1]*vlr->n[1] + nor[2]*vlr->n[2];
- if(ABS(xn) < 0.999995 ) { // checked on noisy fractal grid
+ if(ABS(xn) < 0.999995f ) { // checked on noisy fractal grid
float d1, d2;
@@ -5461,7 +5461,7 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float *
for(j=0;j<3;j++) fsvec[j] = velarray[a].vel[j];
/* (bad) HACK insert average velocity if none is there (see previous comment) */
- if((fsvec[0] == 0.0) && (fsvec[1] == 0.0) && (fsvec[2] == 0.0))
+ if((fsvec[0] == 0.0f) && (fsvec[1] == 0.0f) && (fsvec[2] == 0.0f))
{
fsvec[0] = avgvel[0];
fsvec[1] = avgvel[1];
diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c
index e2ab21ef877..66a73b47790 100644
--- a/source/blender/render/intern/source/envmap.c
+++ b/source/blender/render/intern/source/envmap.c
@@ -595,7 +595,7 @@ static int envcube_isect(EnvMap *env, float *vec, float *answ)
if(env->type==ENV_PLANE) {
face= 1;
- labda= 1.0/vec[2];
+ labda= 1.0f/vec[2];
answ[0]= env->viewscale*labda*vec[0];
answ[1]= -env->viewscale*labda*vec[1];
}
@@ -603,44 +603,44 @@ static int envcube_isect(EnvMap *env, float *vec, float *answ)
/* which face */
if( vec[2]<=-fabs(vec[0]) && vec[2]<=-fabs(vec[1]) ) {
face= 0;
- labda= -1.0/vec[2];
+ 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]) ) {
face= 1;
- labda= 1.0/vec[2];
+ labda= 1.0f/vec[2];
answ[0]= labda*vec[0];
answ[1]= -labda*vec[1];
}
else if( vec[1]>=fabs(vec[0]) ) {
face= 2;
- labda= 1.0/vec[1];
+ labda= 1.0f/vec[1];
answ[0]= labda*vec[0];
answ[1]= labda*vec[2];
}
else if( vec[0]<=-fabs(vec[1]) ) {
face= 3;
- labda= -1.0/vec[0];
+ labda= -1.0f/vec[0];
answ[0]= labda*vec[1];
answ[1]= labda*vec[2];
}
else if( vec[1]<=-fabs(vec[0]) ) {
face= 4;
- labda= -1.0/vec[1];
+ labda= -1.0f/vec[1];
answ[0]= -labda*vec[0];
answ[1]= labda*vec[2];
}
else {
face= 5;
- labda= 1.0/vec[0];
+ labda= 1.0f/vec[0];
answ[0]= -labda*vec[1];
answ[1]= labda*vec[2];
}
}
- answ[0]= 0.5+0.5*answ[0];
- answ[1]= 0.5+0.5*answ[1];
+ answ[0]= 0.5f+0.5f*answ[0];
+ answ[1]= 0.5f+0.5f*answ[1];
return face;
}
@@ -725,7 +725,7 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe
/* edges? */
- if(texres->ta<1.0) {
+ if(texres->ta<1.0f) {
TexResult texr1, texr2;
texr1.nor= texr2.nor= NULL;
@@ -756,8 +756,8 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe
else texr2.tr= texr2.tg= texr2.tb= texr2.ta= 0.0;
fac= (texres->ta+texr1.ta+texr2.ta);
- if(fac!=0.0) {
- fac= 1.0/fac;
+ if(fac!=0.0f) {
+ fac= 1.0f/fac;
texres->tr= fac*(texres->ta*texres->tr + texr1.ta*texr1.tr + texr2.ta*texr2.tr );
texres->tg= fac*(texres->ta*texres->tg + texr1.ta*texr1.tg + texr2.ta*texr2.tg );
diff --git a/source/blender/render/intern/source/gammaCorrectionTables.c b/source/blender/render/intern/source/gammaCorrectionTables.c
index 4a16341093c..f88a5d240c3 100644
--- a/source/blender/render/intern/source/gammaCorrectionTables.c
+++ b/source/blender/render/intern/source/gammaCorrectionTables.c
@@ -107,7 +107,7 @@ void makeGammaTables(float gamma)
int i;
valid_gamma = gamma;
- valid_inv_gamma = 1.0 / gamma;
+ valid_inv_gamma = 1.0f / gamma;
color_step = 1.0 / RE_GAMMA_TABLE_SIZE;
inv_color_step = (float) RE_GAMMA_TABLE_SIZE;
diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c
index 2f09742f130..bea86264af1 100644
--- a/source/blender/render/intern/source/initrender.c
+++ b/source/blender/render/intern/source/initrender.c
@@ -126,8 +126,8 @@ static float filt_cubic(float x)
if (x < 0.0f) x = -x;
- if (x < 1.0f) return 0.5*x*x2 - x2 + 2.0f/3.0f;
- if (x < 2.0f) return (2.0-x)*(2.0-x)*(2.0-x)/6.0f;
+ if (x < 1.0f) return 0.5f*x*x2 - x2 + 2.0f/3.0f;
+ if (x < 2.0f) return (2.0f-x)*(2.0f-x)*(2.0f-x)/6.0f;
return 0.0f;
}
@@ -138,27 +138,27 @@ static float filt_catrom(float x)
if (x < 0.0f) x = -x;
if (x < 1.0f) return 1.5f*x2*x - 2.5f*x2 + 1.0f;
- if (x < 2.0f) return -0.5f*x2*x + 2.5*x2 - 4.0f*x + 2.0f;
+ if (x < 2.0f) return -0.5f*x2*x + 2.5f*x2 - 4.0f*x + 2.0f;
return 0.0f;
}
static float filt_mitchell(float x) /* Mitchell & Netravali's two-param cubic */
{
float b = 1.0f/3.0f, c = 1.0f/3.0f;
- float p0 = ( 6.0 - 2.0*b ) / 6.0;
- float p2 = (-18.0 + 12.0*b + 6.0*c) / 6.0;
- float p3 = ( 12.0 - 9.0*b - 6.0*c) / 6.0;
- float q0 = ( 8.0*b + 24.0*c) / 6.0;
- float q1 = ( - 12.0*b - 48.0*c) / 6.0;
- float q2 = ( 6.0*b + 30.0*c) / 6.0;
- float q3 = ( - b - 6.0*c) / 6.0;
-
- if (x<-2.0) return 0.0;
- if (x<-1.0) return (q0-x*(q1-x*(q2-x*q3)));
- if (x< 0.0) return (p0+x*x*(p2-x*p3));
- if (x< 1.0) return (p0+x*x*(p2+x*p3));
- if (x< 2.0) return (q0+x*(q1+x*(q2+x*q3)));
- return 0.0;
+ float p0 = ( 6.0f - 2.0f*b ) / 6.0f;
+ float p2 = (-18.0f + 12.0f*b + 6.0f*c) / 6.0f;
+ float p3 = ( 12.0f - 9.0f*b - 6.0f*c) / 6.0f;
+ float q0 = ( 8.0f*b + 24.0f*c) / 6.0f;
+ float q1 = ( - 12.0f *b - 48.0f*c) / 6.0f;
+ float q2 = ( 6.0f *b + 30.0f*c) / 6.0f;
+ float q3 = ( - b - 6.0f*c) / 6.0f;
+
+ if (x<-2.0f) return 0.0f;
+ if (x<-1.0f) return (q0-x*(q1-x*(q2-x*q3)));
+ if (x< 0.0f) return (p0+x*x*(p2-x*p3));
+ if (x< 1.0f) return (p0+x*x*(p2+x*p3));
+ if (x< 2.0f) return (q0+x*(q1+x*(q2+x*q3)));
+ return 0.0f;
}
/* x ranges from -1 to 1 */
@@ -170,16 +170,16 @@ float RE_filter_value(int type, float x)
switch(type) {
case R_FILTER_BOX:
- if(x>1.0) return 0.0f;
- return 1.0;
+ if(x>1.0f) return 0.0f;
+ return 1.0f;
case R_FILTER_TENT:
- if(x>1.0) return 0.0f;
+ if(x>1.0f) return 0.0f;
return 1.0f-x;
case R_FILTER_GAUSS:
x*= gaussfac;
- return (1.0/exp(x*x) - 1.0/exp(gaussfac*gaussfac*2.25));
+ return (1.0f/expf(x*x) - 1.0f/expf(gaussfac*gaussfac*2.25f));
case R_FILTER_MITCH:
return filt_mitchell(x*gaussfac);
@@ -221,7 +221,7 @@ static float calc_weight(Render *re, float *weight, int i, int j)
case R_FILTER_GAUSS:
x = dist*re->r.gauss;
- weight[a]= (1.0/exp(x*x) - 1.0/exp(re->r.gauss*re->r.gauss*2.25));
+ weight[a]= (1.0f/expf(x*x) - 1.0f/expf(re->r.gauss*re->r.gauss*2.25f));
break;
case R_FILTER_MITCH:
@@ -309,7 +309,7 @@ void make_sample_tables(Render *re)
st->centmask= MEM_mallocN((1<<re->osa), "Initfilt3");
for(a=0; a<16; a++) {
- st->centLut[a]= -0.45+((float)a)/16.0;
+ st->centLut[a]= -0.45f+((float)a)/16.0f;
}
/* calculate totw */
@@ -327,7 +327,7 @@ void make_sample_tables(Render *re)
memset(weight, 0, sizeof(weight));
calc_weight(re, weight, i, j);
- for(a=0; a<16; a++) flweight[a]= weight[a]*(1.0/totw);
+ for(a=0; a<16; a++) flweight[a]= weight[a]*(1.0f/totw);
m3= st->fmask1[ 3*(j+1)+i+1 ];
m4= st->fmask2[ 3*(j+1)+i+1 ];
@@ -430,9 +430,9 @@ void make_sample_tables(Render *re)
for(a= (1<<re->osa)-1; a>0; a--) {
val= st->cmask[a & 255] + st->cmask[a>>8];
- i= 8+(15.9*(fpy1[a & 255]+fpy2[a>>8])/val);
+ i= 8+(15.9f*(fpy1[a & 255]+fpy2[a>>8])/val);
CLAMP(i, 0, 15);
- j= 8+(15.9*(fpx1[a & 255]+fpx2[a>>8])/val);
+ j= 8+(15.9f*(fpx1[a & 255]+fpx2[a>>8])/val);
CLAMP(j, 0, 15);
i= j + (i<<4);
st->centmask[a]= i;
diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c
index 0aa65479a4f..54137c62d22 100644
--- a/source/blender/render/intern/source/occlusion.c
+++ b/source/blender/render/intern/source/occlusion.c
@@ -1414,7 +1414,7 @@ static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, f
if(env) {
/* sky shading using bent normal */
if(ELEM(envcolor, WO_AOSKYCOL, WO_AOSKYTEX)) {
- fac= 0.5*(1.0f+bn[0]*re->grvec[0]+ bn[1]*re->grvec[1]+ bn[2]*re->grvec[2]);
+ fac= 0.5f*(1.0f+bn[0]*re->grvec[0]+ bn[1]*re->grvec[1]+ bn[2]*re->grvec[2]);
env[0]= (1.0f-fac)*re->wrld.horr + fac*re->wrld.zenr;
env[1]= (1.0f-fac)*re->wrld.horg + fac*re->wrld.zeng;
env[2]= (1.0f-fac)*re->wrld.horb + fac*re->wrld.zenb;
diff --git a/source/blender/render/intern/source/pixelblending.c b/source/blender/render/intern/source/pixelblending.c
index c2e34e2a70d..d945436be6b 100644
--- a/source/blender/render/intern/source/pixelblending.c
+++ b/source/blender/render/intern/source/pixelblending.c
@@ -68,11 +68,11 @@ extern struct Render R;
/* Threshold for a 'full' pixel: pixels with alpha above this level are */
/* considered opaque This is the decimal value for 0xFFF0 / 0xFFFF */
-#define RE_FULL_COLOR_FLOAT 0.9998
+#define RE_FULL_COLOR_FLOAT 0.9998f
/* Threshold for an 'empty' pixel: pixels with alpha above this level are */
/* considered completely transparent. This is the decimal value */
/* for 0x000F / 0xFFFF */
-#define RE_EMPTY_COLOR_FLOAT 0.0002
+#define RE_EMPTY_COLOR_FLOAT 0.0002f
/* ------------------------------------------------------------------------- */
@@ -82,7 +82,7 @@ void addAlphaOverFloat(float *dest, float *source)
/* d = s + (1-alpha_s)d*/
float mul;
- mul= 1.0 - source[3];
+ mul= 1.0f - source[3];
dest[0]= (mul*dest[0]) + source[0];
dest[1]= (mul*dest[1]) + source[1];
@@ -98,7 +98,7 @@ void addAlphaUnderFloat(float *dest, float *source)
{
float mul;
- mul= 1.0 - dest[3];
+ mul= 1.0f - dest[3];
dest[0]+= (mul*source[0]);
dest[1]+= (mul*source[1]);
@@ -115,7 +115,7 @@ void addalphaAddfacFloat(float *dest, float *source, char addfac)
/* Addfac is a number between 0 and 1: rescale */
/* final target is to diminish the influence of dest when addfac rises */
- m = 1.0 - ( source[3] * ((255.0 - addfac) / 255.0));
+ m = 1.0f - ( source[3] * ((255 - addfac) / 255.0f));
/* blend colors*/
c= (m * dest[0]) + source[0];
@@ -178,7 +178,7 @@ void add_filt_fmask(unsigned int mask, float *col, float *rowbuf, int row_w)
a= j;
val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift);
- if(val!=0.0) {
+ if(val!=0.0f) {
rb1[0]+= val*r;
rb1[1]+= val*g;
rb1[2]+= val*b;
@@ -187,7 +187,7 @@ void add_filt_fmask(unsigned int mask, float *col, float *rowbuf, int row_w)
a+=3;
val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift);
- if(val!=0.0) {
+ if(val!=0.0f) {
rb2[0]+= val*r;
rb2[1]+= val*g;
rb2[2]+= val*b;
@@ -196,7 +196,7 @@ void add_filt_fmask(unsigned int mask, float *col, float *rowbuf, int row_w)
a+=3;
val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift);
- if(val!=0.0) {
+ if(val!=0.0f) {
rb3[0]+= val*r;
rb3[1]+= val*g;
rb3[2]+= val*b;
@@ -345,21 +345,21 @@ void add_filt_fmask_pixsize(unsigned int mask, float *in, float *rowbuf, int row
a= j;
val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift);
- if(val!=0.0) {
+ if(val!=0.0f) {
for(i= 0; i<pixsize; i++)
rb1[i]+= val*in[i];
}
a+=3;
val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift);
- if(val!=0.0) {
+ if(val!=0.0f) {
for(i= 0; i<pixsize; i++)
rb2[i]+= val*in[i];
}
a+=3;
val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift);
- if(val!=0.0) {
+ if(val!=0.0f) {
for(i= 0; i<pixsize; i++)
rb3[i]+= val*in[i];
}
@@ -396,5 +396,3 @@ void addalphaAddFloat(float *dest, float *source)
/* eof pixelblending.c */
-
-
diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c
index 56a1c870904..febfea89f04 100644
--- a/source/blender/render/intern/source/pixelshading.c
+++ b/source/blender/render/intern/source/pixelshading.c
@@ -86,7 +86,7 @@ static void render_lighting_halo(HaloRen *har, float *colf)
ir= ig= ib= 0.0;
VECCOPY(rco, har->co);
- dco[0]=dco[1]=dco[2]= 1.0/har->rad;
+ dco[0]=dco[1]=dco[2]= 1.0f/har->rad;
vn= har->no;
@@ -114,9 +114,9 @@ static void render_lighting_halo(HaloRen *har, float *colf)
if(lar->mode & LA_QUAD) {
t= 1.0;
- if(lar->ld1>0.0)
+ if(lar->ld1>0.0f)
t= lar->dist/(lar->dist+lar->ld1*ld);
- if(lar->ld2>0.0)
+ if(lar->ld2>0.0f)
t*= lar->distkw/(lar->distkw+lar->ld2*ld*ld);
lampdist= t;
@@ -127,7 +127,7 @@ static void render_lighting_halo(HaloRen *har, float *colf)
if(lar->mode & LA_SPHERE) {
t= lar->dist - ld;
- if(t<0.0) continue;
+ if(t<0.0f) continue;
t/= lar->dist;
lampdist*= (t);
@@ -155,7 +155,7 @@ static void render_lighting_halo(HaloRen *har, float *colf)
if(lar->type==LA_SPOT) {
if(lar->mode & LA_SQUARE) {
- if(lv[0]*lar->vec[0]+lv[1]*lar->vec[1]+lv[2]*lar->vec[2]>0.0) {
+ if(lv[0]*lar->vec[0]+lv[1]*lar->vec[1]+lv[2]*lar->vec[2]>0.0f) {
float x, lvrot[3];
/* rotate view to lampspace */
@@ -165,7 +165,7 @@ static void render_lighting_halo(HaloRen *har, float *colf)
x= MAX2(fabs(lvrot[0]/lvrot[2]) , fabs(lvrot[1]/lvrot[2]));
/* 1.0/(sqrt(1+x*x)) is equivalent to cos(atan(x)) */
- inpr= 1.0/(sqrt(1.0+x*x));
+ inpr= 1.0/(sqrt(1.0f+x*x));
}
else inpr= 0.0;
}
@@ -179,21 +179,21 @@ static void render_lighting_halo(HaloRen *har, float *colf)
t= inpr-t;
i= 1.0;
soft= 1.0;
- if(t<lar->spotbl && lar->spotbl!=0.0) {
+ if(t<lar->spotbl && lar->spotbl!=0.0f) {
/* soft area */
i= t/lar->spotbl;
t= i*i;
- soft= (3.0*t-2.0*t*i);
+ soft= (3.0f*t-2.0f*t*i);
inpr*= soft;
}
if(lar->mode & LA_ONLYSHADOW) {
/* if(ma->mode & MA_SHADOW) { */
/* dot product positive: front side face! */
inp= vn[0]*lv[0] + vn[1]*lv[1] + vn[2]*lv[2];
- if(inp>0.0) {
+ if(inp>0.0f) {
/* testshadowbuf==0.0 : 100% shadow */
shadfac = testshadowbuf(&R, lar->shb, rco, dco, dco, inp, 0.0f);
- if( shadfac>0.0 ) {
+ if( shadfac>0.0f ) {
shadfac*= inp*soft*lar->energy;
ir -= shadfac;
ig -= shadfac;
@@ -219,32 +219,32 @@ static void render_lighting_halo(HaloRen *har, float *colf)
i= inp;
if(lar->type==LA_HEMI) {
- i= 0.5*i+0.5;
+ i= 0.5f*i+0.5f;
}
- if(i>0.0) {
+ if(i>0.0f) {
i*= lampdist;
}
/* shadow */
- if(i> -0.41) { /* heuristic valua! */
+ if(i> -0.41f) { /* heuristic valua! */
shadfac= 1.0;
if(lar->shb) {
shadfac = testshadowbuf(&R, lar->shb, rco, dco, dco, inp, 0.0f);
- if(shadfac==0.0) continue;
+ if(shadfac==0.0f) continue;
i*= shadfac;
}
}
- if(i>0.0) {
+ if(i>0.0f) {
ir+= i*lacol[0];
ig+= i*lacol[1];
ib+= i*lacol[2];
}
}
- if(ir<0.0) ir= 0.0;
- if(ig<0.0) ig= 0.0;
- if(ib<0.0) ib= 0.0;
+ if(ir<0.0f) ir= 0.0f;
+ if(ig<0.0f) ig= 0.0f;
+ if(ib<0.0f) ib= 0.0f;
colf[0]*= ir;
colf[1]*= ig;
@@ -301,7 +301,7 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz,
}
else alpha= har->alfa;
- if(alpha==0.0)
+ if(alpha==0.0f)
return 0;
/* soften the halo if it intersects geometry */
@@ -355,15 +355,15 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz,
fac= fabs( rc[1]*(har->rad*fabs(rc[0]) - radist) );
- if(fac< 1.0) {
- ringf+= (1.0-fac);
+ if(fac< 1.0f) {
+ ringf+= (1.0f-fac);
}
}
}
if(har->type & HA_VECT) {
dist= fabs( har->cos*(yn) - har->sin*(xn) )/har->rad;
- if(dist>1.0) dist= 1.0;
+ if(dist>1.0f) dist= 1.0f;
if(har->tex) {
zn= har->sin*xn - har->cos*yn;
yn= har->cos*xn + har->sin*yn;
@@ -374,7 +374,7 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz,
if(har->type & HA_FLARECIRC) {
- dist= 0.5+fabs(dist-0.5);
+ dist= 0.5+fabs(dist-0.5f);
}
@@ -418,7 +418,7 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz,
float ster, angle;
/* rotation */
angle= atan2(yn, xn);
- angle*= (1.0+0.25*har->starpoints);
+ angle*= (1.0f+0.25f*har->starpoints);
co= cos(angle);
si= sin(angle);
@@ -426,15 +426,15 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz,
angle= (co*xn+si*yn)*(co*yn-si*xn);
ster= fabs(angle);
- if(ster>1.0) {
+ if(ster>1.0f) {
ster= (har->rad)/(ster);
- if(ster<1.0) dist*= sqrt(ster);
+ if(ster<1.0f) dist*= sqrt(ster);
}
}
/* disputable optimize... (ton) */
- if(dist<=0.00001)
+ if(dist<=0.00001f)
return 0;
dist*= alpha;
@@ -471,7 +471,7 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz,
}
/* Next, we do the line and ring factor modifications. */
- if(linef!=0.0) {
+ if(linef!=0.0f) {
Material *ma= har->mat;
col[0]+= linef * ma->specr;
@@ -481,7 +481,7 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz,
if(har->type & HA_XALPHA) col[3]+= linef*linef;
else col[3]+= linef;
}
- if(ringf!=0.0) {
+ if(ringf!=0.0f) {
Material *ma= har->mat;
col[0]+= ringf * ma->mirr;
@@ -516,16 +516,16 @@ void shadeSkyView(float *colf, float *rco, float *view, float *dxyview, short th
blend= view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2];
- if(blend<0.0) skyflag= 0;
+ if(blend<0.0f) skyflag= 0;
blend= fabs(blend);
}
else if(R.wrld.skytype & WO_SKYPAPER) {
- blend= 0.5+ 0.5*view[1];
+ blend= 0.5f + 0.5f * view[1];
}
else {
/* the fraction of how far we are above the bottom of the screen */
- blend= fabs(0.5+ view[1]);
+ blend= fabs(0.5f + view[1]);
}
VECCOPY(hor, &R.wrld.horr);
@@ -545,8 +545,8 @@ void shadeSkyView(float *colf, float *rco, float *view, float *dxyview, short th
do_sky_tex(rco, lo, dxyview, hor, zen, &blend, skyflag, thread);
}
- if(blend>1.0) blend= 1.0;
- blendm= 1.0-blend;
+ if(blend>1.0f) blend= 1.0f;
+ blendm= 1.0f-blend;
/* No clipping, no conversion! */
if(R.wrld.skytype & WO_SKYBLEND) {
@@ -580,8 +580,8 @@ void shadeSunView(float *colf, float *view)
VECCOPY(sview, view);
normalize_v3(sview);
mul_m3_v3(R.imat, sview);
- if (sview[2] < 0.0)
- sview[2] = 0.0;
+ if (sview[2] < 0.0f)
+ sview[2] = 0.0f;
normalize_v3(sview);
do_init= 0;
}
diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c
index d62f411a7c5..e82e969d502 100644
--- a/source/blender/render/intern/source/rayshade.c
+++ b/source/blender/render/intern/source/rayshade.c
@@ -611,12 +611,12 @@ static int refraction(float *refract, float *n, float *view, float index)
index = 1.0f/index;
fac= 1.0f - (1.0f - dot*dot)*index*index;
if(fac<= 0.0f) return 0;
- fac= -dot*index + sqrt(fac);
+ fac= -dot*index + sqrtf(fac);
}
else {
fac= 1.0f - (1.0f - dot*dot)*index*index;
if(fac<= 0.0f) return 0;
- fac= -dot*index - sqrt(fac);
+ fac= -dot*index - sqrtf(fac);
}
refract[0]= index*view[0] + fac*n[0];
@@ -693,7 +693,7 @@ static float shade_by_transmission(Isect *is, ShadeInput *shi, ShadeResult *shr)
if(p < 0.0f) p= 0.0f;
else if (p > 10.0f) p= 10.0f;
- shr->alpha *= pow(d, p);
+ shr->alpha *= powf(d, p);
if (shr->alpha > 1.0f)
shr->alpha= 1.0f;
}
@@ -720,11 +720,11 @@ static void ray_fadeout(Isect *is, ShadeInput *shi, float *col, float *blendcol,
/* if fading out, linear blend against fade color */
float blendfac;
- blendfac = 1.0 - len_v3v3(shi->co, is->start)/dist_mir;
+ blendfac = 1.0f - len_v3v3(shi->co, is->start)/dist_mir;
- col[0] = col[0]*blendfac + (1.0 - blendfac)*blendcol[0];
- col[1] = col[1]*blendfac + (1.0 - blendfac)*blendcol[1];
- col[2] = col[2]*blendfac + (1.0 - blendfac)*blendcol[2];
+ col[0] = col[0]*blendfac + (1.0f - blendfac)*blendcol[0];
+ col[1] = col[1]*blendfac + (1.0f - blendfac)*blendcol[1];
+ col[2] = col[2]*blendfac + (1.0f - blendfac)*blendcol[2];
}
/* the main recursive tracer itself
@@ -870,7 +870,7 @@ static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, flo
col[2]= shr.diff[2] + shr.spec[2];
}
- if (dist_mir > 0.0) {
+ if (dist_mir > 0.0f) {
float blendcol[3];
/* max ray distance set, but found an intersection, so fade this color
@@ -922,11 +922,11 @@ static void DP_energy(float *table, float *vec, int tot, float xsize, float ysiz
}
}
}
- vec[0] += 0.1*min*result[0]/(float)tot;
- vec[1] += 0.1*min*result[1]/(float)tot;
+ vec[0] += 0.1f*min*result[0]/(float)tot;
+ vec[1] += 0.1f*min*result[1]/(float)tot;
// cyclic clamping
- vec[0]= vec[0] - xsize*floor(vec[0]/xsize + 0.5);
- vec[1]= vec[1] - ysize*floor(vec[1]/ysize + 0.5);
+ vec[0]= vec[0] - xsize*floorf(vec[0]/xsize + 0.5f);
+ vec[1]= vec[1] - ysize*floorf(vec[1]/ysize + 0.5f);
}
// random offset of 1 in 2
@@ -934,7 +934,7 @@ static void jitter_plane_offset(float *jitter1, float *jitter2, int tot, float s
{
float dsizex= sizex*ofsx;
float dsizey= sizey*ofsy;
- float hsizex= 0.5*sizex, hsizey= 0.5*sizey;
+ float hsizex= 0.5f*sizex, hsizey= 0.5f*sizey;
int x;
for(x=tot; x>0; x--, jitter1+=2, jitter2+=2) {
@@ -968,8 +968,8 @@ void init_jitter_plane(LampRen *lar)
/* fill table with random locations, area_size large */
for(x=0; x<tot; x++, fp+=2) {
- fp[0]= (BLI_frand()-0.5)*lar->area_size;
- fp[1]= (BLI_frand()-0.5)*lar->area_sizey;
+ fp[0]= (BLI_frand()-0.5f)*lar->area_size;
+ fp[1]= (BLI_frand()-0.5f)*lar->area_sizey;
}
while(iter--) {
@@ -1081,8 +1081,8 @@ static void QMC_initPixel(QMCSampler *qsa, int thread)
{
/* hammersley sequence is fixed, already created in QMCSampler init.
* per pixel, gets a random offset. We create separate offsets per thread, for write-safety */
- qsa->offs[thread][0] = 0.5 * BLI_thread_frand(thread);
- qsa->offs[thread][1] = 0.5 * BLI_thread_frand(thread);
+ qsa->offs[thread][0] = 0.5f * BLI_thread_frand(thread);
+ qsa->offs[thread][1] = 0.5f * BLI_thread_frand(thread);
}
else { /* SAMP_TYPE_HALTON */
@@ -1136,8 +1136,8 @@ static void QMC_samplePhong(float *vec, QMCSampler *qsa, int thread, int num, fl
pz = pow(s[1], blur);
sqr = sqrt(1.0f-pz*pz);
- vec[0] = cos(phi)*sqr;
- vec[1] = sin(phi)*sqr;
+ vec[0] = (float)(cosf(phi)*sqr);
+ vec[1] = (float)(sinf(phi)*sqr);
vec[2] = 0.0f;
}
@@ -1148,8 +1148,8 @@ static void QMC_sampleRect(float *vec, QMCSampler *qsa, int thread, int num, flo
QMC_getSample(s, qsa, thread, num);
- vec[0] = (s[0] - 0.5) * sizex;
- vec[1] = (s[1] - 0.5) * sizey;
+ vec[0] = (float)(s[0] - 0.5) * sizex;
+ vec[1] = (float)(s[1] - 0.5) * sizey;
vec[2] = 0.0f;
}
@@ -1164,8 +1164,8 @@ static void QMC_sampleDisc(float *vec, QMCSampler *qsa, int thread, int num, flo
phi = s[0]*2*M_PI;
sqr = sqrt(s[1]);
- vec[0] = cos(phi)*sqr* radius/2.0;
- vec[1] = sin(phi)*sqr* radius/2.0;
+ vec[0] = cosf(phi)*sqr* radius/2.0f;
+ vec[1] = sinf(phi)*sqr* radius/2.0f;
vec[2] = 0.0f;
}
@@ -1177,12 +1177,12 @@ static void QMC_sampleHemi(float *vec, QMCSampler *qsa, int thread, int num)
QMC_getSample(s, qsa, thread, num);
- phi = s[0]*2.f*M_PI;
+ phi = s[0]*2.0*M_PI;
sqr = sqrt(s[1]);
- vec[0] = cos(phi)*sqr;
- vec[1] = sin(phi)*sqr;
- vec[2] = 1.f - s[1]*s[1];
+ vec[0] = cosf(phi)*sqr;
+ vec[1] = sinf(phi)*sqr;
+ vec[2] = (float)(1.0 - s[1]*s[1]);
}
#if 0 /* currently not used */
@@ -1272,7 +1272,7 @@ static int adaptive_sample_variance(int samples, float *col, float *colsq, float
var[1] = (colsq[1] / (float)samples) - (mean[1]*mean[1]);
var[2] = (colsq[2] / (float)samples) - (mean[2]*mean[2]);
- if ((var[0] * 0.4 < thresh) && (var[1] * 0.3 < thresh) && (var[2] * 0.6 < thresh))
+ if ((var[0] * 0.4f < thresh) && (var[1] * 0.3f < thresh) && (var[2] * 0.6f < thresh))
return 1;
else
return 0;
@@ -1283,7 +1283,7 @@ static int adaptive_sample_contrast_val(int samples, float prev, float val, floa
/* if the last sample's contribution to the total value was below a small threshold
* (i.e. the samples taken are very similar), then taking more samples that are probably
* going to be the same is wasting effort */
- if (fabs( prev/(float)(samples-1) - val/(float)samples ) < thresh) {
+ if (fabsf( prev/(float)(samples-1) - val/(float)samples ) < thresh) {
return 1;
} else
return 0;
@@ -1293,10 +1293,10 @@ static float get_avg_speed(ShadeInput *shi)
{
float pre_x, pre_y, post_x, post_y, speedavg;
- pre_x = (shi->winspeed[0] == PASS_VECTOR_MAX)?0.0:shi->winspeed[0];
- pre_y = (shi->winspeed[1] == PASS_VECTOR_MAX)?0.0:shi->winspeed[1];
- post_x = (shi->winspeed[2] == PASS_VECTOR_MAX)?0.0:shi->winspeed[2];
- post_y = (shi->winspeed[3] == PASS_VECTOR_MAX)?0.0:shi->winspeed[3];
+ pre_x = (shi->winspeed[0] == PASS_VECTOR_MAX)?0.0f:shi->winspeed[0];
+ pre_y = (shi->winspeed[1] == PASS_VECTOR_MAX)?0.0f:shi->winspeed[1];
+ post_x = (shi->winspeed[2] == PASS_VECTOR_MAX)?0.0f:shi->winspeed[2];
+ post_y = (shi->winspeed[3] == PASS_VECTOR_MAX)?0.0f:shi->winspeed[3];
speedavg = (sqrt(pre_x*pre_x + pre_y*pre_y) + sqrt(post_x*post_x + post_y*post_y)) / 2.0;
@@ -1316,7 +1316,7 @@ static void trace_refract(float *col, ShadeInput *shi, ShadeResult *shr)
float v_refract[3], v_refract_new[3];
float sampcol[4], colsq[4];
- float blur = pow(1.0 - shi->mat->gloss_tra, 3);
+ float blur = powf(1.0f - shi->mat->gloss_tra, 3);
short max_samples = shi->mat->samp_gloss_tra;
float adapt_thresh = shi->mat->adapt_thresh_tra;
@@ -1325,9 +1325,9 @@ static void trace_refract(float *col, ShadeInput *shi, ShadeResult *shr)
colsq[0] = colsq[1] = colsq[2] = 0.0;
col[0] = col[1] = col[2] = 0.0;
col[3]= shr->alpha;
-
- if (blur > 0.0) {
- if (adapt_thresh != 0.0) samp_type = SAMP_TYPE_HALTON;
+
+ if (blur > 0.0f) {
+ if (adapt_thresh != 0.0f) samp_type = SAMP_TYPE_HALTON;
else samp_type = SAMP_TYPE_HAMMERSLEY;
/* all samples are generated per pixel */
@@ -1386,13 +1386,13 @@ static void trace_refract(float *col, ShadeInput *shi, ShadeResult *shr)
samples++;
/* adaptive sampling */
- if (adapt_thresh < 1.0 && samples > max_samples/2)
+ if (adapt_thresh < 1.0f && samples > max_samples/2)
{
if (adaptive_sample_variance(samples, col, colsq, adapt_thresh))
break;
/* if the pixel so far is very dark, we can get away with less samples */
- if ( (col[0] + col[1] + col[2])/3.0/(float)samples < 0.01 )
+ if ( (col[0] + col[1] + col[2])/3.0f/(float)samples < 0.01f )
max_samples--;
}
}
@@ -1415,18 +1415,18 @@ static void trace_reflect(float *col, ShadeInput *shi, ShadeResult *shr, float f
float v_nor_new[3], v_reflect[3];
float sampcol[4], colsq[4];
- float blur = pow(1.0 - shi->mat->gloss_mir, 3);
+ float blur = powf(1.0f - shi->mat->gloss_mir, 3);
short max_samples = shi->mat->samp_gloss_mir;
float adapt_thresh = shi->mat->adapt_thresh_mir;
- float aniso = 1.0 - shi->mat->aniso_gloss_mir;
+ float aniso = 1.0f - shi->mat->aniso_gloss_mir;
int samples=0;
col[0] = col[1] = col[2] = 0.0;
colsq[0] = colsq[1] = colsq[2] = 0.0;
- if (blur > 0.0) {
- if (adapt_thresh != 0.0) samp_type = SAMP_TYPE_HALTON;
+ if (blur > 0.0f) {
+ if (adapt_thresh != 0.0f) samp_type = SAMP_TYPE_HALTON;
else samp_type = SAMP_TYPE_HAMMERSLEY;
/* all samples are generated per pixel */
@@ -1485,22 +1485,22 @@ static void trace_reflect(float *col, ShadeInput *shi, ShadeResult *shr, float f
samples++;
/* adaptive sampling */
- if (adapt_thresh > 0.0 && samples > max_samples/3)
+ if (adapt_thresh > 0.0f && samples > max_samples/3)
{
if (adaptive_sample_variance(samples, col, colsq, adapt_thresh))
break;
/* if the pixel so far is very dark, we can get away with less samples */
- if ( (col[0] + col[1] + col[2])/3.0/(float)samples < 0.01 )
+ if ( (col[0] + col[1] + col[2])/3.0f/(float)samples < 0.01f )
max_samples--;
/* reduce samples when reflection is dim due to low ray mirror blend value or fresnel factor
* and when reflection is blurry */
- if (fresnelfac < 0.1 * (blur+1)) {
+ if (fresnelfac < 0.1f * (blur+1)) {
max_samples--;
/* even more for very dim */
- if (fresnelfac < 0.05 * (blur+1))
+ if (fresnelfac < 0.05f * (blur+1))
max_samples--;
}
}
@@ -1659,7 +1659,7 @@ static void ray_trace_shadow_tra(Isect *is, ShadeInput *origshi, int depth, int
col[1] = a*col[1] + shr.alpha*shr.combined[1];
col[2] = a*col[2] + shr.alpha*shr.combined[2];
- col[3] = (1.0 - shr.alpha)*a;
+ col[3] = (1.0f - shr.alpha)*a;
}
if(depth>0 && col[3]>0.0f) {
@@ -1758,8 +1758,8 @@ static void RandomSpherical(float *v)
if ((r = 1.f - v[2]*v[2])>0.f) {
float a = 6.283185307f*BLI_frand();
r = sqrt(r);
- v[0] = r * cos(a);
- v[1] = r * sin(a);
+ v[0] = r * cosf(a);
+ v[1] = r * sinf(a);
}
else v[2] = 1.f;
}
@@ -1956,7 +1956,7 @@ static void ray_ao_qmc(ShadeInput *shi, float *ao, float *env)
float speedfac;
speedfac = get_avg_speed(shi) * adapt_speed_fac;
- CLAMP(speedfac, 1.0, 1000.0);
+ CLAMP(speedfac, 1.0f, 1000.0f);
max_samples /= speedfac;
if (max_samples < 5) max_samples = 5;
@@ -1985,7 +1985,7 @@ static void ray_ao_qmc(ShadeInput *shi, float *ao, float *env)
prev = fac;
if(RE_rayobject_raycast(R.raytree, &isec)) {
- if (R.wrld.aomode & WO_AODIST) fac+= exp(-isec.dist*R.wrld.aodistfac);
+ if (R.wrld.aomode & WO_AODIST) fac+= expf(-isec.dist*R.wrld.aodistfac);
else fac+= 1.0f;
}
else if(envcolor!=WO_AOPLAIN) {
@@ -1998,7 +1998,7 @@ static void ray_ao_qmc(ShadeInput *shi, float *ao, float *env)
normalize_v3(view);
if(envcolor==WO_AOSKYCOL) {
- skyfac= 0.5*(1.0f+view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2]);
+ skyfac= 0.5f*(1.0f+view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2]);
env[0]+= (1.0f-skyfac)*R.wrld.horr + skyfac*R.wrld.zenr;
env[1]+= (1.0f-skyfac)*R.wrld.horg + skyfac*R.wrld.zeng;
env[2]+= (1.0f-skyfac)*R.wrld.horb + skyfac*R.wrld.zenb;
@@ -2017,7 +2017,7 @@ static void ray_ao_qmc(ShadeInput *shi, float *ao, float *env)
if (qsa->type == SAMP_TYPE_HALTON) {
/* adaptive sampling - consider samples below threshold as in shadow (or vice versa) and exit early */
- if (adapt_thresh > 0.0 && (samples > max_samples/2) ) {
+ if (adapt_thresh > 0.0f && (samples > max_samples/2) ) {
if (adaptive_sample_contrast_val(samples, prev, fac, adapt_thresh)) {
break;
@@ -2123,7 +2123,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float *ao, float *env)
/* do the trace */
if(RE_rayobject_raycast(R.raytree, &isec)) {
- if (R.wrld.aomode & WO_AODIST) sh+= exp(-isec.dist*R.wrld.aodistfac);
+ if (R.wrld.aomode & WO_AODIST) sh+= expf(-isec.dist*R.wrld.aodistfac);
else sh+= 1.0f;
}
else if(envcolor!=WO_AOPLAIN) {
@@ -2136,7 +2136,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float *ao, float *env)
normalize_v3(view);
if(envcolor==WO_AOSKYCOL) {
- fac= 0.5*(1.0f+view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2]);
+ fac= 0.5f*(1.0f+view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2]);
env[0]+= (1.0f-fac)*R.wrld.horr + fac*R.wrld.zenr;
env[1]+= (1.0f-fac)*R.wrld.horg + fac*R.wrld.zeng;
env[2]+= (1.0f-fac)*R.wrld.horb + fac*R.wrld.zenb;
@@ -2367,14 +2367,14 @@ static void ray_shadow_qmc(ShadeInput *shi, LampRen *lar, float *lampco, float *
if (lar->ray_samp_method == LA_SAMP_HALTON) {
/* adaptive sampling - consider samples below threshold as in shadow (or vice versa) and exit early */
- if ((max_samples > min_adapt_samples) && (adapt_thresh > 0.0) && (samples > max_samples / 3)) {
+ if ((max_samples > min_adapt_samples) && (adapt_thresh > 0.0f) && (samples > max_samples / 3)) {
if (isec->mode==RE_RAY_SHADOW_TRA) {
- if ((shadfac[3] / samples > (1.0-adapt_thresh)) || (shadfac[3] / samples < adapt_thresh))
+ if ((shadfac[3] / samples > (1.0f-adapt_thresh)) || (shadfac[3] / samples < adapt_thresh))
break;
else if (adaptive_sample_variance(samples, shadfac, colsq, adapt_thresh))
break;
} else {
- if ((fac / samples > (1.0-adapt_thresh)) || (fac / samples < adapt_thresh))
+ if ((fac / samples > (1.0f-adapt_thresh)) || (fac / samples < adapt_thresh))
break;
}
}
diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c
index 5aad055a8f6..a4c1778c624 100644
--- a/source/blender/render/intern/source/render_texture.c
+++ b/source/blender/render/intern/source/render_texture.c
@@ -175,9 +175,9 @@ static void tex_normal_derivate(Tex *tex, TexResult *texres)
do_colorband(tex->coba, texres->nor[2], col);
fac3= (col[0]+col[1]+col[2]);
- texres->nor[0]= 0.3333*(fac0 - fac1);
- texres->nor[1]= 0.3333*(fac0 - fac2);
- texres->nor[2]= 0.3333*(fac0 - fac3);
+ texres->nor[0]= 0.3333f*(fac0 - fac1);
+ texres->nor[1]= 0.3333f*(fac0 - fac2);
+ texres->nor[2]= 0.3333f*(fac0 - fac3);
return;
}
@@ -203,31 +203,31 @@ static int blend(Tex *tex, float *texvec, TexResult *texres)
}
if(tex->stype==TEX_LIN) { /* lin */
- texres->tin= (1.0+x)/2.0;
+ texres->tin= (1.0f+x)/2.0f;
}
else if(tex->stype==TEX_QUAD) { /* quad */
- texres->tin= (1.0+x)/2.0;
- if(texres->tin<0.0) texres->tin= 0.0;
+ texres->tin= (1.0f+x)/2.0f;
+ if(texres->tin<0.0f) texres->tin= 0.0f;
else texres->tin*= texres->tin;
}
else if(tex->stype==TEX_EASE) { /* ease */
- texres->tin= (1.0+x)/2.0;
- if(texres->tin<=.0) texres->tin= 0.0;
- else if(texres->tin>=1.0) texres->tin= 1.0;
+ texres->tin= (1.0f+x)/2.0f;
+ if(texres->tin<=0.0f) texres->tin= 0.0f;
+ else if(texres->tin>=1.0f) texres->tin= 1.0f;
else {
t= texres->tin*texres->tin;
- texres->tin= (3.0*t-2.0*t*texres->tin);
+ texres->tin= (3.0f*t-2.0f*t*texres->tin);
}
}
else if(tex->stype==TEX_DIAG) { /* diag */
- texres->tin= (2.0+x+y)/4.0;
+ texres->tin= (2.0f+x+y)/4.0f;
}
else if(tex->stype==TEX_RAD) { /* radial */
texres->tin= (atan2(y,x) / (2*M_PI) + 0.5);
}
else { /* sphere TEX_SPHERE */
texres->tin= 1.0-sqrt(x*x+ y*y+texvec[2]*texvec[2]);
- if(texres->tin<0.0) texres->tin= 0.0;
+ if(texres->tin<0.0f) texres->tin= 0.0f;
if(tex->stype==TEX_HALO) texres->tin*= texres->tin; /* halo */
}
@@ -299,7 +299,7 @@ static float tex_tri(float a)
const float b = 2*M_PI;
const float rmax = 1.0;
- a = rmax - 2.0*fabs(floor((a*(1.0/b))+0.5) - (a*(1.0/b)));
+ a = rmax - 2.0f*fabsf(floorf((a*(1.0f/b))+0.5f) - (a*(1.0f/b)));
return a;
}
@@ -319,18 +319,18 @@ static float wood_int(Tex *tex, float x, float y, float z)
if ((wf>TEX_TRI) || (wf<TEX_SIN)) wf=0; /* check to be sure noisebasis2 is initialized ahead of time */
if (wt==TEX_BAND) {
- wi = waveform[wf]((x + y + z)*10.0);
+ wi = waveform[wf]((x + y + z)*10.0f);
}
else if (wt==TEX_RING) {
- wi = waveform[wf](sqrt(x*x + y*y + z*z)*20.0);
+ wi = waveform[wf](sqrt(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);
- wi = waveform[wf]((x + y + z)*10.0 + wi);
+ wi = waveform[wf]((x + y + z)*10.0f + wi);
}
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.0 + wi);
+ wi = waveform[wf](sqrt(x*x + y*y + z*z)*20.0f + wi);
}
return wi;
@@ -370,7 +370,7 @@ static float marble_int(Tex *tex, float x, float y, float z)
if ((wf>TEX_TRI) || (wf<TEX_SIN)) wf=0; /* check to be sure noisebasis2 isn't initialized ahead of time */
- n = 5.0 * (x + y + z);
+ n = 5.0f * (x + y + z);
mi = n + tex->turbul * BLI_gTurbulence(tex->noisesize, x, y, z, tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
@@ -417,11 +417,11 @@ static int magic(Tex *tex, float *texvec, TexResult *texres)
int n;
n= tex->noisedepth;
- turb= tex->turbul/5.0;
+ turb= tex->turbul/5.0f;
- x= sin( ( texvec[0]+texvec[1]+texvec[2])*5.0 );
- y= cos( (-texvec[0]+texvec[1]-texvec[2])*5.0 );
- z= -cos( (-texvec[0]-texvec[1]+texvec[2])*5.0 );
+ x= sin( ( texvec[0]+texvec[1]+texvec[2])*5.0f );
+ y= cos( (-texvec[0]+texvec[1]-texvec[2])*5.0f );
+ z= -cos( (-texvec[0]-texvec[1]+texvec[2])*5.0f );
if(n>0) {
x*= turb;
y*= turb;
@@ -466,17 +466,17 @@ static int magic(Tex *tex, float *texvec, TexResult *texres)
}
}
- if(turb!=0.0) {
- turb*= 2.0;
+ if(turb!=0.0f) {
+ turb*= 2.0f;
x/= turb;
y/= turb;
z/= turb;
}
- texres->tr= 0.5-x;
- texres->tg= 0.5-y;
- texres->tb= 0.5-z;
+ texres->tr= 0.5f-x;
+ texres->tg= 0.5f-y;
+ texres->tb= 0.5f-z;
- texres->tin= 0.3333*(texres->tr+texres->tg+texres->tb);
+ texres->tin= 0.3333f*(texres->tr+texres->tg+texres->tb);
BRICONTRGB;
texres->ta= 1.0;
@@ -494,7 +494,7 @@ static int stucci(Tex *tex, float *texvec, TexResult *texres)
b2= BLI_gNoise(tex->noisesize, texvec[0], texvec[1], texvec[2], (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
- ofs= tex->turbul/200.0;
+ ofs= tex->turbul/200.0f;
if(tex->stype) ofs*=(b2*b2);
nor[0] = BLI_gNoise(tex->noisesize, texvec[0]+ofs, texvec[1], texvec[2], (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
@@ -732,7 +732,7 @@ static int texnoise(Tex *tex, TexResult *texres)
while(loop--) {
ran= (ran>>2);
val*= (ran & 3);
- div*= 3.0;
+ div*= 3.0f;
}
texres->tin= ((float)val)/div;
@@ -829,18 +829,18 @@ static int cubemap_glob(float *n, float x, float y, float z, float *adr1, float
z1= fabs(nor[2]);
if(z1>=x1 && z1>=y1) {
- *adr1 = (x + 1.0) / 2.0;
- *adr2 = (y + 1.0) / 2.0;
+ *adr1 = (x + 1.0f) / 2.0f;
+ *adr2 = (y + 1.0f) / 2.0f;
ret= 0;
}
else if(y1>=x1 && y1>=z1) {
- *adr1 = (x + 1.0) / 2.0;
- *adr2 = (z + 1.0) / 2.0;
+ *adr1 = (x + 1.0f) / 2.0f;
+ *adr2 = (z + 1.0f) / 2.0f;
ret= 1;
}
else {
- *adr1 = (y + 1.0) / 2.0;
- *adr2 = (z + 1.0) / 2.0;
+ *adr1 = (y + 1.0f) / 2.0f;
+ *adr2 = (z + 1.0f) / 2.0f;
ret= 2;
}
return ret;
@@ -884,17 +884,17 @@ static int cubemap(MTex *mtex, VlakRen *vlr, float *n, float x, float y, float z
}
if(vlr->puno & proj[1]) {
- *adr1 = (x + 1.0) / 2.0;
- *adr2 = (y + 1.0) / 2.0;
+ *adr1 = (x + 1.0f) / 2.0f;
+ *adr2 = (y + 1.0f) / 2.0f;
}
else if(vlr->puno & proj[2]) {
- *adr1 = (x + 1.0) / 2.0;
- *adr2 = (z + 1.0) / 2.0;
+ *adr1 = (x + 1.0f) / 2.0f;
+ *adr2 = (z + 1.0f) / 2.0f;
ret= 1;
}
else {
- *adr1 = (y + 1.0) / 2.0;
- *adr2 = (z + 1.0) / 2.0;
+ *adr1 = (y + 1.0f) / 2.0f;
+ *adr2 = (z + 1.0f) / 2.0f;
ret= 2;
}
}
@@ -922,18 +922,18 @@ static int cubemap_ob(Object *ob, float *n, float x, float y, float z, float *ad
z1= fabs(nor[2]);
if(z1>=x1 && z1>=y1) {
- *adr1 = (x + 1.0) / 2.0;
- *adr2 = (y + 1.0) / 2.0;
+ *adr1 = (x + 1.0f) / 2.0f;
+ *adr2 = (y + 1.0f) / 2.0f;
ret= 0;
}
else if(y1>=x1 && y1>=z1) {
- *adr1 = (x + 1.0) / 2.0;
- *adr2 = (z + 1.0) / 2.0;
+ *adr1 = (x + 1.0f) / 2.0f;
+ *adr2 = (z + 1.0f) / 2.0f;
ret= 1;
}
else {
- *adr1 = (y + 1.0) / 2.0;
- *adr2 = (z + 1.0) / 2.0;
+ *adr1 = (y + 1.0f) / 2.0f;
+ *adr2 = (z + 1.0f) / 2.0f;
ret= 2;
}
return ret;
@@ -957,8 +957,8 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *n, float *d
if(R.osa==0) {
if(wrap==MTEX_FLAT) {
- fx = (t[0] + 1.0) / 2.0;
- fy = (t[1] + 1.0) / 2.0;
+ fx = (t[0] + 1.0f) / 2.0f;
+ fy = (t[1] + 1.0f) / 2.0f;
}
else if(wrap==MTEX_TUBE) map_to_tube( &fx, &fy,t[0], t[1], t[2]);
else if(wrap==MTEX_SPHERE) map_to_sphere( &fx, &fy,t[0], t[1], t[2]);
@@ -973,34 +973,34 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *n, float *d
if(tex->xrepeat>1) {
float origf= fx *= tex->xrepeat;
- if(fx>1.0) fx -= (int)(fx);
- else if(fx<0.0) fx+= 1-(int)(fx);
+ if(fx>1.0f) fx -= (int)(fx);
+ else if(fx<0.0f) fx+= 1-(int)(fx);
if(tex->flag & TEX_REPEAT_XMIR) {
int orig= (int)floor(origf);
if(orig & 1)
- fx= 1.0-fx;
+ fx= 1.0f-fx;
}
}
if(tex->yrepeat>1) {
float origf= fy *= tex->yrepeat;
- if(fy>1.0) fy -= (int)(fy);
- else if(fy<0.0) fy+= 1-(int)(fy);
+ if(fy>1.0f) fy -= (int)(fy);
+ else if(fy<0.0f) fy+= 1-(int)(fy);
if(tex->flag & TEX_REPEAT_YMIR) {
int orig= (int)floor(origf);
if(orig & 1)
- fy= 1.0-fy;
+ fy= 1.0f-fy;
}
}
}
/* crop */
- if(tex->cropxmin!=0.0 || tex->cropxmax!=1.0) {
+ if(tex->cropxmin!=0.0f || tex->cropxmax!=1.0f) {
fac1= tex->cropxmax - tex->cropxmin;
fx= tex->cropxmin+ fx*fac1;
}
- if(tex->cropymin!=0.0 || tex->cropymax!=1.0) {
+ if(tex->cropymin!=0.0f || tex->cropymax!=1.0f) {
fac1= tex->cropymax - tex->cropymin;
fy= tex->cropymin+ fy*fac1;
}
@@ -1011,23 +1011,23 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *n, float *d
else {
if(wrap==MTEX_FLAT) {
- fx= (t[0] + 1.0) / 2.0;
- fy= (t[1] + 1.0) / 2.0;
- dxt[0]/= 2.0;
- dxt[1]/= 2.0;
- dxt[2]/= 2.0;
- dyt[0]/= 2.0;
- dyt[1]/= 2.0;
- dyt[2]/= 2.0;
+ fx= (t[0] + 1.0f) / 2.0f;
+ fy= (t[1] + 1.0f) / 2.0f;
+ dxt[0]/= 2.0f;
+ dxt[1]/= 2.0f;
+ dxt[2]/= 2.0f;
+ dyt[0]/= 2.0f;
+ dyt[1]/= 2.0f;
+ dyt[2]/= 2.0f;
}
else if ELEM(wrap, MTEX_TUBE, MTEX_SPHERE) {
/* exception: the seam behind (y<0.0) */
ok= 1;
- if(t[1]<=0.0) {
+ if(t[1]<=0.0f) {
fx= t[0]+dxt[0];
fy= t[0]+dyt[0];
- if(fx>=0.0 && fy>=0.0 && t[0]>=0.0);
- else if(fx<=0.0 && fy<=0.0 && t[0]<=0.0);
+ if(fx>=0.0f && fy>=0.0f && t[0]>=0.0f);
+ else if(fx<=0.0f && fy<=0.0f && t[0]<=0.0f);
else ok= 0;
}
if(ok) {
@@ -1046,10 +1046,10 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *n, float *d
else {
if(wrap==MTEX_TUBE) map_to_tube( &fx, &fy,t[0], t[1], t[2]);
else map_to_sphere( &fx, &fy,t[0], t[1], t[2]);
- dxt[0]/= 2.0;
- dxt[1]/= 2.0;
- dyt[0]/= 2.0;
- dyt[1]/= 2.0;
+ dxt[0]/= 2.0f;
+ dxt[1]/= 2.0f;
+ dyt[0]/= 2.0f;
+ dyt[1]/= 2.0f;
}
}
else {
@@ -1143,13 +1143,13 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *n, float *d
}
/* crop */
- if(tex->cropxmin!=0.0 || tex->cropxmax!=1.0) {
+ if(tex->cropxmin!=0.0f || tex->cropxmax!=1.0f) {
fac1= tex->cropxmax - tex->cropxmin;
fx= tex->cropxmin+ fx*fac1;
dxt[0]*= fac1;
dyt[0]*= fac1;
}
- if(tex->cropymin!=0.0 || tex->cropymax!=1.0) {
+ if(tex->cropymin!=0.0f || tex->cropymax!=1.0f) {
fac1= tex->cropymax - tex->cropymin;
fy= tex->cropymin+ fy*fac1;
dxt[1]*= fac1;
@@ -1220,7 +1220,7 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex,
* artificer: added the use of tmpvec to avoid scaling texvec
*/
VECCOPY(tmpvec, texvec);
- mul_v3_fl(tmpvec, 1.0/tex->noisesize);
+ mul_v3_fl(tmpvec, 1.0f/tex->noisesize);
switch(tex->stype) {
case TEX_MFRACTAL:
@@ -1242,7 +1242,7 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex,
* artificer: added the use of tmpvec to avoid scaling texvec
*/
VECCOPY(tmpvec, texvec);
- mul_v3_fl(tmpvec, 1.0/tex->noisesize);
+ mul_v3_fl(tmpvec, 1.0f/tex->noisesize);
retval= voronoiTex(tex, tmpvec, texres);
break;
@@ -1251,7 +1251,7 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex,
* artificer: added the use of tmpvec to avoid scaling texvec
*/
VECCOPY(tmpvec, texvec);
- mul_v3_fl(tmpvec, 1.0/tex->noisesize);
+ mul_v3_fl(tmpvec, 1.0f/tex->noisesize);
retval= mg_distNoiseTex(tex, tmpvec, texres);
break;
@@ -1381,7 +1381,7 @@ void texture_rgb_blend(float *in, float *tex, float *out, float fact, float facg
switch(blendtype) {
case MTEX_BLEND:
fact*= facg;
- facm= 1.0-fact;
+ facm= 1.0f-fact;
in[0]= (fact*tex[0] + facm*out[0]);
in[1]= (fact*tex[1] + facm*out[1]);
@@ -1390,7 +1390,7 @@ void texture_rgb_blend(float *in, float *tex, float *out, float fact, float facg
case MTEX_MUL:
fact*= facg;
- facm= 1.0-facg;
+ facm= 1.0f-facg;
in[0]= (facm+fact*tex[0])*out[0];
in[1]= (facm+fact*tex[1])*out[1];
in[2]= (facm+fact*tex[2])*out[2];
@@ -1398,28 +1398,28 @@ void texture_rgb_blend(float *in, float *tex, float *out, float fact, float facg
case MTEX_SCREEN:
fact*= facg;
- facm= 1.0-facg;
- in[0]= 1.0 - (facm+fact*(1.0-tex[0])) * (1.0-out[0]);
- in[1]= 1.0 - (facm+fact*(1.0-tex[1])) * (1.0-out[1]);
- in[2]= 1.0 - (facm+fact*(1.0-tex[2])) * (1.0-out[2]);
+ facm= 1.0f-facg;
+ in[0]= 1.0f - (facm+fact*(1.0f-tex[0])) * (1.0f-out[0]);
+ in[1]= 1.0f - (facm+fact*(1.0f-tex[1])) * (1.0f-out[1]);
+ in[2]= 1.0f - (facm+fact*(1.0f-tex[2])) * (1.0f-out[2]);
break;
case MTEX_OVERLAY:
fact*= facg;
- facm= 1.0-facg;
+ facm= 1.0f-facg;
if(out[0] < 0.5f)
in[0] = out[0] * (facm + 2.0f*fact*tex[0]);
else
- in[0] = 1.0f - (facm + 2.0f*fact*(1.0 - tex[0])) * (1.0 - out[0]);
+ in[0] = 1.0f - (facm + 2.0f*fact*(1.0f - tex[0])) * (1.0f - out[0]);
if(out[1] < 0.5f)
in[1] = out[1] * (facm + 2.0f*fact*tex[1]);
else
- in[1] = 1.0f - (facm + 2.0f*fact*(1.0 - tex[1])) * (1.0 - out[1]);
+ in[1] = 1.0f - (facm + 2.0f*fact*(1.0f - tex[1])) * (1.0f - out[1]);
if(out[2] < 0.5f)
in[2] = out[2] * (facm + 2.0f*fact*tex[2]);
else
- in[2] = 1.0f - (facm + 2.0f*fact*(1.0 - tex[2])) * (1.0 - out[2]);
+ in[2] = 1.0f - (facm + 2.0f*fact*(1.0f - tex[2])) * (1.0f - out[2]);
break;
case MTEX_SUB:
@@ -1433,20 +1433,20 @@ void texture_rgb_blend(float *in, float *tex, float *out, float fact, float facg
case MTEX_DIV:
fact*= facg;
- facm= 1.0-fact;
+ facm= 1.0f-fact;
- if(tex[0]!=0.0)
+ if(tex[0]!=0.0f)
in[0]= facm*out[0] + fact*out[0]/tex[0];
- if(tex[1]!=0.0)
+ if(tex[1]!=0.0f)
in[1]= facm*out[1] + fact*out[1]/tex[1];
- if(tex[2]!=0.0)
+ if(tex[2]!=0.0f)
in[2]= facm*out[2] + fact*out[2]/tex[2];
break;
case MTEX_DIFF:
fact*= facg;
- facm= 1.0-fact;
+ 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]);
@@ -1454,7 +1454,7 @@ void texture_rgb_blend(float *in, float *tex, float *out, float fact, float facg
case MTEX_DARK:
fact*= facg;
- facm= 1.0-fact;
+ facm= 1.0f-fact;
col= tex[0]+((1-tex[0])*facm);
if(col < out[0]) in[0]= col; else in[0]= out[0];
@@ -1516,7 +1516,7 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen
facg= fabsf(facg);
fact*= facg;
- facm= 1.0-fact;
+ facm= 1.0f-fact;
if(flip) SWAP(float, fact, facm);
switch(blendtype) {
@@ -1525,21 +1525,21 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen
break;
case MTEX_MUL:
- facm= 1.0-facg;
+ facm= 1.0f-facg;
in= (facm+fact*tex)*out;
break;
case MTEX_SCREEN:
- facm= 1.0-facg;
- in= 1.0-(facm+fact*(1.0-tex))*(1.0-out);
+ facm= 1.0f-facg;
+ in= 1.0f-(facm+fact*(1.0f-tex))*(1.0f-out);
break;
case MTEX_OVERLAY:
- facm= 1.0-facg;
+ facm= 1.0f-facg;
if(out < 0.5f)
in = out * (facm + 2.0f*fact*tex);
else
- in = 1.0f - (facm + 2.0f*fact*(1.0 - tex)) * (1.0 - out);
+ in = 1.0f - (facm + 2.0f*fact*(1.0f - tex)) * (1.0f - out);
break;
case MTEX_SUB:
@@ -1549,7 +1549,7 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen
break;
case MTEX_DIV:
- if(tex!=0.0)
+ if(tex!=0.0f)
in= facm*out + fact*out/tex;
break;
@@ -1568,15 +1568,15 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen
break;
case MTEX_SOFT_LIGHT:
- scf=1.0 - (1.0 - tex) * (1.0 - out);
- in= facm*out + fact * ((1.0 - out) * tex * out) + (out * scf);
+ scf=1.0f - (1.0f - tex) * (1.0f - out);
+ in= facm*out + fact * ((1.0f - out) * tex * out) + (out * scf);
break;
case MTEX_LIN_LIGHT:
- if (tex > 0.5)
- in = out + fact*(2*(tex - 0.5));
+ if (tex > 0.5f)
+ in = out + fact*(2.0f*(tex - 0.5f));
else
- in = out + fact*(2*tex - 1);
+ in = out + fact*(2.0f*tex - 1.0f);
break;
}
@@ -1905,11 +1905,13 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T
const int fromrgb = ((tex->type == TEX_IMAGE) || ((tex->flag & TEX_COLORBAND)!=0));
float Hscale = Tnor*mtex->norfac;
+ int dimx=512, dimy=512;
// 2 channels for 2D texture and 3 for 3D textures.
const int nr_channels = (mtex->texco == TEXCO_UV)? 2 : 3;
int c, rgbnor, iBumpSpace;
float dHdx, dHdy;
+ int found_deriv_map = (tex->type==TEX_IMAGE) && (tex->imaflag & TEX_DERIVATIVEMAP);
// disable internal bump eval in sampler, save pointer
float *nvec = texres->nor;
@@ -1929,8 +1931,31 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T
ntap_bump->init_done = 1;
}
+
+ // resolve image dimensions
+ if(found_deriv_map || (mtex->texflag&MTEX_BUMP_TEXTURESPACE)!=0) {
+ ImBuf* ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser);
+ if (ibuf) {
+ dimx = ibuf->x;
+ dimy = ibuf->y;
+ }
+ }
- if(!(mtex->texflag & MTEX_5TAP_BUMP)) {
+ if(found_deriv_map) {
+ float dBdu, dBdv;
+ float s = 1; // negate this if flipped texture coordinate
+ texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt);
+ rgbnor = multitex_mtex(shi, mtex, texvec, dxt, dyt, texres);
+
+ // this variant using a derivative map is described here
+ // http://mmikkelsen3d.blogspot.com/2011/07/derivative-maps.html
+ dBdu = Hscale*dimx*(2*texres->tr-1);
+ dBdv = Hscale*dimy*(2*texres->tg-1);
+
+ dHdx = dBdu*dxt[0] + s * dBdv*dxt[1];
+ dHdy = dBdu*dyt[0] + s * dBdv*dyt[1];
+ }
+ else if(!(mtex->texflag & MTEX_5TAP_BUMP)) {
// compute height derivatives with respect to output image pixel coordinates x and y
float STll[3], STlr[3], STul[3];
float Hll, Hlr, Hul;
@@ -2087,11 +2112,11 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T
// crazy hack solution that gives results similar to normal mapping - part 2
float vec[2];
- vec[0] = tex->ima->gen_x*dxt[0];
- vec[1] = tex->ima->gen_y*dxt[1];
+ vec[0] = dimx*dxt[0];
+ vec[1] = dimy*dxt[1];
dHdx *= 1.0f/len_v2(vec);
- vec[0] = tex->ima->gen_x*dyt[0];
- vec[1] = tex->ima->gen_y*dyt[1];
+ vec[0] = dimx*dyt[0];
+ vec[1] = dimy*dyt[1];
dHdy *= 1.0f/len_v2(vec);
}
}
@@ -2119,7 +2144,7 @@ void do_material_tex(ShadeInput *shi)
float texvec[3], dxt[3], dyt[3], tempvec[3], norvec[3], warpvec[3]={0.0f, 0.0f, 0.0f}, Tnor=1.0;
int tex_nr, rgbnor= 0, warpdone=0;
int use_compat_bump = 0, use_ntap_bump = 0;
- int found_nmapping = 0;
+ int found_nmapping = 0, found_deriv_map = 0;
int iFirstTimeNMap=1;
compatible_bump_init(&compat_bump);
@@ -2139,8 +2164,9 @@ void do_material_tex(ShadeInput *shi)
tex= mtex->tex;
if(tex==0) continue;
+ found_deriv_map = (tex->type==TEX_IMAGE) && (tex->imaflag & TEX_DERIVATIVEMAP);
use_compat_bump= (mtex->texflag & MTEX_COMPAT_BUMP);
- use_ntap_bump= (mtex->texflag & (MTEX_3TAP_BUMP|MTEX_5TAP_BUMP));
+ use_ntap_bump= ((mtex->texflag & (MTEX_3TAP_BUMP|MTEX_5TAP_BUMP))!=0 || found_deriv_map!=0) ? 1 : 0;
/* XXX texture node trees don't work for this yet */
if(tex->nodetree && tex->use_nodes) {
@@ -2289,16 +2315,16 @@ void do_material_tex(ShadeInput *shi)
/* texture output */
if( (rgbnor & TEX_RGB) && (mtex->texflag & MTEX_RGBTOINT)) {
- texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb);
+ texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb);
rgbnor-= TEX_RGB;
}
if(mtex->texflag & MTEX_NEGATIVE) {
if(rgbnor & TEX_RGB) {
- texres.tr= 1.0-texres.tr;
- texres.tg= 1.0-texres.tg;
- texres.tb= 1.0-texres.tb;
+ texres.tr= 1.0f-texres.tr;
+ texres.tg= 1.0f-texres.tg;
+ texres.tb= 1.0f-texres.tb;
}
- texres.tin= 1.0-texres.tin;
+ texres.tin= 1.0f-texres.tin;
}
if(mtex->texflag & MTEX_STENCIL) {
if(rgbnor & TEX_RGB) {
@@ -2325,8 +2351,8 @@ void do_material_tex(ShadeInput *shi)
texres.nor[2]= texres.tb;
}
else {
- float co_nor= 0.5*cos(texres.tin-0.5);
- float si= 0.5*sin(texres.tin-0.5);
+ float co_nor= 0.5*cos(texres.tin-0.5f);
+ float si= 0.5*sin(texres.tin-0.5f);
float f1, f2;
f1= shi->vn[0];
@@ -2412,7 +2438,7 @@ void do_material_tex(ShadeInput *shi)
// exception for envmap only
if(tex->type==TEX_ENVMAP && mtex->blendtype==MTEX_BLEND) {
fact= texres.tin*mirrfac;
- facm= 1.0- fact;
+ facm= 1.0f- fact;
shi->refcol[0]= fact + facm*shi->refcol[0];
shi->refcol[1]= fact*tcol[0] + facm*shi->refcol[1];
shi->refcol[2]= fact*tcol[1] + facm*shi->refcol[2];
@@ -2557,65 +2583,65 @@ void do_material_tex(ShadeInput *shi)
if(rgbnor & TEX_RGB) {
if(texres.talpha) texres.tin= texres.ta;
- else texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb);
+ else texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb);
}
if(mtex->mapto & MAP_REF) {
float difffac= mtex->difffac*stencilTin;
shi->refl= texture_value_blend(mtex->def_var, shi->refl, texres.tin, difffac, mtex->blendtype);
- if(shi->refl<0.0) shi->refl= 0.0;
+ if(shi->refl<0.0f) shi->refl= 0.0f;
}
if(mtex->mapto & MAP_SPEC) {
float specfac= mtex->specfac*stencilTin;
shi->spec= texture_value_blend(mtex->def_var, shi->spec, texres.tin, specfac, mtex->blendtype);
- if(shi->spec<0.0) shi->spec= 0.0;
+ if(shi->spec<0.0f) shi->spec= 0.0f;
}
if(mtex->mapto & MAP_EMIT) {
float emitfac= mtex->emitfac*stencilTin;
shi->emit= texture_value_blend(mtex->def_var, shi->emit, texres.tin, emitfac, mtex->blendtype);
- if(shi->emit<0.0) shi->emit= 0.0;
+ if(shi->emit<0.0f) shi->emit= 0.0f;
}
if(mtex->mapto & MAP_ALPHA) {
float alphafac= mtex->alphafac*stencilTin;
shi->alpha= texture_value_blend(mtex->def_var, shi->alpha, texres.tin, alphafac, mtex->blendtype);
- if(shi->alpha<0.0) shi->alpha= 0.0;
- else if(shi->alpha>1.0) shi->alpha= 1.0;
+ if(shi->alpha<0.0f) shi->alpha= 0.0f;
+ else if(shi->alpha>1.0f) shi->alpha= 1.0f;
}
if(mtex->mapto & MAP_HAR) {
float har; // have to map to 0-1
float hardfac= mtex->hardfac*stencilTin;
- har= ((float)shi->har)/128.0;
- har= 128.0*texture_value_blend(mtex->def_var, har, texres.tin, hardfac, mtex->blendtype);
+ har= ((float)shi->har)/128.0f;
+ har= 128.0f*texture_value_blend(mtex->def_var, har, texres.tin, hardfac, mtex->blendtype);
- if(har<1.0) shi->har= 1;
- else if(har>511.0) shi->har= 511;
+ if(har<1.0f) shi->har= 1;
+ else if(har>511) shi->har= 511;
else shi->har= (int)har;
}
if(mtex->mapto & MAP_RAYMIRR) {
float raymirrfac= mtex->raymirrfac*stencilTin;
shi->ray_mirror= texture_value_blend(mtex->def_var, shi->ray_mirror, texres.tin, raymirrfac, mtex->blendtype);
- if(shi->ray_mirror<0.0) shi->ray_mirror= 0.0;
- else if(shi->ray_mirror>1.0) shi->ray_mirror= 1.0;
+ if(shi->ray_mirror<0.0f) shi->ray_mirror= 0.0f;
+ else if(shi->ray_mirror>1.0f) shi->ray_mirror= 1.0f;
}
if(mtex->mapto & MAP_TRANSLU) {
float translfac= mtex->translfac*stencilTin;
shi->translucency= texture_value_blend(mtex->def_var, shi->translucency, texres.tin, translfac, mtex->blendtype);
- if(shi->translucency<0.0) shi->translucency= 0.0;
- else if(shi->translucency>1.0) shi->translucency= 1.0;
+ if(shi->translucency<0.0f) shi->translucency= 0.0f;
+ else if(shi->translucency>1.0f) shi->translucency= 1.0f;
}
if(mtex->mapto & MAP_AMB) {
float ambfac= mtex->ambfac*stencilTin;
shi->amb= texture_value_blend(mtex->def_var, shi->amb, texres.tin, ambfac, mtex->blendtype);
- if(shi->amb<0.0) shi->amb= 0.0;
- else if(shi->amb>1.0) shi->amb= 1.0;
+ if(shi->amb<0.0f) shi->amb= 0.0f;
+ else if(shi->amb>1.0f) shi->amb= 1.0f;
shi->ambr= shi->amb*R.wrld.ambr;
shi->ambg= shi->amb*R.wrld.ambg;
@@ -2711,16 +2737,16 @@ void do_volume_tex(ShadeInput *shi, float *xyz, int mapto_flag, float *col, floa
/* texture output */
if( (rgbnor & TEX_RGB) && (mtex->texflag & MTEX_RGBTOINT)) {
- texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb);
+ texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb);
rgbnor-= TEX_RGB;
}
if(mtex->texflag & MTEX_NEGATIVE) {
if(rgbnor & TEX_RGB) {
- texres.tr= 1.0-texres.tr;
- texres.tg= 1.0-texres.tg;
- texres.tb= 1.0-texres.tb;
+ texres.tr= 1.0f-texres.tr;
+ texres.tg= 1.0f-texres.tg;
+ texres.tb= 1.0f-texres.tb;
}
- texres.tin= 1.0-texres.tin;
+ texres.tin= 1.0f-texres.tin;
}
if(mtex->texflag & MTEX_STENCIL) {
if(rgbnor & TEX_RGB) {
@@ -2777,7 +2803,7 @@ void do_volume_tex(ShadeInput *shi, float *xyz, int mapto_flag, float *col, floa
if (!(rgbnor & TEX_INT)) {
if (rgbnor & TEX_RGB) {
if(texres.talpha) texres.tin= texres.ta;
- else texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb);
+ else texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb);
}
}
@@ -2785,25 +2811,25 @@ void do_volume_tex(ShadeInput *shi, float *xyz, int mapto_flag, float *col, floa
float emitfac= mtex->emitfac*stencilTin;
*val = texture_value_blend(mtex->def_var, *val, texres.tin, emitfac, mtex->blendtype);
- if(*val<0.0) *val= 0.0;
+ if(*val<0.0f) *val= 0.0f;
}
if((mapto_flag & MAP_DENSITY) && (mtex->mapto & MAP_DENSITY)) {
float densfac= mtex->densfac*stencilTin;
*val = texture_value_blend(mtex->def_var, *val, texres.tin, densfac, mtex->blendtype);
- CLAMP(*val, 0.0, 1.0);
+ CLAMP(*val, 0.0f, 1.0f);
}
if((mapto_flag & MAP_SCATTERING) && (mtex->mapto & MAP_SCATTERING)) {
float scatterfac= mtex->scatterfac*stencilTin;
*val = texture_value_blend(mtex->def_var, *val, texres.tin, scatterfac, mtex->blendtype);
- CLAMP(*val, 0.0, 1.0);
+ CLAMP(*val, 0.0f, 1.0f);
}
if((mapto_flag & MAP_REFLECTION) && (mtex->mapto & MAP_REFLECTION)) {
float reflfac= mtex->reflfac*stencilTin;
*val = texture_value_blend(mtex->def_var, *val, texres.tin, reflfac, mtex->blendtype);
- CLAMP(*val, 0.0, 1.0);
+ CLAMP(*val, 0.0f, 1.0f);
}
}
}
@@ -2847,7 +2873,7 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float *colf)
if(osatex) {
- dx= 1.0/har->rad;
+ dx= 1.0f/har->rad;
if(mtex->projx) {
dxt[0]= mtex->size[0]*dx;
@@ -2875,16 +2901,16 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float *colf)
/* texture output */
if(rgb && (mtex->texflag & MTEX_RGBTOINT)) {
- texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb);
+ texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb);
rgb= 0;
}
if(mtex->texflag & MTEX_NEGATIVE) {
if(rgb) {
- texres.tr= 1.0-texres.tr;
- texres.tg= 1.0-texres.tg;
- texres.tb= 1.0-texres.tb;
+ texres.tr= 1.0f-texres.tr;
+ texres.tg= 1.0f-texres.tg;
+ texres.tb= 1.0f-texres.tb;
}
- else texres.tin= 1.0-texres.tin;
+ else texres.tin= 1.0f-texres.tin;
}
/* mapping */
@@ -2911,10 +2937,10 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float *colf)
}
fact= texres.tin*mtex->colfac;
- facm= 1.0-fact;
+ facm= 1.0f-fact;
if(mtex->blendtype==MTEX_MUL) {
- facm= 1.0-mtex->colfac;
+ facm= 1.0f-mtex->colfac;
}
if(mtex->blendtype==MTEX_SUB) fact= -fact;
@@ -2934,15 +2960,15 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float *colf)
colf[1]= (fact*texres.tg + har->g);
colf[2]= (fact*texres.tb + har->b);
- CLAMP(colf[0], 0.0, 1.0);
- CLAMP(colf[1], 0.0, 1.0);
- CLAMP(colf[2], 0.0, 1.0);
+ CLAMP(colf[0], 0.0f, 1.0f);
+ CLAMP(colf[1], 0.0f, 1.0f);
+ CLAMP(colf[2], 0.0f, 1.0f);
}
}
if(mtex->mapto & MAP_ALPHA) {
if(rgb) {
if(texres.talpha) texres.tin= texres.ta;
- else texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb);
+ else texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb);
}
colf[3]*= texres.tin;
@@ -2992,7 +3018,7 @@ void do_sky_tex(float *rco, float *lo, float *dxyview, float *hor, float *zen, f
/* 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.0/M_PI)*saacos(lo[2])/(sqrt(lo[0]*lo[0] + lo[1]*lo[1]));
+ fact= (1.0f/(float)M_PI)*saacos(lo[2])/(sqrt(lo[0]*lo[0] + lo[1]*lo[1]));
tempvec[0]= lo[0]*fact;
tempvec[1]= lo[1]*fact;
tempvec[2]= 0.0;
@@ -3013,13 +3039,13 @@ void do_sky_tex(float *rco, float *lo, float *dxyview, float *hor, float *zen, f
if(mtex->texco==TEXCO_H_TUBEMAP) map_to_tube( tempvec, tempvec+1,lo[0], lo[2], lo[1]);
else map_to_sphere( tempvec, tempvec+1,lo[0], lo[2], lo[1]);
/* tube/spheremap maps for outside view, not inside */
- tempvec[0]= 1.0-tempvec[0];
+ tempvec[0]= 1.0f-tempvec[0];
/* only top half */
- tempvec[1]= 2.0*tempvec[1]-1.0;
+ tempvec[1]= 2.0f*tempvec[1]-1.0f;
tempvec[2]= 0.0;
/* and correction for do_2d_mapping */
- tempvec[0]= 2.0*tempvec[0]-1.0;
- tempvec[1]= 2.0*tempvec[1]-1.0;
+ tempvec[0]= 2.0f*tempvec[0]-1.0f;
+ tempvec[1]= 2.0f*tempvec[1]-1.0f;
co= tempvec;
}
else {
@@ -3068,16 +3094,16 @@ void do_sky_tex(float *rco, float *lo, float *dxyview, float *hor, float *zen, f
/* texture output */
if(rgb && (mtex->texflag & MTEX_RGBTOINT)) {
- texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb);
+ texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb);
rgb= 0;
}
if(mtex->texflag & MTEX_NEGATIVE) {
if(rgb) {
- texres.tr= 1.0-texres.tr;
- texres.tg= 1.0-texres.tg;
- texres.tb= 1.0-texres.tb;
+ texres.tr= 1.0f-texres.tr;
+ texres.tg= 1.0f-texres.tg;
+ texres.tb= 1.0f-texres.tb;
}
- else texres.tin= 1.0-texres.tin;
+ else texres.tin= 1.0f-texres.tin;
}
if(mtex->texflag & MTEX_STENCIL) {
if(rgb) {
@@ -3138,7 +3164,7 @@ void do_sky_tex(float *rco, float *lo, float *dxyview, float *hor, float *zen, f
}
}
if(mtex->mapto & WOMAP_BLEND) {
- if(rgb) texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb);
+ if(rgb) texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb);
*blend= texture_value_blend(mtex->def_var, *blend, texres.tin, mtex->blendfac, mtex->blendtype);
}
@@ -3274,16 +3300,16 @@ void do_lamp_tex(LampRen *la, float *lavec, ShadeInput *shi, float *colf, int ef
/* texture output */
if(rgb && (mtex->texflag & MTEX_RGBTOINT)) {
- texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb);
+ texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb);
rgb= 0;
}
if(mtex->texflag & MTEX_NEGATIVE) {
if(rgb) {
- texres.tr= 1.0-texres.tr;
- texres.tg= 1.0-texres.tg;
- texres.tb= 1.0-texres.tb;
+ texres.tr= 1.0f-texres.tr;
+ texres.tg= 1.0f-texres.tg;
+ texres.tb= 1.0f-texres.tb;
}
- else texres.tin= 1.0-texres.tin;
+ else texres.tin= 1.0f-texres.tin;
}
if(mtex->texflag & MTEX_STENCIL) {
if(rgb) {
@@ -3368,7 +3394,7 @@ int externtex(MTex *mtex, float *vec, float *tin, float *tr, float *tg, float *t
rgb= multitex(tex, texvec, dxt, dyt, 0, &texr, thread, mtex->which_output);
if(rgb) {
- texr.tin= (0.35*texr.tr+0.45*texr.tg+0.2*texr.tb);
+ texr.tin= (0.35f*texr.tr+0.45f*texr.tg+0.2f*texr.tb);
}
else {
texr.tr= mtex->r;
@@ -3417,14 +3443,14 @@ void render_realtime_texture(ShadeInput *shi, Image *ima)
tex= &imatex[shi->thread];
tex->iuser.ok= ima->ok;
- texvec[0]= 0.5+0.5*suv->uv[0];
- texvec[1]= 0.5+0.5*suv->uv[1];
- texvec[2] = 0; // initalize it because imagewrap looks at it.
+ texvec[0]= 0.5f+0.5f*suv->uv[0];
+ texvec[1]= 0.5f+0.5f*suv->uv[1];
+ texvec[2] = 0.0f; // initalize it because imagewrap looks at it.
if(shi->osatex) {
- dx[0]= 0.5*suv->dxuv[0];
- dx[1]= 0.5*suv->dxuv[1];
- dy[0]= 0.5*suv->dyuv[0];
- dy[1]= 0.5*suv->dyuv[1];
+ dx[0]= 0.5f*suv->dxuv[0];
+ dx[1]= 0.5f*suv->dxuv[1];
+ dy[0]= 0.5f*suv->dyuv[0];
+ dy[1]= 0.5f*suv->dyuv[1];
}
texr.nor= NULL;
diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c
index c08d6c0f456..b66740c87ba 100644
--- a/source/blender/render/intern/source/rendercore.c
+++ b/source/blender/render/intern/source/rendercore.c
@@ -758,7 +758,7 @@ static void atm_tile(RenderPart *pa, RenderLayer *rl)
if(lar->type==LA_SUN && lar->sunsky) {
/* if it's sky continue and don't apply atmosphere effect on it */
- if(*zrect >= 9.9e10 || rgbrect[3]==0.0f) {
+ if(*zrect >= 9.9e10f || rgbrect[3]==0.0f) {
continue;
}
@@ -1098,7 +1098,7 @@ static unsigned short *make_solid_mask(RenderPart *pa)
static void addAlphaOverFloatMask(float *dest, float *source, unsigned short dmask, unsigned short smask)
{
unsigned short shared= dmask & smask;
- float mul= 1.0 - source[3];
+ float mul= 1.0f - source[3];
if(shared) { /* overlapping masks */
@@ -1892,13 +1892,13 @@ static void renderflare(RenderResult *rr, float *rectf, HaloRen *har)
fla.r= fabs(rc[0]);
fla.g= fabs(rc[1]);
fla.b= fabs(rc[2]);
- fla.alfa= ma->flareboost*fabs(alfa*visifac*rc[3]);
- fla.hard= 20.0f + fabs(70*rc[7]);
+ fla.alfa= ma->flareboost*fabsf(alfa*visifac*rc[3]);
+ fla.hard= 20.0f + fabsf(70.0f*rc[7]);
fla.tex= 0;
- type= (int)(fabs(3.9*rc[6]));
+ type= (int)(fabs(3.9f*rc[6]));
- fla.rad= ma->subsize*sqrt(fabs(2.0f*har->rad*rc[4]));
+ fla.rad= ma->subsize*sqrtf(fabs(2.0f*har->rad*rc[4]));
if(type==3) {
fla.rad*= 3.0f;
@@ -1907,22 +1907,22 @@ static void renderflare(RenderResult *rr, float *rectf, HaloRen *har)
fla.radsq= fla.rad*fla.rad;
- vec[0]= 1.4*rc[5]*(har->xs-R.winx/2);
- vec[1]= 1.4*rc[5]*(har->ys-R.winy/2);
- vec[2]= 32.0f*sqrt(vec[0]*vec[0] + vec[1]*vec[1] + 1.0f);
+ vec[0]= 1.4f*rc[5]*(har->xs-R.winx/2);
+ vec[1]= 1.4f*rc[5]*(har->ys-R.winy/2);
+ vec[2]= 32.0f*sqrtf(vec[0]*vec[0] + vec[1]*vec[1] + 1.0f);
- fla.xs= R.winx/2 + vec[0] + (1.2+rc[8])*R.rectx*vec[0]/vec[2];
- fla.ys= R.winy/2 + vec[1] + (1.2+rc[8])*R.rectx*vec[1]/vec[2];
+ fla.xs= R.winx/2 + vec[0] + (1.2f+rc[8])*R.rectx*vec[0]/vec[2];
+ fla.ys= R.winy/2 + vec[1] + (1.2f+rc[8])*R.rectx*vec[1]/vec[2];
if(R.flag & R_SEC_FIELD) {
- if(R.r.mode & R_ODDFIELD) fla.ys += 0.5;
- else fla.ys -= 0.5;
+ if(R.r.mode & R_ODDFIELD) fla.ys += 0.5f;
+ else fla.ys -= 0.5f;
}
if(type & 1) fla.type= HA_FLARECIRC;
else fla.type= 0;
renderhalo_post(rr, rectf, &fla);
- fla.alfa*= 0.5;
+ fla.alfa*= 0.5f;
if(type & 2) fla.type= HA_FLARECIRC;
else fla.type= 0;
renderhalo_post(rr, rectf, &fla);
@@ -2205,7 +2205,7 @@ static void bake_displacement(void *handle, ShadeInput *UNUSED(shi), float dist,
if(R.r.bake_flag & R_BAKE_NORMALIZE && R.r.bake_maxdist) {
disp = (dist+R.r.bake_maxdist) / (R.r.bake_maxdist*2); /* alter the range from [-bake_maxdist, bake_maxdist] to [0, 1]*/
} else {
- disp = 0.5 + dist; /* alter the range from [-0.5,0.5] to [0,1]*/
+ disp = 0.5f + dist; /* alter the range from [-0.5,0.5] to [0,1]*/
}
if(bs->rect_float) {
@@ -2277,7 +2277,7 @@ static void bake_set_vlr_dxyco(BakeShade *bs, float *uv1, float *uv2, float *uv3
* then taking u and v partial derivatives to get dxco and dyco */
A= (uv2[0] - uv1[0])*(uv3[1] - uv1[1]) - (uv3[0] - uv1[0])*(uv2[1] - uv1[1]);
- if(fabs(A) > FLT_EPSILON) {
+ if(fabsf(A) > FLT_EPSILON) {
A= 0.5f/A;
d1= uv2[1] - uv3[1];
@@ -2532,8 +2532,8 @@ static void shade_tface(BakeShade *bs)
* where a pixel gets in between 2 faces or the middle of a quad,
* camera aligned quads also have this problem but they are less common.
* Add a small offset to the UVs, fixes bug #18685 - Campbell */
- vec[a][0]= tface->uv[a][0]*(float)bs->rectx - (0.5f + 0.001);
- vec[a][1]= tface->uv[a][1]*(float)bs->recty - (0.5f + 0.002);
+ vec[a][0]= tface->uv[a][0]*(float)bs->rectx - (0.5f + 0.001f);
+ vec[a][1]= tface->uv[a][1]*(float)bs->recty - (0.5f + 0.002f);
}
/* UV indices have to be corrected for possible quad->tria splits */
diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c
index 456162d2d30..0c5ad0475ab 100644
--- a/source/blender/render/intern/source/renderdatabase.c
+++ b/source/blender/render/intern/source/renderdatabase.c
@@ -943,13 +943,13 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, float *vec, f
float tin, tr, tg, tb, ta;
float xn, yn, zn, texvec[3], hoco[4], hoco1[4];
- if(hasize==0.0) return NULL;
+ if(hasize==0.0f) return NULL;
projectverto(vec, re->winmat, hoco);
- if(hoco[3]==0.0) return NULL;
+ if(hoco[3]==0.0f) return NULL;
if(vec1) {
projectverto(vec1, re->winmat, hoco1);
- if(hoco1[3]==0.0) return NULL;
+ if(hoco1[3]==0.0f) return NULL;
}
har= RE_findOrAddHalo(obr, obr->tothalo++);
@@ -959,8 +959,8 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, float *vec, f
/* actual projectvert is done in function project_renderdata() because of parts/border/pano */
/* we do it here for sorting of halos */
zn= hoco[3];
- har->xs= 0.5*re->winx*(hoco[0]/zn);
- har->ys= 0.5*re->winy*(hoco[1]/zn);
+ har->xs= 0.5f*re->winx*(hoco[0]/zn);
+ har->ys= 0.5f*re->winy*(hoco[1]/zn);
har->zs= 0x7FFFFF*(hoco[2]/zn);
har->zBufDist = 0x7FFFFFFF*(hoco[2]/zn);
@@ -970,16 +970,16 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, float *vec, f
har->type |= HA_VECT;
- xn= har->xs - 0.5*re->winx*(hoco1[0]/hoco1[3]);
- yn= har->ys - 0.5*re->winy*(hoco1[1]/hoco1[3]);
- if(xn==0.0 || (xn==0.0 && yn==0.0)) zn= 0.0;
+ xn= har->xs - 0.5f*re->winx*(hoco1[0]/hoco1[3]);
+ yn= har->ys - 0.5f*re->winy*(hoco1[1]/hoco1[3]);
+ if(xn==0.0f || (xn==0.0f && yn==0.0f)) zn= 0.0f;
else zn= atan2(yn, xn);
har->sin= sin(zn);
har->cos= cos(zn);
zn= len_v3v3(vec1, vec);
- har->hasize= vectsize*zn + (1.0-vectsize)*hasize;
+ har->hasize= vectsize*zn + (1.0f-vectsize)*hasize;
sub_v3_v3v3(har->no, vec, vec1);
normalize_v3(har->no);
@@ -991,7 +991,7 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, float *vec, f
har->r= ma->r;
har->g= ma->g;
har->b= ma->b;
- har->add= (255.0*ma->add);
+ har->add= (255.0f*ma->add);
har->mat= ma;
har->hard= ma->har;
har->seed= seed % 256;
@@ -1032,7 +1032,7 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, float *vec, f
zn= tin*mtex->alphafac;
if(mtex->mapto & MAP_COL) {
- zn= 1.0-yn;
+ zn= 1.0f-yn;
har->r= (yn*tr+ zn*ma->r);
har->g= (yn*tg+ zn*ma->g);
har->b= (yn*tb+ zn*ma->b);
@@ -1057,13 +1057,13 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater
float xn, yn, zn, texvec[3], hoco[4], hoco1[4], in[3],tex[3],out[3];
int i, hasrgb;
- if(hasize==0.0) return NULL;
+ if(hasize==0.0f) return NULL;
projectverto(vec, re->winmat, hoco);
- if(hoco[3]==0.0) return NULL;
+ if(hoco[3]==0.0f) return NULL;
if(vec1) {
projectverto(vec1, re->winmat, hoco1);
- if(hoco1[3]==0.0) return NULL;
+ if(hoco1[3]==0.0f) return NULL;
}
har= RE_findOrAddHalo(obr, obr->tothalo++);
@@ -1073,8 +1073,8 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater
/* actual projectvert is done in function project_renderdata() because of parts/border/pano */
/* we do it here for sorting of halos */
zn= hoco[3];
- har->xs= 0.5*re->winx*(hoco[0]/zn);
- har->ys= 0.5*re->winy*(hoco[1]/zn);
+ har->xs= 0.5f*re->winx*(hoco[0]/zn);
+ har->ys= 0.5f*re->winy*(hoco[1]/zn);
har->zs= 0x7FFFFF*(hoco[2]/zn);
har->zBufDist = 0x7FFFFFFF*(hoco[2]/zn);
@@ -1084,16 +1084,16 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater
har->type |= HA_VECT;
- xn= har->xs - 0.5*re->winx*(hoco1[0]/hoco1[3]);
- yn= har->ys - 0.5*re->winy*(hoco1[1]/hoco1[3]);
- if(xn==0.0 || (xn==0.0 && yn==0.0)) zn= 0.0;
+ xn= har->xs - 0.5f*re->winx*(hoco1[0]/hoco1[3]);
+ yn= har->ys - 0.5f*re->winy*(hoco1[1]/hoco1[3]);
+ if(xn==0.0f || (xn==0.0f && yn==0.0f)) zn= 0.0;
else zn= atan2(yn, xn);
har->sin= sin(zn);
har->cos= cos(zn);
- zn= len_v3v3(vec1, vec)*0.5;
+ zn= len_v3v3(vec1, vec)*0.5f;
- har->hasize= vectsize*zn + (1.0-vectsize)*hasize;
+ har->hasize= vectsize*zn + (1.0f-vectsize)*hasize;
sub_v3_v3v3(har->no, vec, vec1);
normalize_v3(har->no);
@@ -1105,7 +1105,7 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater
har->r= ma->r;
har->g= ma->g;
har->b= ma->b;
- har->add= (255.0*ma->add);
+ har->add= (255.0f*ma->add);
har->mat= ma;
har->hard= ma->har;
har->seed= seed % 256;
@@ -1185,13 +1185,13 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater
if(mtex->mapto & MAP_ALPHA)
har->alfa = texture_value_blend(mtex->def_var,har->alfa,tin,mtex->alphafac,mtex->blendtype);
if(mtex->mapto & MAP_HAR)
- har->hard = 1.0+126.0*texture_value_blend(mtex->def_var,((float)har->hard)/127.0,tin,mtex->hardfac,mtex->blendtype);
+ har->hard = 1.0f+126.0f*texture_value_blend(mtex->def_var,((float)har->hard)/127.0f,tin,mtex->hardfac,mtex->blendtype);
if(mtex->mapto & MAP_RAYMIRR)
- har->hasize = 100.0*texture_value_blend(mtex->def_var,har->hasize/100.0,tin,mtex->raymirrfac,mtex->blendtype);
+ har->hasize = 100.0f*texture_value_blend(mtex->def_var,har->hasize/100.0f,tin,mtex->raymirrfac,mtex->blendtype);
if(mtex->mapto & MAP_TRANSLU) {
- float add = texture_value_blend(mtex->def_var,(float)har->add/255.0,tin,mtex->translfac,mtex->blendtype);
+ float add = texture_value_blend(mtex->def_var,(float)har->add/255.0f,tin,mtex->translfac,mtex->blendtype);
CLAMP(add, 0.f, 1.f);
- har->add = 255.0*add;
+ har->add = 255.0f*add;
}
/* now what on earth is this good for?? */
//if(mtex->texco & 16) {
@@ -1270,24 +1270,24 @@ void project_renderdata(Render *re, void (*projectfunc)(float *, float mat[][4],
projectfunc(vec, re->winmat, hoco);
/* we clip halos less critical, but not for the Z */
- hoco[0]*= 0.5;
- hoco[1]*= 0.5;
+ hoco[0]*= 0.5f;
+ hoco[1]*= 0.5f;
if( panotestclip(re, do_pano, hoco) ) {
har->miny= har->maxy= -10000; /* that way render clips it */
}
- else if(hoco[3]<0.0) {
+ else if(hoco[3]<0.0f) {
har->miny= har->maxy= -10000; /* render clips it */
}
else /* do the projection...*/
{
/* bring back hocos */
- hoco[0]*= 2.0;
- hoco[1]*= 2.0;
+ hoco[0]*= 2.0f;
+ hoco[1]*= 2.0f;
zn= hoco[3];
- har->xs= 0.5*re->winx*(1.0+hoco[0]/zn); /* the 0.5 negates the previous 2...*/
- har->ys= 0.5*re->winy*(1.0+hoco[1]/zn);
+ har->xs= 0.5f*re->winx*(1.0f+hoco[0]/zn); /* the 0.5 negates the previous 2...*/
+ har->ys= 0.5f*re->winy*(1.0f+hoco[1]/zn);
/* this should be the zbuffer coordinate */
har->zs= 0x7FFFFF*(hoco[2]/zn);
@@ -1298,11 +1298,11 @@ void project_renderdata(Render *re, void (*projectfunc)(float *, float mat[][4],
projectfunc(vec, re->winmat, hoco);
vec[0]-= har->hasize;
zn= hoco[3];
- har->rad= fabs(har->xs- 0.5*re->winx*(1.0+hoco[0]/zn));
+ har->rad= fabsf(har->xs- 0.5f*re->winx*(1.0f+hoco[0]/zn));
/* this clip is not really OK, to prevent stars to become too large */
if(har->type & HA_ONLYSKY) {
- if(har->rad>3.0) har->rad= 3.0;
+ if(har->rad>3.0f) har->rad= 3.0f;
}
har->radsq= har->rad*har->rad;
diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c
index dcb9a3063e1..5860c395b07 100644
--- a/source/blender/render/intern/source/shadbuf.c
+++ b/source/blender/render/intern/source/shadbuf.c
@@ -260,7 +260,7 @@ static int compress_deepsamples(DeepSample *dsample, int tot, float epsilon)
}
else {
/* compute visibility at center between slopes at z */
- slope= (slopemin+slopemax)*0.5;
+ slope= (slopemin+slopemax)*0.5f;
v= newds->v + slope*((z - newds->z)/(double)0x7FFFFFFF);
}
@@ -774,7 +774,7 @@ void makeshadowbuf(Render *re, LampRen *lar)
angle= saacos(lar->spotsi);
temp= 0.5f*shb->size*cos(angle)/sin(angle);
shb->pixsize= (shb->d)/temp;
- wsize= shb->pixsize*(shb->size/2.0);
+ wsize= shb->pixsize*(shb->size/2.0f);
perspective_m4( shb->winmat,-wsize, wsize, -wsize, wsize, shb->d, shb->clipend);
mul_m4_m4m4(shb->persmat, shb->viewmat, shb->winmat);
@@ -1094,7 +1094,7 @@ static float readshadowbuf(ShadBuf *shb, ShadSampleBuf *shsample, int bias, int
else { /* soft area */
temp= ( (float)(zs- zsamp) )/(float)bias;
- return 1.0 - temp*temp;
+ return 1.0f - temp*temp;
}
}
@@ -1287,7 +1287,7 @@ static float readshadowbuf_halo(ShadBuf *shb, ShadSampleBuf *shsample, int xs, i
/* soft area */
temp= ( (float)(zs- zsamp) )/(float)bias;
- return 1.0 - temp*temp;
+ return 1.0f - temp*temp;
}
@@ -1303,15 +1303,15 @@ float shadow_halo(LampRen *lar, float *p1, float *p2)
int x, y, z, xs1, ys1;
int dx = 0, dy = 0;
- siz= 0.5*(float)shb->size;
+ siz= 0.5f*(float)shb->size;
co[0]= p1[0];
co[1]= p1[1];
co[2]= p1[2]/lar->sh_zfac;
co[3]= 1.0;
mul_m4_v4(shb->winmat, co); /* rational hom co */
- xf1= siz*(1.0+co[0]/co[3]);
- yf1= siz*(1.0+co[1]/co[3]);
+ xf1= siz*(1.0f+co[0]/co[3]);
+ yf1= siz*(1.0f+co[1]/co[3]);
zf1= (co[2]/co[3]);
@@ -1320,8 +1320,8 @@ float shadow_halo(LampRen *lar, float *p1, float *p2)
co[2]= p2[2]/lar->sh_zfac;
co[3]= 1.0;
mul_m4_v4(shb->winmat, co); /* rational hom co */
- xf2= siz*(1.0+co[0]/co[3]);
- yf2= siz*(1.0+co[1]/co[3]);
+ xf2= siz*(1.0f+co[0]/co[3]);
+ yf2= siz*(1.0f+co[1]/co[3]);
zf2= (co[2]/co[3]);
/* the 2dda (a pixel line formula) */
@@ -1330,8 +1330,8 @@ float shadow_halo(LampRen *lar, float *p1, float *p2)
ys1= (int)yf1;
if(xf1 != xf2) {
- if(xf2-xf1 > 0.0) {
- labdax= (xf1-xs1-1.0)/(xf1-xf2);
+ if(xf2-xf1 > 0.0f) {
+ labdax= (xf1-xs1-1.0f)/(xf1-xf2);
ldx= -shb->shadhalostep/(xf1-xf2);
dx= shb->shadhalostep;
}
@@ -1347,8 +1347,8 @@ float shadow_halo(LampRen *lar, float *p1, float *p2)
}
if(yf1 != yf2) {
- if(yf2-yf1 > 0.0) {
- labday= (yf1-ys1-1.0)/(yf1-yf2);
+ if(yf2-yf1 > 0.0f) {
+ labday= (yf1-ys1-1.0f)/(yf1-yf2);
ldy= -shb->shadhalostep/(yf1-yf2);
dy= shb->shadhalostep;
}
@@ -1389,16 +1389,16 @@ float shadow_halo(LampRen *lar, float *p1, float *p2)
}
labda= MIN2(labdax, labday);
- if(labda==labdao || labda>=1.0) break;
+ if(labda==labdao || labda>=1.0f) break;
zf= zf1 + labda*(zf2-zf1);
count+= (float)shb->totbuf;
- if(zf<= -1.0) lightcount += 1.0; /* close to the spot */
+ if(zf<= -1.0f) lightcount += 1.0f; /* close to the spot */
else {
/* make sure, behind the clipend we extend halolines. */
- if(zf>=1.0) z= 0x7FFFF000;
+ if(zf>=1.0f) z= 0x7FFFF000;
else z= (int)(0x7FFFF000*zf);
for(shsample= shb->buffers.first; shsample; shsample= shsample->next)
@@ -1407,8 +1407,8 @@ float shadow_halo(LampRen *lar, float *p1, float *p2)
}
}
- if(count!=0.0) return (lightcount/count);
- return 0.0;
+ if(count!=0.0f) return (lightcount/count);
+ return 0.0f;
}
@@ -2081,11 +2081,11 @@ static int viewpixel_to_lampbuf(ShadBuf *shb, ObjectInstanceRen *obi, VlakRen *v
/* ortho viewplane cannot intersect using view vector originating in (0,0,0) */
if(R.r.mode & R_ORTHO) {
/* x and y 3d coordinate can be derived from pixel coord and winmat */
- float fx= 2.0/(R.winx*R.winmat[0][0]);
- float fy= 2.0/(R.winy*R.winmat[1][1]);
+ float fx= 2.0f/(R.winx*R.winmat[0][0]);
+ float fy= 2.0f/(R.winy*R.winmat[1][1]);
- hoco[0]= (x - 0.5*R.winx)*fx - R.winmat[3][0]/R.winmat[0][0];
- hoco[1]= (y - 0.5*R.winy)*fy - R.winmat[3][1]/R.winmat[1][1];
+ hoco[0]= (x - 0.5f*R.winx)*fx - R.winmat[3][0]/R.winmat[0][0];
+ hoco[1]= (y - 0.5f*R.winy)*fy - R.winmat[3][1]/R.winmat[1][1];
/* using a*x + b*y + c*z = d equation, (a b c) is normal */
if(nor[2]!=0.0f)
@@ -2141,9 +2141,9 @@ static void isb_add_shadfac(ISBShadfacA **isbsapp, MemArena *mem, int obi, int f
/* in osa case, the samples were filled in with factor 1.0/R.osa. if fewer samples we have to correct */
if(R.osa)
- shadfacf= ((float)shadfac*R.osa)/(4096.0*samples);
+ shadfacf= ((float)shadfac*R.osa)/(4096.0f*samples);
else
- shadfacf= ((float)shadfac)/(4096.0);
+ shadfacf= ((float)shadfac)/(4096.0f);
new= BLI_memarena_alloc(mem, sizeof(ISBShadfacA));
new->obi= obi;
@@ -2640,4 +2640,3 @@ void ISB_free(RenderPart *pa)
}
}
}
-
diff --git a/source/blender/render/intern/source/sss.c b/source/blender/render/intern/source/sss.c
index f7d1b43d4f7..0ba13b31c4b 100644
--- a/source/blender/render/intern/source/sss.c
+++ b/source/blender/render/intern/source/sss.c
@@ -172,7 +172,7 @@ static float f_Rd(float alpha_, float A, float ro)
float sq;
sq= sqrt(3.0f*(1.0f - alpha_));
- return (alpha_/2.0f)*(1.0f + exp((-4.0f/3.0f)*A*sq))*exp(-sq) - ro;
+ return (alpha_/2.0f)*(1.0f + expf((-4.0f/3.0f)*A*sq))*expf(-sq) - ro;
}
static float compute_reduced_albedo(ScatterSettings *ss)
@@ -189,10 +189,10 @@ static float compute_reduced_albedo(ScatterSettings *ss)
for(i= 0; i < max_iteration_count; i++) {
fsub= (fxn - fxn_1);
- if(fabs(fsub) < tolerance)
+ if(fabsf(fsub) < tolerance)
break;
d= ((xn - xn_1)/fsub)*fxn;
- if(fabs(d) < tolerance)
+ if(fabsf(d) < tolerance)
break;
xn_1= xn;
@@ -221,10 +221,10 @@ static float Rd_rsquare(ScatterSettings *ss, float rr)
sr= sqrt(rr + ss->zr*ss->zr);
sv= sqrt(rr + ss->zv*ss->zv);
- Rdr= ss->zr*(1.0f + ss->sigma*sr)*exp(-ss->sigma*sr)/(sr*sr*sr);
- Rdv= ss->zv*(1.0f + ss->sigma*sv)*exp(-ss->sigma*sv)/(sv*sv*sv);
+ Rdr= ss->zr*(1.0f + ss->sigma*sr)*expf(-ss->sigma*sr)/(sr*sr*sr);
+ Rdv= ss->zv*(1.0f + ss->sigma*sv)*expf(-ss->sigma*sv)/(sv*sv*sv);
- return /*ss->alpha_*/(1.0f/(4.0f*M_PI))*(Rdr + Rdv);
+ return /*ss->alpha_*/(1.0f/(4.0f*(float)M_PI))*(Rdr + Rdv);
}
static float Rd(ScatterSettings *ss, float r)
@@ -316,7 +316,7 @@ ScatterSettings *scatter_settings_new(float refl, float radius, float ior, float
ss->alpha_= compute_reduced_albedo(ss);
ss->sigma= 1.0f/ss->ld;
- ss->sigma_t_= ss->sigma/sqrt(3.0f*(1.0f - ss->alpha_));
+ ss->sigma_t_= ss->sigma/sqrtf(3.0f*(1.0f - ss->alpha_));
ss->sigma_s_= ss->alpha_*ss->sigma_t_;
ss->sigma_a= ss->sigma_t_ - ss->sigma_s_;
@@ -489,7 +489,7 @@ static void sum_leaf_radiance(ScatterTree *UNUSED(tree), ScatterNode *node)
for(i=0; i<node->totpoint; i++) {
p= &node->points[i];
- rad= p->area*fabs(p->rad[0] + p->rad[1] + p->rad[2]);
+ rad= p->area*fabsf(p->rad[0] + p->rad[1] + p->rad[2]);
totrad += rad;
node->co[0] += rad*p->co[0];
@@ -513,20 +513,20 @@ static void sum_leaf_radiance(ScatterTree *UNUSED(tree), ScatterNode *node)
}
if(node->area > 1e-16f) {
- inv= 1.0/node->area;
+ inv= 1.0f/node->area;
node->rad[0] *= inv;
node->rad[1] *= inv;
node->rad[2] *= inv;
}
if(node->backarea > 1e-16f) {
- inv= 1.0/node->backarea;
+ inv= 1.0f/node->backarea;
node->backrad[0] *= inv;
node->backrad[1] *= inv;
node->backrad[2] *= inv;
}
if(totrad > 1e-16f) {
- inv= 1.0/totrad;
+ inv= 1.0f/totrad;
node->co[0] *= inv;
node->co[1] *= inv;
node->co[2] *= inv;
@@ -566,8 +566,8 @@ static void sum_branch_radiance(ScatterTree *UNUSED(tree), ScatterNode *node)
subnode= node->child[i];
- rad= subnode->area*fabs(subnode->rad[0] + subnode->rad[1] + subnode->rad[2]);
- rad += subnode->backarea*fabs(subnode->backrad[0] + subnode->backrad[1] + subnode->backrad[2]);
+ rad= subnode->area*fabsf(subnode->rad[0] + subnode->rad[1] + subnode->rad[2]);
+ rad += subnode->backarea*fabsf(subnode->backrad[0] + subnode->backrad[1] + subnode->backrad[2]);
totrad += rad;
node->co[0] += rad*subnode->co[0];
@@ -587,20 +587,20 @@ static void sum_branch_radiance(ScatterTree *UNUSED(tree), ScatterNode *node)
}
if(node->area > 1e-16f) {
- inv= 1.0/node->area;
+ inv= 1.0f/node->area;
node->rad[0] *= inv;
node->rad[1] *= inv;
node->rad[2] *= inv;
}
if(node->backarea > 1e-16f) {
- inv= 1.0/node->backarea;
+ inv= 1.0f/node->backarea;
node->backrad[0] *= inv;
node->backrad[1] *= inv;
node->backrad[2] *= inv;
}
if(totrad > 1e-16f) {
- inv= 1.0/totrad;
+ inv= 1.0f/totrad;
node->co[0] *= inv;
node->co[1] *= inv;
node->co[2] *= inv;
@@ -668,9 +668,9 @@ static void create_octree_node(ScatterTree *tree, ScatterNode *node, float *mid,
return;
}
- subsize[0]= size[0]*0.5;
- subsize[1]= size[1]*0.5;
- subsize[2]= size[2]*0.5;
+ subsize[0]= size[0]*0.5f;
+ subsize[1]= size[1]*0.5f;
+ subsize[2]= size[2]*0.5f;
node->split[0]= mid[0];
node->split[1]= mid[1];
@@ -764,7 +764,7 @@ ScatterTree *scatter_tree_new(ScatterSettings *ss[3], float scale, float error,
for(i=0; i<totpoint; i++) {
VECCOPY(points[i].co, co[i]);
VECCOPY(points[i].rad, color[i]);
- points[i].area= fabs(area[i])/(tree->scale*tree->scale);
+ points[i].area= fabsf(area[i])/(tree->scale*tree->scale);
points[i].back= (area[i] < 0.0f);
mul_v3_fl(points[i].co, 1.0f/tree->scale);
@@ -794,13 +794,13 @@ void scatter_tree_build(ScatterTree *tree)
tree->root->points= newpoints;
tree->root->totpoint= totpoint;
- mid[0]= (tree->min[0]+tree->max[0])*0.5;
- mid[1]= (tree->min[1]+tree->max[1])*0.5;
- mid[2]= (tree->min[2]+tree->max[2])*0.5;
+ mid[0]= (tree->min[0]+tree->max[0])*0.5f;
+ mid[1]= (tree->min[1]+tree->max[1])*0.5f;
+ mid[2]= (tree->min[2]+tree->max[2])*0.5f;
- size[0]= (tree->max[0]-tree->min[0])*0.5;
- size[1]= (tree->max[1]-tree->min[1])*0.5;
- size[2]= (tree->max[2]-tree->min[2])*0.5;
+ size[0]= (tree->max[0]-tree->min[0])*0.5f;
+ size[1]= (tree->max[1]-tree->min[1])*0.5f;
+ size[2]= (tree->max[2]-tree->min[2])*0.5f;
create_octree_node(tree, tree->root, mid, size, tree->refpoints, 0);
diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c
index 72cb35e7827..840e5444ff0 100644
--- a/source/blender/render/intern/source/strand.c
+++ b/source/blender/render/intern/source/strand.c
@@ -78,9 +78,9 @@ static float strand_eval_width(Material *ma, float strandco)
if(ma->strand_ease!=0.0f) {
if(ma->strand_ease<0.0f)
- fac= pow(strandco, 1.0+ma->strand_ease);
+ fac= pow(strandco, 1.0f+ma->strand_ease);
else
- fac= pow(strandco, 1.0/(1.0f-ma->strand_ease));
+ fac= pow(strandco, 1.0f/(1.0f-ma->strand_ease));
}
else fac= strandco;
@@ -816,8 +816,8 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBa
zbuf_alloc_span(&zspan, pa->rectx, pa->recty, clipcrop);
/* needed for transform from hoco to zbuffer co */
- zspan.zmulx= ((float)winx)/2.0;
- zspan.zmuly= ((float)winy)/2.0;
+ zspan.zmulx= ((float)winx)/2.0f;
+ zspan.zmuly= ((float)winy)/2.0f;
zspan.zofsx= -pa->disprect.xmin;
zspan.zofsy= -pa->disprect.ymin;
diff --git a/source/blender/render/intern/source/sunsky.c b/source/blender/render/intern/source/sunsky.c
index 5877fa42292..e824b81096b 100644
--- a/source/blender/render/intern/source/sunsky.c
+++ b/source/blender/render/intern/source/sunsky.c
@@ -68,12 +68,12 @@
* */
void ClipColor(float c[3])
{
- if (c[0] > 1.0) c[0] = 1.0;
- if (c[0] < 0.0) c[0] = 0.0;
- if (c[1] > 1.0) c[1] = 1.0;
- if (c[1] < 0.0) c[1] = 0.0;
- if (c[2] > 1.0) c[2] = 1.0;
- if (c[2] < 0.0) c[2] = 0.0;
+ if (c[0] > 1.0f) c[0] = 1.0f;
+ if (c[0] < 0.0f) c[0] = 0.0f;
+ if (c[1] > 1.0f) c[1] = 1.0f;
+ if (c[1] < 0.0f) c[1] = 0.0f;
+ if (c[2] > 1.0f) c[2] = 1.0f;
+ if (c[2] < 0.0f) c[2] = 0.0f;
}
/**
@@ -85,9 +85,9 @@ static float AngleBetween(float thetav, float phiv, float theta, float phi)
{
float cospsi = sin(thetav) * sin(theta) * cos(phi - phiv) + cos(thetav) * cos(theta);
- if (cospsi > 1.0)
+ if (cospsi > 1.0f)
return 0;
- if (cospsi < -1.0)
+ if (cospsi < -1.0f)
return M_PI;
return acos(cospsi);
@@ -117,11 +117,11 @@ static float PerezFunction(struct SunSky *sunsky, const float *lam, float theta,
{
float den, num;
- den = ((1 + lam[0] * exp(lam[1])) *
- (1 + lam[2] * exp(lam[3] * sunsky->theta) + lam[4] * cos(sunsky->theta) * cos(sunsky->theta)));
+ den = ((1 + lam[0] * expf(lam[1])) *
+ (1 + lam[2] * expf(lam[3] * sunsky->theta) + lam[4] * cosf(sunsky->theta) * cosf(sunsky->theta)));
- num = ((1 + lam[0] * exp(lam[1] / cos(theta))) *
- (1 + lam[2] * exp(lam[3] * gamma) + lam[4] * cos(gamma) * cos(gamma)));
+ num = ((1 + lam[0] * expf(lam[1] / cosf(theta))) *
+ (1 + lam[2] * expf(lam[3] * gamma) + lam[4] * cosf(gamma) * cosf(gamma)));
return(lvz * num / den);}
@@ -173,41 +173,41 @@ void InitSunSky(struct SunSky *sunsky, float turb, float *toSun, float horizon_b
T = turb;
T2 = turb*turb;
- chi = (4.0 / 9.0 - T / 120.0) * (M_PI - 2 * sunsky->theta);
- sunsky->zenith_Y = (4.0453 * T - 4.9710) * tan(chi) - .2155 * T + 2.4192;
+ chi = (4.0f / 9.0f - T / 120.0f) * ((float)M_PI - 2.0f * sunsky->theta);
+ sunsky->zenith_Y = (4.0453f * T - 4.9710f) * tanf(chi) - 0.2155f * T + 2.4192f;
sunsky->zenith_Y *= 1000; // conversion from kcd/m^2 to cd/m^2
if (sunsky->zenith_Y<=0)
sunsky->zenith_Y = 1e-6;
sunsky->zenith_x =
- ( + 0.00165 * theta3 - 0.00374 * theta2 + 0.00208 * sunsky->theta + 0) * T2 +
- ( -0.02902 * theta3 + 0.06377 * theta2 - 0.03202 * sunsky->theta + 0.00394) * T +
- ( + 0.11693 * theta3 - 0.21196 * theta2 + 0.06052 * sunsky->theta + 0.25885);
+ ( + 0.00165f * theta3 - 0.00374f * theta2 + 0.00208f * sunsky->theta + 0.0f) * T2 +
+ ( -0.02902f * theta3 + 0.06377f * theta2 - 0.03202f * sunsky->theta + 0.00394f) * T +
+ ( + 0.11693f * theta3 - 0.21196f * theta2 + 0.06052f * sunsky->theta + 0.25885f);
sunsky->zenith_y =
- ( + 0.00275 * theta3 - 0.00610 * theta2 + 0.00316 * sunsky->theta + 0) * T2 +
- ( -0.04214 * theta3 + 0.08970 * theta2 - 0.04153 * sunsky->theta + 0.00515) * T +
- ( + 0.15346 * theta3 - 0.26756 * theta2 + 0.06669 * sunsky->theta + 0.26688);
+ ( + 0.00275f * theta3 - 0.00610f * theta2 + 0.00316f * sunsky->theta + 0.0f) * T2 +
+ ( -0.04214f * theta3 + 0.08970f * theta2 - 0.04153f * sunsky->theta + 0.00515f) * T +
+ ( + 0.15346f * theta3 - 0.26756f * theta2 + 0.06669f * sunsky->theta + 0.26688f);
- sunsky->perez_Y[0] = 0.17872 * T - 1.46303;
- sunsky->perez_Y[1] = -0.35540 * T + 0.42749;
- sunsky->perez_Y[2] = -0.02266 * T + 5.32505;
- sunsky->perez_Y[3] = 0.12064 * T - 2.57705;
- sunsky->perez_Y[4] = -0.06696 * T + 0.37027;
-
- sunsky->perez_x[0] = -0.01925 * T - 0.25922;
- sunsky->perez_x[1] = -0.06651 * T + 0.00081;
- sunsky->perez_x[2] = -0.00041 * T + 0.21247;
- sunsky->perez_x[3] = -0.06409 * T - 0.89887;
- sunsky->perez_x[4] = -0.00325 * T + 0.04517;
-
- sunsky->perez_y[0] = -0.01669 * T - 0.26078;
- sunsky->perez_y[1] = -0.09495 * T + 0.00921;
- sunsky->perez_y[2] = -0.00792 * T + 0.21023;
- sunsky->perez_y[3] = -0.04405 * T - 1.65369;
- sunsky->perez_y[4] = -0.01092 * T + 0.05291;
+ sunsky->perez_Y[0] = 0.17872f * T - 1.46303f;
+ sunsky->perez_Y[1] = -0.35540f * T + 0.42749f;
+ sunsky->perez_Y[2] = -0.02266f * T + 5.32505f;
+ sunsky->perez_Y[3] = 0.12064f * T - 2.57705f;
+ sunsky->perez_Y[4] = -0.06696f * T + 0.37027f;
+
+ sunsky->perez_x[0] = -0.01925f * T - 0.25922f;
+ sunsky->perez_x[1] = -0.06651f * T + 0.00081f;
+ sunsky->perez_x[2] = -0.00041f * T + 0.21247f;
+ sunsky->perez_x[3] = -0.06409f * T - 0.89887f;
+ sunsky->perez_x[4] = -0.00325f * T + 0.04517f;
+
+ sunsky->perez_y[0] = -0.01669f * T - 0.26078f;
+ sunsky->perez_y[1] = -0.09495f * T + 0.00921f;
+ sunsky->perez_y[2] = -0.00792f * T + 0.21023f;
+ sunsky->perez_y[3] = -0.04405f * T - 1.65369f;
+ sunsky->perez_y[4] = -0.01092f * T + 0.05291f;
/* suggested by glome in
* http://projects.blender.org/tracker/?func=detail&atid=127&aid=8063&group_id=9*/
@@ -248,17 +248,17 @@ void GetSkyXYZRadiance(struct SunSky* sunsky, float theta, float phi, float colo
float hfade=1, nfade=1;
- if (theta>(0.5*M_PI)) {
- hfade = 1.0-(theta*M_1_PI-0.5)*2.0;
- hfade = hfade*hfade*(3.0-2.0*hfade);
+ if (theta>(0.5f*(float)M_PI)) {
+ hfade = 1.0f-(theta*(float)M_1_PI-0.5f)*2.0f;
+ hfade = hfade*hfade*(3.0f-2.0f*hfade);
theta = 0.5*M_PI;
}
- if (sunsky->theta>(0.5*M_PI)) {
- if (theta<=0.5*M_PI) {
- nfade = 1.0-(0.5-theta*M_1_PI)*2.0;
- nfade *= 1.0-(sunsky->theta*M_1_PI-0.5)*2.0;
- nfade = nfade*nfade*(3.0-2.0*nfade);
+ if (sunsky->theta>(0.5f*(float)M_PI)) {
+ if (theta<=0.5f*(float)M_PI) {
+ nfade = 1.0f-(0.5f-theta*(float)M_1_PI)*2.0f;
+ nfade *= 1.0f-(sunsky->theta*(float)M_1_PI-0.5f)*2.0f;
+ nfade = nfade*nfade*(3.0f-2.0f*nfade);
}
}
@@ -267,7 +267,7 @@ void GetSkyXYZRadiance(struct SunSky* sunsky, float theta, float phi, float colo
// Compute xyY values
x = PerezFunction(sunsky, sunsky->perez_x, theta, gamma, sunsky->zenith_x);
y = PerezFunction(sunsky, sunsky->perez_y, theta, gamma, sunsky->zenith_y);
- Y = 6.666666667e-5 * nfade * hfade * PerezFunction(sunsky, sunsky->perez_Y, theta, gamma, sunsky->zenith_Y);
+ Y = 6.666666667e-5f * nfade * hfade * PerezFunction(sunsky, sunsky->perez_Y, theta, gamma, sunsky->zenith_Y);
if(sunsky->sky_exposure!=0.0f)
Y = 1.0 - exp(Y*sunsky->sky_exposure);
@@ -296,8 +296,8 @@ void GetSkyXYZRadiancef(struct SunSky* sunsky, const float varg[3], float color_
copy_v3_v3(v, (float*)varg);
normalize_v3(v);
- if (v[2] < 0.001){
- v[2] = 0.001;
+ if (v[2] < 0.001f) {
+ v[2] = 0.001f;
normalize_v3(v);
}
@@ -329,15 +329,15 @@ static void ComputeAttenuatedSunlight(float theta, int turbidity, float fTau[3])
fAlpha = 1.3f;
fBeta = 0.04608365822050f * turbidity - 0.04586025928522f;
- m = 1.0/(cos(theta) + 0.15f*pow(93.885f-theta/M_PI*180.0f,-1.253f));
+ m = 1.0f/(cosf(theta) + 0.15f*powf(93.885f-theta/(float)M_PI*180.0f,-1.253f));
for(i = 0; i < 3; i++)
{
// Rayleigh Scattering
- fTauR = exp( -m * 0.008735f * pow(fLambda[i], (float)(-4.08f)));
+ fTauR = expf( -m * 0.008735f * powf(fLambda[i], (float)(-4.08f)));
// Aerosal (water + dust) attenuation
- fTauA = exp(-m * fBeta * pow(fLambda[i], -fAlpha));
+ fTauA = exp(-m * fBeta * powf(fLambda[i], -fAlpha));
fTau[i] = fTauR * fTauA;
}
@@ -364,8 +364,8 @@ void InitAtmosphere(struct SunSky *sunSky, float sun_intens, float mief, float r
const float pn = 0.035f;
const float T = 2.0f;
float fTemp, fTemp2, fTemp3, fBeta, fBetaDash;
- float c = (6.544*T - 6.51)*1e-17;
- float K[3] = {0.685f, 0.679f, 0.670f};
+ float c = (6.544f*T - 6.51f)*1e-17f;
+ float K[3] = {0.685f, 0.679f, 0.670f};
float vBetaMieTemp[3];
float fLambda[3],fLambda2[3], fLambda4[3];
@@ -410,7 +410,7 @@ void InitAtmosphere(struct SunSky *sunSky, float sun_intens, float mief, float r
// Mie scattering constants.
- fTemp2 = 0.434*c*(2*pi)*(2*pi)*0.5f;
+ fTemp2 = 0.434f*c*(2*pi)*(2*pi)*0.5f;
vec3opf(sunSky->atm_BetaDashMie, vLambda2, *, fTemp2);
fTemp3 = 0.434f*c*pi*(2*pi)*(2*pi);
@@ -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/M_LN2);
+ vec3opf(E1, sunSky->atm_BetaRM, *, -s/(float)M_LN2);
E1[0] = exp(E1[0]);
E1[1] = exp(E1[1]);
E1[2] = exp(E1[2]);
@@ -469,17 +469,17 @@ void AtmospherePixleShader( struct SunSky* sunSky, float view[3], float s, float
//Phase2(theta) = (1-g^2)/(1+g-2g*cos(theta))^(3/2)
fTemp = 1 + sunSky->atm_HGg - 2 * sunSky->atm_HGg * costheta;
- fTemp = fTemp * sqrt(fTemp);
+ fTemp = fTemp * sqrtf(fTemp);
Phase_2 = (1 - sunSky->atm_HGg * sunSky->atm_HGg)/fTemp;
vec3opf(vTemp1, sunSky->atm_BetaDashRay, *, Phase_1);
vec3opf(vTemp2, sunSky->atm_BetaDashMie, *, Phase_2);
vec3opv(vTemp1, vTemp1, +, vTemp2);
- fopvec3(vTemp2, 1.0, -, E1);
+ fopvec3(vTemp2, 1.0f, -, E1);
vec3opv(vTemp1, vTemp1, *, vTemp2);
- fopvec3(vTemp2, 1.0, / , sunSky->atm_BetaRM);
+ fopvec3(vTemp2, 1.0f, / , sunSky->atm_BetaRM);
vec3opv(I, vTemp1, *, vTemp2);
diff --git a/source/blender/render/intern/source/volume_precache.c b/source/blender/render/intern/source/volume_precache.c
index faa915b7f6c..2037acc943f 100644
--- a/source/blender/render/intern/source/volume_precache.c
+++ b/source/blender/render/intern/source/volume_precache.c
@@ -400,7 +400,7 @@ static void multiple_scattering_diffusion(Render *re, VolumePrecache *vp, Materi
sb[j] += vp->data_b[i];
/* Displays progress every second */
- if(time-lasttime>1.0f) {
+ if(time-lasttime>1.0) {
char str[64];
BLI_snprintf(str, sizeof(str), "Simulating multiple scattering: %d%%", (int)(100.0f * (c / total)));
re->i.infostr= str;
@@ -747,7 +747,7 @@ static void vol_precache_objectinstance_threads(Render *re, ObjectInstanceRen *o
caching=0;
time= PIL_check_seconds_timer();
- if(time-lasttime>1.0f) {
+ if(time-lasttime>1.0) {
char str[64];
BLI_snprintf(str, sizeof(str), "Precaching volume: %d%%", (int)(100.0f * ((float)counter / (float)totparts)));
re->i.infostr= str;
diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c
index 359002d05ae..19bbb11e143 100644
--- a/source/blender/render/intern/source/volumetric.c
+++ b/source/blender/render/intern/source/volumetric.c
@@ -422,9 +422,9 @@ static void vol_get_transmittance_seg(ShadeInput *shi, float *tr, float stepsize
tau[1] += stepd * sigma_t[1];
tau[2] += stepd * sigma_t[2];
- tr[0] *= exp(-tau[0]);
- tr[1] *= exp(-tau[1]);
- tr[2] *= exp(-tau[2]);
+ tr[0] *= expf(-tau[0]);
+ tr[1] *= expf(-tau[1]);
+ tr[2] *= expf(-tau[2]);
}
/* Compute transmittance = e^(-attenuation) */
@@ -473,7 +473,7 @@ static void vol_shade_one_lamp(struct ShadeInput *shi, float *co, LampRen *lar,
if (lar->mode & LA_LAYER) if((lar->lay & shi->obi->lay)==0) return;
if ((lar->lay & shi->lay)==0) return;
- if (lar->energy == 0.0) return;
+ if (lar->energy == 0.0f) return;
if ((visifac= lamp_get_visibility(lar, co, lv, &lampdist)) == 0.f) return;
@@ -613,7 +613,7 @@ static void volumeintegrate(struct ShadeInput *shi, float *col, float *co, float
/* transmittance component (alpha) */
vol_get_transmittance_seg(shi, tr, stepsize, co, density);
- if (t0 > t1 * 0.25) {
+ if (t0 > t1 * 0.25f) {
/* only use depth cutoff after we've traced a little way into the volume */
if (luminance(tr) < shi->mat->vol.depth_cutoff) break;
}
@@ -623,9 +623,9 @@ static void volumeintegrate(struct ShadeInput *shi, float *col, float *co, float
if (shi->obi->volume_precache) {
float p2[3];
- p2[0] = p[0] + (step_vec[0] * 0.5);
- p2[1] = p[1] + (step_vec[1] * 0.5);
- p2[2] = p[2] + (step_vec[2] * 0.5);
+ p2[0] = p[0] + (step_vec[0] * 0.5f);
+ p2[1] = p[1] + (step_vec[1] * 0.5f);
+ p2[2] = p[2] + (step_vec[2] * 0.5f);
vol_get_precached_scattering(&R, shi, scatter_col, p2);
} else
@@ -817,7 +817,7 @@ void shade_volume_inside(ShadeInput *shi, ShadeResult *shr)
volume_trace(shi, shr, VOL_SHADE_INSIDE);
shr->alpha = shr->alpha + prev_alpha;
- CLAMP(shr->alpha, 0.0, 1.0);
+ CLAMP(shr->alpha, 0.0f, 1.0f);
shi->mat = mat_backup;
shi->obi = obi_backup;
diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c
index 232f7fdeede..2ba346ae4c5 100644
--- a/source/blender/render/intern/source/voxeldata.c
+++ b/source/blender/render/intern/source/voxeldata.c
@@ -413,9 +413,9 @@ int voxeldatatex(struct Tex *tex, float *texvec, struct TexResult *texres)
}
case TEX_REPEAT:
{
- co[0] = co[0] - floor(co[0]);
- co[1] = co[1] - floor(co[1]);
- co[2] = co[2] - floor(co[2]);
+ co[0] = co[0] - floorf(co[0]);
+ co[1] = co[1] - floorf(co[1]);
+ co[2] = co[2] - floorf(co[2]);
break;
}
case TEX_EXTEND:
diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c
index 13d9ead79e8..04e4ce2c647 100644
--- a/source/blender/render/intern/source/zbuf.c
+++ b/source/blender/render/intern/source/zbuf.c
@@ -217,24 +217,24 @@ static short cliptestf(float p, float q, float *u1, float *u2)
{
float r;
- if(p<0.0) {
+ if(p<0.0f) {
if(q<p) return 0;
- else if(q<0.0) {
+ else if(q<0.0f) {
r= q/p;
if(r>*u2) return 0;
else if(r>*u1) *u1=r;
}
}
else {
- if(p>0.0) {
- if(q<0.0) return 0;
+ if(p>0.0f) {
+ if(q<0.0f) return 0;
else if(q<p) {
r= q/p;
if(r<*u1) return 0;
else if(r<*u2) *u2=r;
}
}
- else if(q<0.0) return 0;
+ else if(q<0.0f) return 0;
}
return 1;
}
@@ -344,7 +344,7 @@ static void zbuffillAc4(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v2,
y0= z1*x2-x1*z2;
z0= x1*y2-y1*x2;
- if(z0==0.0) return;
+ if(z0==0.0f) return;
xx1= (x0*v1[0] + y0*v1[1])/z0 + v1[2];
@@ -859,8 +859,8 @@ static int clipline(float *v1, float *v2) /* return 0: do not draw */
if(cliptestf(dz-dw, v1[3]-v1[2], &u1,&u2)) {
dx= v2[0]-v1[0];
- dz= 1.01*(v2[3]-v1[3]);
- v13= 1.01*v1[3];
+ dz= 1.01f*(v2[3]-v1[3]);
+ v13= 1.01f*v1[3];
if(cliptestf(-dx-dz, v1[0]+v13, &u1,&u2)) {
if(cliptestf(dx-dz, v13-v1[0], &u1,&u2)) {
@@ -870,13 +870,13 @@ static int clipline(float *v1, float *v2) /* return 0: do not draw */
if(cliptestf(-dy-dz, v1[1]+v13, &u1,&u2)) {
if(cliptestf(dy-dz, v13-v1[1], &u1,&u2)) {
- if(u2<1.0) {
+ if(u2<1.0f) {
v2[0]= v1[0]+u2*dx;
v2[1]= v1[1]+u2*dy;
v2[2]= v1[2]+u2*dz;
v2[3]= v1[3]+u2*dw;
}
- if(u1>0.0) {
+ if(u1>0.0f) {
v1[0]= v1[0]+u1*dx;
v1[1]= v1[1]+u1*dy;
v1[2]= v1[2]+u1*dz;
@@ -898,8 +898,8 @@ void hoco_to_zco(ZSpan *zspan, float *zco, float *hoco)
float div;
div= 1.0f/hoco[3];
- zco[0]= zspan->zmulx*(1.0+hoco[0]*div) + zspan->zofsx;
- zco[1]= zspan->zmuly*(1.0+hoco[1]*div) + zspan->zofsy;
+ zco[0]= zspan->zmulx*(1.0f+hoco[0]*div) + zspan->zofsx;
+ zco[1]= zspan->zmuly*(1.0f+hoco[1]*div) + zspan->zofsy;
zco[2]= 0x7FFFFFFF *(hoco[2]*div);
}
@@ -1083,7 +1083,7 @@ static void zbuffillGLinv4(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v
y0= z1*x2-x1*z2;
z0= x1*y2-y1*x2;
- if(z0==0.0) return;
+ if(z0==0.0f) return;
xx1= (x0*v1[0] + y0*v1[1])/z0 + v1[2];
@@ -1203,7 +1203,7 @@ static void zbuffillGL4(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v2,
y0= z1*x2-x1*z2;
z0= x1*y2-y1*x2;
- if(z0==0.0) return;
+ if(z0==0.0f) return;
xx1= (x0*v1[0] + y0*v1[1])/z0 + v1[2];
@@ -1330,7 +1330,7 @@ static void zbuffillGL_onlyZ(ZSpan *zspan, int UNUSED(obi), int UNUSED(zvlnr), f
y0= z1*x2-x1*z2;
z0= x1*y2-y1*x2;
- if(z0==0.0) return;
+ if(z0==0.0f) return;
xx1= (x0*v1[0] + y0*v1[1])/z0 + v1[2];
@@ -1627,12 +1627,12 @@ static void clippyra(float *labda, float *v1, float *v2, int *b2, int *b3, int a
if(cliptestf(-da-dw, v13+v1[a], &u1,&u2)) {
if(cliptestf(da-dw, v13-v1[a], &u1,&u2)) {
*b3=1;
- if(u2<1.0) {
+ if(u2<1.0f) {
labda[1]= u2;
*b2=1;
}
else labda[1]=1.0; /* u2 */
- if(u1>0.0) {
+ if(u1>0.0f) {
labda[0]= u1;
*b2=1;
} else labda[0]=0.0;
@@ -1662,8 +1662,8 @@ static void makevertpyra(float *vez, float *labda, float **trias, float *v1, flo
l1= labda[0];
l2= labda[1];
- if(l1!= -1.0) {
- if(l1!= 0.0) {
+ if(l1!= -1.0f) {
+ if(l1!= 0.0f) {
adr= vez+4*(*clve);
trias[*b1]=adr;
(*clve)++;
@@ -1676,8 +1676,8 @@ static void makevertpyra(float *vez, float *labda, float **trias, float *v1, flo
(*b1)++;
}
- if(l2!= -1.0) {
- if(l2!= 1.0) {
+ if(l2!= -1.0f) {
+ if(l2!= 1.0f) {
adr= vez+4*(*clve);
trias[*b1]=adr;
(*clve)++;
@@ -2066,8 +2066,8 @@ void zbuffer_solid(RenderPart *pa, RenderLayer *rl, void(*fillfunc)(RenderPart*,
zbuf_alloc_span(zspan, pa->rectx, pa->recty, R.clipcrop);
/* needed for transform from hoco to zbuffer co */
- zspan->zmulx= ((float)R.winx)/2.0;
- zspan->zmuly= ((float)R.winy)/2.0;
+ zspan->zmulx= ((float)R.winx)/2.0f;
+ zspan->zmuly= ((float)R.winy)/2.0f;
if(R.osa) {
zspan->zofsx= -pa->disprect.xmin - R.jit[pa->sample+zsample][0];
@@ -2290,8 +2290,8 @@ void zbuffer_shadow(Render *re, float winmat[][4], LampRen *lar, int *rectz, int
/* 1.0f for clipping in clippyra()... bad stuff actually */
zbuf_alloc_span(&zspan, size, size, 1.0f);
- zspan.zmulx= ((float)size)/2.0;
- zspan.zmuly= ((float)size)/2.0;
+ zspan.zmulx= ((float)size)/2.0f;
+ zspan.zmuly= ((float)size)/2.0f;
/* -0.5f to center the sample position */
zspan.zofsx= jitx - 0.5f;
zspan.zofsy= jity - 0.5f;
@@ -2527,8 +2527,8 @@ void zbuffer_sss(RenderPart *pa, unsigned int lay, void *handle, void (*func)(vo
zspan.sss_func= func;
/* needed for transform from hoco to zbuffer co */
- zspan.zmulx= ((float)R.winx)/2.0;
- zspan.zmuly= ((float)R.winy)/2.0;
+ zspan.zmulx= ((float)R.winx)/2.0f;
+ zspan.zmuly= ((float)R.winy)/2.0f;
/* -0.5f to center the sample position */
zspan.zofsx= -pa->disprect.xmin - 0.5f;
@@ -2671,7 +2671,7 @@ static void zbuf_fill_in_rgba(ZSpan *zspan, DrawBufPixel *col, float *v1, float
y0= z1*x2-x1*z2;
z0= x1*y2-y1*x2;
- if(z0==0.0) return;
+ if(z0==0.0f) return;
xx1= (x0*v1[0] + y0*v1[1])/z0 + v1[2];
@@ -2840,8 +2840,8 @@ static void quad_bezier_2d(float *result, float *v1, float *v2, float *ipodata)
p1[1]= v1[1];
/* official formula 2*p2 - .5*p1 - .5*p3 */
- p2[0]= -0.5*p1[0] - 0.5*p3[0];
- p2[1]= -0.5*p1[1] - 0.5*p3[1];
+ p2[0]= -0.5f*p1[0] - 0.5f*p3[0];
+ p2[1]= -0.5f*p1[1] - 0.5f*p3[1];
result[0]= ipodata[0]*p1[0] + ipodata[1]*p2[0] + ipodata[2]*p3[0];
result[1]= ipodata[0]*p1[1] + ipodata[1]*p2[1] + ipodata[2]*p3[1];
@@ -2871,8 +2871,8 @@ void RE_zbuf_accumulate_vecblur(NodeBlurData *nbd, int xsize, int ysize, float *
char *rectmove, *dm;
zbuf_alloc_span(&zspan, xsize, ysize, 1.0f);
- zspan.zmulx= ((float)xsize)/2.0;
- zspan.zmuly= ((float)ysize)/2.0;
+ zspan.zmulx= ((float)xsize)/2.0f;
+ zspan.zmuly= ((float)ysize)/2.0f;
zspan.zofsx= 0.0f;
zspan.zofsy= 0.0f;
@@ -3258,8 +3258,8 @@ static int zbuffer_abuf(Render *re, RenderPart *pa, APixstr *APixbuf, ListBase *
zbuf_alloc_span(zspan, pa->rectx, pa->recty, re->clipcrop);
/* needed for transform from hoco to zbuffer co */
- zspan->zmulx= ((float)winx)/2.0;
- zspan->zmuly= ((float)winy)/2.0;
+ zspan->zmulx= ((float)winx)/2.0f;
+ zspan->zmuly= ((float)winy)/2.0f;
/* the buffers */
zspan->arectz= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "Arectz");
@@ -3344,15 +3344,15 @@ static int zbuffer_abuf(Render *re, RenderPart *pa, APixstr *APixbuf, ListBase *
if(partclip==0) {
/* a little advantage for transp rendering (a z offset) */
- if(!shadow && ma->zoffs != 0.0) {
+ if(!shadow && ma->zoffs != 0.0f) {
mul= 0x7FFFFFFF;
- zval= mul*(1.0+ho1[2]/ho1[3]);
+ zval= mul*(1.0f+ho1[2]/ho1[3]);
VECCOPY(vec, v1->co);
/* z is negative, otherwise its being clipped */
vec[2]-= ma->zoffs;
projectverto(vec, obwinmat, hoco);
- fval= mul*(1.0+hoco[2]/hoco[3]);
+ fval= mul*(1.0f+hoco[2]/hoco[3]);
polygon_offset= (int) fabs(zval - fval );
}
@@ -4240,7 +4240,3 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas
/* end of zbuf.c */
-
-
-
-