Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Stockner <lukas.stockner@freenet.de>2016-06-08 04:17:19 +0300
committerJeroen Bakker <j.bakker@atmind.nl>2016-06-08 22:45:40 +0300
commit74c65981ceb55ed8007be2ee8fd1dd7624c29b0c (patch)
tree00851ce4727adc4621573079b1a1bb5e1da77620
parentb5a9434a29a19e214c2fee8427351392620f3762 (diff)
Cycles: Fix two numerical issues in the volume code
This hopefully fixes T48383 by avoiding two numerical problems that I found in the volume code. Reviewers: sergey, dingto, brecht Reviewed By: sergey, dingto, brecht Maniphest Tasks: T48383 Differential Revision: https://developer.blender.org/D2051
-rw-r--r--intern/cycles/kernel/kernel_volume.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/intern/cycles/kernel/kernel_volume.h b/intern/cycles/kernel/kernel_volume.h
index 0e313b8e88c..bf8301fe5fb 100644
--- a/intern/cycles/kernel/kernel_volume.h
+++ b/intern/cycles/kernel/kernel_volume.h
@@ -276,7 +276,7 @@ ccl_device float kernel_volume_distance_sample(float max_t, float3 sigma_t, int
float sample_t = min(max_t, -logf(1.0f - xi*(1.0f - sample_transmittance))/sample_sigma_t);
*transmittance = volume_color_transmittance(sigma_t, sample_t);
- *pdf = (sigma_t * *transmittance)/(make_float3(1.0f, 1.0f, 1.0f) - full_transmittance);
+ *pdf = safe_divide_color(sigma_t * *transmittance, make_float3(1.0f, 1.0f, 1.0f) - full_transmittance);
/* todo: optimization: when taken together with hit/miss decision,
* the full_transmittance cancels out drops out and xi does not
@@ -290,7 +290,7 @@ ccl_device float3 kernel_volume_distance_pdf(float max_t, float3 sigma_t, float
float3 full_transmittance = volume_color_transmittance(sigma_t, max_t);
float3 transmittance = volume_color_transmittance(sigma_t, sample_t);
- return (sigma_t * transmittance)/(make_float3(1.0f, 1.0f, 1.0f) - full_transmittance);
+ return safe_divide_color(sigma_t * transmittance, make_float3(1.0f, 1.0f, 1.0f) - full_transmittance);
}
/* Emission */
@@ -625,11 +625,13 @@ ccl_device void kernel_volume_decoupled_record(KernelGlobals *kg, PathState *sta
const int global_max_steps = kernel_data.integrator.volume_max_steps;
step_size = kernel_data.integrator.volume_step_size;
/* compute exact steps in advance for malloc */
- max_steps = max((int)ceilf(ray->t/step_size), 1);
- if(max_steps > global_max_steps) {
+ if(ray->t > global_max_steps*step_size) {
max_steps = global_max_steps;
step_size = ray->t / (float)max_steps;
}
+ else {
+ max_steps = max((int)ceilf(ray->t/step_size), 1);
+ }
#ifdef __KERNEL_CPU__
/* NOTE: For the branched path tracing it's possible to have direct
* and indirect light integration both having volume segments allocated.