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:
authorSergey Sharybin <sergey@blender.org>2021-08-03 13:20:28 +0300
committerSergey Sharybin <sergey@blender.org>2021-08-04 18:26:24 +0300
commitc18d91918fbb18d8c0d2e95de210ba818937cd87 (patch)
tree1f12519ad0f9ad4dd815adebac61b5ac57e8f287 /intern/cycles/kernel
parent58ba75f9e3bfc4ff08dbd1f2ce269c65388dfcfd (diff)
Cycles: More flexible GI Approximation AO distance control
The goal: allow to easily use AO approximation in scenes which combines both small and large scale objects. The idea: use per-object AO distance which will allow to override world settings. Instancer object will "propagate" its AO distance to all its instances unless the instance defines own distance (this allows to modify AO distance in the shot files, without requiring to modify props used in the shots. Available from the new Fats GI Approximation panel in object properties. Differential Revision: https://developer.blender.org/D12112
Diffstat (limited to 'intern/cycles/kernel')
-rw-r--r--intern/cycles/kernel/bvh/bvh_util.h10
-rw-r--r--intern/cycles/kernel/kernel_bake.h6
-rw-r--r--intern/cycles/kernel/kernel_path.h16
-rw-r--r--intern/cycles/kernel/kernel_path_branched.h11
-rw-r--r--intern/cycles/kernel/kernel_types.h5
-rw-r--r--intern/cycles/kernel/split/kernel_scene_intersect.h5
6 files changed, 41 insertions, 12 deletions
diff --git a/intern/cycles/kernel/bvh/bvh_util.h b/intern/cycles/kernel/bvh/bvh_util.h
index 867ea3af8d1..b1faebce957 100644
--- a/intern/cycles/kernel/bvh/bvh_util.h
+++ b/intern/cycles/kernel/bvh/bvh_util.h
@@ -239,4 +239,14 @@ ccl_device_forceinline int intersection_get_shader(KernelGlobals *ccl_restrict k
return shader & SHADER_MASK;
}
+ccl_device_forceinline int intersection_get_object(KernelGlobals *ccl_restrict kg,
+ const Intersection *ccl_restrict isect)
+{
+ if (isect->object != OBJECT_NONE) {
+ return isect->object;
+ }
+
+ return kernel_tex_fetch(__prim_object, isect->prim);
+}
+
CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/kernel_bake.h b/intern/cycles/kernel/kernel_bake.h
index d1f33a4d0f0..7da890b908d 100644
--- a/intern/cycles/kernel/kernel_bake.h
+++ b/intern/cycles/kernel/kernel_bake.h
@@ -81,7 +81,8 @@ ccl_device_noinline void compute_light_pass(
kg, sd, emission_sd, L, &state, &ray, &throughput, &ss_indirect)) {
while (ss_indirect.num_rays) {
kernel_path_subsurface_setup_indirect(kg, &ss_indirect, &state, &ray, L, &throughput);
- kernel_path_indirect(kg, &indirect_sd, emission_sd, &ray, throughput, &state, L);
+ kernel_path_indirect(
+ kg, &indirect_sd, emission_sd, &ray, throughput, &state, L, sd->object);
}
is_sss_sample = true;
}
@@ -97,7 +98,8 @@ ccl_device_noinline void compute_light_pass(
state.ray_t = 0.0f;
# endif
/* compute indirect light */
- kernel_path_indirect(kg, &indirect_sd, emission_sd, &ray, throughput, &state, L);
+ kernel_path_indirect(
+ kg, &indirect_sd, emission_sd, &ray, throughput, &state, L, sd->object);
/* sum and reset indirect light pass variables for the next samples */
path_radiance_sum_indirect(L);
diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h
index 3430543bc8e..ec577fa20b0 100644
--- a/intern/cycles/kernel/kernel_path.h
+++ b/intern/cycles/kernel/kernel_path.h
@@ -58,7 +58,8 @@ ccl_device_forceinline bool kernel_path_scene_intersect(KernelGlobals *kg,
ccl_addr_space PathState *state,
Ray *ray,
Intersection *isect,
- PathRadiance *L)
+ PathRadiance *L,
+ const int last_object)
{
PROFILING_INIT(kg, PROFILING_SCENE_INTERSECT);
@@ -66,6 +67,12 @@ ccl_device_forceinline bool kernel_path_scene_intersect(KernelGlobals *kg,
if (path_state_ao_bounce(kg, state)) {
ray->t = kernel_data.background.ao_distance;
+ if (last_object != OBJECT_NONE) {
+ const float object_ao_distance = kernel_tex_fetch(__objects, last_object).ao_distance;
+ if (object_ao_distance != 0.0f) {
+ ray->t = object_ao_distance;
+ }
+ }
}
bool hit = scene_intersect(kg, ray, visibility, isect);
@@ -369,7 +376,8 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
Ray *ray,
float3 throughput,
PathState *state,
- PathRadiance *L)
+ PathRadiance *L,
+ const int last_object)
{
# ifdef __SUBSURFACE__
SubsurfaceIndirectRays ss_indirect;
@@ -382,7 +390,7 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
for (;;) {
/* Find intersection with objects in scene. */
Intersection isect;
- bool hit = kernel_path_scene_intersect(kg, state, ray, &isect, L);
+ bool hit = kernel_path_scene_intersect(kg, state, ray, &isect, L, last_object);
/* Find intersection with lamps and compute emission for MIS. */
kernel_path_lamp_emission(kg, state, ray, throughput, &isect, sd, L);
@@ -526,7 +534,7 @@ ccl_device_forceinline void kernel_path_integrate(KernelGlobals *kg,
for (;;) {
/* Find intersection with objects in scene. */
Intersection isect;
- bool hit = kernel_path_scene_intersect(kg, state, ray, &isect, L);
+ bool hit = kernel_path_scene_intersect(kg, state, ray, &isect, L, sd.object);
/* Find intersection with lamps and compute emission for MIS. */
kernel_path_lamp_emission(kg, state, ray, throughput, &isect, &sd, L);
diff --git a/intern/cycles/kernel/kernel_path_branched.h b/intern/cycles/kernel/kernel_path_branched.h
index 5ea7687ec3b..a1ee1bc107e 100644
--- a/intern/cycles/kernel/kernel_path_branched.h
+++ b/intern/cycles/kernel/kernel_path_branched.h
@@ -92,6 +92,7 @@ ccl_device_forceinline void kernel_branched_path_volume(KernelGlobals *kg,
volume_ray.t = (hit) ? isect->t : FLT_MAX;
float step_size = volume_stack_step_size(kg, state->volume_stack);
+ const int object = sd->object;
# ifdef __VOLUME_DECOUPLED__
/* decoupled ray marching only supported on CPU */
@@ -134,7 +135,8 @@ ccl_device_forceinline void kernel_branched_path_volume(KernelGlobals *kg,
if (result == VOLUME_PATH_SCATTERED &&
kernel_path_volume_bounce(kg, sd, &tp, &ps, &L->state, &pray)) {
- kernel_path_indirect(kg, indirect_sd, emission_sd, &pray, tp * num_samples_inv, &ps, L);
+ kernel_path_indirect(
+ kg, indirect_sd, emission_sd, &pray, tp * num_samples_inv, &ps, L, object);
/* for render passes, sum and reset indirect light pass variables
* for the next samples */
@@ -180,7 +182,7 @@ ccl_device_forceinline void kernel_branched_path_volume(KernelGlobals *kg,
kernel_path_volume_connect_light(kg, sd, emission_sd, tp, state, L);
if (kernel_path_volume_bounce(kg, sd, &tp, &ps, &L->state, &pray)) {
- kernel_path_indirect(kg, indirect_sd, emission_sd, &pray, tp, &ps, L);
+ kernel_path_indirect(kg, indirect_sd, emission_sd, &pray, tp, &ps, L, object);
/* for render passes, sum and reset indirect light pass variables
* for the next samples */
@@ -266,7 +268,8 @@ ccl_device_noinline_cpu void kernel_branched_path_surface_indirect_light(KernelG
ps.rng_hash = state->rng_hash;
- kernel_path_indirect(kg, indirect_sd, emission_sd, &bsdf_ray, tp * num_samples_inv, &ps, L);
+ kernel_path_indirect(
+ kg, indirect_sd, emission_sd, &bsdf_ray, tp * num_samples_inv, &ps, L, sd->object);
/* for render passes, sum and reset indirect light pass variables
* for the next samples */
@@ -395,7 +398,7 @@ ccl_device void kernel_branched_path_integrate(KernelGlobals *kg,
for (;;) {
/* Find intersection with objects in scene. */
Intersection isect;
- bool hit = kernel_path_scene_intersect(kg, &state, &ray, &isect, L);
+ bool hit = kernel_path_scene_intersect(kg, &state, &ray, &isect, L, sd.object);
# ifdef __VOLUME__
/* Volume integration. */
diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h
index f9ea3a2d0a8..7cbe18acf28 100644
--- a/intern/cycles/kernel/kernel_types.h
+++ b/intern/cycles/kernel/kernel_types.h
@@ -1447,7 +1447,10 @@ typedef struct KernelObject {
float shadow_terminator_shading_offset;
float shadow_terminator_geometry_offset;
- float pad1, pad2, pad3;
+
+ float ao_distance;
+
+ float pad1, pad2;
} KernelObject;
static_assert_align(KernelObject, 16);
diff --git a/intern/cycles/kernel/split/kernel_scene_intersect.h b/intern/cycles/kernel/split/kernel_scene_intersect.h
index 5fef3e045f8..9ac95aafd2f 100644
--- a/intern/cycles/kernel/split/kernel_scene_intersect.h
+++ b/intern/cycles/kernel/split/kernel_scene_intersect.h
@@ -65,7 +65,10 @@ ccl_device void kernel_scene_intersect(KernelGlobals *kg)
PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
Intersection isect;
- bool hit = kernel_path_scene_intersect(kg, state, &ray, &isect, L);
+ const int last_object = state->bounce > 0 ?
+ intersection_get_object(kg, &kernel_split_state.isect[ray_index]) :
+ OBJECT_NONE;
+ bool hit = kernel_path_scene_intersect(kg, state, &ray, &isect, L, last_object);
kernel_split_state.isect[ray_index] = isect;
if (!hit) {