2011-04-27 11:58:34 +00:00
|
|
|
/*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Copyright 2011-2013 Blender Foundation
|
2011-04-27 11:58:34 +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
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-04-27 11:58:34 +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
|
2014-12-25 01:50:24 +00:00
|
|
|
* limitations under the License.
|
2011-04-27 11:58:34 +00:00
|
|
|
*/
|
|
|
|
|
2012-12-01 19:15:05 +00:00
|
|
|
#ifdef __OSL__
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 18:39:14 +00:00
|
|
|
# include "kernel/osl/osl_shader.h"
|
2012-12-01 19:15:05 +00:00
|
|
|
#endif
|
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 18:39:14 +00:00
|
|
|
#include "kernel/kernel_random.h"
|
|
|
|
#include "kernel/kernel_projection.h"
|
|
|
|
#include "kernel/kernel_montecarlo.h"
|
|
|
|
#include "kernel/kernel_differential.h"
|
|
|
|
#include "kernel/kernel_camera.h"
|
2014-03-29 12:03:45 +00:00
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 18:39:14 +00:00
|
|
|
#include "kernel/geom/geom.h"
|
|
|
|
#include "kernel/bvh/bvh.h"
|
2014-03-29 12:03:45 +00:00
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 18:39:14 +00:00
|
|
|
#include "kernel/kernel_accumulate.h"
|
|
|
|
#include "kernel/kernel_shader.h"
|
|
|
|
#include "kernel/kernel_light.h"
|
|
|
|
#include "kernel/kernel_passes.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2013-04-01 20:26:52 +00:00
|
|
|
#ifdef __SUBSURFACE__
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 18:39:14 +00:00
|
|
|
# include "kernel/kernel_subsurface.h"
|
2013-04-01 20:26:52 +00:00
|
|
|
#endif
|
|
|
|
|
2013-12-28 15:56:19 +00:00
|
|
|
#ifdef __VOLUME__
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 18:39:14 +00:00
|
|
|
# include "kernel/kernel_volume.h"
|
2013-12-28 15:56:19 +00:00
|
|
|
#endif
|
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 18:39:14 +00:00
|
|
|
#include "kernel/kernel_path_state.h"
|
|
|
|
#include "kernel/kernel_shadow.h"
|
|
|
|
#include "kernel/kernel_emission.h"
|
|
|
|
#include "kernel/kernel_path_common.h"
|
|
|
|
#include "kernel/kernel_path_surface.h"
|
|
|
|
#include "kernel/kernel_path_volume.h"
|
|
|
|
#include "kernel/kernel_path_subsurface.h"
|
2011-09-12 13:13:56 +00:00
|
|
|
|
2013-12-28 01:56:53 +00:00
|
|
|
CCL_NAMESPACE_BEGIN
|
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
|
|
|
|
2017-09-13 00:10:24 +00:00
|
|
|
ccl_device_forceinline bool kernel_path_scene_intersect(
|
|
|
|
KernelGlobals *kg,
|
|
|
|
ccl_addr_space PathState *state,
|
|
|
|
Ray *ray,
|
|
|
|
Intersection *isect,
|
|
|
|
PathRadiance *L)
|
|
|
|
{
|
|
|
|
uint visibility = path_state_ray_visibility(kg, state);
|
|
|
|
|
|
|
|
#ifdef __HAIR__
|
|
|
|
float difl = 0.0f, extmax = 0.0f;
|
|
|
|
uint lcg_state = 0;
|
|
|
|
|
|
|
|
if(kernel_data.bvh.have_curves) {
|
|
|
|
if((kernel_data.cam.resolution == 1) && (state->flag & PATH_RAY_CAMERA)) {
|
|
|
|
float3 pixdiff = ray->dD.dx + ray->dD.dy;
|
|
|
|
/*pixdiff = pixdiff - dot(pixdiff, ray.D)*ray.D;*/
|
|
|
|
difl = kernel_data.curve.minimum_width * len(pixdiff) * 0.5f;
|
|
|
|
}
|
|
|
|
|
|
|
|
extmax = kernel_data.curve.maximum_width;
|
|
|
|
lcg_state = lcg_state_init_addrspace(state, 0x51633e2d);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(path_state_ao_bounce(kg, state)) {
|
|
|
|
visibility = PATH_RAY_SHADOW;
|
|
|
|
ray->t = kernel_data.background.ao_distance;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hit = scene_intersect(kg, *ray, visibility, isect, &lcg_state, difl, extmax);
|
|
|
|
#else
|
|
|
|
bool hit = scene_intersect(kg, *ray, visibility, isect, NULL, 0.0f, 0.0f);
|
|
|
|
#endif /* __HAIR__ */
|
|
|
|
|
|
|
|
#ifdef __KERNEL_DEBUG__
|
|
|
|
if(state->flag & PATH_RAY_CAMERA) {
|
|
|
|
L->debug_data.num_bvh_traversed_nodes += isect->num_traversed_nodes;
|
|
|
|
L->debug_data.num_bvh_traversed_instances += isect->num_traversed_instances;
|
|
|
|
L->debug_data.num_bvh_intersections += isect->num_intersections;
|
|
|
|
}
|
|
|
|
L->debug_data.num_ray_bounces++;
|
|
|
|
#endif /* __KERNEL_DEBUG__ */
|
|
|
|
|
|
|
|
return hit;
|
|
|
|
}
|
|
|
|
|
|
|
|
ccl_device_forceinline void kernel_path_lamp_emission(
|
|
|
|
KernelGlobals *kg,
|
|
|
|
ccl_addr_space PathState *state,
|
|
|
|
Ray *ray,
|
|
|
|
float3 throughput,
|
|
|
|
ccl_addr_space Intersection *isect,
|
|
|
|
ShaderData *emission_sd,
|
|
|
|
PathRadiance *L)
|
|
|
|
{
|
|
|
|
#ifdef __LAMP_MIS__
|
|
|
|
if(kernel_data.integrator.use_lamp_mis && !(state->flag & PATH_RAY_CAMERA)) {
|
|
|
|
/* ray starting from previous non-transparent bounce */
|
|
|
|
Ray light_ray;
|
|
|
|
|
|
|
|
light_ray.P = ray->P - state->ray_t*ray->D;
|
|
|
|
state->ray_t += isect->t;
|
|
|
|
light_ray.D = ray->D;
|
|
|
|
light_ray.t = state->ray_t;
|
|
|
|
light_ray.time = ray->time;
|
|
|
|
light_ray.dD = ray->dD;
|
|
|
|
light_ray.dP = ray->dP;
|
|
|
|
|
|
|
|
/* intersect with lamp */
|
|
|
|
float3 emission;
|
|
|
|
|
|
|
|
if(indirect_lamp_emission(kg, emission_sd, state, &light_ray, &emission))
|
2017-08-28 11:33:37 +00:00
|
|
|
path_radiance_accum_emission(L, state, throughput, emission);
|
2017-09-13 00:10:24 +00:00
|
|
|
}
|
|
|
|
#endif /* __LAMP_MIS__ */
|
|
|
|
}
|
|
|
|
|
|
|
|
ccl_device_forceinline void kernel_path_background(
|
|
|
|
KernelGlobals *kg,
|
|
|
|
ccl_addr_space PathState *state,
|
|
|
|
ccl_addr_space Ray *ray,
|
|
|
|
float3 throughput,
|
|
|
|
ShaderData *emission_sd,
|
|
|
|
PathRadiance *L)
|
|
|
|
{
|
|
|
|
/* eval background shader if nothing hit */
|
|
|
|
if(kernel_data.background.transparent && (state->flag & PATH_RAY_CAMERA)) {
|
|
|
|
L->transparent += average(throughput);
|
|
|
|
|
|
|
|
#ifdef __PASSES__
|
|
|
|
if(!(kernel_data.film.pass_flag & PASS_BACKGROUND))
|
|
|
|
#endif /* __PASSES__ */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-25 19:07:44 +00:00
|
|
|
/* When using the ao bounces approximation, adjust background
|
|
|
|
* shader intensity with ao factor. */
|
|
|
|
if(path_state_ao_bounce(kg, state)) {
|
|
|
|
throughput *= kernel_data.background.ao_bounces_factor;
|
|
|
|
}
|
|
|
|
|
2017-09-13 00:10:24 +00:00
|
|
|
#ifdef __BACKGROUND__
|
|
|
|
/* sample background shader */
|
|
|
|
float3 L_background = indirect_background(kg, emission_sd, state, ray);
|
|
|
|
path_radiance_accum_background(L, state, throughput, L_background);
|
|
|
|
#endif /* __BACKGROUND__ */
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef __SPLIT_KERNEL__
|
|
|
|
|
2017-09-18 10:31:17 +00:00
|
|
|
#ifdef __VOLUME__
|
2017-09-13 00:10:24 +00:00
|
|
|
ccl_device_forceinline VolumeIntegrateResult kernel_path_volume(
|
|
|
|
KernelGlobals *kg,
|
|
|
|
ShaderData *sd,
|
|
|
|
PathState *state,
|
|
|
|
Ray *ray,
|
|
|
|
float3 *throughput,
|
|
|
|
ccl_addr_space Intersection *isect,
|
|
|
|
bool hit,
|
|
|
|
ShaderData *emission_sd,
|
|
|
|
PathRadiance *L)
|
|
|
|
{
|
|
|
|
/* Sanitize volume stack. */
|
|
|
|
if(!hit) {
|
|
|
|
kernel_volume_clean_stack(kg, state->volume_stack);
|
|
|
|
}
|
2017-10-08 02:32:25 +00:00
|
|
|
|
|
|
|
if(state->volume_stack[0].shader == SHADER_NONE) {
|
|
|
|
return VOLUME_PATH_ATTENUATED;
|
|
|
|
}
|
|
|
|
|
2017-09-13 00:10:24 +00:00
|
|
|
/* volume attenuation, emission, scatter */
|
2017-10-08 02:32:25 +00:00
|
|
|
Ray volume_ray = *ray;
|
|
|
|
volume_ray.t = (hit)? isect->t: FLT_MAX;
|
2017-09-13 00:10:24 +00:00
|
|
|
|
2017-10-08 02:32:25 +00:00
|
|
|
bool heterogeneous = volume_stack_is_heterogeneous(kg, state->volume_stack);
|
2017-09-13 00:10:24 +00:00
|
|
|
|
|
|
|
# ifdef __VOLUME_DECOUPLED__
|
2017-10-08 02:32:25 +00:00
|
|
|
int sampling_method = volume_stack_sampling_method(kg, state->volume_stack);
|
|
|
|
bool direct = (state->flag & PATH_RAY_CAMERA) != 0;
|
|
|
|
bool decoupled = kernel_volume_use_decoupled(kg, heterogeneous, direct, sampling_method);
|
|
|
|
|
|
|
|
if(decoupled) {
|
|
|
|
/* cache steps along volume for repeated sampling */
|
|
|
|
VolumeSegment volume_segment;
|
|
|
|
|
|
|
|
shader_setup_from_volume(kg, sd, &volume_ray);
|
|
|
|
kernel_volume_decoupled_record(kg, state,
|
|
|
|
&volume_ray, sd, &volume_segment, heterogeneous);
|
|
|
|
|
|
|
|
volume_segment.sampling_method = sampling_method;
|
|
|
|
|
|
|
|
/* emission */
|
|
|
|
if(volume_segment.closure_flag & SD_EMISSION)
|
|
|
|
path_radiance_accum_emission(L, state, *throughput, volume_segment.accum_emission);
|
|
|
|
|
|
|
|
/* scattering */
|
|
|
|
VolumeIntegrateResult result = VOLUME_PATH_ATTENUATED;
|
|
|
|
|
|
|
|
if(volume_segment.closure_flag & SD_SCATTER) {
|
|
|
|
int all = kernel_data.integrator.sample_all_lights_indirect;
|
|
|
|
|
|
|
|
/* direct light sampling */
|
|
|
|
kernel_branched_path_volume_connect_light(kg, sd,
|
|
|
|
emission_sd, *throughput, state, L, all,
|
|
|
|
&volume_ray, &volume_segment);
|
|
|
|
|
|
|
|
/* indirect sample. if we use distance sampling and take just
|
|
|
|
* one sample for direct and indirect light, we could share
|
|
|
|
* this computation, but makes code a bit complex */
|
|
|
|
float rphase = path_state_rng_1D(kg, state, PRNG_PHASE_CHANNEL);
|
|
|
|
float rscatter = path_state_rng_1D(kg, state, PRNG_SCATTER_DISTANCE);
|
|
|
|
|
|
|
|
result = kernel_volume_decoupled_scatter(kg,
|
|
|
|
state, &volume_ray, sd, throughput,
|
|
|
|
rphase, rscatter, &volume_segment, NULL, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free cached steps */
|
|
|
|
kernel_volume_decoupled_free(kg, &volume_segment);
|
|
|
|
|
|
|
|
if(result == VOLUME_PATH_SCATTERED) {
|
|
|
|
if(kernel_path_volume_bounce(kg, sd, throughput, state, &L->state, ray))
|
|
|
|
return VOLUME_PATH_SCATTERED;
|
|
|
|
else
|
|
|
|
return VOLUME_PATH_MISSED;
|
2017-09-13 00:10:24 +00:00
|
|
|
}
|
2017-10-08 02:32:25 +00:00
|
|
|
else {
|
|
|
|
*throughput *= volume_segment.accum_transmittance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2017-09-13 00:10:24 +00:00
|
|
|
# endif /* __VOLUME_DECOUPLED__ */
|
2017-10-08 02:32:25 +00:00
|
|
|
{
|
|
|
|
/* integrate along volume segment with distance sampling */
|
|
|
|
VolumeIntegrateResult result = kernel_volume_integrate(
|
|
|
|
kg, state, sd, &volume_ray, L, throughput, heterogeneous);
|
2017-09-13 00:10:24 +00:00
|
|
|
|
|
|
|
# ifdef __VOLUME_SCATTER__
|
2017-10-08 02:32:25 +00:00
|
|
|
if(result == VOLUME_PATH_SCATTERED) {
|
|
|
|
/* direct lighting */
|
|
|
|
kernel_path_volume_connect_light(kg, sd, emission_sd, *throughput, state, L);
|
|
|
|
|
|
|
|
/* indirect light bounce */
|
|
|
|
if(kernel_path_volume_bounce(kg, sd, throughput, state, &L->state, ray))
|
|
|
|
return VOLUME_PATH_SCATTERED;
|
|
|
|
else
|
|
|
|
return VOLUME_PATH_MISSED;
|
2017-09-13 00:10:24 +00:00
|
|
|
}
|
2017-10-08 02:32:25 +00:00
|
|
|
# endif /* __VOLUME_SCATTER__ */
|
2017-09-13 00:10:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return VOLUME_PATH_ATTENUATED;
|
|
|
|
}
|
2017-09-18 10:31:17 +00:00
|
|
|
#endif /* __VOLUME__ */
|
2017-09-13 00:10:24 +00:00
|
|
|
|
|
|
|
#endif /* __SPLIT_KERNEL__ */
|
|
|
|
|
|
|
|
ccl_device_forceinline bool kernel_path_shader_apply(
|
|
|
|
KernelGlobals *kg,
|
|
|
|
ShaderData *sd,
|
|
|
|
ccl_addr_space PathState *state,
|
|
|
|
ccl_addr_space Ray *ray,
|
|
|
|
float3 throughput,
|
|
|
|
ShaderData *emission_sd,
|
|
|
|
PathRadiance *L,
|
|
|
|
ccl_global float *buffer)
|
|
|
|
{
|
|
|
|
#ifdef __SHADOW_TRICKS__
|
|
|
|
if((sd->object_flag & SD_OBJECT_SHADOW_CATCHER)) {
|
|
|
|
if(state->flag & PATH_RAY_CAMERA) {
|
|
|
|
state->flag |= (PATH_RAY_SHADOW_CATCHER |
|
|
|
|
PATH_RAY_STORE_SHADOW_INFO);
|
2017-08-28 11:33:37 +00:00
|
|
|
|
|
|
|
float3 bg = make_float3(0.0f, 0.0f, 0.0f);
|
2017-09-13 00:10:24 +00:00
|
|
|
if(!kernel_data.background.transparent) {
|
2017-08-28 11:33:37 +00:00
|
|
|
bg = indirect_background(kg, emission_sd, state, ray);
|
2017-09-13 00:10:24 +00:00
|
|
|
}
|
2017-08-28 11:33:37 +00:00
|
|
|
path_radiance_accum_shadowcatcher(L, throughput, bg);
|
2017-09-13 00:10:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(state->flag & PATH_RAY_SHADOW_CATCHER) {
|
|
|
|
/* Only update transparency after shadow catcher bounce. */
|
|
|
|
L->shadow_transparency *=
|
|
|
|
average(shader_bsdf_transparency(kg, sd));
|
|
|
|
}
|
|
|
|
#endif /* __SHADOW_TRICKS__ */
|
|
|
|
|
|
|
|
/* holdout */
|
|
|
|
#ifdef __HOLDOUT__
|
|
|
|
if(((sd->flag & SD_HOLDOUT) ||
|
|
|
|
(sd->object_flag & SD_OBJECT_HOLDOUT_MASK)) &&
|
|
|
|
(state->flag & PATH_RAY_CAMERA))
|
|
|
|
{
|
|
|
|
if(kernel_data.background.transparent) {
|
|
|
|
float3 holdout_weight;
|
|
|
|
if(sd->object_flag & SD_OBJECT_HOLDOUT_MASK) {
|
|
|
|
holdout_weight = make_float3(1.0f, 1.0f, 1.0f);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
holdout_weight = shader_holdout_eval(kg, sd);
|
|
|
|
}
|
|
|
|
/* any throughput is ok, should all be identical here */
|
|
|
|
L->transparent += average(holdout_weight*throughput);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(sd->object_flag & SD_OBJECT_HOLDOUT_MASK) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* __HOLDOUT__ */
|
|
|
|
|
|
|
|
/* holdout mask objects do not write data passes */
|
|
|
|
kernel_write_data_passes(kg, buffer, L, sd, state, throughput);
|
|
|
|
|
|
|
|
/* blurring of bsdf after bounces, for rays that have a small likelihood
|
|
|
|
* of following this particular path (diffuse, rough glossy) */
|
|
|
|
if(kernel_data.integrator.filter_glossy != FLT_MAX) {
|
|
|
|
float blur_pdf = kernel_data.integrator.filter_glossy*state->min_ray_pdf;
|
|
|
|
|
|
|
|
if(blur_pdf < 1.0f) {
|
|
|
|
float blur_roughness = sqrtf(1.0f - blur_pdf)*0.5f;
|
|
|
|
shader_bsdf_blur(kg, sd, blur_roughness);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef __EMISSION__
|
|
|
|
/* emission */
|
|
|
|
if(sd->flag & SD_EMISSION) {
|
|
|
|
float3 emission = indirect_primitive_emission(kg, sd, sd->ray_length, state->flag, state->ray_pdf);
|
2017-08-28 11:33:37 +00:00
|
|
|
path_radiance_accum_emission(L, state, throughput, emission);
|
2017-09-13 00:10:24 +00:00
|
|
|
}
|
|
|
|
#endif /* __EMISSION__ */
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-10-30 23:40:05 +00:00
|
|
|
ccl_device_noinline void kernel_path_ao(KernelGlobals *kg,
|
|
|
|
ShaderData *sd,
|
|
|
|
ShaderData *emission_sd,
|
|
|
|
PathRadiance *L,
|
2017-03-21 02:31:54 +00:00
|
|
|
ccl_addr_space PathState *state,
|
2016-10-30 23:40:05 +00:00
|
|
|
float3 throughput,
|
|
|
|
float3 ao_alpha)
|
|
|
|
{
|
|
|
|
/* todo: solve correlation */
|
|
|
|
float bsdf_u, bsdf_v;
|
|
|
|
|
2017-08-19 02:11:25 +00:00
|
|
|
path_state_rng_2D(kg, state, PRNG_BSDF_U, &bsdf_u, &bsdf_v);
|
2016-10-30 23:40:05 +00:00
|
|
|
|
|
|
|
float ao_factor = kernel_data.background.ao_factor;
|
|
|
|
float3 ao_N;
|
|
|
|
float3 ao_bsdf = shader_bsdf_ao(kg, sd, ao_factor, &ao_N);
|
|
|
|
float3 ao_D;
|
|
|
|
float ao_pdf;
|
|
|
|
|
|
|
|
sample_cos_hemisphere(ao_N, bsdf_u, bsdf_v, &ao_D, &ao_pdf);
|
|
|
|
|
2017-02-16 11:24:13 +00:00
|
|
|
if(dot(sd->Ng, ao_D) > 0.0f && ao_pdf != 0.0f) {
|
2016-10-30 23:40:05 +00:00
|
|
|
Ray light_ray;
|
|
|
|
float3 ao_shadow;
|
|
|
|
|
2017-02-16 11:24:13 +00:00
|
|
|
light_ray.P = ray_offset(sd->P, sd->Ng);
|
2016-10-30 23:40:05 +00:00
|
|
|
light_ray.D = ao_D;
|
|
|
|
light_ray.t = kernel_data.background.ao_distance;
|
2017-02-16 11:24:13 +00:00
|
|
|
light_ray.time = sd->time;
|
|
|
|
light_ray.dP = sd->dP;
|
2016-10-30 23:40:05 +00:00
|
|
|
light_ray.dD = differential3_zero();
|
|
|
|
|
2017-09-05 13:38:11 +00:00
|
|
|
if(!shadow_blocked(kg, sd, emission_sd, state, &light_ray, &ao_shadow)) {
|
2017-05-07 12:40:58 +00:00
|
|
|
path_radiance_accum_ao(L, state, throughput, ao_alpha, ao_bsdf, ao_shadow);
|
2016-10-30 23:40:05 +00:00
|
|
|
}
|
2017-02-09 13:19:01 +00:00
|
|
|
else {
|
2017-05-07 12:40:58 +00:00
|
|
|
path_radiance_accum_total_ao(L, state, throughput, ao_bsdf);
|
2017-02-09 13:19:01 +00:00
|
|
|
}
|
2016-10-30 23:40:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-21 02:31:54 +00:00
|
|
|
#ifndef __SPLIT_KERNEL__
|
|
|
|
|
2017-08-05 13:46:40 +00:00
|
|
|
#if defined(__BRANCHED_PATH__) || defined(__BAKING__)
|
|
|
|
|
2015-11-22 10:48:33 +00:00
|
|
|
ccl_device void kernel_path_indirect(KernelGlobals *kg,
|
2016-05-24 20:28:03 +00:00
|
|
|
ShaderData *sd,
|
2016-05-22 20:35:47 +00:00
|
|
|
ShaderData *emission_sd,
|
2015-11-22 10:48:33 +00:00
|
|
|
Ray *ray,
|
|
|
|
float3 throughput,
|
|
|
|
PathState *state,
|
|
|
|
PathRadiance *L)
|
2013-08-24 15:02:08 +00:00
|
|
|
{
|
2011-04-27 11:58:34 +00:00
|
|
|
/* path iteration */
|
2014-01-03 01:48:48 +00:00
|
|
|
for(;;) {
|
2017-09-13 00:10:24 +00:00
|
|
|
/* Find intersection with objects in scene. */
|
2011-04-27 11:58:34 +00:00
|
|
|
Intersection isect;
|
2017-09-13 00:10:24 +00:00
|
|
|
bool hit = kernel_path_scene_intersect(kg, state, ray, &isect, L);
|
|
|
|
|
|
|
|
/* Find intersection with lamps and compute emission for MIS. */
|
|
|
|
kernel_path_lamp_emission(kg, state, ray, throughput, &isect, emission_sd, L);
|
|
|
|
|
2017-09-18 10:31:17 +00:00
|
|
|
#ifdef __VOLUME__
|
2017-09-13 00:10:24 +00:00
|
|
|
/* Volume integration. */
|
|
|
|
VolumeIntegrateResult result = kernel_path_volume(kg,
|
|
|
|
sd,
|
|
|
|
state,
|
|
|
|
ray,
|
|
|
|
&throughput,
|
|
|
|
&isect,
|
|
|
|
hit,
|
|
|
|
emission_sd,
|
|
|
|
L);
|
|
|
|
|
|
|
|
if(result == VOLUME_PATH_SCATTERED) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(result == VOLUME_PATH_MISSED) {
|
|
|
|
break;
|
2013-12-28 15:56:19 +00:00
|
|
|
}
|
2017-09-18 10:31:17 +00:00
|
|
|
#endif /* __VOLUME__*/
|
2013-12-28 15:56:19 +00:00
|
|
|
|
2017-09-13 00:10:24 +00:00
|
|
|
/* Shade background. */
|
2013-01-09 21:09:20 +00:00
|
|
|
if(!hit) {
|
2017-09-13 00:10:24 +00:00
|
|
|
kernel_path_background(kg, state, ray, throughput, emission_sd, L);
|
2011-04-27 11:58:34 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-09-13 00:10:24 +00:00
|
|
|
else if(path_state_ao_bounce(kg, state)) {
|
2016-11-25 17:59:43 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2017-09-13 00:10:24 +00:00
|
|
|
/* Setup and evaluate shader. */
|
2015-11-22 10:48:33 +00:00
|
|
|
shader_setup_from_ray(kg,
|
2016-05-24 20:28:03 +00:00
|
|
|
sd,
|
2015-11-22 10:48:33 +00:00
|
|
|
&isect,
|
2016-01-06 22:38:13 +00:00
|
|
|
ray);
|
2017-09-14 20:56:32 +00:00
|
|
|
shader_eval_surface(kg, sd, state, state->flag);
|
2017-09-13 16:28:31 +00:00
|
|
|
shader_prepare_closures(sd, state);
|
2013-06-04 15:41:45 +00:00
|
|
|
|
2017-09-13 00:10:24 +00:00
|
|
|
/* Apply shadow catcher, holdout, emission. */
|
|
|
|
if(!kernel_path_shader_apply(kg,
|
|
|
|
sd,
|
|
|
|
state,
|
|
|
|
ray,
|
|
|
|
throughput,
|
|
|
|
emission_sd,
|
|
|
|
L,
|
|
|
|
NULL))
|
2017-08-11 07:33:18 +00:00
|
|
|
{
|
2017-09-13 00:10:24 +00:00
|
|
|
break;
|
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
|
|
|
}
|
2011-09-01 15:53:36 +00:00
|
|
|
|
|
|
|
/* path termination. this is a strange place to put the termination, it's
|
2012-06-09 17:22:52 +00:00
|
|
|
* mainly due to the mixed in MIS that we use. gives too many unneeded
|
|
|
|
* shader evaluations, only need emission if we are going to terminate */
|
2017-09-10 12:09:12 +00:00
|
|
|
float probability = path_state_continuation_probability(kg, state, throughput);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2013-06-07 16:06:22 +00:00
|
|
|
if(probability == 0.0f) {
|
2011-09-01 15:53:36 +00:00
|
|
|
break;
|
2013-06-07 16:06:22 +00:00
|
|
|
}
|
|
|
|
else if(probability != 1.0f) {
|
2017-09-14 19:53:00 +00:00
|
|
|
float terminate = path_state_rng_1D(kg, state, PRNG_TERMINATE);
|
2013-06-07 16:06:22 +00:00
|
|
|
|
|
|
|
if(terminate >= probability)
|
|
|
|
break;
|
2011-09-01 15:53:36 +00:00
|
|
|
|
2013-06-07 16:06:22 +00:00
|
|
|
throughput /= probability;
|
|
|
|
}
|
2011-09-01 15:53:36 +00:00
|
|
|
|
2017-05-07 12:40:58 +00:00
|
|
|
kernel_update_denoising_features(kg, sd, state, L);
|
|
|
|
|
2012-02-28 16:45:08 +00:00
|
|
|
#ifdef __AO__
|
|
|
|
/* ambient occlusion */
|
2016-05-24 20:28:03 +00:00
|
|
|
if(kernel_data.integrator.use_ambient_occlusion || (sd->flag & SD_AO)) {
|
2017-08-19 02:11:25 +00:00
|
|
|
kernel_path_ao(kg, sd, emission_sd, L, state, throughput, make_float3(0.0f, 0.0f, 0.0f));
|
2013-08-24 15:02:08 +00:00
|
|
|
}
|
2016-10-06 12:55:56 +00:00
|
|
|
#endif /* __AO__ */
|
2013-08-24 15:02:08 +00:00
|
|
|
|
|
|
|
#ifdef __SUBSURFACE__
|
|
|
|
/* bssrdf scatter to a different location on the same object, replacing
|
|
|
|
* the closures with a diffuse BSDF */
|
2016-05-24 20:28:03 +00:00
|
|
|
if(sd->flag & SD_BSSRDF) {
|
2017-09-14 20:56:32 +00:00
|
|
|
float bssrdf_u, bssrdf_v;
|
|
|
|
path_state_rng_2D(kg,
|
|
|
|
state,
|
|
|
|
PRNG_BSDF_U,
|
|
|
|
&bssrdf_u, &bssrdf_v);
|
|
|
|
|
|
|
|
const ShaderClosure *sc = shader_bssrdf_pick(sd, &throughput, &bssrdf_u);
|
2013-08-24 15:02:08 +00:00
|
|
|
|
|
|
|
/* do bssrdf scatter step if we picked a bssrdf closure */
|
|
|
|
if(sc) {
|
2017-08-19 02:11:25 +00:00
|
|
|
uint lcg_state = lcg_state_init(state, 0x68bc21eb);
|
2013-08-24 15:02:08 +00:00
|
|
|
|
2015-11-22 10:48:33 +00:00
|
|
|
subsurface_scatter_step(kg,
|
2016-05-24 20:28:03 +00:00
|
|
|
sd,
|
2016-01-06 22:38:13 +00:00
|
|
|
state,
|
2015-11-22 10:48:33 +00:00
|
|
|
state->flag,
|
|
|
|
sc,
|
|
|
|
&lcg_state,
|
|
|
|
bssrdf_u, bssrdf_v,
|
|
|
|
false);
|
2012-02-28 16:45:08 +00:00
|
|
|
}
|
|
|
|
}
|
2016-10-06 12:55:56 +00:00
|
|
|
#endif /* __SUBSURFACE__ */
|
2012-02-28 16:45:08 +00:00
|
|
|
|
2017-05-16 10:15:11 +00:00
|
|
|
#if defined(__EMISSION__)
|
2011-09-27 20:37:24 +00:00
|
|
|
if(kernel_data.integrator.use_direct_light) {
|
2017-02-09 13:19:01 +00:00
|
|
|
int all = (kernel_data.integrator.sample_all_lights_indirect) ||
|
|
|
|
(state->flag & PATH_RAY_SHADOW_CATCHER);
|
2015-11-22 10:48:33 +00:00
|
|
|
kernel_branched_path_surface_connect_light(kg,
|
2016-05-24 20:28:03 +00:00
|
|
|
sd,
|
2016-05-22 20:35:47 +00:00
|
|
|
emission_sd,
|
2015-11-22 10:48:33 +00:00
|
|
|
state,
|
|
|
|
throughput,
|
|
|
|
1.0f,
|
|
|
|
L,
|
|
|
|
all);
|
2012-06-13 11:44:48 +00:00
|
|
|
}
|
2017-05-16 10:15:11 +00:00
|
|
|
#endif /* defined(__EMISSION__) */
|
2013-12-28 15:56:19 +00:00
|
|
|
|
2017-08-23 01:57:27 +00:00
|
|
|
if(!kernel_path_surface_bounce(kg, sd, &throughput, state, &L->state, ray))
|
2013-12-28 15:56:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-06-13 11:44:48 +00:00
|
|
|
}
|
|
|
|
|
2017-08-05 13:46:40 +00:00
|
|
|
#endif /* defined(__BRANCHED_PATH__) || defined(__BAKING__) */
|
2014-05-07 14:55:09 +00:00
|
|
|
|
2017-09-12 22:12:51 +00:00
|
|
|
ccl_device_forceinline void kernel_path_integrate(
|
|
|
|
KernelGlobals *kg,
|
|
|
|
PathState *state,
|
|
|
|
float3 throughput,
|
|
|
|
Ray *ray,
|
|
|
|
PathRadiance *L,
|
2017-09-13 00:10:24 +00:00
|
|
|
ccl_global float *buffer,
|
2017-08-28 11:33:37 +00:00
|
|
|
ShaderData *emission_sd)
|
2012-06-13 11:44:48 +00:00
|
|
|
{
|
2017-09-12 22:12:51 +00:00
|
|
|
/* Shader data memory used for both volumes and surfaces, saves stack space. */
|
2016-05-22 20:35:47 +00:00
|
|
|
ShaderData sd;
|
2013-08-24 15:02:08 +00:00
|
|
|
|
2015-11-22 10:48:33 +00:00
|
|
|
#ifdef __SUBSURFACE__
|
|
|
|
SubsurfaceIndirectRays ss_indirect;
|
2015-11-28 14:43:54 +00:00
|
|
|
kernel_path_subsurface_init_indirect(&ss_indirect);
|
2015-11-22 11:08:03 +00:00
|
|
|
|
2015-11-27 11:41:05 +00:00
|
|
|
for(;;) {
|
2016-10-06 12:55:56 +00:00
|
|
|
#endif /* __SUBSURFACE__ */
|
2015-11-22 10:48:33 +00:00
|
|
|
|
2012-06-13 11:44:48 +00:00
|
|
|
/* path iteration */
|
2014-01-03 01:48:48 +00:00
|
|
|
for(;;) {
|
2017-09-13 00:10:24 +00:00
|
|
|
/* Find intersection with objects in scene. */
|
2012-06-13 11:44:48 +00:00
|
|
|
Intersection isect;
|
2017-09-13 00:10:24 +00:00
|
|
|
bool hit = kernel_path_scene_intersect(kg, state, ray, &isect, L);
|
|
|
|
|
|
|
|
/* Find intersection with lamps and compute emission for MIS. */
|
|
|
|
kernel_path_lamp_emission(kg, state, ray, throughput, &isect, emission_sd, L);
|
|
|
|
|
2017-09-18 10:31:17 +00:00
|
|
|
#ifdef __VOLUME__
|
2017-09-13 00:10:24 +00:00
|
|
|
/* Volume integration. */
|
|
|
|
VolumeIntegrateResult result = kernel_path_volume(kg,
|
|
|
|
&sd,
|
|
|
|
state,
|
|
|
|
ray,
|
|
|
|
&throughput,
|
|
|
|
&isect,
|
|
|
|
hit,
|
|
|
|
emission_sd,
|
|
|
|
L);
|
|
|
|
|
|
|
|
if(result == VOLUME_PATH_SCATTERED) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(result == VOLUME_PATH_MISSED) {
|
|
|
|
break;
|
2013-12-28 15:56:19 +00:00
|
|
|
}
|
2017-09-18 10:31:17 +00:00
|
|
|
#endif /* __VOLUME__*/
|
2013-12-28 15:56:19 +00:00
|
|
|
|
2017-09-13 00:10:24 +00:00
|
|
|
/* Shade background. */
|
2013-01-09 21:09:20 +00:00
|
|
|
if(!hit) {
|
2017-09-13 00:10:24 +00:00
|
|
|
kernel_path_background(kg, state, ray, throughput, emission_sd, L);
|
2012-06-13 11:44:48 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-09-12 22:12:51 +00:00
|
|
|
else if(path_state_ao_bounce(kg, state)) {
|
2016-11-25 17:59:43 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-06-13 11:44:48 +00:00
|
|
|
|
2017-09-13 00:10:24 +00:00
|
|
|
/* Setup and evaluate shader. */
|
2017-09-12 22:12:51 +00:00
|
|
|
shader_setup_from_ray(kg, &sd, &isect, ray);
|
2017-09-14 20:56:32 +00:00
|
|
|
shader_eval_surface(kg, &sd, state, state->flag);
|
2017-09-13 16:28:31 +00:00
|
|
|
shader_prepare_closures(&sd, state);
|
2013-08-24 15:02:08 +00:00
|
|
|
|
2017-09-13 00:10:24 +00:00
|
|
|
/* Apply shadow catcher, holdout, emission. */
|
|
|
|
if(!kernel_path_shader_apply(kg,
|
|
|
|
&sd,
|
|
|
|
state,
|
|
|
|
ray,
|
|
|
|
throughput,
|
|
|
|
emission_sd,
|
|
|
|
L,
|
|
|
|
buffer))
|
2016-12-23 10:31:19 +00:00
|
|
|
{
|
2017-09-13 00:10:24 +00:00
|
|
|
break;
|
2012-06-13 11:44:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* path termination. this is a strange place to put the termination, it's
|
|
|
|
* mainly due to the mixed in MIS that we use. gives too many unneeded
|
|
|
|
* shader evaluations, only need emission if we are going to terminate */
|
2017-09-12 22:12:51 +00:00
|
|
|
float probability = path_state_continuation_probability(kg, state, throughput);
|
2012-06-13 11:44:48 +00:00
|
|
|
|
2013-06-07 16:06:22 +00:00
|
|
|
if(probability == 0.0f) {
|
2012-06-13 11:44:48 +00:00
|
|
|
break;
|
2013-06-07 16:06:22 +00:00
|
|
|
}
|
|
|
|
else if(probability != 1.0f) {
|
2017-09-14 19:53:00 +00:00
|
|
|
float terminate = path_state_rng_1D(kg, state, PRNG_TERMINATE);
|
2013-06-07 16:06:22 +00:00
|
|
|
if(terminate >= probability)
|
|
|
|
break;
|
2012-06-13 11:44:48 +00:00
|
|
|
|
2013-06-07 16:06:22 +00:00
|
|
|
throughput /= probability;
|
|
|
|
}
|
2012-06-13 11:44:48 +00:00
|
|
|
|
2017-09-12 22:12:51 +00:00
|
|
|
kernel_update_denoising_features(kg, &sd, state, L);
|
2017-05-07 12:40:58 +00:00
|
|
|
|
2012-06-13 11:44:48 +00:00
|
|
|
#ifdef __AO__
|
|
|
|
/* ambient occlusion */
|
2012-11-06 19:59:02 +00:00
|
|
|
if(kernel_data.integrator.use_ambient_occlusion || (sd.flag & SD_AO)) {
|
2017-09-12 22:12:51 +00:00
|
|
|
kernel_path_ao(kg, &sd, emission_sd, L, state, throughput, shader_bsdf_alpha(kg, &sd));
|
2012-06-13 11:44:48 +00:00
|
|
|
}
|
2016-10-06 12:55:56 +00:00
|
|
|
#endif /* __AO__ */
|
2012-06-13 11:44:48 +00:00
|
|
|
|
2013-08-24 15:02:08 +00:00
|
|
|
#ifdef __SUBSURFACE__
|
|
|
|
/* bssrdf scatter to a different location on the same object, replacing
|
|
|
|
* the closures with a diffuse BSDF */
|
|
|
|
if(sd.flag & SD_BSSRDF) {
|
2015-11-22 10:48:33 +00:00
|
|
|
if(kernel_path_subsurface_scatter(kg,
|
|
|
|
&sd,
|
2017-09-12 22:12:51 +00:00
|
|
|
emission_sd,
|
2017-05-07 12:40:58 +00:00
|
|
|
L,
|
2017-09-12 22:12:51 +00:00
|
|
|
state,
|
|
|
|
ray,
|
2015-11-22 10:48:33 +00:00
|
|
|
&throughput,
|
|
|
|
&ss_indirect))
|
|
|
|
{
|
2013-10-08 17:07:18 +00:00
|
|
|
break;
|
2015-11-22 10:48:33 +00:00
|
|
|
}
|
2013-08-24 15:02:08 +00:00
|
|
|
}
|
2015-11-27 12:12:44 +00:00
|
|
|
#endif /* __SUBSURFACE__ */
|
2013-12-28 15:56:19 +00:00
|
|
|
|
2014-04-04 12:21:35 +00:00
|
|
|
/* direct lighting */
|
2017-09-12 22:12:51 +00:00
|
|
|
kernel_path_surface_connect_light(kg, &sd, emission_sd, throughput, state, L);
|
2013-12-28 15:56:19 +00:00
|
|
|
|
2014-04-04 12:21:35 +00:00
|
|
|
/* compute direct lighting and next bounce */
|
2017-08-23 01:57:27 +00:00
|
|
|
if(!kernel_path_surface_bounce(kg, &sd, &throughput, state, &L->state, ray))
|
2013-12-28 15:56:19 +00:00
|
|
|
break;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
2013-08-24 15:02:08 +00:00
|
|
|
|
2015-11-28 14:30:35 +00:00
|
|
|
#ifdef __SUBSURFACE__
|
2015-11-22 11:08:03 +00:00
|
|
|
/* Trace indirect subsurface rays by restarting the loop. this uses less
|
|
|
|
* stack memory than invoking kernel_path_indirect.
|
|
|
|
*/
|
|
|
|
if(ss_indirect.num_rays) {
|
|
|
|
kernel_path_subsurface_setup_indirect(kg,
|
|
|
|
&ss_indirect,
|
2017-09-12 22:12:51 +00:00
|
|
|
state,
|
|
|
|
ray,
|
2017-05-07 12:40:58 +00:00
|
|
|
L,
|
2015-11-22 11:08:03 +00:00
|
|
|
&throughput);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
break;
|
|
|
|
}
|
2015-11-22 10:48:33 +00:00
|
|
|
}
|
2015-11-28 14:30:35 +00:00
|
|
|
#endif /* __SUBSURFACE__ */
|
2012-06-13 11:44:48 +00:00
|
|
|
}
|
|
|
|
|
2013-11-15 23:17:10 +00:00
|
|
|
ccl_device void kernel_path_trace(KernelGlobals *kg,
|
2017-09-26 22:39:53 +00:00
|
|
|
ccl_global float *buffer,
|
2013-08-09 18:47:25 +00:00
|
|
|
int sample, int x, int y, int offset, int stride)
|
|
|
|
{
|
|
|
|
/* buffer offset */
|
|
|
|
int index = offset + x + y*stride;
|
|
|
|
int pass_stride = kernel_data.film.pass_stride;
|
|
|
|
|
|
|
|
buffer += index*pass_stride;
|
|
|
|
|
2017-09-12 22:12:51 +00:00
|
|
|
/* Initialize random numbers and sample ray. */
|
2017-08-19 02:11:25 +00:00
|
|
|
uint rng_hash;
|
2013-08-09 18:47:25 +00:00
|
|
|
Ray ray;
|
|
|
|
|
2017-09-26 22:39:53 +00:00
|
|
|
kernel_path_trace_setup(kg, sample, x, y, &rng_hash, &ray);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2017-09-12 22:12:51 +00:00
|
|
|
if(ray.t == 0.0f) {
|
|
|
|
return;
|
2017-05-07 12:40:58 +00:00
|
|
|
}
|
2017-09-12 22:12:51 +00:00
|
|
|
|
|
|
|
/* Initialize state. */
|
|
|
|
float3 throughput = make_float3(1.0f, 1.0f, 1.0f);
|
|
|
|
|
|
|
|
PathRadiance L;
|
|
|
|
path_radiance_init(&L, kernel_data.film.use_light_pass);
|
|
|
|
|
|
|
|
ShaderData emission_sd;
|
|
|
|
PathState state;
|
|
|
|
path_state_init(kg, &emission_sd, &state, rng_hash, sample, &ray);
|
|
|
|
|
|
|
|
/* Integrate. */
|
|
|
|
kernel_path_integrate(kg,
|
|
|
|
&state,
|
|
|
|
throughput,
|
|
|
|
&ray,
|
|
|
|
&L,
|
|
|
|
buffer,
|
2017-08-28 11:33:37 +00:00
|
|
|
&emission_sd);
|
2017-09-12 22:12:51 +00:00
|
|
|
|
2017-08-28 11:33:37 +00:00
|
|
|
kernel_write_result(kg, buffer, sample, &L);
|
2013-08-09 18:47:25 +00:00
|
|
|
}
|
|
|
|
|
2017-03-21 02:31:54 +00:00
|
|
|
#endif /* __SPLIT_KERNEL__ */
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|