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>2013-09-08 22:59:39 +0400
committerThomas Dinges <blender@dingto.org>2013-09-08 22:59:39 +0400
commit5a6bcd1d42f7498a91316232f70bf2d69fb4df2a (patch)
treeec7c97c437395137ca290d94b24d0bc8ec744d9a /intern/cycles/kernel/kernel_path.h
parent74a4ac85f420764b25048e0b5013f55d894cb539 (diff)
Cycles:
* Refactor PathState struct and functions into its own file.
Diffstat (limited to 'intern/cycles/kernel/kernel_path.h')
-rw-r--r--intern/cycles/kernel/kernel_path.h114
1 files changed, 1 insertions, 113 deletions
diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h
index 4b1955e8523..b33192a54cd 100644
--- a/intern/cycles/kernel/kernel_path.h
+++ b/intern/cycles/kernel/kernel_path.h
@@ -34,6 +34,7 @@
#include "kernel_light.h"
#include "kernel_emission.h"
#include "kernel_passes.h"
+#include "kernel_path_state.h"
#ifdef __SUBSURFACE__
#include "kernel_subsurface.h"
@@ -41,119 +42,6 @@
CCL_NAMESPACE_BEGIN
-typedef struct PathState {
- int flag;
- int bounce;
-
- int diffuse_bounce;
- int glossy_bounce;
- int transmission_bounce;
- int transparent_bounce;
-} PathState;
-
-__device_inline void path_state_init(PathState *state)
-{
- state->flag = PATH_RAY_CAMERA|PATH_RAY_SINGULAR|PATH_RAY_MIS_SKIP;
- state->bounce = 0;
- state->diffuse_bounce = 0;
- state->glossy_bounce = 0;
- state->transmission_bounce = 0;
- state->transparent_bounce = 0;
-}
-
-__device_inline void path_state_next(KernelGlobals *kg, PathState *state, int label)
-{
- /* ray through transparent keeps same flags from previous ray and is
- * not counted as a regular bounce, transparent has separate max */
- if(label & LABEL_TRANSPARENT) {
- state->flag |= PATH_RAY_TRANSPARENT;
- state->transparent_bounce++;
-
- if(!kernel_data.integrator.transparent_shadows)
- state->flag |= PATH_RAY_MIS_SKIP;
-
- return;
- }
-
- state->bounce++;
-
- /* reflection/transmission */
- if(label & LABEL_REFLECT) {
- state->flag |= PATH_RAY_REFLECT;
- state->flag &= ~(PATH_RAY_TRANSMIT|PATH_RAY_CAMERA|PATH_RAY_TRANSPARENT);
-
- if(label & LABEL_DIFFUSE)
- state->diffuse_bounce++;
- else
- state->glossy_bounce++;
- }
- else {
- kernel_assert(label & LABEL_TRANSMIT);
-
- state->flag |= PATH_RAY_TRANSMIT;
- state->flag &= ~(PATH_RAY_REFLECT|PATH_RAY_CAMERA|PATH_RAY_TRANSPARENT);
-
- state->transmission_bounce++;
- }
-
- /* diffuse/glossy/singular */
- if(label & LABEL_DIFFUSE) {
- state->flag |= PATH_RAY_DIFFUSE|PATH_RAY_DIFFUSE_ANCESTOR;
- state->flag &= ~(PATH_RAY_GLOSSY|PATH_RAY_SINGULAR|PATH_RAY_MIS_SKIP);
- }
- else if(label & LABEL_GLOSSY) {
- state->flag |= PATH_RAY_GLOSSY|PATH_RAY_GLOSSY_ANCESTOR;
- state->flag &= ~(PATH_RAY_DIFFUSE|PATH_RAY_SINGULAR|PATH_RAY_MIS_SKIP);
- }
- else {
- kernel_assert(label & LABEL_SINGULAR);
-
- state->flag |= PATH_RAY_GLOSSY|PATH_RAY_SINGULAR|PATH_RAY_MIS_SKIP;
- state->flag &= ~PATH_RAY_DIFFUSE;
- }
-}
-
-__device_inline uint path_state_ray_visibility(KernelGlobals *kg, PathState *state)
-{
- uint flag = state->flag & PATH_RAY_ALL_VISIBILITY;
-
- /* for visibility, diffuse/glossy are for reflection only */
- if(flag & PATH_RAY_TRANSMIT)
- flag &= ~(PATH_RAY_DIFFUSE|PATH_RAY_GLOSSY);
- /* for camera visibility, use render layer flags */
- if(flag & PATH_RAY_CAMERA)
- flag |= kernel_data.integrator.layer_flag;
-
- return flag;
-}
-
-__device_inline float path_state_terminate_probability(KernelGlobals *kg, PathState *state, const float3 throughput)
-{
- if(state->flag & PATH_RAY_TRANSPARENT) {
- /* transparent rays treated separately */
- if(state->transparent_bounce >= kernel_data.integrator.transparent_max_bounce)
- return 0.0f;
- else if(state->transparent_bounce <= kernel_data.integrator.transparent_min_bounce)
- return 1.0f;
- }
- else {
- /* other rays */
- if((state->bounce >= kernel_data.integrator.max_bounce) ||
- (state->diffuse_bounce >= kernel_data.integrator.max_diffuse_bounce) ||
- (state->glossy_bounce >= kernel_data.integrator.max_glossy_bounce) ||
- (state->transmission_bounce >= kernel_data.integrator.max_transmission_bounce))
- {
- return 0.0f;
- }
- else if(state->bounce <= kernel_data.integrator.min_bounce) {
- return 1.0f;
- }
- }
-
- /* probalistic termination */
- return average(throughput); /* todo: try using max here */
-}
-
__device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ray, float3 *shadow)
{
*shadow = make_float3(1.0f, 1.0f, 1.0f);