[Bf-blender-cvs] [5cd43fc91a1] cycles-x: Fix incorrect volume stack for shadow rays
Brecht Van Lommel
noreply at git.blender.org
Mon Jun 28 17:15:23 CEST 2021
Commit: 5cd43fc91a1cd15e67ec73b6476336183cf041a1
Author: Brecht Van Lommel
Date: Fri Jun 25 20:31:16 2021 +0200
Branches: cycles-x
https://developer.blender.org/rB5cd43fc91a1cd15e67ec73b6476336183cf041a1
Fix incorrect volume stack for shadow rays
===================================================================
M intern/cycles/kernel/integrator/integrator_shade_surface.h
M intern/cycles/kernel/integrator/integrator_subsurface.h
M intern/cycles/kernel/kernel_types.h
===================================================================
diff --git a/intern/cycles/kernel/integrator/integrator_shade_surface.h b/intern/cycles/kernel/integrator/integrator_shade_surface.h
index f06813a7178..4feda3ab904 100644
--- a/intern/cycles/kernel/integrator/integrator_shade_surface.h
+++ b/intern/cycles/kernel/integrator/integrator_shade_surface.h
@@ -157,6 +157,15 @@ ccl_device_forceinline void integrate_surface_direct_light(INTEGRATOR_STATE_ARGS
light_sample_to_shadow_ray(sd, &ls, &ray);
const bool is_light = light_sample_is_light(&ls);
+ /* Copy volume stack and enter/exit volume. */
+ integrator_state_copy_volume_stack_to_shadow(INTEGRATOR_STATE_PASS);
+
+ if (is_transmission) {
+# ifdef __VOLUME__
+ shadow_volume_stack_enter_exit(INTEGRATOR_STATE_PASS, sd);
+# endif
+ }
+
/* Write shadow ray and associated state to global memory. */
integrator_state_write_shadow_ray(INTEGRATOR_STATE_PASS, &ray);
@@ -176,21 +185,19 @@ ccl_device_forceinline void integrate_surface_direct_light(INTEGRATOR_STATE_ARGS
INTEGRATOR_STATE_WRITE(shadow_path, diffuse_glossy_ratio) = diffuse_glossy_ratio;
INTEGRATOR_STATE_WRITE(shadow_path, throughput) = throughput;
- integrator_state_copy_volume_stack_to_shadow(INTEGRATOR_STATE_PASS);
-
/* Branch off shadow kernel. */
INTEGRATOR_SHADOW_PATH_INIT(DEVICE_KERNEL_INTEGRATOR_INTERSECT_SHADOW);
}
#endif
/* Path tracing: bounce off or through surface with new direction. */
-ccl_device_forceinline bool integrate_surface_bsdf_bssrdf_bounce(INTEGRATOR_STATE_ARGS,
- ShaderData *sd,
- const RNGState *rng_state)
+ccl_device_forceinline int integrate_surface_bsdf_bssrdf_bounce(INTEGRATOR_STATE_ARGS,
+ ShaderData *sd,
+ const RNGState *rng_state)
{
/* Sample BSDF or BSSRDF. */
if (!(sd->flag & (SD_BSDF | SD_BSSRDF))) {
- return false;
+ return LABEL_NONE;
}
float bsdf_u, bsdf_v;
@@ -215,7 +222,7 @@ ccl_device_forceinline bool integrate_surface_bsdf_bssrdf_bounce(INTEGRATOR_STAT
kg, sd, sc, bsdf_u, bsdf_v, &bsdf_eval, &bsdf_omega_in, &bsdf_domega_in, &bsdf_pdf);
if (bsdf_pdf == 0.0f || bsdf_eval_is_zero(&bsdf_eval)) {
- return false;
+ return LABEL_NONE;
}
/* Setup ray. Note that clipping works through transparent bounces. */
@@ -248,7 +255,7 @@ ccl_device_forceinline bool integrate_surface_bsdf_bssrdf_bounce(INTEGRATOR_STAT
}
path_state_next(INTEGRATOR_STATE_PASS, label);
- return true;
+ return label;
}
#ifdef __VOLUME__
@@ -256,7 +263,7 @@ ccl_device_forceinline bool integrate_surface_volume_only_bounce(INTEGRATOR_STAT
ShaderData *sd)
{
if (!path_state_volume_next(INTEGRATOR_STATE_PASS)) {
- return false;
+ return LABEL_NONE;
}
/* Setup ray position, direction stays unchanged. */
@@ -269,7 +276,7 @@ ccl_device_forceinline bool integrate_surface_volume_only_bounce(INTEGRATOR_STAT
INTEGRATOR_STATE_WRITE(ray, dP) = differential_make_compact(sd->dP);
# endif
- return true;
+ return LABEL_TRANSMIT | LABEL_TRANSPARENT;
}
#endif
@@ -282,7 +289,7 @@ ccl_device bool integrate_surface(INTEGRATOR_STATE_ARGS,
ShaderData sd;
integrate_surface_shader_setup(INTEGRATOR_STATE_PASS, &sd);
- bool continue_path;
+ int continue_path_label = 0;
/* Skip most work for volume bounding surface. */
#ifdef __VOLUME__
@@ -365,20 +372,23 @@ ccl_device bool integrate_surface(INTEGRATOR_STATE_ARGS,
# endif /* __AO__ */
#endif
- continue_path = integrate_surface_bsdf_bssrdf_bounce(INTEGRATOR_STATE_PASS, &sd, &rng_state);
+ continue_path_label = integrate_surface_bsdf_bssrdf_bounce(
+ INTEGRATOR_STATE_PASS, &sd, &rng_state);
#ifdef __VOLUME__
}
else {
- continue_path = integrate_surface_volume_only_bounce(INTEGRATOR_STATE_PASS, &sd);
+ continue_path_label = integrate_surface_volume_only_bounce(INTEGRATOR_STATE_PASS, &sd);
}
#endif
- /* Enter/Exit volume. */
+ if (continue_path_label & LABEL_TRANSMIT) {
+ /* Enter/Exit volume. */
#ifdef __VOLUME__
- volume_stack_enter_exit(INTEGRATOR_STATE_PASS, &sd);
+ volume_stack_enter_exit(INTEGRATOR_STATE_PASS, &sd);
#endif
+ }
- return continue_path;
+ return continue_path_label != 0;
}
template<uint node_feature_mask = NODE_FEATURE_MASK_SURFACE & ~NODE_FEATURE_RAYTRACE,
diff --git a/intern/cycles/kernel/integrator/integrator_subsurface.h b/intern/cycles/kernel/integrator/integrator_subsurface.h
index fe7bb1f3000..9a9f19ea5ff 100644
--- a/intern/cycles/kernel/integrator/integrator_subsurface.h
+++ b/intern/cycles/kernel/integrator/integrator_subsurface.h
@@ -91,7 +91,7 @@ ccl_device void subsurface_color_bump_blur(const KernelGlobals *kg,
}
# endif
-ccl_device bool subsurface_bounce(INTEGRATOR_STATE_ARGS, ShaderData *sd, const ShaderClosure *sc)
+ccl_device int subsurface_bounce(INTEGRATOR_STATE_ARGS, ShaderData *sd, const ShaderClosure *sc)
{
/* We should never have two consecutive BSSRDF bounces, the second one should
* be converted to a diffuse BSDF to avoid this. */
diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h
index 87b17765fde..f8a470291d4 100644
--- a/intern/cycles/kernel/kernel_types.h
+++ b/intern/cycles/kernel/kernel_types.h
@@ -330,6 +330,7 @@ typedef enum ClosureLabel {
LABEL_TRANSPARENT = 32,
LABEL_VOLUME_SCATTER = 64,
LABEL_TRANSMIT_TRANSPARENT = 128,
+ LABEL_SUBSURFACE_SCATTER = 256,
} ClosureLabel;
/* Render Passes */
More information about the Bf-blender-cvs
mailing list