forked from bartvdbraak/blender
Cycles: Code cleanyp, sky model
For as long as code stays in official folders it should follow our code style.
This commit is contained in:
parent
5ff132182d
commit
e1bcc2d779
@ -142,8 +142,7 @@ static void ArHosekSkyModel_CookConfiguration(
|
|||||||
ArHosekSkyModelConfiguration config,
|
ArHosekSkyModelConfiguration config,
|
||||||
double turbidity,
|
double turbidity,
|
||||||
double albedo,
|
double albedo,
|
||||||
double solar_elevation
|
double solar_elevation)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
const double * elev_matrix;
|
const double * elev_matrix;
|
||||||
|
|
||||||
@ -154,11 +153,9 @@ static void ArHosekSkyModel_CookConfiguration(
|
|||||||
|
|
||||||
// alb 0 low turb
|
// alb 0 low turb
|
||||||
|
|
||||||
elev_matrix = dataset + ( 9 * 6 * (int_turbidity-1) );
|
elev_matrix = dataset + ( 9 * 6 * (int_turbidity-1));
|
||||||
|
|
||||||
|
for(unsigned int i = 0; i < 9; ++i) {
|
||||||
for( unsigned int i = 0; i < 9; ++i )
|
|
||||||
{
|
|
||||||
//(1-t).^3* A1 + 3*(1-t).^2.*t * A2 + 3*(1-t) .* t .^ 2 * A3 + t.^3 * A4;
|
//(1-t).^3* A1 + 3*(1-t).^2.*t * A2 + 3*(1-t) .* t .^ 2 * A3 + t.^3 * A4;
|
||||||
config[i] =
|
config[i] =
|
||||||
(1.0-albedo) * (1.0 - turbidity_rem)
|
(1.0-albedo) * (1.0 - turbidity_rem)
|
||||||
@ -172,8 +169,7 @@ static void ArHosekSkyModel_CookConfiguration(
|
|||||||
|
|
||||||
// alb 1 low turb
|
// alb 1 low turb
|
||||||
elev_matrix = dataset + (9*6*10 + 9*6*(int_turbidity-1));
|
elev_matrix = dataset + (9*6*10 + 9*6*(int_turbidity-1));
|
||||||
for(unsigned int i = 0; i < 9; ++i)
|
for(unsigned int i = 0; i < 9; ++i) {
|
||||||
{
|
|
||||||
//(1-t).^3* A1 + 3*(1-t).^2.*t * A2 + 3*(1-t) .* t .^ 2 * A3 + t.^3 * A4;
|
//(1-t).^3* A1 + 3*(1-t).^2.*t * A2 + 3*(1-t) .* t .^ 2 * A3 + t.^3 * A4;
|
||||||
config[i] +=
|
config[i] +=
|
||||||
(albedo) * (1.0 - turbidity_rem)
|
(albedo) * (1.0 - turbidity_rem)
|
||||||
@ -190,8 +186,7 @@ static void ArHosekSkyModel_CookConfiguration(
|
|||||||
|
|
||||||
// alb 0 high turb
|
// alb 0 high turb
|
||||||
elev_matrix = dataset + (9*6*(int_turbidity));
|
elev_matrix = dataset + (9*6*(int_turbidity));
|
||||||
for(unsigned int i = 0; i < 9; ++i)
|
for(unsigned int i = 0; i < 9; ++i) {
|
||||||
{
|
|
||||||
//(1-t).^3* A1 + 3*(1-t).^2.*t * A2 + 3*(1-t) .* t .^ 2 * A3 + t.^3 * A4;
|
//(1-t).^3* A1 + 3*(1-t).^2.*t * A2 + 3*(1-t) .* t .^ 2 * A3 + t.^3 * A4;
|
||||||
config[i] +=
|
config[i] +=
|
||||||
(1.0-albedo) * (turbidity_rem)
|
(1.0-albedo) * (turbidity_rem)
|
||||||
@ -205,8 +200,7 @@ static void ArHosekSkyModel_CookConfiguration(
|
|||||||
|
|
||||||
// alb 1 high turb
|
// alb 1 high turb
|
||||||
elev_matrix = dataset + (9*6*10 + 9*6*(int_turbidity));
|
elev_matrix = dataset + (9*6*10 + 9*6*(int_turbidity));
|
||||||
for(unsigned int i = 0; i < 9; ++i)
|
for(unsigned int i = 0; i < 9; ++i) {
|
||||||
{
|
|
||||||
//(1-t).^3* A1 + 3*(1-t).^2.*t * A2 + 3*(1-t) .* t .^ 2 * A3 + t.^3 * A4;
|
//(1-t).^3* A1 + 3*(1-t).^2.*t * A2 + 3*(1-t) .* t .^ 2 * A3 + t.^3 * A4;
|
||||||
config[i] +=
|
config[i] +=
|
||||||
(albedo) * (turbidity_rem)
|
(albedo) * (turbidity_rem)
|
||||||
@ -223,8 +217,7 @@ static double ArHosekSkyModel_CookRadianceConfiguration(
|
|||||||
ArHosekSkyModel_Radiance_Dataset dataset,
|
ArHosekSkyModel_Radiance_Dataset dataset,
|
||||||
double turbidity,
|
double turbidity,
|
||||||
double albedo,
|
double albedo,
|
||||||
double solar_elevation
|
double solar_elevation)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
const double* elev_matrix;
|
const double* elev_matrix;
|
||||||
|
|
||||||
@ -284,8 +277,7 @@ static double ArHosekSkyModel_CookRadianceConfiguration(
|
|||||||
static double ArHosekSkyModel_GetRadianceInternal(
|
static double ArHosekSkyModel_GetRadianceInternal(
|
||||||
ArHosekSkyModelConfiguration configuration,
|
ArHosekSkyModelConfiguration configuration,
|
||||||
double theta,
|
double theta,
|
||||||
double gamma
|
double gamma)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
const double expM = exp(configuration[4] * gamma);
|
const double expM = exp(configuration[4] * gamma);
|
||||||
const double rayM = cos(gamma)*cos(gamma);
|
const double rayM = cos(gamma)*cos(gamma);
|
||||||
@ -296,23 +288,19 @@ static double ArHosekSkyModel_GetRadianceInternal(
|
|||||||
(configuration[2] + configuration[3] * expM + configuration[5] * rayM + configuration[6] * mieM + configuration[7] * zenith);
|
(configuration[2] + configuration[3] * expM + configuration[5] * rayM + configuration[6] * mieM + configuration[7] * zenith);
|
||||||
}
|
}
|
||||||
|
|
||||||
void arhosekskymodelstate_free(
|
void arhosekskymodelstate_free(ArHosekSkyModelState * state)
|
||||||
ArHosekSkyModelState * state
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
free(state);
|
free(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
double arhosekskymodel_radiance(
|
double arhosekskymodel_radiance(ArHosekSkyModelState *state,
|
||||||
ArHosekSkyModelState * state,
|
|
||||||
double theta,
|
double theta,
|
||||||
double gamma,
|
double gamma,
|
||||||
double wavelength
|
double wavelength)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
int low_wl = (int)((wavelength - 320.0) / 40.0);
|
int low_wl = (int)((wavelength - 320.0) / 40.0);
|
||||||
|
|
||||||
if( low_wl < 0 || low_wl >= 11 )
|
if(low_wl < 0 || low_wl >= 11)
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
|
||||||
double interp = fmod((wavelength - 320.0 ) / 40.0, 1.0);
|
double interp = fmod((wavelength - 320.0 ) / 40.0, 1.0);
|
||||||
@ -321,25 +309,22 @@ double arhosekskymodel_radiance(
|
|||||||
ArHosekSkyModel_GetRadianceInternal(
|
ArHosekSkyModel_GetRadianceInternal(
|
||||||
state->configs[low_wl],
|
state->configs[low_wl],
|
||||||
theta,
|
theta,
|
||||||
gamma
|
gamma)
|
||||||
)
|
|
||||||
* state->radiances[low_wl]
|
* state->radiances[low_wl]
|
||||||
* state->emission_correction_factor_sky[low_wl];
|
* state->emission_correction_factor_sky[low_wl];
|
||||||
|
|
||||||
if( interp < 1e-6 )
|
if(interp < 1e-6)
|
||||||
return val_low;
|
return val_low;
|
||||||
|
|
||||||
double result = ( 1.0 - interp ) * val_low;
|
double result = ( 1.0 - interp ) * val_low;
|
||||||
|
|
||||||
if( low_wl+1 < 11 )
|
if(low_wl+1 < 11) {
|
||||||
{
|
|
||||||
result +=
|
result +=
|
||||||
interp
|
interp
|
||||||
* ArHosekSkyModel_GetRadianceInternal(
|
* ArHosekSkyModel_GetRadianceInternal(
|
||||||
state->configs[low_wl+1],
|
state->configs[low_wl+1],
|
||||||
theta,
|
theta,
|
||||||
gamma
|
gamma)
|
||||||
)
|
|
||||||
* state->radiances[low_wl+1]
|
* state->radiances[low_wl+1]
|
||||||
* state->emission_correction_factor_sky[low_wl+1];
|
* state->emission_correction_factor_sky[low_wl+1];
|
||||||
}
|
}
|
||||||
@ -353,8 +338,7 @@ double arhosekskymodel_radiance(
|
|||||||
ArHosekSkyModelState * arhosek_xyz_skymodelstate_alloc_init(
|
ArHosekSkyModelState * arhosek_xyz_skymodelstate_alloc_init(
|
||||||
const double turbidity,
|
const double turbidity,
|
||||||
const double albedo,
|
const double albedo,
|
||||||
const double elevation
|
const double elevation)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
ArHosekSkyModelState * state = ALLOC(ArHosekSkyModelState);
|
ArHosekSkyModelState * state = ALLOC(ArHosekSkyModelState);
|
||||||
|
|
||||||
@ -363,23 +347,20 @@ ArHosekSkyModelState * arhosek_xyz_skymodelstate_alloc_init(
|
|||||||
state->albedo = albedo;
|
state->albedo = albedo;
|
||||||
state->elevation = elevation;
|
state->elevation = elevation;
|
||||||
|
|
||||||
for( unsigned int channel = 0; channel < 3; ++channel )
|
for(unsigned int channel = 0; channel < 3; ++channel) {
|
||||||
{
|
|
||||||
ArHosekSkyModel_CookConfiguration(
|
ArHosekSkyModel_CookConfiguration(
|
||||||
datasetsXYZ[channel],
|
datasetsXYZ[channel],
|
||||||
state->configs[channel],
|
state->configs[channel],
|
||||||
turbidity,
|
turbidity,
|
||||||
albedo,
|
albedo,
|
||||||
elevation
|
elevation);
|
||||||
);
|
|
||||||
|
|
||||||
state->radiances[channel] =
|
state->radiances[channel] =
|
||||||
ArHosekSkyModel_CookRadianceConfiguration(
|
ArHosekSkyModel_CookRadianceConfiguration(
|
||||||
datasetsXYZRad[channel],
|
datasetsXYZRad[channel],
|
||||||
turbidity,
|
turbidity,
|
||||||
albedo,
|
albedo,
|
||||||
elevation
|
elevation);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
|
@ -358,11 +358,10 @@ ArHosekSkyModelState;
|
|||||||
|
|
||||||
---------------------------------------------------------------------------- */
|
---------------------------------------------------------------------------- */
|
||||||
|
|
||||||
ArHosekSkyModelState * arhosekskymodelstate_alloc_init(
|
ArHosekSkyModelState *arhosekskymodelstate_alloc_init(
|
||||||
const double solar_elevation,
|
const double solar_elevation,
|
||||||
const double atmospheric_turbidity,
|
const double atmospheric_turbidity,
|
||||||
const double ground_albedo
|
const double ground_albedo);
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
||||||
@ -394,24 +393,19 @@ ArHosekSkyModelState * arhosekskymodelstate_alloc_init(
|
|||||||
|
|
||||||
---------------------------------------------------------------------------- */
|
---------------------------------------------------------------------------- */
|
||||||
|
|
||||||
ArHosekSkyModelState * arhosekskymodelstate_alienworld_alloc_init(
|
ArHosekSkyModelState* arhosekskymodelstate_alienworld_alloc_init(
|
||||||
const double solar_elevation,
|
const double solar_elevation,
|
||||||
const double solar_intensity,
|
const double solar_intensity,
|
||||||
const double solar_surface_temperature_kelvin,
|
const double solar_surface_temperature_kelvin,
|
||||||
const double atmospheric_turbidity,
|
const double atmospheric_turbidity,
|
||||||
const double ground_albedo
|
const double ground_albedo);
|
||||||
);
|
|
||||||
|
|
||||||
void arhosekskymodelstate_free(
|
void arhosekskymodelstate_free(ArHosekSkyModelState *state);
|
||||||
ArHosekSkyModelState * state
|
|
||||||
);
|
|
||||||
|
|
||||||
double arhosekskymodel_radiance(
|
double arhosekskymodel_radiance(ArHosekSkyModelState *state,
|
||||||
ArHosekSkyModelState * state,
|
|
||||||
double theta,
|
double theta,
|
||||||
double gamma,
|
double gamma,
|
||||||
double wavelength
|
double wavelength);
|
||||||
);
|
|
||||||
|
|
||||||
// CIE XYZ and RGB versions
|
// CIE XYZ and RGB versions
|
||||||
|
|
||||||
@ -419,34 +413,28 @@ double arhosekskymodel_radiance(
|
|||||||
ArHosekSkyModelState * arhosek_xyz_skymodelstate_alloc_init(
|
ArHosekSkyModelState * arhosek_xyz_skymodelstate_alloc_init(
|
||||||
const double turbidity,
|
const double turbidity,
|
||||||
const double albedo,
|
const double albedo,
|
||||||
const double elevation
|
const double elevation);
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
ArHosekSkyModelState * arhosek_rgb_skymodelstate_alloc_init(
|
ArHosekSkyModelState * arhosek_rgb_skymodelstate_alloc_init(
|
||||||
const double turbidity,
|
const double turbidity,
|
||||||
const double albedo,
|
const double albedo,
|
||||||
const double elevation
|
const double elevation);
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
double arhosek_tristim_skymodel_radiance(
|
double arhosek_tristim_skymodel_radiance(ArHosekSkyModelState* state,
|
||||||
ArHosekSkyModelState * state,
|
|
||||||
double theta,
|
double theta,
|
||||||
double gamma,
|
double gamma,
|
||||||
int channel
|
int channel);
|
||||||
);
|
|
||||||
|
|
||||||
// Delivers the complete function: sky + sun, including limb darkening.
|
// Delivers the complete function: sky + sun, including limb darkening.
|
||||||
// Please read the above description before using this - there are several
|
// Please read the above description before using this - there are several
|
||||||
// caveats!
|
// caveats!
|
||||||
|
|
||||||
double arhosekskymodel_solar_radiance(
|
double arhosekskymodel_solar_radiance(ArHosekSkyModelState* state,
|
||||||
ArHosekSkyModelState * state,
|
|
||||||
double theta,
|
double theta,
|
||||||
double gamma,
|
double gamma,
|
||||||
double wavelength
|
double wavelength);
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
#endif // _SKY_MODEL_H_
|
#endif // _SKY_MODEL_H_
|
||||||
|
@ -103,8 +103,7 @@ the model.
|
|||||||
|
|
||||||
// Uses Sep 9 pattern / Aug 23 mean dataset
|
// Uses Sep 9 pattern / Aug 23 mean dataset
|
||||||
|
|
||||||
static const double datasetXYZ1[] =
|
static const double datasetXYZ1[] = {
|
||||||
{
|
|
||||||
// albedo 0, turbidity 1
|
// albedo 0, turbidity 1
|
||||||
-1.117001e+000,
|
-1.117001e+000,
|
||||||
-1.867262e-001,
|
-1.867262e-001,
|
||||||
@ -3849,15 +3848,13 @@ static const double datasetXYZRad3[] =
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const double* datasetsXYZ[] =
|
static const double* datasetsXYZ[] = {
|
||||||
{
|
|
||||||
datasetXYZ1,
|
datasetXYZ1,
|
||||||
datasetXYZ2,
|
datasetXYZ2,
|
||||||
datasetXYZ3
|
datasetXYZ3
|
||||||
};
|
};
|
||||||
|
|
||||||
static const double* datasetsXYZRad[] =
|
static const double* datasetsXYZRad[] = {
|
||||||
{
|
|
||||||
datasetXYZRad1,
|
datasetXYZRad1,
|
||||||
datasetXYZRad2,
|
datasetXYZRad2,
|
||||||
datasetXYZRad3
|
datasetXYZRad3
|
||||||
|
Loading…
Reference in New Issue
Block a user