Fix T91893, T92455: wrong transmission pass with hair and multiscatter glass
We need to increase GPU memory usage a bit. Unfortunately we can't get away with writing either reflection or transmission passes because these BSDFs may scatter in either direction but still must be in a fixed reflection or transmission category to match up with the color passes.
This commit is contained in:
parent
ef0b8d6306
commit
b4d9b8b7f8
|
@ -33,62 +33,72 @@ CCL_NAMESPACE_BEGIN
|
||||||
* them separately. */
|
* them separately. */
|
||||||
|
|
||||||
ccl_device_inline void bsdf_eval_init(ccl_private BsdfEval *eval,
|
ccl_device_inline void bsdf_eval_init(ccl_private BsdfEval *eval,
|
||||||
const bool is_diffuse,
|
const ClosureType closure_type,
|
||||||
float3 value)
|
float3 value)
|
||||||
{
|
{
|
||||||
eval->diffuse = zero_float3();
|
eval->diffuse = zero_float3();
|
||||||
eval->glossy = zero_float3();
|
eval->glossy = zero_float3();
|
||||||
|
|
||||||
if (is_diffuse) {
|
if (CLOSURE_IS_BSDF_DIFFUSE(closure_type)) {
|
||||||
eval->diffuse = value;
|
eval->diffuse = value;
|
||||||
}
|
}
|
||||||
else {
|
else if (CLOSURE_IS_BSDF_GLOSSY(closure_type)) {
|
||||||
eval->glossy = value;
|
eval->glossy = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eval->sum = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
ccl_device_inline void bsdf_eval_accum(ccl_private BsdfEval *eval,
|
ccl_device_inline void bsdf_eval_accum(ccl_private BsdfEval *eval,
|
||||||
const bool is_diffuse,
|
const ClosureType closure_type,
|
||||||
float3 value,
|
float3 value)
|
||||||
float mis_weight)
|
|
||||||
{
|
{
|
||||||
value *= mis_weight;
|
if (CLOSURE_IS_BSDF_DIFFUSE(closure_type)) {
|
||||||
|
|
||||||
if (is_diffuse) {
|
|
||||||
eval->diffuse += value;
|
eval->diffuse += value;
|
||||||
}
|
}
|
||||||
else {
|
else if (CLOSURE_IS_BSDF_GLOSSY(closure_type)) {
|
||||||
eval->glossy += value;
|
eval->glossy += value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eval->sum += value;
|
||||||
}
|
}
|
||||||
|
|
||||||
ccl_device_inline bool bsdf_eval_is_zero(ccl_private BsdfEval *eval)
|
ccl_device_inline bool bsdf_eval_is_zero(ccl_private BsdfEval *eval)
|
||||||
{
|
{
|
||||||
return is_zero(eval->diffuse) && is_zero(eval->glossy);
|
return is_zero(eval->sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
ccl_device_inline void bsdf_eval_mul(ccl_private BsdfEval *eval, float value)
|
ccl_device_inline void bsdf_eval_mul(ccl_private BsdfEval *eval, float value)
|
||||||
{
|
{
|
||||||
eval->diffuse *= value;
|
eval->diffuse *= value;
|
||||||
eval->glossy *= value;
|
eval->glossy *= value;
|
||||||
|
eval->sum *= value;
|
||||||
}
|
}
|
||||||
|
|
||||||
ccl_device_inline void bsdf_eval_mul3(ccl_private BsdfEval *eval, float3 value)
|
ccl_device_inline void bsdf_eval_mul3(ccl_private BsdfEval *eval, float3 value)
|
||||||
{
|
{
|
||||||
eval->diffuse *= value;
|
eval->diffuse *= value;
|
||||||
eval->glossy *= value;
|
eval->glossy *= value;
|
||||||
|
eval->sum *= value;
|
||||||
}
|
}
|
||||||
|
|
||||||
ccl_device_inline float3 bsdf_eval_sum(ccl_private const BsdfEval *eval)
|
ccl_device_inline float3 bsdf_eval_sum(ccl_private const BsdfEval *eval)
|
||||||
{
|
{
|
||||||
return eval->diffuse + eval->glossy;
|
return eval->sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
ccl_device_inline float3 bsdf_eval_diffuse_glossy_ratio(ccl_private const BsdfEval *eval)
|
ccl_device_inline float3 bsdf_eval_pass_diffuse_weight(ccl_private const BsdfEval *eval)
|
||||||
{
|
{
|
||||||
/* Ratio of diffuse and glossy to recover proportions for writing to render pass.
|
/* Ratio of diffuse weight to recover proportions for writing to render pass.
|
||||||
* We assume reflection, transmission and volume scatter to be exclusive. */
|
* We assume reflection, transmission and volume scatter to be exclusive. */
|
||||||
return safe_divide_float3_float3(eval->diffuse, eval->diffuse + eval->glossy);
|
return safe_divide_float3_float3(eval->diffuse, eval->sum);
|
||||||
|
}
|
||||||
|
|
||||||
|
ccl_device_inline float3 bsdf_eval_pass_glossy_weight(ccl_private const BsdfEval *eval)
|
||||||
|
{
|
||||||
|
/* Ratio of glossy weight to recover proportions for writing to render pass.
|
||||||
|
* We assume reflection, transmission and volume scatter to be exclusive. */
|
||||||
|
return safe_divide_float3_float3(eval->glossy, eval->sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------
|
/* --------------------------------------------------------------------
|
||||||
|
@ -351,22 +361,31 @@ ccl_device_inline void kernel_accum_emission_or_background_pass(KernelGlobals kg
|
||||||
/* Directly visible, write to emission or background pass. */
|
/* Directly visible, write to emission or background pass. */
|
||||||
pass_offset = pass;
|
pass_offset = pass;
|
||||||
}
|
}
|
||||||
else if (path_flag & (PATH_RAY_REFLECT_PASS | PATH_RAY_TRANSMISSION_PASS)) {
|
else if (kernel_data.kernel_features & KERNEL_FEATURE_LIGHT_PASSES) {
|
||||||
|
if (path_flag & PATH_RAY_SURFACE_PASS) {
|
||||||
/* Indirectly visible through reflection. */
|
/* Indirectly visible through reflection. */
|
||||||
const int glossy_pass_offset = (path_flag & PATH_RAY_REFLECT_PASS) ?
|
const float3 diffuse_weight = INTEGRATOR_STATE(state, path, pass_diffuse_weight);
|
||||||
((INTEGRATOR_STATE(state, path, bounce) == 1) ?
|
const float3 glossy_weight = INTEGRATOR_STATE(state, path, pass_glossy_weight);
|
||||||
|
|
||||||
|
/* Glossy */
|
||||||
|
const int glossy_pass_offset = ((INTEGRATOR_STATE(state, path, bounce) == 1) ?
|
||||||
kernel_data.film.pass_glossy_direct :
|
kernel_data.film.pass_glossy_direct :
|
||||||
kernel_data.film.pass_glossy_indirect) :
|
kernel_data.film.pass_glossy_indirect);
|
||||||
((INTEGRATOR_STATE(state, path, bounce) == 1) ?
|
if (glossy_pass_offset != PASS_UNUSED) {
|
||||||
|
kernel_write_pass_float3(buffer + glossy_pass_offset, glossy_weight * contribution);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Transmission */
|
||||||
|
const int transmission_pass_offset = ((INTEGRATOR_STATE(state, path, bounce) == 1) ?
|
||||||
kernel_data.film.pass_transmission_direct :
|
kernel_data.film.pass_transmission_direct :
|
||||||
kernel_data.film.pass_transmission_indirect);
|
kernel_data.film.pass_transmission_indirect);
|
||||||
|
|
||||||
if (glossy_pass_offset != PASS_UNUSED) {
|
if (transmission_pass_offset != PASS_UNUSED) {
|
||||||
/* Glossy is a subset of the throughput, reconstruct it here using the
|
/* Transmission is what remains if not diffuse and glossy, not stored explicitly to save
|
||||||
* diffuse-glossy ratio. */
|
* GPU memory. */
|
||||||
const float3 ratio = INTEGRATOR_STATE(state, path, diffuse_glossy_ratio);
|
const float3 transmission_weight = one_float3() - diffuse_weight - glossy_weight;
|
||||||
const float3 glossy_contribution = (one_float3() - ratio) * contribution;
|
kernel_write_pass_float3(buffer + transmission_pass_offset,
|
||||||
kernel_write_pass_float3(buffer + glossy_pass_offset, glossy_contribution);
|
transmission_weight * contribution);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reconstruct diffuse subset of throughput. */
|
/* Reconstruct diffuse subset of throughput. */
|
||||||
|
@ -374,7 +393,7 @@ ccl_device_inline void kernel_accum_emission_or_background_pass(KernelGlobals kg
|
||||||
kernel_data.film.pass_diffuse_direct :
|
kernel_data.film.pass_diffuse_direct :
|
||||||
kernel_data.film.pass_diffuse_indirect;
|
kernel_data.film.pass_diffuse_indirect;
|
||||||
if (pass_offset != PASS_UNUSED) {
|
if (pass_offset != PASS_UNUSED) {
|
||||||
contribution *= INTEGRATOR_STATE(state, path, diffuse_glossy_ratio);
|
contribution *= diffuse_weight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (path_flag & PATH_RAY_VOLUME_PASS) {
|
else if (path_flag & PATH_RAY_VOLUME_PASS) {
|
||||||
|
@ -383,6 +402,7 @@ ccl_device_inline void kernel_accum_emission_or_background_pass(KernelGlobals kg
|
||||||
kernel_data.film.pass_volume_direct :
|
kernel_data.film.pass_volume_direct :
|
||||||
kernel_data.film.pass_volume_indirect;
|
kernel_data.film.pass_volume_indirect;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Single write call for GPU coherence. */
|
/* Single write call for GPU coherence. */
|
||||||
if (pass_offset != PASS_UNUSED) {
|
if (pass_offset != PASS_UNUSED) {
|
||||||
|
@ -426,24 +446,34 @@ ccl_device_inline void kernel_accum_light(KernelGlobals kg,
|
||||||
#ifdef __PASSES__
|
#ifdef __PASSES__
|
||||||
if (kernel_data.film.light_pass_flag & PASS_ANY) {
|
if (kernel_data.film.light_pass_flag & PASS_ANY) {
|
||||||
const uint32_t path_flag = INTEGRATOR_STATE(state, shadow_path, flag);
|
const uint32_t path_flag = INTEGRATOR_STATE(state, shadow_path, flag);
|
||||||
|
|
||||||
|
if (kernel_data.kernel_features & KERNEL_FEATURE_LIGHT_PASSES) {
|
||||||
int pass_offset = PASS_UNUSED;
|
int pass_offset = PASS_UNUSED;
|
||||||
|
|
||||||
if (path_flag & (PATH_RAY_REFLECT_PASS | PATH_RAY_TRANSMISSION_PASS)) {
|
if (path_flag & PATH_RAY_SURFACE_PASS) {
|
||||||
/* Indirectly visible through reflection. */
|
/* Indirectly visible through reflection. */
|
||||||
const int glossy_pass_offset = (path_flag & PATH_RAY_REFLECT_PASS) ?
|
const float3 diffuse_weight = INTEGRATOR_STATE(state, shadow_path, pass_diffuse_weight);
|
||||||
((INTEGRATOR_STATE(state, shadow_path, bounce) == 0) ?
|
const float3 glossy_weight = INTEGRATOR_STATE(state, shadow_path, pass_glossy_weight);
|
||||||
|
|
||||||
|
/* Glossy */
|
||||||
|
const int glossy_pass_offset = ((INTEGRATOR_STATE(state, shadow_path, bounce) == 0) ?
|
||||||
kernel_data.film.pass_glossy_direct :
|
kernel_data.film.pass_glossy_direct :
|
||||||
kernel_data.film.pass_glossy_indirect) :
|
kernel_data.film.pass_glossy_indirect);
|
||||||
((INTEGRATOR_STATE(state, shadow_path, bounce) == 0) ?
|
if (glossy_pass_offset != PASS_UNUSED) {
|
||||||
|
kernel_write_pass_float3(buffer + glossy_pass_offset, glossy_weight * contribution);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Transmission */
|
||||||
|
const int transmission_pass_offset = ((INTEGRATOR_STATE(state, shadow_path, bounce) == 0) ?
|
||||||
kernel_data.film.pass_transmission_direct :
|
kernel_data.film.pass_transmission_direct :
|
||||||
kernel_data.film.pass_transmission_indirect);
|
kernel_data.film.pass_transmission_indirect);
|
||||||
|
|
||||||
if (glossy_pass_offset != PASS_UNUSED) {
|
if (transmission_pass_offset != PASS_UNUSED) {
|
||||||
/* Glossy is a subset of the throughput, reconstruct it here using the
|
/* Transmission is what remains if not diffuse and glossy, not stored explicitly to save
|
||||||
* diffuse-glossy ratio. */
|
* GPU memory. */
|
||||||
const float3 ratio = INTEGRATOR_STATE(state, shadow_path, diffuse_glossy_ratio);
|
const float3 transmission_weight = one_float3() - diffuse_weight - glossy_weight;
|
||||||
const float3 glossy_contribution = (one_float3() - ratio) * contribution;
|
kernel_write_pass_float3(buffer + transmission_pass_offset,
|
||||||
kernel_write_pass_float3(buffer + glossy_pass_offset, glossy_contribution);
|
transmission_weight * contribution);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reconstruct diffuse subset of throughput. */
|
/* Reconstruct diffuse subset of throughput. */
|
||||||
|
@ -451,7 +481,7 @@ ccl_device_inline void kernel_accum_light(KernelGlobals kg,
|
||||||
kernel_data.film.pass_diffuse_direct :
|
kernel_data.film.pass_diffuse_direct :
|
||||||
kernel_data.film.pass_diffuse_indirect;
|
kernel_data.film.pass_diffuse_indirect;
|
||||||
if (pass_offset != PASS_UNUSED) {
|
if (pass_offset != PASS_UNUSED) {
|
||||||
contribution *= INTEGRATOR_STATE(state, shadow_path, diffuse_glossy_ratio);
|
contribution *= diffuse_weight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (path_flag & PATH_RAY_VOLUME_PASS) {
|
else if (path_flag & PATH_RAY_VOLUME_PASS) {
|
||||||
|
@ -465,6 +495,7 @@ ccl_device_inline void kernel_accum_light(KernelGlobals kg,
|
||||||
if (pass_offset != PASS_UNUSED) {
|
if (pass_offset != PASS_UNUSED) {
|
||||||
kernel_write_pass_float3(buffer + pass_offset, contribution);
|
kernel_write_pass_float3(buffer + pass_offset, contribution);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Write shadow pass. */
|
/* Write shadow pass. */
|
||||||
if (kernel_data.film.pass_shadow != PASS_UNUSED && (path_flag & PATH_RAY_SHADOW_FOR_LIGHT) &&
|
if (kernel_data.film.pass_shadow != PASS_UNUSED && (path_flag & PATH_RAY_SHADOW_FOR_LIGHT) &&
|
||||||
|
|
|
@ -185,7 +185,7 @@ ccl_device_inline void path_state_next(KernelGlobals kg, IntegratorState state,
|
||||||
|
|
||||||
/* Render pass categories. */
|
/* Render pass categories. */
|
||||||
if (bounce == 1) {
|
if (bounce == 1) {
|
||||||
flag |= (label & LABEL_TRANSMIT) ? PATH_RAY_TRANSMISSION_PASS : PATH_RAY_REFLECT_PASS;
|
flag |= PATH_RAY_SURFACE_PASS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -191,14 +191,18 @@ ccl_device_forceinline void integrate_surface_direct_light(KernelGlobals kg,
|
||||||
const uint16_t transparent_bounce = INTEGRATOR_STATE(state, path, transparent_bounce);
|
const uint16_t transparent_bounce = INTEGRATOR_STATE(state, path, transparent_bounce);
|
||||||
uint32_t shadow_flag = INTEGRATOR_STATE(state, path, flag);
|
uint32_t shadow_flag = INTEGRATOR_STATE(state, path, flag);
|
||||||
shadow_flag |= (is_light) ? PATH_RAY_SHADOW_FOR_LIGHT : 0;
|
shadow_flag |= (is_light) ? PATH_RAY_SHADOW_FOR_LIGHT : 0;
|
||||||
shadow_flag |= (is_transmission) ? PATH_RAY_TRANSMISSION_PASS : PATH_RAY_REFLECT_PASS;
|
shadow_flag |= PATH_RAY_SURFACE_PASS;
|
||||||
const float3 throughput = INTEGRATOR_STATE(state, path, throughput) * bsdf_eval_sum(&bsdf_eval);
|
const float3 throughput = INTEGRATOR_STATE(state, path, throughput) * bsdf_eval_sum(&bsdf_eval);
|
||||||
|
|
||||||
if (kernel_data.kernel_features & KERNEL_FEATURE_LIGHT_PASSES) {
|
if (kernel_data.kernel_features & KERNEL_FEATURE_LIGHT_PASSES) {
|
||||||
const float3 diffuse_glossy_ratio = (bounce == 0) ?
|
const float3 pass_diffuse_weight = (bounce == 0) ?
|
||||||
bsdf_eval_diffuse_glossy_ratio(&bsdf_eval) :
|
bsdf_eval_pass_diffuse_weight(&bsdf_eval) :
|
||||||
INTEGRATOR_STATE(state, path, diffuse_glossy_ratio);
|
INTEGRATOR_STATE(state, path, pass_diffuse_weight);
|
||||||
INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, diffuse_glossy_ratio) = diffuse_glossy_ratio;
|
const float3 pass_glossy_weight = (bounce == 0) ?
|
||||||
|
bsdf_eval_pass_glossy_weight(&bsdf_eval) :
|
||||||
|
INTEGRATOR_STATE(state, path, pass_glossy_weight);
|
||||||
|
INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, pass_diffuse_weight) = pass_diffuse_weight;
|
||||||
|
INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, pass_glossy_weight) = pass_glossy_weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, render_pixel_index) = INTEGRATOR_STATE(
|
INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, render_pixel_index) = INTEGRATOR_STATE(
|
||||||
|
@ -283,7 +287,9 @@ ccl_device_forceinline int integrate_surface_bsdf_bssrdf_bounce(
|
||||||
|
|
||||||
if (kernel_data.kernel_features & KERNEL_FEATURE_LIGHT_PASSES) {
|
if (kernel_data.kernel_features & KERNEL_FEATURE_LIGHT_PASSES) {
|
||||||
if (INTEGRATOR_STATE(state, path, bounce) == 0) {
|
if (INTEGRATOR_STATE(state, path, bounce) == 0) {
|
||||||
INTEGRATOR_STATE_WRITE(state, path, diffuse_glossy_ratio) = bsdf_eval_diffuse_glossy_ratio(
|
INTEGRATOR_STATE_WRITE(state, path, pass_diffuse_weight) = bsdf_eval_pass_diffuse_weight(
|
||||||
|
&bsdf_eval);
|
||||||
|
INTEGRATOR_STATE_WRITE(state, path, pass_glossy_weight) = bsdf_eval_pass_glossy_weight(
|
||||||
&bsdf_eval);
|
&bsdf_eval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -794,10 +794,11 @@ ccl_device_forceinline void integrate_volume_direct_light(
|
||||||
const float3 throughput_phase = throughput * bsdf_eval_sum(&phase_eval);
|
const float3 throughput_phase = throughput * bsdf_eval_sum(&phase_eval);
|
||||||
|
|
||||||
if (kernel_data.kernel_features & KERNEL_FEATURE_LIGHT_PASSES) {
|
if (kernel_data.kernel_features & KERNEL_FEATURE_LIGHT_PASSES) {
|
||||||
const float3 diffuse_glossy_ratio = (bounce == 0) ?
|
const float3 pass_diffuse_weight = (bounce == 0) ?
|
||||||
one_float3() :
|
one_float3() :
|
||||||
INTEGRATOR_STATE(state, path, diffuse_glossy_ratio);
|
INTEGRATOR_STATE(state, path, pass_diffuse_weight);
|
||||||
INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, diffuse_glossy_ratio) = diffuse_glossy_ratio;
|
INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, pass_diffuse_weight) = pass_diffuse_weight;
|
||||||
|
INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, pass_glossy_weight) = zero_float3();
|
||||||
}
|
}
|
||||||
|
|
||||||
INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, render_pixel_index) = INTEGRATOR_STATE(
|
INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, render_pixel_index) = INTEGRATOR_STATE(
|
||||||
|
@ -876,7 +877,8 @@ ccl_device_forceinline bool integrate_volume_phase_scatter(
|
||||||
INTEGRATOR_STATE_WRITE(state, path, throughput) = throughput_phase;
|
INTEGRATOR_STATE_WRITE(state, path, throughput) = throughput_phase;
|
||||||
|
|
||||||
if (kernel_data.kernel_features & KERNEL_FEATURE_LIGHT_PASSES) {
|
if (kernel_data.kernel_features & KERNEL_FEATURE_LIGHT_PASSES) {
|
||||||
INTEGRATOR_STATE_WRITE(state, path, diffuse_glossy_ratio) = one_float3();
|
INTEGRATOR_STATE_WRITE(state, path, pass_diffuse_weight) = one_float3();
|
||||||
|
INTEGRATOR_STATE_WRITE(state, path, pass_glossy_weight) = zero_float3();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update path state */
|
/* Update path state */
|
||||||
|
|
|
@ -246,8 +246,7 @@ ccl_device_inline float _shader_bsdf_multi_eval(KernelGlobals kg,
|
||||||
float3 eval = bsdf_eval(kg, sd, sc, omega_in, is_transmission, &bsdf_pdf);
|
float3 eval = bsdf_eval(kg, sd, sc, omega_in, is_transmission, &bsdf_pdf);
|
||||||
|
|
||||||
if (bsdf_pdf != 0.0f) {
|
if (bsdf_pdf != 0.0f) {
|
||||||
const bool is_diffuse = CLOSURE_IS_BSDF_DIFFUSE(sc->type);
|
bsdf_eval_accum(result_eval, sc->type, eval * sc->weight);
|
||||||
bsdf_eval_accum(result_eval, is_diffuse, eval * sc->weight, 1.0f);
|
|
||||||
sum_pdf += bsdf_pdf * sc->sample_weight;
|
sum_pdf += bsdf_pdf * sc->sample_weight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,7 +271,7 @@ ccl_device_inline
|
||||||
ccl_private BsdfEval *bsdf_eval,
|
ccl_private BsdfEval *bsdf_eval,
|
||||||
const uint light_shader_flags)
|
const uint light_shader_flags)
|
||||||
{
|
{
|
||||||
bsdf_eval_init(bsdf_eval, false, zero_float3());
|
bsdf_eval_init(bsdf_eval, CLOSURE_NONE_ID, zero_float3());
|
||||||
|
|
||||||
return _shader_bsdf_multi_eval(
|
return _shader_bsdf_multi_eval(
|
||||||
kg, sd, omega_in, is_transmission, NULL, bsdf_eval, 0.0f, 0.0f, light_shader_flags);
|
kg, sd, omega_in, is_transmission, NULL, bsdf_eval, 0.0f, 0.0f, light_shader_flags);
|
||||||
|
@ -365,8 +364,7 @@ ccl_device int shader_bsdf_sample_closure(KernelGlobals kg,
|
||||||
label = bsdf_sample(kg, sd, sc, randu, randv, &eval, omega_in, domega_in, pdf);
|
label = bsdf_sample(kg, sd, sc, randu, randv, &eval, omega_in, domega_in, pdf);
|
||||||
|
|
||||||
if (*pdf != 0.0f) {
|
if (*pdf != 0.0f) {
|
||||||
const bool is_diffuse = CLOSURE_IS_BSDF_DIFFUSE(sc->type);
|
bsdf_eval_init(bsdf_eval, sc->type, eval * sc->weight);
|
||||||
bsdf_eval_init(bsdf_eval, is_diffuse, eval * sc->weight);
|
|
||||||
|
|
||||||
if (sd->num_closure > 1) {
|
if (sd->num_closure > 1) {
|
||||||
const bool is_transmission = shader_bsdf_is_transmission(sd, *omega_in);
|
const bool is_transmission = shader_bsdf_is_transmission(sd, *omega_in);
|
||||||
|
@ -692,7 +690,7 @@ ccl_device_inline float _shader_volume_phase_multi_eval(
|
||||||
float3 eval = volume_phase_eval(sd, svc, omega_in, &phase_pdf);
|
float3 eval = volume_phase_eval(sd, svc, omega_in, &phase_pdf);
|
||||||
|
|
||||||
if (phase_pdf != 0.0f) {
|
if (phase_pdf != 0.0f) {
|
||||||
bsdf_eval_accum(result_eval, false, eval, 1.0f);
|
bsdf_eval_accum(result_eval, CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID, eval);
|
||||||
sum_pdf += phase_pdf * svc->sample_weight;
|
sum_pdf += phase_pdf * svc->sample_weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -708,7 +706,7 @@ ccl_device float shader_volume_phase_eval(KernelGlobals kg,
|
||||||
const float3 omega_in,
|
const float3 omega_in,
|
||||||
ccl_private BsdfEval *phase_eval)
|
ccl_private BsdfEval *phase_eval)
|
||||||
{
|
{
|
||||||
bsdf_eval_init(phase_eval, false, zero_float3());
|
bsdf_eval_init(phase_eval, CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID, zero_float3());
|
||||||
|
|
||||||
return _shader_volume_phase_multi_eval(sd, phases, omega_in, -1, phase_eval, 0.0f, 0.0f);
|
return _shader_volume_phase_multi_eval(sd, phases, omega_in, -1, phase_eval, 0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
|
@ -766,7 +764,7 @@ ccl_device int shader_volume_phase_sample(KernelGlobals kg,
|
||||||
label = volume_phase_sample(sd, svc, randu, randv, &eval, omega_in, domega_in, pdf);
|
label = volume_phase_sample(sd, svc, randu, randv, &eval, omega_in, domega_in, pdf);
|
||||||
|
|
||||||
if (*pdf != 0.0f) {
|
if (*pdf != 0.0f) {
|
||||||
bsdf_eval_init(phase_eval, false, eval);
|
bsdf_eval_init(phase_eval, CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID, eval);
|
||||||
}
|
}
|
||||||
|
|
||||||
return label;
|
return label;
|
||||||
|
@ -789,7 +787,7 @@ ccl_device int shader_phase_sample_closure(KernelGlobals kg,
|
||||||
label = volume_phase_sample(sd, sc, randu, randv, &eval, omega_in, domega_in, pdf);
|
label = volume_phase_sample(sd, sc, randu, randv, &eval, omega_in, domega_in, pdf);
|
||||||
|
|
||||||
if (*pdf != 0.0f)
|
if (*pdf != 0.0f)
|
||||||
bsdf_eval_init(phase_eval, false, eval);
|
bsdf_eval_init(phase_eval, CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID, eval);
|
||||||
|
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,9 @@ KERNEL_STRUCT_MEMBER(shadow_path,
|
||||||
float3,
|
float3,
|
||||||
unshadowed_throughput,
|
unshadowed_throughput,
|
||||||
KERNEL_FEATURE_SHADOW_PASS | KERNEL_FEATURE_AO_ADDITIVE)
|
KERNEL_FEATURE_SHADOW_PASS | KERNEL_FEATURE_AO_ADDITIVE)
|
||||||
/* Ratio of throughput to distinguish diffuse and glossy render passes. */
|
/* Ratio of throughput to distinguish diffuse / glossy / transmission render passes. */
|
||||||
KERNEL_STRUCT_MEMBER(shadow_path, float3, diffuse_glossy_ratio, KERNEL_FEATURE_LIGHT_PASSES)
|
KERNEL_STRUCT_MEMBER(shadow_path, float3, pass_diffuse_weight, KERNEL_FEATURE_LIGHT_PASSES)
|
||||||
|
KERNEL_STRUCT_MEMBER(shadow_path, float3, pass_glossy_weight, KERNEL_FEATURE_LIGHT_PASSES)
|
||||||
/* Number of intersections found by ray-tracing. */
|
/* Number of intersections found by ray-tracing. */
|
||||||
KERNEL_STRUCT_MEMBER(shadow_path, uint16_t, num_hits, KERNEL_FEATURE_PATH_TRACING)
|
KERNEL_STRUCT_MEMBER(shadow_path, uint16_t, num_hits, KERNEL_FEATURE_PATH_TRACING)
|
||||||
KERNEL_STRUCT_END(shadow_path)
|
KERNEL_STRUCT_END(shadow_path)
|
||||||
|
|
|
@ -60,8 +60,9 @@ KERNEL_STRUCT_MEMBER(path, float, min_ray_pdf, KERNEL_FEATURE_PATH_TRACING)
|
||||||
KERNEL_STRUCT_MEMBER(path, float, continuation_probability, KERNEL_FEATURE_PATH_TRACING)
|
KERNEL_STRUCT_MEMBER(path, float, continuation_probability, KERNEL_FEATURE_PATH_TRACING)
|
||||||
/* Throughput. */
|
/* Throughput. */
|
||||||
KERNEL_STRUCT_MEMBER(path, float3, throughput, KERNEL_FEATURE_PATH_TRACING)
|
KERNEL_STRUCT_MEMBER(path, float3, throughput, KERNEL_FEATURE_PATH_TRACING)
|
||||||
/* Ratio of throughput to distinguish diffuse and glossy render passes. */
|
/* Ratio of throughput to distinguish diffuse / glossy / transmission render passes. */
|
||||||
KERNEL_STRUCT_MEMBER(path, float3, diffuse_glossy_ratio, KERNEL_FEATURE_LIGHT_PASSES)
|
KERNEL_STRUCT_MEMBER(path, float3, pass_diffuse_weight, KERNEL_FEATURE_LIGHT_PASSES)
|
||||||
|
KERNEL_STRUCT_MEMBER(path, float3, pass_glossy_weight, KERNEL_FEATURE_LIGHT_PASSES)
|
||||||
/* Denoising. */
|
/* Denoising. */
|
||||||
KERNEL_STRUCT_MEMBER(path, float3, denoising_feature_throughput, KERNEL_FEATURE_DENOISING)
|
KERNEL_STRUCT_MEMBER(path, float3, denoising_feature_throughput, KERNEL_FEATURE_DENOISING)
|
||||||
/* Shader sorting. */
|
/* Shader sorting. */
|
||||||
|
|
|
@ -79,7 +79,8 @@ ccl_device int subsurface_bounce(KernelGlobals kg,
|
||||||
|
|
||||||
if (kernel_data.kernel_features & KERNEL_FEATURE_LIGHT_PASSES) {
|
if (kernel_data.kernel_features & KERNEL_FEATURE_LIGHT_PASSES) {
|
||||||
if (INTEGRATOR_STATE(state, path, bounce) == 0) {
|
if (INTEGRATOR_STATE(state, path, bounce) == 0) {
|
||||||
INTEGRATOR_STATE_WRITE(state, path, diffuse_glossy_ratio) = one_float3();
|
INTEGRATOR_STATE_WRITE(state, path, pass_diffuse_weight) = one_float3();
|
||||||
|
INTEGRATOR_STATE_WRITE(state, path, pass_glossy_weight) = zero_float3();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -286,27 +286,26 @@ enum PathRayFlag {
|
||||||
PATH_RAY_DENOISING_FEATURES = (1U << 23U),
|
PATH_RAY_DENOISING_FEATURES = (1U << 23U),
|
||||||
|
|
||||||
/* Render pass categories. */
|
/* Render pass categories. */
|
||||||
PATH_RAY_REFLECT_PASS = (1U << 24U),
|
PATH_RAY_SURFACE_PASS = (1U << 24U),
|
||||||
PATH_RAY_TRANSMISSION_PASS = (1U << 25U),
|
PATH_RAY_VOLUME_PASS = (1U << 25U),
|
||||||
PATH_RAY_VOLUME_PASS = (1U << 26U),
|
PATH_RAY_ANY_PASS = (PATH_RAY_SURFACE_PASS | PATH_RAY_VOLUME_PASS),
|
||||||
PATH_RAY_ANY_PASS = (PATH_RAY_REFLECT_PASS | PATH_RAY_TRANSMISSION_PASS | PATH_RAY_VOLUME_PASS),
|
|
||||||
|
|
||||||
/* Shadow ray is for a light or surface, or AO. */
|
/* Shadow ray is for a light or surface, or AO. */
|
||||||
PATH_RAY_SHADOW_FOR_LIGHT = (1U << 27U),
|
PATH_RAY_SHADOW_FOR_LIGHT = (1U << 26U),
|
||||||
PATH_RAY_SHADOW_FOR_AO = (1U << 28U),
|
PATH_RAY_SHADOW_FOR_AO = (1U << 27U),
|
||||||
|
|
||||||
/* A shadow catcher object was hit and the path was split into two. */
|
/* A shadow catcher object was hit and the path was split into two. */
|
||||||
PATH_RAY_SHADOW_CATCHER_HIT = (1U << 29U),
|
PATH_RAY_SHADOW_CATCHER_HIT = (1U << 28U),
|
||||||
|
|
||||||
/* A shadow catcher object was hit and this path traces only shadow catchers, writing them into
|
/* A shadow catcher object was hit and this path traces only shadow catchers, writing them into
|
||||||
* their dedicated pass for later division.
|
* their dedicated pass for later division.
|
||||||
*
|
*
|
||||||
* NOTE: Is not covered with `PATH_RAY_ANY_PASS` because shadow catcher does special handling
|
* NOTE: Is not covered with `PATH_RAY_ANY_PASS` because shadow catcher does special handling
|
||||||
* which is separate from the light passes. */
|
* which is separate from the light passes. */
|
||||||
PATH_RAY_SHADOW_CATCHER_PASS = (1U << 30U),
|
PATH_RAY_SHADOW_CATCHER_PASS = (1U << 29U),
|
||||||
|
|
||||||
/* Path is evaluating background for an approximate shadow catcher with non-transparent film. */
|
/* Path is evaluating background for an approximate shadow catcher with non-transparent film. */
|
||||||
PATH_RAY_SHADOW_CATCHER_BACKGROUND = (1U << 31U),
|
PATH_RAY_SHADOW_CATCHER_BACKGROUND = (1U << 30U),
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Configure ray visibility bits for rays and objects respectively,
|
/* Configure ray visibility bits for rays and objects respectively,
|
||||||
|
@ -428,6 +427,7 @@ typedef enum CryptomatteType {
|
||||||
typedef struct BsdfEval {
|
typedef struct BsdfEval {
|
||||||
float3 diffuse;
|
float3 diffuse;
|
||||||
float3 glossy;
|
float3 glossy;
|
||||||
|
float3 sum;
|
||||||
} BsdfEval;
|
} BsdfEval;
|
||||||
|
|
||||||
/* Closure Filter */
|
/* Closure Filter */
|
||||||
|
|
|
@ -187,8 +187,6 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
|
||||||
kfilm->pass_transmission_indirect = PASS_UNUSED;
|
kfilm->pass_transmission_indirect = PASS_UNUSED;
|
||||||
kfilm->pass_volume_direct = PASS_UNUSED;
|
kfilm->pass_volume_direct = PASS_UNUSED;
|
||||||
kfilm->pass_volume_indirect = PASS_UNUSED;
|
kfilm->pass_volume_indirect = PASS_UNUSED;
|
||||||
kfilm->pass_volume_direct = PASS_UNUSED;
|
|
||||||
kfilm->pass_volume_indirect = PASS_UNUSED;
|
|
||||||
kfilm->pass_shadow = PASS_UNUSED;
|
kfilm->pass_shadow = PASS_UNUSED;
|
||||||
|
|
||||||
/* Mark passes as unused so that the kernel knows the pass is inaccessible. */
|
/* Mark passes as unused so that the kernel knows the pass is inaccessible. */
|
||||||
|
@ -673,14 +671,13 @@ uint Film::get_kernel_features(const Scene *scene) const
|
||||||
kernel_features |= KERNEL_FEATURE_DENOISING;
|
kernel_features |= KERNEL_FEATURE_DENOISING;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pass_type != PASS_NONE && pass_type != PASS_COMBINED &&
|
if (pass_type >= PASS_DIFFUSE && pass_type <= PASS_VOLUME_INDIRECT) {
|
||||||
pass_type <= PASS_CATEGORY_LIGHT_END) {
|
|
||||||
kernel_features |= KERNEL_FEATURE_LIGHT_PASSES;
|
kernel_features |= KERNEL_FEATURE_LIGHT_PASSES;
|
||||||
|
}
|
||||||
|
|
||||||
if (pass_type == PASS_SHADOW) {
|
if (pass_type == PASS_SHADOW) {
|
||||||
kernel_features |= KERNEL_FEATURE_SHADOW_PASS;
|
kernel_features |= KERNEL_FEATURE_SHADOW_PASS;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (pass_type == PASS_AO) {
|
if (pass_type == PASS_AO) {
|
||||||
kernel_features |= KERNEL_FEATURE_AO_PASS;
|
kernel_features |= KERNEL_FEATURE_AO_PASS;
|
||||||
|
|
|
@ -274,19 +274,26 @@ void OSLShaderManager::shading_system_init()
|
||||||
|
|
||||||
"diffuse_ancestor", /* PATH_RAY_DIFFUSE_ANCESTOR */
|
"diffuse_ancestor", /* PATH_RAY_DIFFUSE_ANCESTOR */
|
||||||
|
|
||||||
"__unused__", /* PATH_RAY_SINGLE_PASS_DONE */
|
/* Remaining irrelevant bits up to 32. */
|
||||||
"__unused__", /* PATH_RAY_TRANSPARENT_BACKGROUND */
|
"__unused__",
|
||||||
"__unused__", /* PATH_RAY_TERMINATE_IMMEDIATE */
|
"__unused__",
|
||||||
"__unused__", /* PATH_RAY_TERMINATE_AFTER_TRANSPARENT */
|
"__unused__",
|
||||||
"__unused__", /* PATH_RAY_EMISSION */
|
"__unused__",
|
||||||
"__unused__", /* PATH_RAY_SUBSURFACE */
|
"__unused__",
|
||||||
"__unused__", /* PATH_RAY_DENOISING_FEATURES */
|
"__unused__",
|
||||||
"__unused__", /* PATH_RAY_REFLECT_PASS */
|
"__unused__",
|
||||||
"__unused__", /* PATH_RAY_TRANSMISSION_PASS */
|
"__unused__",
|
||||||
"__unused__", /* PATH_RAY_VOLUME_PASS */
|
"__unused__",
|
||||||
"__unused__", /* PATH_RAY_SHADOW_FOR_LIGHT */
|
"__unused__",
|
||||||
"__unused__", /* PATH_RAY_SHADOW_CATCHER_HIT */
|
"__unused__",
|
||||||
"__unused__", /* PATH_RAY_SHADOW_CATCHER_PASS */
|
"__unused__",
|
||||||
|
"__unused__",
|
||||||
|
"__unused__",
|
||||||
|
"__unused__",
|
||||||
|
"__unused__",
|
||||||
|
"__unused__",
|
||||||
|
"__unused__",
|
||||||
|
"__unused__",
|
||||||
};
|
};
|
||||||
|
|
||||||
const int nraytypes = sizeof(raytypes) / sizeof(raytypes[0]);
|
const int nraytypes = sizeof(raytypes) / sizeof(raytypes[0]);
|
||||||
|
|
Loading…
Reference in New Issue