[Bf-blender-cvs] [8f63581] soc-2013-dingto: Merge branch 'master' into soc-2013-dingto
Brecht Van Lommel
noreply at git.blender.org
Mon Nov 18 09:03:07 CET 2013
Commit: 8f6358182eaa519d6b17fe61b0f51af7105d5782
Author: Brecht Van Lommel
Date: Mon Nov 18 09:00:30 2013 +0100
http://developer.blender.org/rB8f6358182eaa519d6b17fe61b0f51af7105d5782
Merge branch 'master' into soc-2013-dingto
Solved conflicts with __device to ccl_device change, was actually quite easy.
===================================================================
===================================================================
diff --cc intern/cycles/blender/addon/properties.py
index 7809491,ac15ace..5e48b33
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@@ -284,14 -272,8 +284,14 @@@ class CyclesRenderSettings(bpy.types.Pr
name="Transmission Bounces",
description="Maximum number of transmission bounces, bounded by total maximum",
min=0, max=1024,
- default=128,
+ default=12,
)
+ cls.scattering_bounces = IntProperty(
+ name="Scattering Bounces",
+ description="Maximum number of volumetric scattering events",
+ min=0, max=1024,
+ default=128,
+ )
cls.transparent_min_bounces = IntProperty(
name="Transparent Min Bounces",
diff --cc intern/cycles/kernel/closure/bsdf.h
index 09fec4c,b3141d1..ff2afd0
--- a/intern/cycles/kernel/closure/bsdf.h
+++ b/intern/cycles/kernel/closure/bsdf.h
@@@ -33,13 -33,9 +33,13 @@@
#include "../closure/bssrdf.h"
#endif
+#ifdef __VOLUME__
+#include "../closure/volume.h"
+#endif
+
CCL_NAMESPACE_BEGIN
- __device int bsdf_sample(KernelGlobals *kg, const ShaderData *sd, const ShaderClosure *sc, float randu, float randv, float3 *eval, float3 *omega_in, differential3 *domega_in, float *pdf)
+ ccl_device int bsdf_sample(KernelGlobals *kg, const ShaderData *sd, const ShaderClosure *sc, float randu, float randv, float3 *eval, float3 *omega_in, differential3 *domega_in, float *pdf)
{
int label;
diff --cc intern/cycles/kernel/closure/volume.h
index dd5a82e,f30b30c..4b4cfd0
--- a/intern/cycles/kernel/closure/volume.h
+++ b/intern/cycles/kernel/closure/volume.h
@@@ -14,119 -14,50 +14,119 @@@
* limitations under the License
*/
+#ifndef __VOLUME_H__
+#define __VOLUME_H__
+
CCL_NAMESPACE_BEGIN
-/* note: the interfaces here are just as an example, need to figure
- * out the right functions and parameters to use */
+/* HENYEY-GREENSTEIN CLOSURE */
-/* ISOTROPIC VOLUME CLOSURE */
+/* Given cosine between rays, return probability density that photon bounce to that direction
+ * g parameter controls how far it difference from uniform sphere. g=0 uniform diffusion-like, g=1 - very close to sharp single ray. */
- __device float single_peaked_henyey_greenstein(float cos_theta, float m_g)
-ccl_device int volume_isotropic_setup(ShaderClosure *sc, float density)
++ccl_device float single_peaked_henyey_greenstein(float cos_theta, float m_g)
{
- sc->type = CLOSURE_VOLUME_ISOTROPIC_ID;
- sc->data0 = density;
+ float p = (1.0f - m_g * m_g) / pow(1.0f + m_g * m_g - 2.0f * m_g * cos_theta, 1.5f) / 4.0f / M_PI_F;
- return SD_VOLUME;
+ return p;
+};
+
- __device int volume_henyey_greenstein_setup(ShaderClosure *sc)
++ccl_device int volume_henyey_greenstein_setup(ShaderClosure *sc)
+{
+ sc->type = CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID;
+
+ return SD_BSDF|SD_BSDF_HAS_EVAL;
}
-ccl_device float3 volume_isotropic_eval_phase(const ShaderClosure *sc, const float3 omega_in, const float3 omega_out)
+// just return bsdf at input vector
- __device float3 volume_henyey_greenstein_eval_phase(const ShaderClosure *sc, const float3 I, float3 omega_in, float *pdf)
++ccl_device float3 volume_henyey_greenstein_eval_phase(const ShaderClosure *sc, const float3 I, float3 omega_in, float *pdf)
{
- return make_float3(1.0f, 1.0f, 1.0f);
+ float m_g = sc->data1;
+ const float magic_eps = 0.001f;
+
+// WARNING! I point in backward direction!
+// float cos_theta = dot(I, omega_in);
+ float cos_theta = dot(-I, omega_in);
+
+ if(fabsf(m_g) < magic_eps)
+ *pdf = M_1_PI_F * 0.25f; // ?? double check it
+ else
+ *pdf = single_peaked_henyey_greenstein(cos_theta, m_g);
+
+ return make_float3(*pdf, *pdf, *pdf);
+}
+
- __device int volume_henyey_greenstein_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv,
++ccl_device int volume_henyey_greenstein_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv,
+ float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+{
+ float m_g = sc->data1;
+ const float magic_eps = 0.001f;
+
+ // WARNING! I point in backward direction!
+
+ if(fabsf(m_g) < magic_eps) {
+ *omega_in = sample_uniform_sphere(randu, randv);
+ *pdf = M_1_PI_F * 0.25f; // ?? double check it
+ }
+ else {
+ float cos_phi, sin_phi, cos_theta;
+
+ if(fabsf(m_g) < magic_eps)
+ cos_theta = (1.0f - 2.0f * randu);
+ else {
+ float k = (1.0f - m_g * m_g) / (1.0f - m_g + 2.0f * m_g * randu);
+ cos_theta = (1.0f + m_g * m_g - k * k) / (2.0f * m_g);
+ // float cos_theta = 1.0f / (2.0f * m_g) * (1.0f + m_g * m_g - k*k);
+ // float cos_theta = (1.0f - 2.0f * randu);
+ // float cos_theta = randu;
+ }
+ float sin_theta = sqrt(1 - cos_theta * cos_theta);
+
+ float3 T, B;
+ make_orthonormals(-I, &T, &B);
+ float phi = M_2PI_F * randv;
+ cos_phi = cosf(phi);
+ sin_phi = sinf(phi);
+ *omega_in = sin_theta * cos_phi * T + sin_theta * sin_phi * B + cos_theta * (-I);
+ *pdf = single_peaked_henyey_greenstein(cos_theta, m_g);
+ }
+
+ *eval = make_float3(*pdf, *pdf, *pdf); // perfect importance sampling
+#ifdef __RAY_DIFFERENTIALS__
+ // TODO: find a better approximation for the diffuse bounce
+ *domega_in_dx = (2 * dot(Ng, dIdx)) * Ng - dIdx;
+ *domega_in_dy = (2 * dot(Ng, dIdy)) * Ng - dIdy;
+ *domega_in_dx *= 125.0f;
+ *domega_in_dy *= 125.0f;
+#endif
+ return LABEL_REFLECT|LABEL_DIFFUSE;
}
/* TRANSPARENT VOLUME CLOSURE */
- __device int volume_transparent_setup(ShaderClosure *sc)
-ccl_device int volume_transparent_setup(ShaderClosure *sc, float density)
++ccl_device int volume_transparent_setup(ShaderClosure *sc)
{
sc->type = CLOSURE_VOLUME_TRANSPARENT_ID;
- sc->data0 = density;
return SD_VOLUME;
}
- __device float3 volume_transparent_eval_phase(const ShaderClosure *sc, const float3 I, float3 omega_in, float *pdf)
-ccl_device float3 volume_transparent_eval_phase(const ShaderClosure *sc, const float3 omega_in, const float3 omega_out)
++ccl_device float3 volume_transparent_eval_phase(const ShaderClosure *sc, const float3 I, float3 omega_in, float *pdf)
{
return make_float3(1.0f, 1.0f, 1.0f);
}
- __device int volume_transparent_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv,
++ccl_device int volume_transparent_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv,
+ float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
+{
+ /* XXX Implement */
+ return LABEL_REFLECT|LABEL_DIFFUSE;
+}
+
/* VOLUME CLOSURE */
- __device float3 volume_eval_phase(KernelGlobals *kg, const ShaderClosure *sc, const float3 I, float3 omega_in, float *pdf)
-ccl_device float3 volume_eval_phase(KernelGlobals *kg, const ShaderClosure *sc, const float3 omega_in, const float3 omega_out)
++ccl_device float3 volume_eval_phase(KernelGlobals *kg, const ShaderClosure *sc, const float3 I, float3 omega_in, float *pdf)
{
-#ifdef __OSL__
- if(kg->osl && sc->prim)
- return OSLShader::volume_eval_phase(sc, omega_in, omega_out);
-#endif
-
float3 eval;
switch(sc->type) {
@@@ -144,29 -75,5 +144,29 @@@
return eval;
}
- __device int volume_sample(KernelGlobals *kg, const ShaderData *sd, const ShaderClosure *sc, float randu,
++ccl_device int volume_sample(KernelGlobals *kg, const ShaderData *sd, const ShaderClosure *sc, float randu,
+ float randv, float3 *eval, float3 *omega_in, differential3 *domega_in, float *pdf)
+{
+ int label;
+
+ switch(sc->type) {
+ case CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID:
+ label = volume_henyey_greenstein_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
+ break;
+ case CLOSURE_VOLUME_TRANSPARENT_ID:
+ label = volume_transparent_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
+ break;
+ default:
+ *eval = make_float3(0.0f, 0.0f, 0.0f);
+ label = LABEL_NONE;
+ break;
+ }
+
+// *eval *= sd->svm_closure_weight;
+
+ return label;
+}
+
CCL_NAMESPACE_END
+#endif
diff --cc intern/cycles/kernel/kernel_emission.h
index 4eecdbb,2ce0b75..2a75a3d
--- a/intern/cycles/kernel/kernel_emission.h
+++ b/intern/cycles/kernel/kernel_emission.h
@@@ -70,46 -70,7 +70,46 @@@ ccl_device_noinline float3 direct_emiss
return eval;
}
+#ifdef __VOLUME__
+/* ToDo: Remove these 2 duplicate functions */
- __device float sigma_from_value_(float value, float geom_factor)
++ccl_device float sigma_from_value_(float value, float geom_factor)
+{
+#if 0
+// const float att_magic_eps = 1e-7f;
+ const float att_magic_eps = 1e-15f;
+ float attenuation = 1-value;
+ // protect infinity nan from too big density materials
+ if( attenuation < att_magic_eps) attenuation = att_magic_eps;
+ return (-logf( attenuation )/geom_factor);
+#else
+ return value * geom_factor;
+#endif
+}
+
- __device float get_sigma_sample_(KernelGlobals *kg, ShaderData *sd, float randv, int path_flag, float3 p)
++ccl_device float get_sigma_sample_(KernelGlobals *kg, ShaderData *sd, float randv, int path_flag, float3 p)
+{
+ ShaderData vsd = *sd;
+ vsd.P = p;
+
+#ifdef __MULTI_CLOSURE__
+ int sampled = 0;
+
+ // if(vsd.num_closure > 1)
+
+ const ShaderClosure *sc = &sd->closure[sampled];
+
+ shader_eval_volume(kg, &vsd, randv, path_flag, SHADER_CONTEXT_MAIN);
+ float v = sc->data0;
+#else
+ shader_eval_volume(kg, &vsd, randv, path_flag, SHADER_CONTEXT_MAIN);
+ float v = sd->closure.data0;
+#endif
+
+ return sigma_from_value_(v, kernel_data.integrator.volume_density_factor);
+}
+#endif
+
- __device_noinline bool direct_emission(KernelGlobals *kg, ShaderData *sd, int lindex,
+ ccl_device_noinline bool direct_emission(KernelGlobals *kg, ShaderData *sd, int lindex,
float randt, float r
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list