Fix T95308, T93913: Cycles mist pass wrong with SSS shader

It was wrongly writing passes twice, for both the surface entry and exit points.
We can skip code for filtering closures, emission and holdout also, as these do
nothing with only a subsurface diffuse closure present.
This commit is contained in:
Brecht Van Lommel
2022-05-05 21:52:36 +02:00
parent e4931ab86d
commit 1b566b70c1

View File

@@ -525,8 +525,10 @@ ccl_device bool integrate_surface(KernelGlobals kg,
subsurface_shader_data_setup(kg, state, &sd, path_flag);
INTEGRATOR_STATE_WRITE(state, path, flag) &= ~PATH_RAY_SUBSURFACE;
}
else
#endif
{
/* Filter closures. */
shader_prepare_surface_closures(kg, state, &sd, path_flag);
#ifdef __HOLDOUT__
@@ -543,28 +545,29 @@ ccl_device bool integrate_surface(KernelGlobals kg,
}
#endif
#ifdef __PASSES__
/* Write render passes. */
PROFILING_EVENT(PROFILING_SHADE_SURFACE_PASSES);
kernel_write_data_passes(kg, state, &sd, render_buffer);
#endif
/* Load random number state. */
RNGState rng_state;
path_state_rng_load(state, &rng_state);
/* Perform path termination. Most paths have already been terminated in
* the intersect_closest kernel, this is just for emission and for dividing
* throughput by the probability at the right moment.
*
* Also ensure we don't do it twice for SSS at both the entry and exit point. */
if (!(path_flag & PATH_RAY_SUBSURFACE) && integrate_surface_terminate(state, path_flag)) {
if (integrate_surface_terminate(state, path_flag)) {
return false;
}
/* Write render passes. */
#ifdef __PASSES__
PROFILING_EVENT(PROFILING_SHADE_SURFACE_PASSES);
kernel_write_data_passes(kg, state, &sd, render_buffer);
#endif
#ifdef __DENOISING_FEATURES__
kernel_write_denoising_features_surface(kg, state, &sd, render_buffer);
#endif
}
/* Load random number state. */
RNGState rng_state;
path_state_rng_load(state, &rng_state);
/* Direct light. */
PROFILING_EVENT(PROFILING_SHADE_SURFACE_DIRECT_LIGHT);