kernel_shadow_blocked_ao.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. CCL_NAMESPACE_BEGIN
  17. /* Shadow ray cast for AO. */
  18. ccl_device void kernel_shadow_blocked_ao(KernelGlobals *kg)
  19. {
  20. unsigned int ao_queue_length = kernel_split_params.queue_index[QUEUE_SHADOW_RAY_CAST_AO_RAYS];
  21. ccl_barrier(CCL_LOCAL_MEM_FENCE);
  22. int ray_index = QUEUE_EMPTY_SLOT;
  23. int thread_index = ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0);
  24. if (thread_index < ao_queue_length) {
  25. ray_index = get_ray_index(kg,
  26. thread_index,
  27. QUEUE_SHADOW_RAY_CAST_AO_RAYS,
  28. kernel_split_state.queue_data,
  29. kernel_split_params.queue_size,
  30. 1);
  31. }
  32. if (ray_index == QUEUE_EMPTY_SLOT) {
  33. return;
  34. }
  35. ShaderData *sd = kernel_split_sd(sd, ray_index);
  36. ShaderData *emission_sd = AS_SHADER_DATA(&kernel_split_state.sd_DL_shadow[ray_index]);
  37. PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
  38. ccl_global PathState *state = &kernel_split_state.path_state[ray_index];
  39. float3 throughput = kernel_split_state.throughput[ray_index];
  40. #ifdef __BRANCHED_PATH__
  41. if (!kernel_data.integrator.branched ||
  42. IS_FLAG(kernel_split_state.ray_state, ray_index, RAY_BRANCHED_INDIRECT)) {
  43. #endif
  44. kernel_path_ao(kg, sd, emission_sd, L, state, throughput, shader_bsdf_alpha(kg, sd));
  45. #ifdef __BRANCHED_PATH__
  46. }
  47. else {
  48. kernel_branched_path_ao(kg, sd, emission_sd, L, state, throughput);
  49. }
  50. #endif
  51. }
  52. CCL_NAMESPACE_END