Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2008-09-29 21:03:24 +0400
committerTon Roosendaal <ton@blender.org>2008-09-29 21:03:24 +0400
commit7ebeceb399002076106333202ec59483fc3ed4ba (patch)
tree0a457468afdc834467eed8ba7e96a2f7c27b44f9 /source/blender/render
parent4fbacd671756c435f503149a28c6b44d25e795e4 (diff)
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 :)
Diffstat (limited to 'source/blender/render')
-rw-r--r--source/blender/render/intern/include/sunsky.h5
-rw-r--r--source/blender/render/intern/source/convertblender.c2
-rw-r--r--source/blender/render/intern/source/pixelshading.c10
-rw-r--r--source/blender/render/intern/source/sunsky.c24
4 files changed, 20 insertions, 21 deletions
diff --git a/source/blender/render/intern/include/sunsky.h b/source/blender/render/intern/include/sunsky.h
index c5e547097d2..f61338bcf27 100644
--- a/source/blender/render/intern/include/sunsky.h
+++ b/source/blender/render/intern/include/sunsky.h
@@ -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 @@ typedef struct SunSky
float sun_size;
float backscattered_light;
float skyblendfac;
+ float sky_exposure;
float atm_HGg;
@@ -86,7 +87,7 @@ typedef struct SunSky
* */
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:
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
index aba96fae1c2..4af6bf6f543 100644
--- a/source/blender/render/intern/source/convertblender.c
+++ b/source/blender/render/intern/source/convertblender.c
@@ -3528,7 +3528,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob)
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);
diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c
index 9551a7b3227..a13829d0306 100644
--- a/source/blender/render/intern/source/pixelshading.c
+++ b/source/blender/render/intern/source/pixelshading.c
@@ -573,7 +573,6 @@ void shadeSkyView(float *colf, float *rco, float *view, float *dxyview)
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 @@ void shadeSunView(struct SunSky *sunsky, float *colf, float *rco, float *view, f
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);
}
diff --git a/source/blender/render/intern/source/sunsky.c b/source/blender/render/intern/source/sunsky.c
index e1c7933cea1..2b490e71142 100644
--- a/source/blender/render/intern/source/sunsky.c
+++ b/source/blender/render/intern/source/sunsky.c
@@ -22,7 +22,7 @@
#include "sunsky.h"
#include "math.h"
#include "BLI_arithb.h"
-
+#include "BKE_global.h"
/**
* These macros are defined for vector operations
@@ -111,15 +111,14 @@ static void DirectionToThetaPhi(float *toSun, float *theta, float *phi)
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)));
-
- return(lvz * num / den);
-}
+ (1 + lam[2] * exp(lam[3] * gamma) + lam[4] * cos(gamma) * cos(gamma)));
+
+ return(lvz * num / den);}
/**
* InitSunSky:
@@ -136,7 +135,7 @@ float PerezFunction(struct SunSky *sunsky, const float *lam, float theta, float
* */
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 @@ void InitSunSky(struct SunSky *sunsky, float turb, float *toSun, float horizon_b
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 @@ void GetSkyXYZRadiance(struct SunSky* sunsky, float theta, float phi, float colo
// 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;