Fix T93246: Cycles wrong volume shading after transparent surface
The Russian roulette probability was not taken into account for volumes in all cases. It should not be left out from the SD_HAS_ONLY_VOLUME case.
This commit is contained in:
parent
b891c72d2d
commit
75a051a6ab
@ -387,6 +387,21 @@ ccl_device_forceinline int integrate_surface_volume_only_bounce(IntegratorState
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
ccl_device_forceinline bool integrate_surface_terminate(IntegratorState state, const uint32_t path_flag)
|
||||||
|
{
|
||||||
|
const float probability = (path_flag & PATH_RAY_TERMINATE_ON_NEXT_SURFACE) ?
|
||||||
|
0.0f :
|
||||||
|
INTEGRATOR_STATE(state, path, continuation_probability);
|
||||||
|
if (probability == 0.0f) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (probability != 1.0f) {
|
||||||
|
INTEGRATOR_STATE_WRITE(state, path, throughput) /= probability;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(__AO__)
|
#if defined(__AO__)
|
||||||
ccl_device_forceinline void integrate_surface_ao(KernelGlobals kg,
|
ccl_device_forceinline void integrate_surface_ao(KernelGlobals kg,
|
||||||
IntegratorState state,
|
IntegratorState state,
|
||||||
@ -478,12 +493,12 @@ ccl_device bool integrate_surface(KernelGlobals kg,
|
|||||||
|
|
||||||
int continue_path_label = 0;
|
int continue_path_label = 0;
|
||||||
|
|
||||||
|
const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag);
|
||||||
|
|
||||||
/* Skip most work for volume bounding surface. */
|
/* Skip most work for volume bounding surface. */
|
||||||
#ifdef __VOLUME__
|
#ifdef __VOLUME__
|
||||||
if (!(sd.flag & SD_HAS_ONLY_VOLUME)) {
|
if (!(sd.flag & SD_HAS_ONLY_VOLUME)) {
|
||||||
#endif
|
#endif
|
||||||
const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag);
|
|
||||||
|
|
||||||
#ifdef __SUBSURFACE__
|
#ifdef __SUBSURFACE__
|
||||||
/* Can skip shader evaluation for BSSRDF exit point without bump mapping. */
|
/* Can skip shader evaluation for BSSRDF exit point without bump mapping. */
|
||||||
if (!(path_flag & PATH_RAY_SUBSURFACE) || ((sd.flag & SD_HAS_BSSRDF_BUMP)))
|
if (!(path_flag & PATH_RAY_SUBSURFACE) || ((sd.flag & SD_HAS_BSSRDF_BUMP)))
|
||||||
@ -542,16 +557,8 @@ ccl_device bool integrate_surface(KernelGlobals kg,
|
|||||||
* throughput by the probability at the right moment.
|
* 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. */
|
* Also ensure we don't do it twice for SSS at both the entry and exit point. */
|
||||||
if (!(path_flag & PATH_RAY_SUBSURFACE)) {
|
if (!(path_flag & PATH_RAY_SUBSURFACE) && integrate_surface_terminate(state, path_flag)) {
|
||||||
const float probability = (path_flag & PATH_RAY_TERMINATE_ON_NEXT_SURFACE) ?
|
|
||||||
0.0f :
|
|
||||||
INTEGRATOR_STATE(state, path, continuation_probability);
|
|
||||||
if (probability == 0.0f) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
else if (probability != 1.0f) {
|
|
||||||
INTEGRATOR_STATE_WRITE(state, path, throughput) /= probability;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __DENOISING_FEATURES__
|
#ifdef __DENOISING_FEATURES__
|
||||||
@ -575,6 +582,10 @@ ccl_device bool integrate_surface(KernelGlobals kg,
|
|||||||
#ifdef __VOLUME__
|
#ifdef __VOLUME__
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (integrate_surface_terminate(state, path_flag)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
PROFILING_EVENT(PROFILING_SHADE_SURFACE_INDIRECT_LIGHT);
|
PROFILING_EVENT(PROFILING_SHADE_SURFACE_INDIRECT_LIGHT);
|
||||||
continue_path_label = integrate_surface_volume_only_bounce(state, &sd);
|
continue_path_label = integrate_surface_volume_only_bounce(state, &sd);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user