Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
/*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Copyright 2011-2013 Blender Foundation
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
2013-11-15 23:17:10 +00:00
|
|
|
ccl_device_inline void kernel_write_pass_float(ccl_global float *buffer, int sample, float value)
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
{
|
2013-11-15 23:17:10 +00:00
|
|
|
ccl_global float *buf = buffer;
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
*buf = (sample == 0)? value: *buf + value;
|
|
|
|
}
|
|
|
|
|
2013-11-15 23:17:10 +00:00
|
|
|
ccl_device_inline void kernel_write_pass_float3(ccl_global float *buffer, int sample, float3 value)
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
{
|
2013-11-15 23:17:10 +00:00
|
|
|
ccl_global float3 *buf = (ccl_global float3*)buffer;
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
*buf = (sample == 0)? value: *buf + value;
|
|
|
|
}
|
|
|
|
|
2013-11-15 23:17:10 +00:00
|
|
|
ccl_device_inline void kernel_write_pass_float4(ccl_global float *buffer, int sample, float4 value)
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
{
|
2013-11-15 23:17:10 +00:00
|
|
|
ccl_global float4 *buf = (ccl_global float4*)buffer;
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
*buf = (sample == 0)? value: *buf + value;
|
|
|
|
}
|
|
|
|
|
2013-11-15 23:17:10 +00:00
|
|
|
ccl_device_inline void kernel_write_data_passes(KernelGlobals *kg, ccl_global float *buffer, PathRadiance *L,
|
2014-02-06 14:18:34 +00:00
|
|
|
ShaderData *sd, int sample, PathState *state, float3 throughput)
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
{
|
|
|
|
#ifdef __PASSES__
|
2014-02-06 14:18:34 +00:00
|
|
|
int path_flag = state->flag;
|
|
|
|
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
if(!(path_flag & PATH_RAY_CAMERA))
|
|
|
|
return;
|
|
|
|
|
|
|
|
int flag = kernel_data.film.pass_flag;
|
|
|
|
|
|
|
|
if(!(flag & PASS_ALL))
|
|
|
|
return;
|
|
|
|
|
2014-02-06 14:18:34 +00:00
|
|
|
if(!(path_flag & PATH_RAY_SINGLE_PASS_DONE)) {
|
|
|
|
if(!(sd->flag & SD_TRANSPARENT) ||
|
|
|
|
kernel_data.film.pass_alpha_threshold == 0.0f ||
|
2014-05-04 16:19:08 +00:00
|
|
|
average(shader_bsdf_alpha(kg, sd)) >= kernel_data.film.pass_alpha_threshold)
|
|
|
|
{
|
2014-02-06 14:18:34 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
}
|
2014-02-06 14:18:34 +00:00
|
|
|
|
|
|
|
if(flag & PASS_NORMAL) {
|
|
|
|
float3 normal = sd->N;
|
|
|
|
kernel_write_pass_float3(buffer + kernel_data.film.pass_normal, sample, normal);
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
}
|
2014-02-06 14:18:34 +00:00
|
|
|
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);
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
}
|
|
|
|
|
2014-02-06 14:18:34 +00:00
|
|
|
state->flag |= PATH_RAY_SINGLE_PASS_DONE;
|
2012-04-30 12:49:26 +00:00
|
|
|
}
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(flag & (PASS_DIFFUSE_INDIRECT|PASS_DIFFUSE_COLOR|PASS_DIFFUSE_DIRECT))
|
|
|
|
L->color_diffuse += shader_bsdf_diffuse(kg, sd)*throughput;
|
|
|
|
if(flag & (PASS_GLOSSY_INDIRECT|PASS_GLOSSY_COLOR|PASS_GLOSSY_DIRECT))
|
|
|
|
L->color_glossy += shader_bsdf_glossy(kg, sd)*throughput;
|
|
|
|
if(flag & (PASS_TRANSMISSION_INDIRECT|PASS_TRANSMISSION_COLOR|PASS_TRANSMISSION_DIRECT))
|
|
|
|
L->color_transmission += shader_bsdf_transmission(kg, sd)*throughput;
|
2013-08-03 13:12:09 +00:00
|
|
|
if(flag & (PASS_SUBSURFACE_INDIRECT|PASS_SUBSURFACE_COLOR|PASS_SUBSURFACE_DIRECT))
|
|
|
|
L->color_subsurface += shader_bsdf_subsurface(kg, sd)*throughput;
|
2013-06-07 12:45:26 +00:00
|
|
|
|
|
|
|
if(flag & PASS_MIST) {
|
|
|
|
/* bring depth into 0..1 range */
|
|
|
|
float mist_start = kernel_data.film.mist_start;
|
|
|
|
float mist_inv_depth = kernel_data.film.mist_inv_depth;
|
|
|
|
|
|
|
|
float depth = camera_distance(kg, sd->P);
|
|
|
|
float mist = clamp((depth - mist_start)*mist_inv_depth, 0.0f, 1.0f);
|
|
|
|
|
|
|
|
/* falloff */
|
|
|
|
float mist_falloff = kernel_data.film.mist_falloff;
|
|
|
|
|
|
|
|
if(mist_falloff == 1.0f)
|
|
|
|
;
|
|
|
|
else if(mist_falloff == 2.0f)
|
|
|
|
mist = mist*mist;
|
|
|
|
else if(mist_falloff == 0.5f)
|
|
|
|
mist = sqrtf(mist);
|
|
|
|
else
|
|
|
|
mist = powf(mist, mist_falloff);
|
|
|
|
|
|
|
|
/* modulate by transparency */
|
2013-09-17 13:22:42 +00:00
|
|
|
float3 alpha = shader_bsdf_alpha(kg, sd);
|
|
|
|
L->mist += (1.0f - mist)*average(throughput*alpha);
|
2013-06-07 12:45:26 +00:00
|
|
|
}
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-11-15 23:17:10 +00:00
|
|
|
ccl_device_inline void kernel_write_light_passes(KernelGlobals *kg, ccl_global float *buffer, PathRadiance *L, int sample)
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
{
|
|
|
|
#ifdef __PASSES__
|
|
|
|
int flag = kernel_data.film.pass_flag;
|
|
|
|
|
|
|
|
if(!kernel_data.film.use_light_pass)
|
|
|
|
return;
|
|
|
|
|
2012-03-28 12:18:12 +00:00
|
|
|
if(flag & PASS_DIFFUSE_INDIRECT)
|
|
|
|
kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_indirect, sample, L->indirect_diffuse);
|
|
|
|
if(flag & PASS_GLOSSY_INDIRECT)
|
|
|
|
kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_indirect, sample, L->indirect_glossy);
|
|
|
|
if(flag & PASS_TRANSMISSION_INDIRECT)
|
|
|
|
kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_indirect, sample, L->indirect_transmission);
|
2013-08-03 13:12:09 +00:00
|
|
|
if(flag & PASS_SUBSURFACE_INDIRECT)
|
|
|
|
kernel_write_pass_float3(buffer + kernel_data.film.pass_subsurface_indirect, sample, L->indirect_subsurface);
|
2012-03-28 12:18:12 +00:00
|
|
|
if(flag & PASS_DIFFUSE_DIRECT)
|
|
|
|
kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_direct, sample, L->direct_diffuse);
|
|
|
|
if(flag & PASS_GLOSSY_DIRECT)
|
|
|
|
kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_direct, sample, L->direct_glossy);
|
|
|
|
if(flag & PASS_TRANSMISSION_DIRECT)
|
|
|
|
kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_direct, sample, L->direct_transmission);
|
2013-08-03 13:12:09 +00:00
|
|
|
if(flag & PASS_SUBSURFACE_DIRECT)
|
|
|
|
kernel_write_pass_float3(buffer + kernel_data.film.pass_subsurface_direct, sample, L->direct_subsurface);
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
|
|
|
|
if(flag & PASS_EMISSION)
|
|
|
|
kernel_write_pass_float3(buffer + kernel_data.film.pass_emission, sample, L->emission);
|
|
|
|
if(flag & PASS_BACKGROUND)
|
|
|
|
kernel_write_pass_float3(buffer + kernel_data.film.pass_background, sample, L->background);
|
2012-02-28 16:45:08 +00:00
|
|
|
if(flag & PASS_AO)
|
|
|
|
kernel_write_pass_float3(buffer + kernel_data.film.pass_ao, sample, L->ao);
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
|
|
|
|
if(flag & PASS_DIFFUSE_COLOR)
|
|
|
|
kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_color, sample, L->color_diffuse);
|
|
|
|
if(flag & PASS_GLOSSY_COLOR)
|
|
|
|
kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_color, sample, L->color_glossy);
|
|
|
|
if(flag & PASS_TRANSMISSION_COLOR)
|
|
|
|
kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_color, sample, L->color_transmission);
|
2013-08-03 13:12:09 +00:00
|
|
|
if(flag & PASS_SUBSURFACE_COLOR)
|
|
|
|
kernel_write_pass_float3(buffer + kernel_data.film.pass_subsurface_color, sample, L->color_subsurface);
|
2012-09-28 13:41:34 +00:00
|
|
|
if(flag & PASS_SHADOW) {
|
|
|
|
float4 shadow = L->shadow;
|
2013-02-13 16:46:18 +00:00
|
|
|
shadow.w = kernel_data.film.pass_shadow_scale;
|
2012-09-28 13:41:34 +00:00
|
|
|
kernel_write_pass_float4(buffer + kernel_data.film.pass_shadow, sample, shadow);
|
|
|
|
}
|
2013-06-07 12:45:26 +00:00
|
|
|
if(flag & PASS_MIST)
|
2013-06-08 17:56:40 +00:00
|
|
|
kernel_write_pass_float(buffer + kernel_data.film.pass_mist, sample, 1.0f - L->mist);
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|