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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2014-02-06 18:18:34 +0400
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2014-02-06 18:24:15 +0400
commita41648c1dc58fcfdb149bf6839ae237d1dadc704 (patch)
tree25fed9ed0a9d5e3f2dcfe60074e7ae3be19914ba /intern/cycles/kernel/kernel_passes.h
parent5cbddd4ca47b4b2b45ae7284129db5b83d1a948c (diff)
Cycles: add pass alpha threshold value to render layers.
Z, Index, normal, UV and vector passes are only affected by surfaces with alpha transparency equal to or higher than this threshold. With value 0.0 the first surface hit will always write to these passes, regardless of transparency. With higher values surfaces that are mostly transparent can be skipped until an opaque surface is encountered.
Diffstat (limited to 'intern/cycles/kernel/kernel_passes.h')
-rw-r--r--intern/cycles/kernel/kernel_passes.h60
1 files changed, 34 insertions, 26 deletions
diff --git a/intern/cycles/kernel/kernel_passes.h b/intern/cycles/kernel/kernel_passes.h
index 512db9ec392..9cdcb8c5229 100644
--- a/intern/cycles/kernel/kernel_passes.h
+++ b/intern/cycles/kernel/kernel_passes.h
@@ -35,9 +35,11 @@ ccl_device_inline void kernel_write_pass_float4(ccl_global float *buffer, int sa
}
ccl_device_inline void kernel_write_data_passes(KernelGlobals *kg, ccl_global float *buffer, PathRadiance *L,
- ShaderData *sd, int sample, int path_flag, float3 throughput)
+ ShaderData *sd, int sample, PathState *state, float3 throughput)
{
#ifdef __PASSES__
+ int path_flag = state->flag;
+
if(!(path_flag & PATH_RAY_CAMERA))
return;
@@ -46,35 +48,41 @@ ccl_device_inline void kernel_write_data_passes(KernelGlobals *kg, ccl_global fl
if(!(flag & PASS_ALL))
return;
- /* todo: add alpha threshold */
- if(!(path_flag & PATH_RAY_TRANSPARENT)) {
- if(sample == 0) {
- if(flag & PASS_DEPTH) {
- float depth = camera_distance(kg, sd->P);
- kernel_write_pass_float(buffer + kernel_data.film.pass_depth, sample, depth);
+ if(!(path_flag & PATH_RAY_SINGLE_PASS_DONE)) {
+ if(!(sd->flag & SD_TRANSPARENT) ||
+ kernel_data.film.pass_alpha_threshold == 0.0f ||
+ average(shader_bsdf_alpha(kg, sd)) >= kernel_data.film.pass_alpha_threshold) {
+
+ if(sample == 0) {
+ if(flag & PASS_DEPTH) {
+ float depth = camera_distance(kg, sd->P);
+ kernel_write_pass_float(buffer + kernel_data.film.pass_depth, sample, depth);
+ }
+ if(flag & PASS_OBJECT_ID) {
+ float id = object_pass_id(kg, sd->object);
+ kernel_write_pass_float(buffer + kernel_data.film.pass_object_id, sample, id);
+ }
+ if(flag & PASS_MATERIAL_ID) {
+ float id = shader_pass_id(kg, sd);
+ kernel_write_pass_float(buffer + kernel_data.film.pass_material_id, sample, id);
+ }
}
- if(flag & PASS_OBJECT_ID) {
- float id = object_pass_id(kg, sd->object);
- kernel_write_pass_float(buffer + kernel_data.film.pass_object_id, sample, id);
+
+ if(flag & PASS_NORMAL) {
+ float3 normal = sd->N;
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_normal, sample, normal);
}
- if(flag & PASS_MATERIAL_ID) {
- float id = shader_pass_id(kg, sd);
- kernel_write_pass_float(buffer + kernel_data.film.pass_material_id, sample, id);
+ if(flag & PASS_UV) {
+ float3 uv = primitive_uv(kg, sd);
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_uv, sample, uv);
+ }
+ if(flag & PASS_MOTION) {
+ float4 speed = primitive_motion_vector(kg, sd);
+ kernel_write_pass_float4(buffer + kernel_data.film.pass_motion, sample, speed);
+ kernel_write_pass_float(buffer + kernel_data.film.pass_motion_weight, sample, 1.0f);
}
- }
- if(flag & PASS_NORMAL) {
- float3 normal = sd->N;
- kernel_write_pass_float3(buffer + kernel_data.film.pass_normal, sample, normal);
- }
- if(flag & PASS_UV) {
- float3 uv = primitive_uv(kg, sd);
- kernel_write_pass_float3(buffer + kernel_data.film.pass_uv, sample, uv);
- }
- if(flag & PASS_MOTION) {
- float4 speed = primitive_motion_vector(kg, sd);
- kernel_write_pass_float4(buffer + kernel_data.film.pass_motion, sample, speed);
- kernel_write_pass_float(buffer + kernel_data.film.pass_motion_weight, sample, 1.0f);
+ state->flag |= PATH_RAY_SINGLE_PASS_DONE;
}
}