Blender  V2.93
kernel_shadow_blocked_dl.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2015 Blender Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 /* Shadow ray cast for direct visible light. */
21 {
22  unsigned int dl_queue_length = kernel_split_params.queue_index[QUEUE_SHADOW_RAY_CAST_DL_RAYS];
24 
25  int ray_index = QUEUE_EMPTY_SLOT;
26  int thread_index = ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0);
27  if (thread_index < dl_queue_length) {
28  ray_index = get_ray_index(kg,
29  thread_index,
31  kernel_split_state.queue_data,
32  kernel_split_params.queue_size,
33  1);
34  }
35 
36 #ifdef __BRANCHED_PATH__
37  /* TODO(mai): move this somewhere else? */
38  if (thread_index == 0) {
39  /* Clear QUEUE_INACTIVE_RAYS before next kernel. */
41  }
42 #endif /* __BRANCHED_PATH__ */
43 
44  if (ray_index == QUEUE_EMPTY_SLOT)
45  return;
46 
47  ccl_global PathState *state = &kernel_split_state.path_state[ray_index];
48  Ray ray = kernel_split_state.light_ray[ray_index];
49  PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
50  ShaderData *sd = kernel_split_sd(sd, ray_index);
51  float3 throughput = kernel_split_state.throughput[ray_index];
52 
53  BsdfEval L_light = kernel_split_state.bsdf_eval[ray_index];
54  ShaderData *emission_sd = AS_SHADER_DATA(&kernel_split_state.sd_DL_shadow[ray_index]);
55  bool is_lamp = kernel_split_state.is_lamp[ray_index];
56 
57 #if defined(__BRANCHED_PATH__) || defined(__SHADOW_TRICKS__)
58  bool use_branched = false;
59  int all = 0;
60 
61  if (state->flag & PATH_RAY_SHADOW_CATCHER) {
62  use_branched = true;
63  all = 1;
64  }
65 # if defined(__BRANCHED_PATH__)
66  else if (kernel_data.integrator.branched) {
67  use_branched = true;
68 
69  if (IS_FLAG(kernel_split_state.ray_state, ray_index, RAY_BRANCHED_INDIRECT)) {
70  all = (kernel_data.integrator.sample_all_lights_indirect);
71  }
72  else {
73  all = (kernel_data.integrator.sample_all_lights_direct);
74  }
75  }
76 # endif /* __BRANCHED_PATH__ */
77 
78  if (use_branched) {
79  kernel_branched_path_surface_connect_light(
80  kg, sd, emission_sd, state, throughput, 1.0f, L, all);
81  }
82  else
83 #endif /* defined(__BRANCHED_PATH__) || defined(__SHADOW_TRICKS__)*/
84  {
85  /* trace shadow ray */
86  float3 shadow;
87 
88  if (!shadow_blocked(kg, sd, emission_sd, state, &ray, &shadow)) {
89  /* accumulate */
90  path_radiance_accum_light(kg, L, state, throughput, &L_light, shadow, 1.0f, is_lamp);
91  }
92  else {
93  path_radiance_accum_total_light(L, state, throughput, &L_light);
94  }
95  }
96 }
97 
ccl_device_inline void path_radiance_accum_total_light(PathRadiance *L, ccl_addr_space PathState *state, float3 throughput, const BsdfEval *bsdf_eval)
ccl_device_inline void path_radiance_accum_light(KernelGlobals *kg, PathRadiance *L, ccl_addr_space PathState *state, float3 throughput, BsdfEval *bsdf_eval, float3 shadow, float shadow_fac, bool is_lamp)
#define kernel_data
#define ccl_global_id(d)
#define ccl_global_size(d)
#define ccl_device
#define ccl_global
#define CCL_NAMESPACE_END
ccl_device int get_ray_index(KernelGlobals *kg, int thread_index, int queue_number, ccl_global int *queues, int queuesize, int empty_queue)
Definition: kernel_queues.h:53
ccl_device_inline bool shadow_blocked(KernelGlobals *kg, ShaderData *sd, ShaderData *shadow_sd, ccl_addr_space PathState *state, Ray *ray, float3 *shadow)
CCL_NAMESPACE_BEGIN ccl_device void kernel_shadow_blocked_dl(KernelGlobals *kg)
#define kernel_split_params
#define kernel_split_sd(sd, ray_index)
#define kernel_split_state
#define IS_FLAG(ray_state, ray_index, flag)
#define AS_SHADER_DATA(shader_data_tiny_storage)
@ PATH_RAY_SHADOW_CATCHER
Definition: kernel_types.h:306
ShaderData
#define QUEUE_EMPTY_SLOT
@ RAY_BRANCHED_INDIRECT
@ QUEUE_SHADOW_RAY_CAST_DL_RAYS
@ QUEUE_INACTIVE_RAYS
static ulong state[N]
#define L
#define CCL_LOCAL_MEM_FENCE
Definition: util_atomic.h:32
#define ccl_barrier(flags)
Definition: util_atomic.h:33
__forceinline bool all(const avxb &b)
Definition: util_avxb.h:214