SunSky didn't include skycolor in raytrace.
Note: there seems to be  an error in sunsky when looking straight down, 
so this option requires raytracing stuff not in outer space. :)
This commit is contained in:
Ton Roosendaal 2008-09-29 17:55:11 +00:00
parent a1513a8c0f
commit 6deea1a5d7
3 changed files with 36 additions and 35 deletions

@ -56,7 +56,7 @@ int shadeHaloFloat(HaloRen *har,
void shadeSkyPixel(float *collector, float fx, float fy);
void shadeSkyView(float *colf, float *rco, float *view, float *dxyview);
void shadeAtmPixel(struct SunSky *sunsky, float *collector, float fx, float fy, float distance);
void shadeSunView(float *colf, float *view);
/* ------------------------------------------------------------------------- */
#endif

@ -570,27 +570,37 @@ void shadeSkyView(float *colf, float *rco, float *view, float *dxyview)
}
/* shade sky according to sun lamps, all parameters are like shadeSkyView except sunsky*/
void shadeSunView(struct SunSky *sunsky, float *colf, float *rco, float *view, float *dxyview)
void shadeSunView(float *colf, float *view)
{
float colorxyz[3];
/**
sunAngle = sqrt(sunsky->sunSolidAngle / M_PI);
sunDir[0] = sunsky->toSun[0];
sunDir[1] = sunsky->toSun[1];
sunDir[2] = sunsky->toSun[2];
*/
Normalize(view);
MTC_Mat3MulVecfl(R.imat, view);
if (view[2] < 0.0)
view[2] = 0.0;
Normalize(view);
GroupObject *go;
LampRen *lar;
float sview[3];
int do_init= 1;
GetSkyXYZRadiancef(sunsky, view, colorxyz);
xyz_to_rgb(colorxyz[0], colorxyz[1], colorxyz[2], &colf[0], &colf[1], &colf[2], sunsky->sky_colorspace);
for(go=R.lights.first; go; go= go->next) {
lar= go->lampren;
if(lar->type==LA_SUN && lar->sunsky && (lar->sunsky->effect_type & LA_SUN_EFFECT_SKY)){
float sun_collector[3];
float colorxyz[3];
if(do_init) {
VECCOPY(sview, view);
Normalize(sview);
MTC_Mat3MulVecfl(R.imat, sview);
if (sview[2] < 0.0)
sview[2] = 0.0;
Normalize(sview);
do_init= 0;
}
GetSkyXYZRadiancef(lar->sunsky, sview, colorxyz);
xyz_to_rgb(colorxyz[0], colorxyz[1], colorxyz[2], &sun_collector[0], &sun_collector[1], &sun_collector[2],
lar->sunsky->sky_colorspace);
ramp_blend(lar->sunsky->skyblendtype, colf, colf+1, colf+2, lar->sunsky->skyblendfac, sun_collector);
}
}
}
@ -599,8 +609,6 @@ void shadeSunView(struct SunSky *sunsky, float *colf, float *rco, float *view, f
*/
void shadeSkyPixel(float *collector, float fx, float fy)
{
GroupObject *go;
LampRen *lar;
float view[3], dxyview[2];
/*
@ -648,19 +656,9 @@ void shadeSkyPixel(float *collector, float fx, float fy)
shadeSkyView(collector, NULL, view, dxyview);
collector[3] = 0.0f;
}
for(go=R.lights.first; go; go= go->next) {
lar= go->lampren;
if(lar->type==LA_SUN && lar->sunsky && (lar->sunsky->effect_type & LA_SUN_EFFECT_SKY)){
float sun_collector[3];
calc_view_vector(view, fx, fy);
Normalize(view);
shadeSunView(lar->sunsky, sun_collector, NULL, view, NULL);
ramp_blend(lar->sunsky->skyblendtype, collector, collector+1, collector+2, lar->sunsky->skyblendfac, sun_collector);
}
}
calc_view_vector(view, fx, fy);
shadeSunView(collector, view);
}
/* aerial perspective */

@ -397,6 +397,7 @@ static void ray_fadeout_endcolor(float *col, ShadeInput *origshi, ShadeInput *sh
Normalize(shi->view);
shadeSkyView(col, isec->start, shi->view, NULL);
shadeSunView(col, shi->view);
}
}
@ -1627,6 +1628,7 @@ static void ray_ao_qmc(ShadeInput *shi, float *shadfac)
}
else { /* WO_AOSKYTEX */
shadeSkyView(skycol, isec.start, view, dxyview);
shadeSunView(skycol, shi->view);
shadfac[0]+= skycol[0];
shadfac[1]+= skycol[1];
shadfac[2]+= skycol[2];
@ -1751,6 +1753,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float *shadfac)
}
else { /* WO_AOSKYTEX */
shadeSkyView(skycol, isec.start, view, dxyview);
shadeSunView(skycol, shi->view);
shadfac[0]+= skycol[0];
shadfac[1]+= skycol[1];
shadfac[2]+= skycol[2];