Revision: 16826 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16826 Author: ton Date: 2008-09-29 19:03:24 +0200 (Mon, 29 Sep 2008)
Log Message: ----------- Updated color calculus for sunsky - removed ugly clamping function (it was dividing XYZ based on max of one of the values) - added option to use Exposure, this only works for brightness (Y). results look very pleasant, foggy and hazy results are possible. with exposre==0, no exposure happens for HDR extreme range skies, this is how yafray rendered it. - added menu for choosing color spaces (CIE = modern lcds) Please review! (and yes i know it's still not in World :) Modified Paths: -------------- trunk/blender/source/blender/blenkernel/BKE_blender.h trunk/blender/source/blender/blenkernel/intern/object.c trunk/blender/source/blender/blenloader/intern/readfile.c trunk/blender/source/blender/makesdna/DNA_lamp_types.h trunk/blender/source/blender/render/intern/include/sunsky.h trunk/blender/source/blender/render/intern/source/convertblender.c trunk/blender/source/blender/render/intern/source/pixelshading.c trunk/blender/source/blender/render/intern/source/sunsky.c trunk/blender/source/blender/src/buttons_shading.c Modified: trunk/blender/source/blender/blenkernel/BKE_blender.h =================================================================== --- trunk/blender/source/blender/blenkernel/BKE_blender.h 2008-09-29 15:50:50 UTC (rev 16825) +++ trunk/blender/source/blender/blenkernel/BKE_blender.h 2008-09-29 17:03:24 UTC (rev 16826) @@ -41,7 +41,7 @@ struct MemFile; #define BLENDER_VERSION 247 -#define BLENDER_SUBVERSION 8 +#define BLENDER_SUBVERSION 9 #define BLENDER_MINVERSION 245 #define BLENDER_MINSUBVERSION 15 Modified: trunk/blender/source/blender/blenkernel/intern/object.c =================================================================== --- trunk/blender/source/blender/blenkernel/intern/object.c 2008-09-29 15:50:50 UTC (rev 16825) +++ trunk/blender/source/blender/blenkernel/intern/object.c 2008-09-29 17:03:24 UTC (rev 16826) @@ -758,7 +758,9 @@ la->sun_intensity = 1.0; la->skyblendtype= MA_RAMP_ADD; la->skyblendfac= 1.0f; - + la->sky_colorspace= BLI_CS_CIE; + la->sky_exposure= 1.0f; + curvemapping_initialize(la->curfalloff); return la; } Modified: trunk/blender/source/blender/blenloader/intern/readfile.c =================================================================== --- trunk/blender/source/blender/blenloader/intern/readfile.c 2008-09-29 15:50:50 UTC (rev 16825) +++ trunk/blender/source/blender/blenloader/intern/readfile.c 2008-09-29 17:03:24 UTC (rev 16826) @@ -7920,6 +7920,15 @@ } } + if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 9)) { + Lamp *la= main->lamp.first; + for(; la; la= la->id.next) { + la->sky_exposure= 1.0f; + } + } + + + /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ /* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */ Modified: trunk/blender/source/blender/makesdna/DNA_lamp_types.h =================================================================== --- trunk/blender/source/blender/makesdna/DNA_lamp_types.h 2008-09-29 15:50:50 UTC (rev 16825) +++ trunk/blender/source/blender/makesdna/DNA_lamp_types.h 2008-09-29 17:03:24 UTC (rev 16826) @@ -91,7 +91,9 @@ float atm_extinction_factor; float atm_distance_factor; float skyblendfac; - + float sky_exposure; + short sky_colorspace, pad4; + /* yafray: photonlight params */ int YF_numphotons, YF_numsearch; short YF_phdepth, YF_useqmc, YF_bufsize, YF_pad; Modified: trunk/blender/source/blender/render/intern/include/sunsky.h =================================================================== --- trunk/blender/source/blender/render/intern/include/sunsky.h 2008-09-29 15:50:50 UTC (rev 16825) +++ trunk/blender/source/blender/render/intern/include/sunsky.h 2008-09-29 17:03:24 UTC (rev 16826) @@ -33,7 +33,7 @@ typedef struct SunSky { - short effect_type, skyblendtype; + short effect_type, skyblendtype, sky_colorspace; float turbidity; float theta, phi; @@ -54,6 +54,7 @@ float sun_size; float backscattered_light; float skyblendfac; + float sky_exposure; float atm_HGg; @@ -86,7 +87,7 @@ * */ void InitSunSky(struct SunSky *sunsky, float turb, float *toSun, float horizon_brightness, float spread,float sun_brightness, float sun_size, float back_scatter, - float skyblendfac, short skyblendtype); + float skyblendfac, short skyblendtype, float sky_exposure, float sky_colorspace); /** * GetSkyXYZRadiance: Modified: trunk/blender/source/blender/render/intern/source/convertblender.c =================================================================== --- trunk/blender/source/blender/render/intern/source/convertblender.c 2008-09-29 15:50:50 UTC (rev 16825) +++ trunk/blender/source/blender/render/intern/source/convertblender.c 2008-09-29 17:03:24 UTC (rev 16826) @@ -3528,7 +3528,7 @@ InitSunSky(lar->sunsky, la->atm_turbidity, vec, la->horizon_brightness, la->spread, la->sun_brightness, la->sun_size, la->backscattered_light, - la->skyblendfac, la->skyblendtype); + la->skyblendfac, la->skyblendtype, la->sky_exposure, la->sky_colorspace); InitAtmosphere(lar->sunsky, la->sun_intensity, 1.0, 1.0, la->atm_inscattering_factor, la->atm_extinction_factor, la->atm_distance_factor); Modified: trunk/blender/source/blender/render/intern/source/pixelshading.c =================================================================== --- trunk/blender/source/blender/render/intern/source/pixelshading.c 2008-09-29 15:50:50 UTC (rev 16825) +++ trunk/blender/source/blender/render/intern/source/pixelshading.c 2008-09-29 17:03:24 UTC (rev 16826) @@ -573,7 +573,6 @@ void shadeSunView(struct SunSky *sunsky, float *colf, float *rco, float *view, float *dxyview) { float colorxyz[3]; - float scale; /** sunAngle = sqrt(sunsky->sunSolidAngle / M_PI); @@ -588,15 +587,10 @@ if (view[2] < 0.0) view[2] = 0.0; Normalize(view); + GetSkyXYZRadiancef(sunsky, view, colorxyz); - scale = MAX3(colorxyz[0], colorxyz[1], colorxyz[2]); - colorxyz[0] /= scale; - colorxyz[1] /= scale; - colorxyz[2] /= scale; - xyz_to_rgb(colorxyz[0], colorxyz[1], colorxyz[2], &colf[0], &colf[1], &colf[2], BLI_CS_SMPTE); - - ClipColor(colf); + xyz_to_rgb(colorxyz[0], colorxyz[1], colorxyz[2], &colf[0], &colf[1], &colf[2], sunsky->sky_colorspace); } Modified: trunk/blender/source/blender/render/intern/source/sunsky.c =================================================================== --- trunk/blender/source/blender/render/intern/source/sunsky.c 2008-09-29 15:50:50 UTC (rev 16825) +++ trunk/blender/source/blender/render/intern/source/sunsky.c 2008-09-29 17:03:24 UTC (rev 16826) @@ -22,8 +22,8 @@ #include "sunsky.h" #include "math.h" #include "BLI_arithb.h" +#include "BKE_global.h" - /** * These macros are defined for vector operations * */ @@ -111,16 +111,15 @@ float PerezFunction(struct SunSky *sunsky, const float *lam, float theta, float gamma, float lvz) { 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))); - + (1 + lam[2] * exp(lam[3] * sunsky->theta) + lam[4] * cos(sunsky->theta) * cos(sunsky->theta))); + num = ((1 + lam[0] * exp(lam[1] / cos(theta))) * - (1 + lam[2] * exp(lam[3] * gamma) + lam[4] * cos(gamma) * cos(gamma))); + (1 + lam[2] * exp(lam[3] * gamma) + lam[4] * cos(gamma) * cos(gamma))); + + return(lvz * num / den);} - return(lvz * num / den); -} - /** * InitSunSky: * this function compute some sun,sky parameters according to input parameters and also initiate some other sun, sky parameters @@ -136,7 +135,7 @@ * */ void InitSunSky(struct SunSky *sunsky, float turb, float *toSun, float horizon_brightness, float spread,float sun_brightness, float sun_size, float back_scatter, - float skyblendfac, short skyblendtype) + float skyblendfac, short skyblendtype, float sky_exposure, float sky_colorspace) { float theta2; @@ -154,6 +153,8 @@ sunsky->backscattered_light = back_scatter; sunsky->skyblendfac= skyblendfac; sunsky->skyblendtype= skyblendtype; + sunsky->sky_exposure= -sky_exposure; + sunsky->sky_colorspace= sky_colorspace; sunsky->toSun[0] = toSun[0]; sunsky->toSun[1] = toSun[1]; @@ -262,8 +263,11 @@ // 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 = nfade * hfade * 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); + if(sunsky->sky_exposure!=0.0f) + Y = 1.0 - exp(Y*sunsky->sky_exposure); + X = (x / y) * Y; Z = ((1 - x - y) / y) * Y; Modified: trunk/blender/source/blender/src/buttons_shading.c =================================================================== --- trunk/blender/source/blender/src/buttons_shading.c 2008-09-29 15:50:50 UTC (rev 16825) +++ trunk/blender/source/blender/src/buttons_shading.c 2008-09-29 17:03:24 UTC (rev 16826) @@ -2892,23 +2892,29 @@ uiDefButS(block, MENU, B_LAMPPRV, "Mix %x0|Add %x1|Subtract %x3|Multiply %x2|Screen %x4|Overlay %x9|Divide %x5|Difference %x6|Darken %x7|Lighten %x8|Dodge %x10|Burn %x11|Color %x15|Value %x14|Saturation %x13|Hue %x12", 10,y-25,BUTW2/2,19, &la->skyblendtype, 0.0f, 0.0f, 0, 0, "Blend type for how it gets combined with sky"); - uiDefButF(block, NUM, B_LAMPPRV, "",10+BUTW2/2,y-25,BUTW2/2,19, &(la->skyblendfac), 0.0f, 1.0f, 10, 0, "Sets blending factor with sky color"); - uiBlockEndAlign(block); + uiDefButF(block, NUM, B_LAMPPRV, "",10+BUTW2/2,y-25,BUTW2/2,19, &(la->skyblendfac), 0.0f, 2.0f, 10, 0, "Sets blending factor with sky color"); - y -= 25; - uiDefButF(block, NUM, B_LAMPPRV, "Hor.Bright:",10,y-25,BUTW2,19, &(la->horizon_brightness), 0.00f, 20.00f, 10, 0, "Sets horizon brightness."); - uiDefButF(block, NUM, B_LAMPPRV, "Hor.Spread:",10,y-50,BUTW2,19, &(la->spread), 0.00f, 10.00f, 10, 0, "Sets horizon spread."); - uiDefButF(block, NUM, B_LAMPPRV, "Sun Bright:",10,y-75,BUTW2,19, &(la->sun_brightness), 0.00f, 10.0f, 10, 0, "Sets sun brightness."); - uiDefButF(block, NUM, B_LAMPPRV, "Sun Size:",10,y-100,BUTW2,19, &(la->sun_size), 0.00f, 10.00f, 10, 0, "Sets sun size."); - uiDefButF(block, NUM, B_LAMPPRV, "Back Light:",10,y-125,BUTW2,19, &(la->backscattered_light), -1.00f, 1.00f, 10, 0, "Sets backscatter light."); + uiBlockBeginAlign(block); + uiDefButS(block, MENU, B_LAMPPRV, "SMPTE %x0|REC709 %x1|CIE %x2", + 10,126,60,22, &la->sky_colorspace, 0.0f, 0.0f, 0, 0, "Color space"); + + uiDefButF(block, NUM, B_LAMPPRV, "Exp:",70,126,BUTW2-60,22, &(la->sky_exposure), 0.00f, 20.00f, 10, 0, "Exposure correction, zero is no correction."); + + uiBlockBeginAlign(block); + uiDefButF(block, NUM, B_LAMPPRV, "Hor.Bright:",10,98,BUTW2,22, &(la->horizon_brightness), 0.00f, 20.00f, 10, 0, "Sets horizon brightness."); + uiDefButF(block, NUM, B_LAMPPRV, "Hor.Spread:",10,76,BUTW2,22, &(la->spread), 0.00f, 10.00f, 10, 0, "Sets horizon spread."); + uiDefButF(block, NUM, B_LAMPPRV, "Sun Bright:",10,54,BUTW2,22, &(la->sun_brightness), 0.00f, 10.0f, 10, 0, "Sets sun brightness."); + uiDefButF(block, NUM, B_LAMPPRV, "Sun Size:",10,32,BUTW2,22, &(la->sun_size), 0.00f, 10.00f, 10, 0, "Sets sun size."); @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs