[Bf-blender-cvs] [d91316d] master: Cycles: Remove the Preetham Sky model.
Thomas Dinges
noreply at git.blender.org
Sat Apr 2 23:41:17 CEST 2016
Commit: d91316dc672dc1ee69fbd24d2f00124a24b75c6b
Author: Thomas Dinges
Date: Sat Apr 2 23:36:14 2016 +0200
Branches: master
https://developer.blender.org/rBd91316dc672dc1ee69fbd24d2f00124a24b75c6b
Cycles: Remove the Preetham Sky model.
The improved Hosek / Wilkie model was added during my GSoC 2013 and the default since then.
The older model was kinda kept for compatibility, but after more than 2 years it's time to remove it.
The Hosek / Wilkie model is more realistic anyway, and people who really want a day / night transition can mix the Sky Shader with another one (e.g. color) and fade between the two.
===================================================================
M intern/cycles/app/cycles_xml.cpp
M intern/cycles/blender/blender_shader.cpp
M intern/cycles/kernel/shaders/node_sky_texture.osl
M intern/cycles/kernel/svm/svm_sky.h
M intern/cycles/kernel/svm/svm_types.h
M intern/cycles/render/nodes.cpp
M intern/cycles/render/nodes.h
M source/blender/editors/space_node/drawnode.c
M source/blender/makesdna/DNA_node_types.h
M source/blender/makesrna/intern/rna_nodetree.c
M source/blender/nodes/shader/nodes/node_shader_tex_sky.c
===================================================================
diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp
index c845f28..e33fce4 100644
--- a/intern/cycles/app/cycles_xml.cpp
+++ b/intern/cycles/app/cycles_xml.cpp
@@ -470,8 +470,7 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug
}
else if(string_iequals(node.name(), "sky_texture")) {
SkyTextureNode *sky = new SkyTextureNode();
-
- xml_read_enum(&sky->type, SkyTextureNode::type_enum, node, "type");
+
xml_read_float3(&sky->sun_direction, node, "sun_direction");
xml_read_float(&sky->turbidity, node, "turbidity");
xml_read_float(&sky->ground_albedo, node, "ground_albedo");
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index 4f7ca30..e186a59 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -833,7 +833,6 @@ static ShaderNode *add_node(Scene *scene,
else if(b_node.is_a(&RNA_ShaderNodeTexSky)) {
BL::ShaderNodeTexSky b_sky_node(b_node);
SkyTextureNode *sky = new SkyTextureNode();
- sky->type = SkyTextureNode::type_enum[(int)b_sky_node.sky_type()];
sky->sun_direction = normalize(get_float3(b_sky_node.sun_direction()));
sky->turbidity = b_sky_node.turbidity();
sky->ground_albedo = b_sky_node.ground_albedo();
diff --git a/intern/cycles/kernel/shaders/node_sky_texture.osl b/intern/cycles/kernel/shaders/node_sky_texture.osl
index 05eed23..9ce9008 100644
--- a/intern/cycles/kernel/shaders/node_sky_texture.osl
+++ b/intern/cycles/kernel/shaders/node_sky_texture.osl
@@ -34,40 +34,6 @@ vector sky_spherical_coordinates(vector dir)
return vector(acos(dir[2]), atan2(dir[0], dir[1]), 0);
}
-/* Preetham */
-float sky_perez_function(float lam[9], float theta, float gamma)
-{
- float ctheta = cos(theta);
- float cgamma = cos(gamma);
-
- return (1.0 + lam[0] * exp(lam[1] / ctheta)) * (1.0 + lam[2] * exp(lam[3] * gamma) + lam[4] * cgamma * cgamma);
-}
-
-color sky_radiance_old(normal dir,
- float sunphi, float suntheta, color radiance,
- float config_x[9], float config_y[9], float config_z[9])
-{
- /* convert vector to spherical coordinates */
- vector spherical = sky_spherical_coordinates(dir);
- float theta = spherical[0];
- float phi = spherical[1];
-
- /* angle between sun direction and dir */
- float gamma = sky_angle_between(theta, phi, suntheta, sunphi);
-
- /* clamp theta to horizon */
- theta = min(theta, M_PI_2 - 0.001);
-
- /* compute xyY color space values */
- float x = radiance[1] * sky_perez_function(config_y, theta, gamma);
- float y = radiance[2] * sky_perez_function(config_z, theta, gamma);
- float Y = radiance[0] * sky_perez_function(config_x, theta, gamma);
-
- /* convert to RGB */
- color xyz = xyY_to_xyz(x, y, Y);
- return xyz_to_rgb(xyz[0], xyz[1], xyz[2]);
-}
-
/* Hosek / Wilkie */
float sky_radiance_internal(float config[9], float theta, float gamma)
{
@@ -83,9 +49,9 @@ float sky_radiance_internal(float config[9], float theta, float gamma)
(config[2] + config[3] * expM + config[5] * rayM + config[6] * mieM + config[7] * zenith);
}
-color sky_radiance_new(normal dir,
- float sunphi, float suntheta, color radiance,
- float config_x[9], float config_y[9], float config_z[9])
+color sky_radiance(normal dir,
+ float sunphi, float suntheta, color radiance,
+ float config_x[9], float config_y[9], float config_z[9])
{
/* convert vector to spherical coordinates */
vector spherical = sky_spherical_coordinates(dir);
@@ -111,7 +77,6 @@ shader node_sky_texture(
int use_mapping = 0,
matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
vector Vector = P,
- string sky_model = "Hosek / Wilkie",
float theta = 0.0,
float phi = 0.0,
color radiance = color(0.0, 0.0, 0.0),
@@ -124,10 +89,7 @@ shader node_sky_texture(
if (use_mapping)
p = transform(mapping, p);
-
- if (sky_model == "Hosek / Wilkie")
- Color = sky_radiance_new(p, phi, theta, radiance, config_x, config_y, config_z);
- else
- Color = sky_radiance_old(p, phi, theta, radiance, config_x, config_y, config_z);
+
+ Color = sky_radiance(p, phi, theta, radiance, config_x, config_y, config_z);
}
diff --git a/intern/cycles/kernel/svm/svm_sky.h b/intern/cycles/kernel/svm/svm_sky.h
index 854e85f..28599f5 100644
--- a/intern/cycles/kernel/svm/svm_sky.h
+++ b/intern/cycles/kernel/svm/svm_sky.h
@@ -25,44 +25,6 @@ ccl_device float sky_angle_between(float thetav, float phiv, float theta, float
}
/*
- * "A Practical Analytic Model for Daylight"
- * A. J. Preetham, Peter Shirley, Brian Smits
- */
-ccl_device float sky_perez_function(float *lam, float theta, float gamma)
-{
- float ctheta = cosf(theta);
- float cgamma = cosf(gamma);
-
- return (1.0f + lam[0]*expf(lam[1]/ctheta)) * (1.0f + lam[2]*expf(lam[3]*gamma) + lam[4]*cgamma*cgamma);
-}
-
-ccl_device float3 sky_radiance_old(KernelGlobals *kg, float3 dir,
- float sunphi, float suntheta,
- float radiance_x, float radiance_y, float radiance_z,
- float *config_x, float *config_y, float *config_z)
-{
- /* convert vector to spherical coordinates */
- float2 spherical = direction_to_spherical(dir);
- float theta = spherical.x;
- float phi = spherical.y;
-
- /* angle between sun direction and dir */
- float gamma = sky_angle_between(theta, phi, suntheta, sunphi);
-
- /* clamp theta to horizon */
- theta = min(theta, M_PI_2_F - 0.001f);
-
- /* compute xyY color space values */
- float x = radiance_y * sky_perez_function(config_y, theta, gamma);
- float y = radiance_z * sky_perez_function(config_z, theta, gamma);
- float Y = radiance_x * sky_perez_function(config_x, theta, gamma);
-
- /* convert to RGB */
- float3 xyz = xyY_to_xyz(x, y, Y);
- return xyz_to_rgb(xyz.x, xyz.y, xyz.z);
-}
-
-/*
* "An Analytic Model for Full Spectral Sky-Dome Radiance"
* Lukas Hosek, Alexander Wilkie
*/
@@ -80,10 +42,10 @@ ccl_device float sky_radiance_internal(float *configuration, float theta, float
(configuration[2] + configuration[3] * expM + configuration[5] * rayM + configuration[6] * mieM + configuration[7] * zenith);
}
-ccl_device float3 sky_radiance_new(KernelGlobals *kg, float3 dir,
- float sunphi, float suntheta,
- float radiance_x, float radiance_y, float radiance_z,
- float *config_x, float *config_y, float *config_z)
+ccl_device float3 sky_radiance(KernelGlobals *kg, float3 dir,
+ float sunphi, float suntheta,
+ float radiance_x, float radiance_y, float radiance_z,
+ float *config_x, float *config_y, float *config_z)
{
/* convert vector to spherical coordinates */
float2 spherical = direction_to_spherical(dir);
@@ -114,7 +76,6 @@ ccl_device void svm_node_tex_sky(KernelGlobals *kg, ShaderData *sd, float *stack
/* 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;
@@ -168,16 +129,9 @@ ccl_device void svm_node_tex_sky(KernelGlobals *kg, ShaderData *sd, float *stack
float3 f;
/* Compute Sky */
- if(sky_model == 0) {
- f = sky_radiance_old(kg, dir, sunphi, suntheta,
- radiance_x, radiance_y, radiance_z,
- config_x, config_y, config_z);
- }
- else {
- f = sky_radiance_new(kg, dir, sunphi, suntheta,
- radiance_x, radiance_y, radiance_z,
- config_x, config_y, config_z);
- }
+ f = sky_radiance(kg, dir, sunphi, suntheta,
+ radiance_x, radiance_y, radiance_z,
+ config_x, config_y, config_z);
stack_store_float3(stack, out_offset, f);
}
diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h
index 21b0cb1..f9d741f 100644
--- a/intern/cycles/kernel/svm/svm_types.h
+++ b/intern/cycles/kernel/svm/svm_types.h
@@ -299,11 +299,6 @@ typedef enum NodeWaveProfiles {
NODE_WAVE_PROFILE_SAW,
} NodeWaveProfile;
-typedef enum NodeSkyType {
- NODE_SKY_OLD,
- NODE_SKY_NEW
-} NodeSkyType;
-
typedef enum NodeGradientType {
NODE_BLEND_LINEAR,
NODE_BLEND_QUADRATIC,
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 57fb1a7..3a9e8de 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -591,78 +591,8 @@ typedef struct SunSky {
float config_x[9], config_y[9], config_z[9];
} SunSky;
-/* Preetham model */
-static float sky_perez_function(float lam[6], float theta, float gamma)
-{
- return (1.0f + lam[0]*expf(lam[1]/cosf(theta))) * (1.0f + lam[2]*expf(lam[3]*gamma) + lam[4]*cosf(gamma)*cosf(gamma));
-}
-
-static void sky_texture_precompute_old(SunSky *sunsky, float3 dir, float turbidity)
-{
- /*
- * We re-use the SunSky struct of the new model, to avoid extra variables
- * zenith_Y/x/y is now radiance_x/y/z
- * perez_Y/x/y is now config_x/y/z
- */
-
- float2 spherical = sky_spherical_coordinates(dir);
- float theta = spherical.x;
- float phi = spherical.y;
-
- sunsky->theta = theta;
- sunsky->phi = phi;
-
- float theta2 = theta*theta;
- float theta3 = theta2*theta;
- float T = turbidity;
- float T2 = T * T;
-
- float chi = (4.0f / 9.0f - T / 120.0f) * (M_PI_F - 2.0f * theta);
- sunsky->radiance_x = (4.0453f * T - 4.9710f) * tanf(chi) - 0.2155f * T + 2.4192f;
- sunsky->radiance_x *= 0.06f;
-
- sunsky->radiance_y =
- (0.00166f * theta3 - 0.00375f * theta2 + 0.00209f * theta) * T2 +
- (-0.02903f * theta3 + 0.06377f * theta2 - 0.03202f * theta + 0.00394f) * T +
- (0.11693f * theta3 - 0.21196f * theta2 + 0.06052f * theta + 0.25886f);
-
- sunsky->radiance_z =
- (0.00275f * theta3 - 0.00610f * theta2 + 0.00317f * theta) * T2 +
- (-0.04214f * theta3 + 0.08970f * theta2 - 0.04153f * theta + 0.00516f) * T +
- (0.15346f * theta3 - 0.26756f * theta2 + 0.06670f * theta + 0.26688f);
-
- sunsky->config_x[0] = (0.1787f * T - 1.4630f);
- sunsky->config_x[1] = (-0
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list