Bugfix 5182

Mist option and "Ray Transp" didn't work together yet. Transparency
during tracing should not be influenced with mist though (as is for
Ztransp), so for this case an extra color blending after raytrace is
added. Still pretty primitive... mostly because mist isn't volumetric
in Blender at all... just an alpha trick.
This commit is contained in:
2006-11-13 14:33:36 +00:00
parent 6c941bb3e1
commit d43ca75b8a

View File

@@ -160,7 +160,8 @@ static void fogcolor(float *colf, float *rco, float *view)
}
#endif
float mistfactor(float zcor, float *co) /* dist en height, return alpha */
/* zcor is distance, co the 3d coordinate in eye space, return alpha */
float mistfactor(float zcor, float *co)
{
float fac, hi;
@@ -2676,16 +2677,27 @@ void *shadepixel(ShadePixelInfo *shpi, float x, float y, int z, volatile int fac
if(shr->alpha!=1.0 || alpha!=1.0) {
if(shi.mat->mode & MA_RAYTRANSP) {
fac= alpha;
shr->combined[3]= shr->alpha;
if(alpha!=1.0) {
/* sky is already included in tracing, no useful alpha here, so we blend in shaded color with sky */
float col[4], malpha;
shadeSkyPixelFloat(col, shi.co, shi.view, NULL);
malpha= 1.0f-alpha;
shr->combined[0]= alpha*shr->combined[0] + malpha*col[0];
shr->combined[1]= alpha*shr->combined[1] + malpha*col[1];
shr->combined[2]= alpha*shr->combined[2] + malpha*col[2];
}
}
else {
fac= alpha*(shr->alpha);
shr->combined[3]= fac;
}
shr->combined[0]*= fac;
shr->combined[1]*= fac;
shr->combined[2]*= fac;
shr->combined[0]*= fac;
shr->combined[1]*= fac;
shr->combined[2]*= fac;
}
}
else shr->combined[3]= 1.0;
}