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
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 :)
-rw-r--r--source/blender/blenkernel/BKE_blender.h2
-rw-r--r--source/blender/blenkernel/intern/object.c4
-rw-r--r--source/blender/blenloader/intern/readfile.c9
-rw-r--r--source/blender/makesdna/DNA_lamp_types.h4
-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
-rw-r--r--source/blender/src/buttons_shading.c30
9 files changed, 54 insertions, 36 deletions
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index f7af2e4b938..0105587c5b4 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -41,7 +41,7 @@ struct ListBase;
struct MemFile;
#define BLENDER_VERSION 247
-#define BLENDER_SUBVERSION 8
+#define BLENDER_SUBVERSION 9
#define BLENDER_MINVERSION 245
#define BLENDER_MINSUBVERSION 15
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 2dfa849fc43..ec110c6ea7c 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -758,7 +758,9 @@ void *add_lamp(char *name)
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;
}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 0999c8b0ce3..4ec773409da 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -7920,6 +7920,15 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
+ 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! */
diff --git a/source/blender/makesdna/DNA_lamp_types.h b/source/blender/makesdna/DNA_lamp_types.h
index 217e3ed1463..f8f2255c1a7 100644
--- a/source/blender/makesdna/DNA_lamp_types.h
+++ b/source/blender/makesdna/DNA_lamp_types.h
@@ -91,7 +91,9 @@ typedef struct Lamp {
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;
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;
diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c
index 2dafa70a350..c377168bdb8 100644
--- a/source/blender/src/buttons_shading.c
+++ b/source/blender/src/buttons_shading.c
@@ -2892,23 +2892,29 @@ static void lamp_panel_atmosphere(Object *ob, Lamp *la)
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");
+
+ 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");
- 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.");
+ 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.");
+ uiDefButF(block, NUM, B_LAMPPRV, "Back Light:",10,10,BUTW2,22, &(la->backscattered_light), -1.00f, 1.00f, 10, 0, "Sets backscatter light.");
}
if(la->sun_effect_type & LA_SUN_EFFECT_AP)
{
- uiDefButF(block, NUM, B_LAMPREDRAW, "Sun Intens.:",20+BUTW2,y-25,BUTW2,19, &(la->sun_intensity), 0.00f, 10.00f, 10, 0, "Sets sun intensity.");
- uiDefButF(block, NUM, B_LAMPREDRAW, "Inscattering:",20+BUTW2,y-50,BUTW2,19, &(la->atm_inscattering_factor), 0.00f, 1.00f, 10, 0, "In Scattering Contribution Factor.");
- uiDefButF(block, NUM, B_LAMPREDRAW, "Extinction:",20+BUTW2,y-75,BUTW2,19, &(la->atm_extinction_factor), 0.00f, 1.00f, 10, 0, "Extinction Scattering Contribution Factor.");
- uiDefButF(block, NUM, B_LAMPREDRAW, "Distance:",20+BUTW2,y-100,BUTW2,19, &(la->atm_distance_factor), 0.000f, 500.0f, 10, 0, "Scale blender distance to real distance.");
+ uiBlockBeginAlign(block);
+ uiDefButF(block, NUM, B_LAMPREDRAW, "Sun Intens.:",20+BUTW2,76,BUTW2,22, &(la->sun_intensity), 0.00f, 10.00f, 10, 0, "Sets sun intensity.");
+ uiDefButF(block, NUM, B_LAMPREDRAW, "Inscattering:",20+BUTW2,54,BUTW2,22, &(la->atm_inscattering_factor), 0.00f, 1.00f, 10, 0, "In Scattering Contribution Factor.");
+ uiDefButF(block, NUM, B_LAMPREDRAW, "Extinction:",20+BUTW2,32,BUTW2,22, &(la->atm_extinction_factor), 0.00f, 1.00f, 10, 0, "Extinction Scattering Contribution Factor.");
+ uiDefButF(block, NUM, B_LAMPREDRAW, "Distance:",20+BUTW2,10,BUTW2,22, &(la->atm_distance_factor), 0.000f, 500.0f, 10, 0, "Scale blender distance to real distance.");
}
}