Commit: f510d96b0a1f2247d5bb2f97f76b69c1f09805ed Author: sherholz-intel Date: Fri Sep 2 12:08:41 2022 +0200 Branches: cycles_path_guiding https://developer.blender.org/rBf510d96b0a1f2247d5bb2f97f76b69c1f09805ed
Guiding: removed bssrdf_weight from the state =================================================================== M intern/cycles/kernel/integrator/guiding.h M intern/cycles/kernel/integrator/state_template.h M intern/cycles/kernel/integrator/subsurface.h M intern/cycles/kernel/integrator/subsurface_disk.h M intern/cycles/kernel/integrator/subsurface_random_walk.h =================================================================== diff --git a/intern/cycles/kernel/integrator/guiding.h b/intern/cycles/kernel/integrator/guiding.h index 31e747a592a..8b83fc0754f 100644 --- a/intern/cycles/kernel/integrator/guiding.h +++ b/intern/cycles/kernel/integrator/guiding.h @@ -137,9 +137,29 @@ ccl_device_forceinline void guiding_record_bssrdf_segment(KernelGlobals kg, #endif } +ccl_device_forceinline void guiding_record_bssrdf_weight(KernelGlobals kg, + IntegratorState state, + const Spectrum weight) +{ +#if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 1 + if (!kernel_data.integrator.use_guiding) { + return; + } + + const float3 weight_rgb = spectrum_to_rgb(weight); + + kernel_assert(state->guiding.path_segment != nullptr); + + openpgl::cpp::SetTransmittanceWeight(state->guiding.path_segment, guiding_vec3f(zero_float3())); + openpgl::cpp::SetScatteringWeight(state->guiding.path_segment, guiding_vec3f(weight_rgb)); + openpgl::cpp::SetIsDelta(state->guiding.path_segment, false); + openpgl::cpp::SetEta(state->guiding.path_segment, 1.0f); + openpgl::cpp::SetRoughness(state->guiding.path_segment, 1.0f); +#endif +} + ccl_device_forceinline void guiding_record_bssrdf_bounce(KernelGlobals kg, IntegratorState state, - const Spectrum weight, const float pdf, const float3 N, const float3 omega_in) @@ -149,20 +169,14 @@ ccl_device_forceinline void guiding_record_bssrdf_bounce(KernelGlobals kg, return; } - const float3 weight_rgb = spectrum_to_rgb(weight); const float3 normal = clamp(N, -one_float3(), one_float3()); kernel_assert(state->guiding.path_segment != nullptr); - openpgl::cpp::SetTransmittanceWeight(state->guiding.path_segment, guiding_vec3f(one_float3())); openpgl::cpp::SetVolumeScatter(state->guiding.path_segment, false); openpgl::cpp::SetNormal(state->guiding.path_segment, guiding_vec3f(normal)); openpgl::cpp::SetDirectionIn(state->guiding.path_segment, guiding_vec3f(omega_in)); openpgl::cpp::SetPDFDirectionIn(state->guiding.path_segment, pdf); - openpgl::cpp::SetScatteringWeight(state->guiding.path_segment, guiding_vec3f(weight_rgb)); - openpgl::cpp::SetIsDelta(state->guiding.path_segment, false); - openpgl::cpp::SetEta(state->guiding.path_segment, 1.0f); - openpgl::cpp::SetRoughness(state->guiding.path_segment, 1.0f); #endif } diff --git a/intern/cycles/kernel/integrator/state_template.h b/intern/cycles/kernel/integrator/state_template.h index 4cf5f4a1e8f..20a262d493a 100644 --- a/intern/cycles/kernel/integrator/state_template.h +++ b/intern/cycles/kernel/integrator/state_template.h @@ -91,7 +91,6 @@ KERNEL_STRUCT_MEMBER(subsurface, PackedSpectrum, albedo, KERNEL_FEATURE_SUBSURFA KERNEL_STRUCT_MEMBER(subsurface, PackedSpectrum, radius, KERNEL_FEATURE_SUBSURFACE) KERNEL_STRUCT_MEMBER(subsurface, float, anisotropy, KERNEL_FEATURE_SUBSURFACE) KERNEL_STRUCT_MEMBER(subsurface, packed_float3, Ng, KERNEL_FEATURE_SUBSURFACE) -KERNEL_STRUCT_MEMBER(subsurface, PackedSpectrum, bssrdf_weight, KERNEL_FEATURE_SUBSURFACE) KERNEL_STRUCT_END(subsurface) /********************************** Volume Stack ******************************/ diff --git a/intern/cycles/kernel/integrator/subsurface.h b/intern/cycles/kernel/integrator/subsurface.h index 4b126007060..979c298e0a9 100644 --- a/intern/cycles/kernel/integrator/subsurface.h +++ b/intern/cycles/kernel/integrator/subsurface.h @@ -77,7 +77,10 @@ ccl_device int subsurface_bounce(KernelGlobals kg, INTEGRATOR_STATE_WRITE(state, subsurface, albedo) = bssrdf->albedo; INTEGRATOR_STATE_WRITE(state, subsurface, radius) = bssrdf->radius; INTEGRATOR_STATE_WRITE(state, subsurface, anisotropy) = bssrdf->anisotropy; - INTEGRATOR_STATE_WRITE(state, subsurface, bssrdf_weight) = weight; + + if (kernel_data.integrator.use_guiding) { + guiding_record_bssrdf_weight(kg, state, safe_divide_color(weight, bssrdf->albedo)); + } return LABEL_SUBSURFACE_SCATTER; } diff --git a/intern/cycles/kernel/integrator/subsurface_disk.h b/intern/cycles/kernel/integrator/subsurface_disk.h index 85ee0ec0585..e623e448b9b 100644 --- a/intern/cycles/kernel/integrator/subsurface_disk.h +++ b/intern/cycles/kernel/integrator/subsurface_disk.h @@ -49,14 +49,11 @@ ccl_device_inline bool subsurface_disk(KernelGlobals kg, Spectrum throughput = INTEGRATOR_STATE(state, path, throughput); throughput = safe_divide_color(throughput, albedo); const bool use_guiding = kernel_data.integrator.use_guiding; - Spectrum bssrdf_weight = INTEGRATOR_STATE(state, subsurface, bssrdf_weight); - // const Spectrum albedo = INTEGRATOR_STATE(state, subsurface, albedo); // we need to add a new segment or add the direction // or at lease the sampling direction to the new path segment - bssrdf_weight = safe_divide_color(bssrdf_weight, albedo); Spectrum initial_throughput = throughput; if (use_guiding) { - guiding_record_bssrdf_bounce(kg, state, bssrdf_weight, 1.f, Ng, -Ng); + guiding_record_bssrdf_bounce(kg, state, 1.f, Ng, -Ng); } #endif diff --git a/intern/cycles/kernel/integrator/subsurface_random_walk.h b/intern/cycles/kernel/integrator/subsurface_random_walk.h index 4375c69446e..33fea84edda 100644 --- a/intern/cycles/kernel/integrator/subsurface_random_walk.h +++ b/intern/cycles/kernel/integrator/subsurface_random_walk.h @@ -177,10 +177,6 @@ ccl_device_inline bool subsurface_random_walk(KernelGlobals kg, const int object = INTEGRATOR_STATE(state, isect, object); const int prim = INTEGRATOR_STATE(state, isect, prim); -#if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 1 - Spectrum bssrdf_weight = INTEGRATOR_STATE(state, subsurface, bssrdf_weight); -#endif - /* Sample diffuse surface scatter into the object. */ float3 D; float pdf; @@ -217,10 +213,9 @@ ccl_device_inline bool subsurface_random_walk(KernelGlobals kg, // we need to add a new segment or add the direction // or at lease the sampling direction to the new path segment const bool use_guiding = kernel_data.integrator.use_guiding; - bssrdf_weight = safe_divide_color(bssrdf_weight, albedo); Spectrum initial_throughput = throughput; if (use_guiding) { - guiding_record_bssrdf_bounce(kg, state, bssrdf_weight, pdf, N, D); + guiding_record_bssrdf_bounce(kg, state, pdf, N, D); } #endif _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs