From 6deea1a5d78ffed8662af44e9405737bc8e837b1 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Mon, 29 Sep 2008 17:55:11 +0000 Subject: Bugfix #17711 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. :) --- .../blender/render/intern/include/pixelshading.h | 2 +- source/blender/render/intern/source/pixelshading.c | 64 +++++++++++----------- source/blender/render/intern/source/rayshade.c | 3 + 3 files changed, 35 insertions(+), 34 deletions(-) (limited to 'source/blender/render') diff --git a/source/blender/render/intern/include/pixelshading.h b/source/blender/render/intern/include/pixelshading.h index 15d696df89d..c6b11b4af9a 100644 --- a/source/blender/render/intern/include/pixelshading.h +++ b/source/blender/render/intern/include/pixelshading.h @@ -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 diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c index a13829d0306..60723963af9 100644 --- a/source/blender/render/intern/source/pixelshading.c +++ b/source/blender/render/intern/source/pixelshading.c @@ -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]; + GroupObject *go; + LampRen *lar; + float sview[3]; + int do_init= 1; + + 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]; - /** - sunAngle = sqrt(sunsky->sunSolidAngle / M_PI); - - sunDir[0] = sunsky->toSun[0]; - sunDir[1] = sunsky->toSun[1]; - sunDir[2] = sunsky->toSun[2]; - */ + 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; + } - Normalize(view); - MTC_Mat3MulVecfl(R.imat, view); - if (view[2] < 0.0) - view[2] = 0.0; - Normalize(view); - - GetSkyXYZRadiancef(sunsky, view, colorxyz); - - xyz_to_rgb(colorxyz[0], colorxyz[1], colorxyz[2], &colf[0], &colf[1], &colf[2], sunsky->sky_colorspace); + 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 */ diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index 48ae84379ba..9d457e7f0fc 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -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]; -- cgit v1.2.3