[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60076] branches/soc-2013-dingto/intern/ cycles/kernel: Volume:
Thomas Dinges
blender at dingto.org
Thu Sep 12 17:01:01 CEST 2013
Revision: 60076
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60076
Author: dingto
Date: 2013-09-12 15:01:00 +0000 (Thu, 12 Sep 2013)
Log Message:
-----------
Volume:
* direct_emission() and indirect_primitive_emission() were inlined for some reason, change back to noinlined (as in trunk).
* Put most volume kernel code behind __VOLUME__ now.
Modified Paths:
--------------
branches/soc-2013-dingto/intern/cycles/kernel/kernel_emission.h
branches/soc-2013-dingto/intern/cycles/kernel/kernel_path.h
Modified: branches/soc-2013-dingto/intern/cycles/kernel/kernel_emission.h
===================================================================
--- branches/soc-2013-dingto/intern/cycles/kernel/kernel_emission.h 2013-09-12 14:45:50 UTC (rev 60075)
+++ branches/soc-2013-dingto/intern/cycles/kernel/kernel_emission.h 2013-09-12 15:01:00 UTC (rev 60076)
@@ -70,6 +70,8 @@
return eval;
}
+#ifdef __VOLUME__
+/* ToDo: Remove these 2 duplicate functions */
__device float sigma_from_value_(float value, float geom_factor)
{
#if 0
@@ -107,10 +109,9 @@
return sigma_from_value_(v, kernel_data.integrator.volume_density_factor);
}
+#endif
-
-
-__device bool direct_emission(KernelGlobals *kg, ShaderData *sd, int lindex,
+__device_noinline bool direct_emission(KernelGlobals *kg, ShaderData *sd, int lindex,
float randt, float rando, float randu, float randv, Ray *ray, BsdfEval *eval,
bool *is_lamp, int bounce)
{
@@ -147,7 +148,7 @@
if(ls.shader & SHADER_USE_MIS) {
/* multiple importance sampling */
-#if 1
+#ifdef __VOLUME__
// with respect to volume pdf
// W = (pdf_dir*pdf_dir) / (pdf_indirect*pdf_indirect + pdf_dir*pdf_dir)
// pdf_dir = pre_hit_bsdf_pdf * 1.0 * 1.0f / (triangle_area) ?
@@ -218,7 +219,7 @@
/* Indirect Primitive Emission */
-__device float3 indirect_primitive_emission(KernelGlobals *kg, ShaderData *sd, float t, int path_flag, float bsdf_pdf, float volume_pdf = 0.0f)
+__device_noinline float3 indirect_primitive_emission(KernelGlobals *kg, ShaderData *sd, float t, int path_flag, float bsdf_pdf, float volume_pdf = 0.0f)
{
/* evaluate emissive closure */
float3 L = shader_emissive_eval(kg, sd);
@@ -231,10 +232,11 @@
/* multiple importance sampling, get triangle light pdf,
* and compute weight with respect to BSDF pdf */
float pdf = triangle_light_pdf(kg, sd->Ng, sd->I, t);
-// float mis_weight = power_heuristic(bsdf_pdf, pdf);
-// float mis_weight = power_heuristic(bsdf_pdf, pdf / volume_pdf);
+#ifdef __VOLUME__
float mis_weight = power_heuristic(bsdf_pdf * volume_pdf, pdf);
-
+#else
+ float mis_weight = power_heuristic(bsdf_pdf, pdf);
+#endif
return L*mis_weight;
}
Modified: branches/soc-2013-dingto/intern/cycles/kernel/kernel_path.h
===================================================================
--- branches/soc-2013-dingto/intern/cycles/kernel/kernel_path.h 2013-09-12 14:45:50 UTC (rev 60075)
+++ branches/soc-2013-dingto/intern/cycles/kernel/kernel_path.h 2013-09-12 15:01:00 UTC (rev 60076)
@@ -471,15 +471,20 @@
float min_ray_pdf = FLT_MAX;
float ray_pdf = 0.0f;
- float3 volume_eval = make_float3(1.0f, 1.0f, 1.0f);
- float volume_pdf = 1.0f;
float ray_t = 0.0f;
PathState state;
int rng_offset = PRNG_BASE_NUM;
+
+#ifdef __VOLUME__
+ float3 volume_eval = make_float3(1.0f, 1.0f, 1.0f);
+ float volume_pdf = 1.0f;
+ float omega_cache = 0.0f;
uint rng_congruential = lcg_init(*rng + sample*0x51633e2d);
int media_volume_shader = kernel_data.background.shader; // assume camera always in air, need proper CSG stack based solution.
//media_volume_shader = get_media_volume_shader(kg, ray.P);
//media_volume_shader = gmsdr(kg, ray.P);
+#endif
+
#ifdef __CMJ__
int num_samples = kernel_data.integrator.aa_samples;
#else
@@ -489,7 +494,6 @@
path_state_init(&state);
/* path iteration */
- float omega_cache = 0.0f;
for(;; rng_offset += PRNG_BOUNCE_NUM) {
/* intersect scene */
Intersection isect;
@@ -569,7 +573,9 @@
break;
}
+#ifdef __VOLUME__
omega_cache = 0.0f;
+#endif
/* setup shading */
ShaderData sd;
@@ -615,8 +621,11 @@
/* emission */
if(sd.flag & SD_EMISSION) {
/* todo: is isect.t wrong here for transparent surfaces? */
-// float3 emission = indirect_primitive_emission(kg, &sd, isect.t, state.flag, ray_pdf);
+#ifdef __VOLUME__
float3 emission = indirect_primitive_emission(kg, &sd, isect.t, state.flag, ray_pdf, volume_pdf);
+#else
+ float3 emission = indirect_primitive_emission(kg, &sd, isect.t, state.flag, ray_pdf);
+#endif
path_radiance_accum_emission(&L, throughput, emission, state.bounce);
}
#endif
@@ -663,12 +672,11 @@
#ifdef __OBJECT_MOTION__
light_ray.time = sd.time;
#endif
- float tmp_volume_pdf;
-
light_ray.dP = sd.dP;
light_ray.dD = differential3_zero();
#ifdef __VOLUME__
+ float tmp_volume_pdf;
if(!shadow_blocked_new(kg, rng, rng_offset, &rng_congruential, sample, &state, &light_ray, &ao_shadow, media_volume_shader, &tmp_volume_pdf, state.bounce))
#else
if(!shadow_blocked(kg, &state, &light_ray, &ao_shadow))
@@ -757,9 +765,8 @@
if(direct_emission(kg, &sd, -1, light_t, light_o, light_u, light_v, &light_ray, &L_light, &is_lamp, state.bounce)) {
/* trace shadow ray */
float3 shadow;
+#ifdef __VOLUME__
float tmp_volume_pdf;
-
-#ifdef __VOLUME__
if(!shadow_blocked_new(kg, rng, rng_offset, &rng_congruential, sample, &state, &light_ray, &shadow, media_volume_shader, &tmp_volume_pdf, state.bounce)) {
#else
if(!shadow_blocked(kg, &state, &light_ray, &shadow)) {
@@ -792,7 +799,9 @@
break;
/* modify throughput */
+#ifdef __VOLUME__
bsdf_eval_mul(&bsdf_eval, volume_eval/volume_pdf);
+#endif
path_radiance_bsdf_bounce(&L, &throughput, &bsdf_eval, bsdf_pdf, state.bounce, label);
/* set labels */
@@ -804,7 +813,9 @@
min_ray_pdf = fminf(bsdf_pdf, min_ray_pdf);
}
+#ifdef __VOLUME__
ray_pdf *= volume_pdf;
+#endif
/* update path state */
path_state_next(kg, &state, label);
@@ -1018,7 +1029,9 @@
/* intersect scene */
Intersection isect;
uint visibility = path_state_ray_visibility(kg, &state);
+#ifdef __VOLUME__
uint rng_congruential = lcg_init(*rng + rng_offset + sample*0x51633e2d);
+#endif
#ifdef __HAIR__
float difl = 0.0f, extmax = 0.0f;
More information about the Bf-blender-cvs
mailing list