[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59601] branches/soc-2013-dingto: Cycles / Sky Model:
Thomas Dinges
blender at dingto.org
Wed Aug 28 15:28:27 CEST 2013
Revision: 59601
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59601
Author: dingto
Date: 2013-08-28 13:28:26 +0000 (Wed, 28 Aug 2013)
Log Message:
-----------
Cycles / Sky Model:
* Rename Albedo to Ground Albedo, and improve tooltip.
* Soft UI Range for Turbidity, between 1 and 10, higher values can produce weird results. I checked and other engines clamp this to 10 as well.
* Some code cleanup.
Modified Paths:
--------------
branches/soc-2013-dingto/intern/cycles/blender/blender_shader.cpp
branches/soc-2013-dingto/intern/cycles/kernel/svm/svm_sky.h
branches/soc-2013-dingto/intern/cycles/render/nodes.cpp
branches/soc-2013-dingto/intern/cycles/render/nodes.h
branches/soc-2013-dingto/intern/cycles/render/sky_model.cpp
branches/soc-2013-dingto/source/blender/editors/space_node/drawnode.c
branches/soc-2013-dingto/source/blender/makesdna/DNA_node_types.h
branches/soc-2013-dingto/source/blender/makesrna/intern/rna_nodetree.c
branches/soc-2013-dingto/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
Modified: branches/soc-2013-dingto/intern/cycles/blender/blender_shader.cpp
===================================================================
--- branches/soc-2013-dingto/intern/cycles/blender/blender_shader.cpp 2013-08-28 12:45:19 UTC (rev 59600)
+++ branches/soc-2013-dingto/intern/cycles/blender/blender_shader.cpp 2013-08-28 13:28:26 UTC (rev 59601)
@@ -635,7 +635,7 @@
sky->type = SkyTextureNode::type_enum[(int)b_sky_node.sky_type()];
sky->sun_direction = get_float3(b_sky_node.sun_direction());
sky->turbidity = b_sky_node.turbidity();
- sky->albedo = b_sky_node.albedo();
+ sky->ground_albedo = b_sky_node.ground_albedo();
get_tex_mapping(&sky->tex_mapping, b_sky_node.texture_mapping());
node = sky;
}
Modified: branches/soc-2013-dingto/intern/cycles/kernel/svm/svm_sky.h
===================================================================
--- branches/soc-2013-dingto/intern/cycles/kernel/svm/svm_sky.h 2013-08-28 12:45:19 UTC (rev 59600)
+++ branches/soc-2013-dingto/intern/cycles/kernel/svm/svm_sky.h 2013-08-28 13:28:26 UTC (rev 59601)
@@ -107,12 +107,15 @@
__device void svm_node_tex_sky(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
- uint dir_offset = node.y, out_offset = node.z;
-
- int sky_model = node.w;
+ /* Define variables */
float sunphi, suntheta, radiance_x, radiance_y, radiance_z;
float config_x[9], config_y[9], config_z[9];
+ /* Load data */
+ uint dir_offset = node.y;
+ uint out_offset = node.z;
+ int sky_model = node.w;
+
float4 data = read_node_float(kg, offset);
sunphi = data.x;
suntheta = data.y;
@@ -164,6 +167,7 @@
float3 dir = stack_load_float3(stack, dir_offset);
float3 f;
+ /* Compute Sky */
if(sky_model == 0)
f = sky_radiance_old(kg, dir, sunphi, suntheta,
radiance_x, radiance_y, radiance_z,
Modified: branches/soc-2013-dingto/intern/cycles/render/nodes.cpp
===================================================================
--- branches/soc-2013-dingto/intern/cycles/render/nodes.cpp 2013-08-28 12:45:19 UTC (rev 59600)
+++ branches/soc-2013-dingto/intern/cycles/render/nodes.cpp 2013-08-28 13:28:26 UTC (rev 59601)
@@ -458,7 +458,7 @@
}
/* Hosek / Wilkie */
-static void sky_texture_precompute_new(SunSky *sunsky, float3 dir, float turbidity, float albedo)
+static void sky_texture_precompute_new(SunSky *sunsky, float3 dir, float turbidity, float ground_albedo)
{
/* Calculate Sun Direction and save coordinates */
float2 spherical = sky_spherical_coordinates(dir);
@@ -472,7 +472,7 @@
/* Initialize Sky Model */
ArHosekSkyModelState *sky_state;
- sky_state = arhosek_xyz_skymodelstate_alloc_init(turbidity, albedo, solarElevation);
+ sky_state = arhosek_xyz_skymodelstate_alloc_init(turbidity, ground_albedo, solarElevation);
/* Copy values from sky_state to SunSky */
for (int i = 0; i < 9; ++i) {
@@ -507,7 +507,7 @@
sun_direction = make_float3(0.0f, 0.0f, 1.0f);
turbidity = 2.2f;
- albedo = 0.3f;
+ ground_albedo = 0.3f;
add_input("Vector", SHADER_SOCKET_VECTOR, ShaderInput::POSITION);
add_output("Color", SHADER_SOCKET_COLOR);
@@ -522,7 +522,7 @@
if(type_enum[type] == NODE_SKY_OLD)
sky_texture_precompute_old(&sunsky, sun_direction, turbidity);
else if(type_enum[type] == NODE_SKY_NEW)
- sky_texture_precompute_new(&sunsky, sun_direction, turbidity, albedo);
+ sky_texture_precompute_new(&sunsky, sun_direction, turbidity, ground_albedo);
if(vector_in->link)
compiler.stack_assign(vector_in);
@@ -558,7 +558,7 @@
if(type_enum[type] == NODE_SKY_OLD)
sky_texture_precompute_old(&sunsky, sun_direction, turbidity);
else if(type_enum[type] == NODE_SKY_NEW)
- sky_texture_precompute_new(&sunsky, sun_direction, turbidity, albedo);
+ sky_texture_precompute_new(&sunsky, sun_direction, turbidity, ground_albedo);
compiler.parameter("sky_model", type);
compiler.parameter("theta", sunsky.theta);
Modified: branches/soc-2013-dingto/intern/cycles/render/nodes.h
===================================================================
--- branches/soc-2013-dingto/intern/cycles/render/nodes.h 2013-08-28 12:45:19 UTC (rev 59600)
+++ branches/soc-2013-dingto/intern/cycles/render/nodes.h 2013-08-28 13:28:26 UTC (rev 59601)
@@ -105,7 +105,7 @@
float3 sun_direction;
float turbidity;
- float albedo;
+ float ground_albedo;
ustring type;
static ShaderEnum type_enum;
Modified: branches/soc-2013-dingto/intern/cycles/render/sky_model.cpp
===================================================================
--- branches/soc-2013-dingto/intern/cycles/render/sky_model.cpp 2013-08-28 12:45:19 UTC (rev 59600)
+++ branches/soc-2013-dingto/intern/cycles/render/sky_model.cpp 2013-08-28 13:28:26 UTC (rev 59601)
@@ -304,214 +304,6 @@
(configuration[2] + configuration[3] * expM + configuration[5] * rayM + configuration[6] * mieM + configuration[7] * zenith);
}
-#if 0
-// spectral version
-
-ArHosekSkyModelState * arhosekskymodelstate_alloc_init(
- const double solar_elevation,
- const double atmospheric_turbidity,
- const double ground_albedo
- )
-{
- ArHosekSkyModelState * state = ALLOC(ArHosekSkyModelState);
-
- state->solar_radius = ( 0.51 DEGREES ) / 2.0;
- state->turbidity = atmospheric_turbidity;
- state->albedo = ground_albedo;
- state->elevation = solar_elevation;
-
- for( unsigned int wl = 0; wl < 11; ++wl )
- {
- ArHosekSkyModel_CookConfiguration(
- datasets[wl],
- state->configs[wl],
- atmospheric_turbidity,
- ground_albedo,
- solar_elevation
- );
-
- state->radiances[wl] =
- ArHosekSkyModel_CookRadianceConfiguration(
- datasetsRad[wl],
- atmospheric_turbidity,
- ground_albedo,
- solar_elevation
- );
-
- state->emission_correction_factor_sun[wl] = 1.0;
- state->emission_correction_factor_sky[wl] = 1.0;
- }
-
- return state;
-}
-
-// 'blackbody_scaling_factor'
-//
-// Fudge factor, computed in Mathematica, to scale the results of the
-// following function to match the solar radiance spectrum used in the
-// original simulation. The scaling is done so their integrals over the
-// range from 380.0 to 720.0 nanometers match for a blackbody temperature
-// of 5800 K.
-// Which leaves the original spectrum being less bright overall than the 5.8k
-// blackbody radiation curve if the ultra-violet part of the spectrum is
-// also considered. But the visible brightness should be very similar.
-
-const double blackbody_scaling_factor = 3.19992 * 10E-11;
-
-// 'art_blackbody_dd_value()' function
-//
-// Blackbody radiance, Planck's formula
-
-double art_blackbody_dd_value(
- const double temperature,
- const double lambda
- )
-{
- double c1 = 3.74177 * 10E-17;
- double c2 = 0.0143878;
- double value;
-
- value = ( c1 / ( pow( lambda, 5.0 ) ) )
- * ( 1.0 / ( exp( c2 / ( lambda * temperature ) ) - 1.0 ) );
-
- return value;
-}
-
-// 'originalSolarRadianceTable[]'
-//
-// The solar spectrum incident at the top of the atmosphere, as it was used
-// in the brute force path tracer that generated the reference results the
-// model was fitted to. We need this as the yardstick to compare any altered
-// Blackbody emission spectra for alien world stars to.
-
-// This is just the data from the Preetham paper, extended into the UV range.
-
-const double originalSolarRadianceTable[] =
-{
- 7500.0,
- 12500.0,
- 21127.5,
- 26760.5,
- 30663.7,
- 27825.0,
- 25503.8,
- 25134.2,
- 23212.1,
- 21526.7,
- 19870.8
-};
-
-ArHosekSkyModelState * arhosekskymodelstate_alienworld_alloc_init(
- const double solar_elevation,
- const double solar_intensity,
- const double solar_surface_temperature_kelvin,
- const double atmospheric_turbidity,
- const double ground_albedo
- )
-{
- ArHosekSkyModelState * state = ALLOC(ArHosekSkyModelState);
-
- state->turbidity = atmospheric_turbidity;
- state->albedo = ground_albedo;
- state->elevation = solar_elevation;
-
- for( unsigned int wl = 0; wl < 11; ++wl )
- {
- // Basic init as for the normal scenario
-
- ArHosekSkyModel_CookConfiguration(
- datasets[wl],
- state->configs[wl],
- atmospheric_turbidity,
- ground_albedo,
- solar_elevation
- );
-
- state->radiances[wl] =
- ArHosekSkyModel_CookRadianceConfiguration(
- datasetsRad[wl],
- atmospheric_turbidity,
- ground_albedo,
- solar_elevation
- );
-
- // The wavelength of this band in nanometers
-
- double owl = ( 320.0 + 40.0 * wl ) * 10E-10;
-
- // The original intensity we just computed
-
- double osr = originalSolarRadianceTable[wl];
-
- // The intensity of a blackbody with the desired temperature
- // The fudge factor described above is used to make sure the BB
- // function matches the used radiance data reasonably well
- // in magnitude.
-
- double nsr =
- art_blackbody_dd_value(solar_surface_temperature_kelvin, owl)
- * blackbody_scaling_factor;
-
- // Correction factor for this waveband is simply the ratio of
- // the two.
-
- state->emission_correction_factor_sun[wl] = nsr / osr;
- }
-
- // We then compute the average correction factor of all wavebands.
-
- // Theoretically, some weighting to favour wavelengths human vision is
- // more sensitive to could be introduced here - think V(lambda). But
- // given that the whole effort is not *that* accurate to begin with (we
- // are talking about the appearance of alien worlds, after all), simple
- // averaging over the visible wavelenghts (! - this is why we start at
- // WL #2, and only use 2-11) seems like a sane first approximation.
-
- double correctionFactor = 0.0;
-
- for ( unsigned int i = 2; i < 11; i++ )
- {
- correctionFactor +=
- state->emission_correction_factor_sun[i];
- }
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list