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:
authorThomas Dinges <blender@dingto.org>2014-08-02 17:04:00 +0400
committerThomas Dinges <blender@dingto.org>2014-08-02 17:04:00 +0400
commit28f8e253667d6f8cc598990b0338160c0c513939 (patch)
tree0dd0387ca683e40d4deb5bd0b2b142c0d5613f6c
parentd98094adde720fd7954535343afb014265705491 (diff)
Cycles: Avoid some NULL checks and conditions in volume sampling code.
* Avoid segment NULL check in kernel_branched_path_volume_connect_light(), we access it before the function call already. * Avoid SD_SCATTER flag check in kernel_volume_decoupled_scatter(), we check for this before already.
-rw-r--r--intern/cycles/kernel/kernel_path_volume.h63
-rw-r--r--intern/cycles/kernel/kernel_volume.h5
2 files changed, 24 insertions, 44 deletions
diff --git a/intern/cycles/kernel/kernel_path_volume.h b/intern/cycles/kernel/kernel_path_volume.h
index fd22daf6055..61d9f74816b 100644
--- a/intern/cycles/kernel/kernel_path_volume.h
+++ b/intern/cycles/kernel/kernel_path_volume.h
@@ -136,23 +136,18 @@ ccl_device void kernel_branched_path_volume_connect_light(KernelGlobals *kg, RNG
float3 tp = throughput;
/* sample position on volume segment */
- if(segment) {
- float rphase = path_branched_rng_1D_for_decision(kg, rng, state, j, num_samples, PRNG_PHASE);
- float rscatter = path_branched_rng_1D_for_decision(kg, rng, state, j, num_samples, PRNG_SCATTER_DISTANCE);
+ float rphase = path_branched_rng_1D_for_decision(kg, rng, state, j, num_samples, PRNG_PHASE);
+ float rscatter = path_branched_rng_1D_for_decision(kg, rng, state, j, num_samples, PRNG_SCATTER_DISTANCE);
- lamp_light_sample_position(kg, i, light_u, light_v, ray->P, &ls);
+ lamp_light_sample_position(kg, i, light_u, light_v, ray->P, &ls);
- VolumeIntegrateResult result = kernel_volume_decoupled_scatter(kg,
- state, ray, sd, &tp, rphase, rscatter, segment, (ls.t != FLT_MAX)? &ls.P: NULL, false);
+ VolumeIntegrateResult result = kernel_volume_decoupled_scatter(kg,
+ state, ray, sd, &tp, rphase, rscatter, segment, (ls.t != FLT_MAX)? &ls.P: NULL, false);
- if(result != VOLUME_PATH_SCATTERED)
- continue;
+ if(result != VOLUME_PATH_SCATTERED)
+ continue;
- lamp_light_sample(kg, i, light_u, light_v, sd->P, &ls);
- }
- else {
- lamp_light_sample(kg, i, light_u, light_v, ray->P, &ls);
- }
+ lamp_light_sample(kg, i, light_u, light_v, sd->P, &ls);
if(direct_emission(kg, sd, &ls, &light_ray, &L_light, &is_lamp, state->bounce, state->transparent_bounce)) {
/* trace shadow ray */
@@ -189,23 +184,18 @@ ccl_device void kernel_branched_path_volume_connect_light(KernelGlobals *kg, RNG
float3 tp = throughput;
/* sample position on volume segment */
- if(segment) {
- float rphase = path_branched_rng_1D_for_decision(kg, rng, state, j, num_samples, PRNG_PHASE);
- float rscatter = path_branched_rng_1D_for_decision(kg, rng, state, j, num_samples, PRNG_SCATTER_DISTANCE);
+ float rphase = path_branched_rng_1D_for_decision(kg, rng, state, j, num_samples, PRNG_PHASE);
+ float rscatter = path_branched_rng_1D_for_decision(kg, rng, state, j, num_samples, PRNG_SCATTER_DISTANCE);
- light_sample_position(kg, light_t, light_u, light_v, sd->time, ray->P, &ls);
+ light_sample_position(kg, light_t, light_u, light_v, sd->time, ray->P, &ls);
- VolumeIntegrateResult result = kernel_volume_decoupled_scatter(kg,
- state, ray, sd, &tp, rphase, rscatter, segment, (ls.t != FLT_MAX)? &ls.P: NULL, false);
+ VolumeIntegrateResult result = kernel_volume_decoupled_scatter(kg,
+ state, ray, sd, &tp, rphase, rscatter, segment, (ls.t != FLT_MAX)? &ls.P: NULL, false);
- if(result != VOLUME_PATH_SCATTERED)
- continue;
+ if(result != VOLUME_PATH_SCATTERED)
+ continue;
- light_sample(kg, light_t, light_u, light_v, sd->time, sd->P, &ls);
- }
- else {
- light_sample(kg, light_t, light_u, light_v, sd->time, ray->P, &ls);
- }
+ light_sample(kg, light_t, light_u, light_v, sd->time, sd->P, &ls);
if(direct_emission(kg, sd, &ls, &light_ray, &L_light, &is_lamp, state->bounce, state->transparent_bounce)) {
/* trace shadow ray */
@@ -231,23 +221,18 @@ ccl_device void kernel_branched_path_volume_connect_light(KernelGlobals *kg, RNG
float3 tp = throughput;
/* sample position on volume segment */
- if(segment) {
- float rphase = path_state_rng_1D_for_decision(kg, rng, state, PRNG_PHASE);
- float rscatter = path_state_rng_1D_for_decision(kg, rng, state, PRNG_SCATTER_DISTANCE);
+ float rphase = path_state_rng_1D_for_decision(kg, rng, state, PRNG_PHASE);
+ float rscatter = path_state_rng_1D_for_decision(kg, rng, state, PRNG_SCATTER_DISTANCE);
- light_sample_position(kg, light_t, light_u, light_v, sd->time, ray->P, &ls);
+ light_sample_position(kg, light_t, light_u, light_v, sd->time, ray->P, &ls);
- VolumeIntegrateResult result = kernel_volume_decoupled_scatter(kg,
- state, ray, sd, &tp, rphase, rscatter, segment, (ls.t != FLT_MAX)? &ls.P: NULL, false);
+ VolumeIntegrateResult result = kernel_volume_decoupled_scatter(kg,
+ state, ray, sd, &tp, rphase, rscatter, segment, (ls.t != FLT_MAX)? &ls.P: NULL, false);
- if(result != VOLUME_PATH_SCATTERED)
- return;
+ if(result != VOLUME_PATH_SCATTERED)
+ return;
- light_sample(kg, light_t, light_u, light_v, sd->time, sd->P, &ls);
- }
- else {
- light_sample(kg, light_t, light_u, light_v, sd->time, ray->P, &ls);
- }
+ light_sample(kg, light_t, light_u, light_v, sd->time, sd->P, &ls);
/* sample random light */
if(direct_emission(kg, sd, &ls, &light_ray, &L_light, &is_lamp, state->bounce, state->transparent_bounce)) {
diff --git a/intern/cycles/kernel/kernel_volume.h b/intern/cycles/kernel/kernel_volume.h
index 6d5b1c2885f..b13168cfa19 100644
--- a/intern/cycles/kernel/kernel_volume.h
+++ b/intern/cycles/kernel/kernel_volume.h
@@ -738,11 +738,6 @@ ccl_device VolumeIntegrateResult kernel_volume_decoupled_scatter(
float3 *throughput, float rphase, float rscatter,
const VolumeSegment *segment, const float3 *light_P, bool probalistic_scatter)
{
- int closure_flag = segment->closure_flag;
-
- if(!(closure_flag & SD_SCATTER))
- return VOLUME_PATH_MISSED;
-
/* pick random color channel, we use the Veach one-sample
* model with balance heuristic for the channels */
int channel = (int)(rphase*3.0f);