kernel_indirect_background.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright 2011-2017 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. ccl_device void kernel_indirect_background(KernelGlobals *kg)
  18. {
  19. ccl_global char *ray_state = kernel_split_state.ray_state;
  20. int thread_index = ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0);
  21. int ray_index;
  22. if (kernel_data.integrator.ao_bounces != INT_MAX) {
  23. ray_index = get_ray_index(kg,
  24. thread_index,
  25. QUEUE_ACTIVE_AND_REGENERATED_RAYS,
  26. kernel_split_state.queue_data,
  27. kernel_split_params.queue_size,
  28. 0);
  29. if (ray_index != QUEUE_EMPTY_SLOT) {
  30. if (IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
  31. ccl_global PathState *state = &kernel_split_state.path_state[ray_index];
  32. if (path_state_ao_bounce(kg, state)) {
  33. kernel_split_path_end(kg, ray_index);
  34. }
  35. }
  36. }
  37. }
  38. ray_index = get_ray_index(kg,
  39. thread_index,
  40. QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS,
  41. kernel_split_state.queue_data,
  42. kernel_split_params.queue_size,
  43. 0);
  44. if (ray_index == QUEUE_EMPTY_SLOT) {
  45. return;
  46. }
  47. if (IS_STATE(ray_state, ray_index, RAY_HIT_BACKGROUND)) {
  48. ccl_global PathState *state = &kernel_split_state.path_state[ray_index];
  49. PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
  50. ccl_global Ray *ray = &kernel_split_state.ray[ray_index];
  51. float3 throughput = kernel_split_state.throughput[ray_index];
  52. ShaderData *sd = kernel_split_sd(sd, ray_index);
  53. kernel_path_background(kg, state, ray, throughput, sd, L);
  54. kernel_split_path_end(kg, ray_index);
  55. }
  56. }
  57. CCL_NAMESPACE_END