[Bf-blender-cvs] [66c3f40da4f] cycles_path_guiding: Merge branch 'master' into cycles_path_guiding
Brecht Van Lommel
noreply at git.blender.org
Thu Aug 11 14:12:49 CEST 2022
Commit: 66c3f40da4fa694197b54876d8c05956ca7654c7
Author: Brecht Van Lommel
Date: Thu Aug 11 13:22:00 2022 +0200
Branches: cycles_path_guiding
https://developer.blender.org/rB66c3f40da4fa694197b54876d8c05956ca7654c7
Merge branch 'master' into cycles_path_guiding
Adapting to the new Spectrum type.
===================================================================
===================================================================
diff --cc intern/cycles/blender/sync.cpp
index 3194094cb70,429a8e665af..6dcf57a0ca7
--- a/intern/cycles/blender/sync.cpp
+++ b/intern/cycles/blender/sync.cpp
@@@ -412,20 -412,15 +412,28 @@@ void BlenderSync::sync_integrator(BL::V
integrator->set_direct_light_sampling_type(direct_light_sampling_type);
#endif
+#ifdef __PATH_GUIDING__
+ integrator->set_use_guiding(get_boolean(cscene, "use_guiding"));
+ integrator->set_use_surface_guiding(get_boolean(cscene, "use_surface_guiding"));
+ integrator->set_surface_guiding_probability(get_float(cscene, "surface_guiding_probability"));
+ integrator->set_use_volume_guiding(get_boolean(cscene, "use_volume_guiding"));
+ integrator->set_volume_guiding_probability(get_float(cscene, "volume_guiding_probability"));
+ integrator->set_use_guide_direct_light(get_boolean(cscene, "use_guide_direct_light"));
+ integrator->set_use_mis_weights(get_boolean(cscene, "use_mis_weights"));
+ GuidingDistributionType guiding_distribution_type = (GuidingDistributionType)get_enum(
+ cscene, "guiding_distribution_type", GUIDING_NUM_TYPES, GUIDING_TYPE_PAVMM);
+ integrator->set_guiding_distribution_type(guiding_distribution_type);
+#endif
+
- const DenoiseParams denoise_params = get_denoise_params(b_scene, b_view_layer, background);
+ DenoiseParams denoise_params = get_denoise_params(b_scene, b_view_layer, background);
+
+ /* No denoising support for vertex color baking, vertices packed into image
+ * buffer have no relation to neighbors. */
+ if (scene->bake_manager->get_baking() &&
+ b_scene.render().bake().target() != BL::BakeSettings::target_IMAGE_TEXTURES) {
+ denoise_params.use = false;
+ }
+
integrator->set_use_denoise(denoise_params.use);
/* Only update denoiser parameters if the denoiser is actually used. This allows to tweak
diff --cc intern/cycles/kernel/closure/bsdf.h
index c05a454c00b,7b28018afad..e1eda577a82
--- a/intern/cycles/kernel/closure/bsdf.h
+++ b/intern/cycles/kernel/closure/bsdf.h
@@@ -103,12 -103,10 +103,12 @@@ ccl_device_inline int bsdf_sample(Kerne
ccl_private const ShaderClosure *sc,
float randu,
float randv,
- ccl_private float3 *eval,
+ ccl_private Spectrum *eval,
ccl_private float3 *omega_in,
ccl_private differential3 *domega_in,
- ccl_private float *pdf)
+ ccl_private float *pdf,
+ ccl_private float2 *sampled_roughness,
+ ccl_private float *eta)
{
/* For curves use the smooth normal, particularly for ribbons the geometric
* normal gives too much darkening otherwise. */
diff --cc intern/cycles/kernel/integrator/path_state.h
index 38cdea079dc,5ec94b934ca..aa3dba9f9b7
--- a/intern/cycles/kernel/integrator/path_state.h
+++ b/intern/cycles/kernel/integrator/path_state.h
@@@ -54,12 -54,8 +54,12 @@@ ccl_device_inline void path_state_init_
INTEGRATOR_STATE_WRITE(state, path, mis_ray_pdf) = 0.0f;
INTEGRATOR_STATE_WRITE(state, path, min_ray_pdf) = FLT_MAX;
INTEGRATOR_STATE_WRITE(state, path, continuation_probability) = 1.0f;
- INTEGRATOR_STATE_WRITE(state, path, throughput) = make_float3(1.0f, 1.0f, 1.0f);
+ INTEGRATOR_STATE_WRITE(state, path, throughput) = one_spectrum();
+#ifdef __PATH_GUIDING__
+ INTEGRATOR_STATE_WRITE(state, path, rr_throughput) = make_float3(1.0f, 1.0f, 1.0f);
+#endif
+
#ifdef __MNEE__
INTEGRATOR_STATE_WRITE(state, path, mnee) = 0;
#endif
diff --cc intern/cycles/kernel/integrator/shade_background.h
index f7c2368465b,57d060d58df..bb93611002d
--- a/intern/cycles/kernel/integrator/shade_background.h
+++ b/intern/cycles/kernel/integrator/shade_background.h
@@@ -71,16 -71,9 +71,16 @@@ ccl_device Spectrum integrator_eval_bac
}
# endif
+# if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 1
+ if (kernel_data.integrator.use_guiding) {
+ guiding_add_background(state, L, mis_weight);
+ }
+# endif
+
+ L *= mis_weight;
return L;
#else
- return make_float3(0.8f, 0.8f, 0.8f);
+ return make_spectrum(0.8f);
#endif
}
diff --cc intern/cycles/kernel/integrator/shade_light.h
index 6f80da30b46,ac9d1415abb..225ab34c9d3
--- a/intern/cycles/kernel/integrator/shade_light.h
+++ b/intern/cycles/kernel/integrator/shade_light.h
@@@ -62,16 -61,12 +62,16 @@@ ccl_device_inline void integrate_light(
/* multiple importance sampling, get regular light pdf,
* and compute weight with respect to BSDF pdf */
const float mis_ray_pdf = INTEGRATOR_STATE(state, path, mis_ray_pdf);
- const float mis_weight = light_sample_mis_weight_forward(kg, mis_ray_pdf, ls.pdf);
- light_eval *= mis_weight;
+ mis_weight = light_sample_mis_weight_forward(kg, mis_ray_pdf, ls.pdf);
}
-
+#if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 1
+ if (kernel_data.integrator.use_guiding) {
+ guiding_add_direct_contribution(state, light_eval, mis_weight);
+ }
+#endif
+ light_eval *= mis_weight;
/* Write to render buffer. */
- const float3 throughput = INTEGRATOR_STATE(state, path, throughput);
+ const Spectrum throughput = INTEGRATOR_STATE(state, path, throughput);
kernel_accum_emission(kg, state, throughput * light_eval, render_buffer, ls.group);
}
diff --cc intern/cycles/kernel/integrator/shade_shadow.h
index 38ab71b538f,a52706a77f1..03b1bc0cdc7
--- a/intern/cycles/kernel/integrator/shade_shadow.h
+++ b/intern/cycles/kernel/integrator/shade_shadow.h
@@@ -102,17 -100,8 +102,17 @@@ ccl_device_inline bool integrate_transp
if (hit < num_recorded_hits || !shadow_intersections_has_remaining(num_hits)) {
# ifdef __VOLUME__
if (!integrator_state_shadow_volume_stack_is_empty(kg, state)) {
- float3 throughput = INTEGRATOR_STATE(state, shadow_path, throughput);
- float3 transmittance = make_float3(1.f, 1.f, 1.f);
+ Spectrum throughput = INTEGRATOR_STATE(state, shadow_path, throughput);
- integrate_transparent_volume_shadow(kg, state, hit, num_recorded_hits, &throughput);
++ Spectrum transmittance = one_spectrum();
+ integrate_transparent_volume_shadow(kg, state, hit, num_recorded_hits, &transmittance);
+ throughput *= transmittance;
+# if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 1
+ // TODO
+ if (use_guiding) {
+ INTEGRATOR_STATE_WRITE(state, shadow_path, scattered_contribution) =
+ INTEGRATOR_STATE(state, shadow_path, scattered_contribution) * transmittance;
+ }
+# endif
if (is_zero(throughput)) {
return true;
}
@@@ -123,14 -113,8 +123,14 @@@
/* Surface shaders. */
if (hit < num_recorded_hits) {
- const float3 shadow = integrate_transparent_surface_shadow(kg, state, hit);
- const float3 throughput = INTEGRATOR_STATE(state, shadow_path, throughput) * shadow;
+ const Spectrum shadow = integrate_transparent_surface_shadow(kg, state, hit);
+ const Spectrum throughput = INTEGRATOR_STATE(state, shadow_path, throughput) * shadow;
+# ifdef __PATH_GUIDING__
+ if (use_guiding) {
+ INTEGRATOR_STATE_WRITE(state, shadow_path, scattered_contribution) =
+ INTEGRATOR_STATE(state, shadow_path, scattered_contribution) * shadow;
+ }
+# endif
if (is_zero(throughput)) {
return true;
}
@@@ -181,14 -165,6 +181,15 @@@ ccl_device void integrator_shade_shadow
return;
}
else {
+#if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 1
+ // we need to find a way to reset this pointer and to identify if we are in AO mode
+ const bool use_guiding = kernel_data.integrator.use_guiding;
+ if (use_guiding && state->shadow_path.path_segment) {
- float3 scattered_contribution = INTEGRATOR_STATE(state, shadow_path, scattered_contribution);
++ Spectrum scattered_contribution = INTEGRATOR_STATE(
++ state, shadow_path, scattered_contribution);
+ guiding_add_scattered_contribution(state, scattered_contribution);
+ }
+#endif
kernel_accum_light(kg, state, render_buffer);
integrator_shadow_path_terminate(kg, state, DEVICE_KERNEL_INTEGRATOR_SHADE_SHADOW);
return;
diff --cc intern/cycles/kernel/integrator/shade_surface.h
index d470568b8b9,4eb50171532..966e5e42cdb
--- a/intern/cycles/kernel/integrator/shade_surface.h
+++ b/intern/cycles/kernel/integrator/shade_surface.h
@@@ -67,8 -111,8 +111,9 @@@ ccl_device_forceinline void integrate_s
const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag);
/* Evaluate emissive closure. */
- float3 L = shader_emissive_eval(sd);
+ Spectrum L = shader_emissive_eval(sd);
+ float mis_weight = 1.0f;
+
# ifdef __HAIR__
if (!(path_flag & PATH_RAY_MIS_SKIP) && (sd->flag & SD_USE_MIS) &&
(sd->type & PRIMITIVE_TRIANGLE))
@@@ -82,17 -126,11 +127,17 @@@
/* Multiple importance sampling, get triangle light pdf,
* and compute weight with respect to BSDF pdf. */
float pdf = triangle_light_pdf(kg, sd, t);
- float mis_weight = light_sample_mis_weight_forward(kg, bsdf_pdf, pdf);
- L *= mis_weight;
+ mis_weight = light_sample_mis_weight_forward(kg, bsdf_pdf, pdf);
}
+# if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 1
+ if (kernel_data.integrator.use_guiding) {
+ guiding_add_direct_contribution(state, L, mis_weight);
+ }
+# endif
+ L *= mis_weight;
+
- const float3 throughput = INTEGRATOR_STATE(state, path, throughput);
+ const Spectrum throughput = INTEGRATOR_STATE(state, path, throughput);
kernel_accum_emission(
kg, state, throughput * L, render_buffer, object_lightgroup(kg, sd->object));
}
@@@ -235,12 -261,12 +284,12 @@@ ccl_device_forceinline void integrate_s
/* Copy state from main path to shadow path. */
uint32_t shadow_flag = INTEGRATOR_STATE(state, path, flag);
shadow_flag |= (is_light) ? PATH_RAY_SHADOW_FOR_LIGHT : 0;
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list