diff options
author | Ton Roosendaal <ton@blender.org> | 2004-10-16 15:29:09 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2004-10-16 15:29:09 +0400 |
commit | 063982914038ecd578bab7849a1e94cccbb8d8b9 (patch) | |
tree | 5db85fe1f0adb526d18d1376b24d87e39ca177db | |
parent | e8b41d139c9fd3bc34d60bb11af785baeefa6efb (diff) |
Fix for #1549
This was something users found since tracing got into blender, having
sometimes small 'dots' or bright pixels or missing reflection rays in
an image. Thanks to the very simple sample file I could disect it...
it appeared to be an incomplete check for all numerical exceptions when
you traverse the octree nodes. Very technical, but clear comments are in
the code to explain ;)
-rw-r--r-- | source/blender/render/intern/source/ray.c | 90 | ||||
-rw-r--r-- | source/blender/render/intern/source/rendercore.c | 13 |
2 files changed, 55 insertions, 48 deletions
diff --git a/source/blender/render/intern/source/ray.c b/source/blender/render/intern/source/ray.c index f600c3d7f29..4482ed31ef6 100644 --- a/source/blender/render/intern/source/ray.c +++ b/source/blender/render/intern/source/ray.c @@ -1144,7 +1144,7 @@ static int d3dda(Isect *is) else { static int coh_ocx1,coh_ocx2,coh_ocy1, coh_ocy2,coh_ocz1,coh_ocz2; float dox, doy, doz; - int coherent=1, nodecount=0; + int coherent=1, nodecount=0, eqval; /* check coherence; coh_test: 0=don't, 1=check @@ -1238,46 +1238,62 @@ static int d3dda(Isect *is) } labdao= ddalabda; - - if(labdax<labday) { - if(labday<labdaz) { - xo+=dx; - labdax+=ldx; - } else if(labdax<labdaz) { - xo+=dx; - labdax+=ldx; - } else { - zo+=dz; - labdaz+=ldz; - if(labdax==labdaz) { - xo+=dx; - labdax+=ldx; + + /* traversing ocree nodes need careful detection of smallest values, with proper + exceptions for equal labdas */ + eqval= (labdax==labday); + if(labday==labdaz) eqval += 2; + if(labdax==labdaz) eqval += 4; + + if(eqval) { // only 4 cases exist! + if(eqval==7) { // x=y=z + xo+=dx; labdax+=ldx; + yo+=dy; labday+=ldy; + zo+=dz; labdaz+=ldz; + } + else if(eqval==1) { // x=y + if(labday < labdaz) { + xo+=dx; labdax+=ldx; + yo+=dy; labday+=ldy; + } + else { + zo+=dz; labdaz+=ldz; } } - } else if(labdax<labdaz) { - yo+=dy; - labday+=ldy; - if(labday==labdax) { - xo+=dx; - labdax+=ldx; + else if(eqval==2) { // y=z + if(labdax < labday) { + xo+=dx; labdax+=ldx; + } + else { + yo+=dy; labday+=ldy; + zo+=dz; labdaz+=ldz; + } } - } else if(labday<labdaz) { - yo+=dy; - labday+=ldy; - } else if(labday<labdax) { - zo+=dz; - labdaz+=ldz; - if(labdaz==labday) { - yo+=dy; - labday+=ldy; + else { // x=z + if(labday < labdax) { + yo+=dy; labday+=ldy; + } + else { + xo+=dx; labdax+=ldx; + zo+=dz; labdaz+=ldz; + } } - } else { - xo+=dx; - labdax+=ldx; - yo+=dy; - labday+=ldy; - zo+=dz; - labdaz+=ldz; + } + else { // all three different, just three cases exist + eqval= (labdax<labday); + if(labday<labdaz) eqval += 2; + if(labdax<labdaz) eqval += 4; + + if(eqval==7 || eqval==5) { // x smallest + xo+=dx; labdax+=ldx; + } + else if(eqval==2 || eqval==6) { // y smallest + yo+=dy; labday+=ldy; + } + else { // z smallest + zo+=dz; labdaz+=ldz; + } + } ddalabda=MIN3(labdax,labday,labdaz); diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index eeeb96a62e9..9abb9fcd83f 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -1643,7 +1643,7 @@ void shade_color(ShadeInput *shi, ShadeResult *shr) } if(ma->mode & (MA_ZTRA|MA_RAYTRANSP)) { - if(ma->fresnel_tra!=1.0) + if(ma->fresnel_tra!=0.0) ma->alpha*= fresnel_fac(shi->view, shi->vn, ma->fresnel_tra_i, ma->fresnel_tra); } @@ -2239,21 +2239,15 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) if(i>0.0 && !(lar->mode & LA_NO_DIFF)) { if(ma->mode & MA_SHADOW_TRA) { add_to_diffuse(shr->diff, shi, is, i*shadfac[0]*lar->r, i*shadfac[1]*lar->g, i*shadfac[2]*lar->b); - //shr->diff[0]+= i*shadfac[0]*lar->r; - //shr->diff[1]+= i*shadfac[1]*lar->g; - //shr->diff[2]+= i*shadfac[2]*lar->b; } else { add_to_diffuse(shr->diff, shi, is, i*lar->r, i*lar->g, i*lar->b); - //shr->diff[0]+= i*lar->r; - //shr->diff[1]+= i*lar->g; - //shr->diff[2]+= i*lar->b; } } } if(ma->mode & (MA_ZTRA|MA_RAYTRANSP)) { - if(ma->fresnel_tra!=1.0) + if(ma->fresnel_tra!=0.0) ma->alpha*= fresnel_fac(shi->view, shi->vn, ma->fresnel_tra_i, ma->fresnel_tra); if(ma->spectra!=0.0) { @@ -2272,17 +2266,14 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) if(shr->spec[2]<0.0) shr->spec[2]= 0.0; shr->diff[0]+= ma->r*ma->amb*shi->rad[0]; - //shr->diff[0]*= ma->r; shr->diff[0]+= ma->ambr; if(shr->diff[0]<0.0) shr->diff[0]= 0.0; shr->diff[1]+= ma->g*ma->amb*shi->rad[1]; - //shr->diff[1]*= ma->g; shr->diff[1]+= ma->ambg; if(shr->diff[1]<0.0) shr->diff[1]= 0.0; shr->diff[2]+= ma->b*ma->amb*shi->rad[2]; - //shr->diff[2]*= ma->b; shr->diff[2]+= ma->ambb; if(shr->diff[2]<0.0) shr->diff[2]= 0.0; |