[Bf-blender-cvs] [015619a849c] cycles-x: Cleanup: remove unused kernel_shadow.h

Brecht Van Lommel noreply at git.blender.org
Wed Jul 14 14:39:28 CEST 2021


Commit: 015619a849cac56d312785b085ea776dd68c2105
Author: Brecht Van Lommel
Date:   Tue Jul 13 18:56:09 2021 +0200
Branches: cycles-x
https://developer.blender.org/rB015619a849cac56d312785b085ea776dd68c2105

Cleanup: remove unused kernel_shadow.h

===================================================================

M	intern/cycles/kernel/CMakeLists.txt
D	intern/cycles/kernel/kernel_shadow.h

===================================================================

diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt
index 44175fec111..793c32dc9c7 100644
--- a/intern/cycles/kernel/CMakeLists.txt
+++ b/intern/cycles/kernel/CMakeLists.txt
@@ -86,7 +86,6 @@ set(SRC_HEADERS
   kernel_projection.h
   kernel_random.h
   kernel_shader.h
-  kernel_shadow.h
   kernel_shadow_catcher.h
   kernel_subsurface.h
   kernel_textures.h
diff --git a/intern/cycles/kernel/kernel_shadow.h b/intern/cycles/kernel/kernel_shadow.h
deleted file mode 100644
index f0a77af1f22..00000000000
--- a/intern/cycles/kernel/kernel_shadow.h
+++ /dev/null
@@ -1,468 +0,0 @@
-/*
- * Copyright 2011-2013 Blender Foundation
- *
- * 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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
- * limitations under the License.
- */
-
-#pragma once
-
-CCL_NAMESPACE_BEGIN
-
-#ifdef __VOLUME__
-/* Get PathState ready for use for volume stack evaluation. */
-#  ifdef __SPLIT_KERNEL__
-ccl_addr_space
-#  endif
-    ccl_device_inline PathState *
-    shadow_blocked_volume_path_state(const KernelGlobals *kg,
-                                     VolumeState *volume_state,
-                                     ccl_addr_space PathState *state,
-                                     ShaderData *sd,
-                                     Ray *ray)
-{
-#  ifdef __SPLIT_KERNEL__
-  ccl_addr_space PathState *ps =
-      &kernel_split_state.state_shadow[ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0)];
-#  else
-  PathState *ps = &volume_state->ps;
-#  endif
-  *ps = *state;
-  /* We are checking for shadow on the "other" side of the surface, so need
-   * to discard volume we are currently at.
-   */
-  if (dot(sd->Ng, ray->D) < 0.0f) {
-    kernel_volume_stack_enter_exit(kg, sd, ps->volume_stack);
-  }
-  return ps;
-}
-#endif /* __VOLUME__ */
-
-/* Attenuate throughput accordingly to the given intersection event.
- * Returns true if the throughput is zero and traversal can be aborted.
- */
-ccl_device_forceinline bool shadow_handle_transparent_isect(const KernelGlobals *kg,
-                                                            ShaderData *shadow_sd,
-                                                            ccl_addr_space PathState *state,
-#ifdef __VOLUME__
-                                                            ccl_addr_space PathState *volume_state,
-#endif
-                                                            Intersection *isect,
-                                                            Ray *ray,
-                                                            float3 *throughput)
-{
-#ifdef __VOLUME__
-  /* Attenuation between last surface and next surface. */
-  if (volume_state->volume_stack[0].shader != SHADER_NONE) {
-    Ray segment_ray = *ray;
-    segment_ray.t = isect->t;
-    kernel_volume_shadow(kg, shadow_sd, volume_state, &segment_ray, throughput);
-  }
-#endif
-  /* Setup shader data at surface. */
-  shader_setup_from_ray(kg, shadow_sd, isect, ray);
-  /* Attenuation from transparent surface. */
-  if (!(shadow_sd->flag & SD_HAS_ONLY_VOLUME)) {
-    path_state_modify_bounce(state, true);
-    shader_eval_surface(kg, shadow_sd, state, NULL, PATH_RAY_SHADOW);
-    path_state_modify_bounce(state, false);
-    *throughput *= shader_bsdf_transparency(kg, shadow_sd);
-  }
-  /* Stop if all light is blocked. */
-  if (is_zero(*throughput)) {
-    return true;
-  }
-#ifdef __VOLUME__
-  /* Exit/enter volume. */
-  kernel_volume_stack_enter_exit(kg, shadow_sd, volume_state->volume_stack);
-#endif
-  return false;
-}
-
-/* Special version which only handles opaque shadows. */
-ccl_device bool shadow_blocked_opaque(const KernelGlobals *kg,
-                                      ShaderData *shadow_sd,
-                                      ccl_addr_space PathState *state,
-                                      const uint visibility,
-                                      Ray *ray,
-                                      Intersection *isect,
-                                      float3 *shadow)
-{
-  const bool blocked = scene_intersect(kg, ray, visibility & PATH_RAY_SHADOW_OPAQUE, isect);
-#ifdef __VOLUME__
-  if (!blocked && state->volume_stack[0].shader != SHADER_NONE) {
-    /* Apply attenuation from current volume shader. */
-    kernel_volume_shadow(kg, shadow_sd, state, ray, shadow);
-  }
-#endif
-  return blocked;
-}
-
-#ifdef __TRANSPARENT_SHADOWS__
-#  ifdef __SHADOW_RECORD_ALL__
-/* Shadow function to compute how much light is blocked,
- *
- * We trace a single ray. If it hits any opaque surface, or more than a given
- * number of transparent surfaces is hit, then we consider the geometry to be
- * entirely blocked. If not, all transparent surfaces will be recorded and we
- * will shade them one by one to determine how much light is blocked. This all
- * happens in one scene intersection function.
- *
- * Recording all hits works well in some cases but may be slower in others. If
- * we have many semi-transparent hairs, one intersection may be faster because
- * you'd be reinteresecting the same hairs a lot with each step otherwise. If
- * however there is mostly binary transparency then we may be recording many
- * unnecessary intersections when one of the first surfaces blocks all light.
- *
- * From tests in real scenes it seems the performance loss is either minimal,
- * or there is a performance increase anyway due to avoiding the need to send
- * two rays with transparent shadows.
- *
- * On CPU it'll handle all transparent bounces (by allocating storage for
- * intersections when they don't fit into the stack storage).
- *
- * On GPU it'll only handle SHADOW_STACK_MAX_HITS-1 intersections, so this
- * is something to be kept an eye on.
- */
-
-#    define SHADOW_STACK_MAX_HITS 64
-
-/* Actual logic with traversal loop implementation which is free from device
- * specific tweaks.
- *
- * Note that hits array should be as big as max_hits+1.
- */
-ccl_device bool shadow_blocked_transparent_all_loop(const KernelGlobals *kg,
-                                                    ShaderData *sd,
-                                                    ShaderData *shadow_sd,
-                                                    ccl_addr_space PathState *state,
-                                                    const uint visibility,
-                                                    Ray *ray,
-                                                    Intersection *hits,
-                                                    uint max_hits,
-                                                    float3 *shadow)
-{
-  /* Intersect to find an opaque surface, or record all transparent
-   * surface hits.
-   */
-  uint num_hits;
-  const bool blocked = scene_intersect_shadow_all(kg, ray, hits, visibility, max_hits, &num_hits);
-#    ifdef __VOLUME__
-#      ifdef __KERNEL_OPTIX__
-  VolumeState &volume_state = kg->volume_state;
-#      else
-  VolumeState volume_state;
-#      endif
-#    endif
-  /* If no opaque surface found but we did find transparent hits,
-   * shade them.
-   */
-  if (!blocked && num_hits > 0) {
-    float3 throughput = one_float3();
-    float3 Pend = ray->P + ray->D * ray->t;
-    float last_t = 0.0f;
-    int bounce = state->transparent_bounce;
-    Intersection *isect = hits;
-#    ifdef __VOLUME__
-#      ifdef __SPLIT_KERNEL__
-    ccl_addr_space
-#      endif
-        PathState *ps = shadow_blocked_volume_path_state(kg, &volume_state, state, sd, ray);
-#    endif
-    sort_intersections(hits, num_hits);
-    for (int hit = 0; hit < num_hits; hit++, isect++) {
-      /* Adjust intersection distance for moving ray forward. */
-      float new_t = isect->t;
-      isect->t -= last_t;
-      /* Skip hit if we did not move forward, step by step raytracing
-       * would have skipped it as well then.
-       */
-      if (last_t == new_t) {
-        continue;
-      }
-      last_t = new_t;
-      /* Attenuate the throughput. */
-      if (shadow_handle_transparent_isect(kg,
-                                          shadow_sd,
-                                          state,
-#    ifdef __VOLUME__
-                                          ps,
-#    endif
-                                          isect,
-                                          ray,
-                                          &throughput)) {
-        return true;
-      }
-      /* Move ray forward. */
-      ray->P = shadow_sd->P;
-      if (ray->t != FLT_MAX) {
-        ray->D = normalize_len(Pend - ray->P, &ray->t);
-      }
-      bounce++;
-    }
-#    ifdef __VOLUME__
-    /* Attenuation for last line segment towards light. */
-    if (ps->volume_stack[0].shader != SHADER_NONE) {
-      kernel_volume_shadow(kg, shadow_sd, ps, ray, &throughput);
-    }
-#    endif
-    *shadow = throughput;
-    return is_zero(throughput);
-  }
-#    ifdef __VOLUME__
-  if (!blocked && state->volume_stack[0].shader != SHADER_NONE) {
-    /* Apply attenuation from current volume shader. */
-#      ifdef __SPLIT_KERNEL__
-    ccl_addr_space
-#      endif
-        PathState *ps = shadow_blocked_volume_path_state(kg, &volume_state, state, sd, ray);
-    kernel_volume_shadow(kg, shadow_sd, ps, ray, shadow);
-  }
-#    endif
-  return blocked;
-}
-
-/* Here we do all device specific trickery before invoking actual traversal
- * loop to help readability of the actual logic.
- */
-ccl_device bool shadow_blocked_transparent_all(const KernelGlobals *kg,
-                                               ShaderData *sd,
-                                               ShaderData *shadow_sd,
-                                               ccl_addr_space PathState *state,
-                                               const uint visibility,
-                                           

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list