Code cleanup: make L_transparent part of PathRadiance.
This commit is contained in:
parent
7542282c06
commit
dc7fcebb33
Notes:
blender-bot
2023-02-14 06:41:44 +01:00
Referenced by issue #52389, No square samples in Cycles
|
@ -208,6 +208,7 @@ ccl_device_inline void path_radiance_init(PathRadiance *L, int use_light_pass)
|
|||
L->path_subsurface = make_float3(0.0f, 0.0f, 0.0f);
|
||||
L->path_scatter = make_float3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
L->transparent = 0.0f;
|
||||
L->emission = make_float3(0.0f, 0.0f, 0.0f);
|
||||
L->background = make_float3(0.0f, 0.0f, 0.0f);
|
||||
L->ao = make_float3(0.0f, 0.0f, 0.0f);
|
||||
|
@ -217,6 +218,7 @@ ccl_device_inline void path_radiance_init(PathRadiance *L, int use_light_pass)
|
|||
else
|
||||
#endif
|
||||
{
|
||||
L->transparent = 0.0f;
|
||||
L->emission = make_float3(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
|
|
|
@ -364,10 +364,12 @@ ccl_device_inline void kernel_write_light_passes(KernelGlobals *kg, ccl_global f
|
|||
}
|
||||
|
||||
ccl_device_inline void kernel_write_result(KernelGlobals *kg, ccl_global float *buffer,
|
||||
int sample, PathRadiance *L, float alpha, bool is_shadow_catcher)
|
||||
int sample, PathRadiance *L, bool is_shadow_catcher)
|
||||
{
|
||||
if(L) {
|
||||
float3 L_sum;
|
||||
float alpha = 1.0f - L->transparent;
|
||||
|
||||
#ifdef __SHADOW_TRICKS__
|
||||
if(is_shadow_catcher) {
|
||||
L_sum = path_radiance_sum_shadowcatcher(kg, L, &alpha);
|
||||
|
|
|
@ -432,17 +432,16 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
|
|||
|
||||
#endif /* defined(__BRANCHED_PATH__) || defined(__BAKING__) */
|
||||
|
||||
ccl_device_inline float kernel_path_integrate(KernelGlobals *kg,
|
||||
RNG *rng,
|
||||
int sample,
|
||||
Ray ray,
|
||||
ccl_global float *buffer,
|
||||
PathRadiance *L,
|
||||
bool *is_shadow_catcher)
|
||||
ccl_device_inline void kernel_path_integrate(KernelGlobals *kg,
|
||||
RNG *rng,
|
||||
int sample,
|
||||
Ray ray,
|
||||
ccl_global float *buffer,
|
||||
PathRadiance *L,
|
||||
bool *is_shadow_catcher)
|
||||
{
|
||||
/* initialize */
|
||||
float3 throughput = make_float3(1.0f, 1.0f, 1.0f);
|
||||
float L_transparent = 0.0f;
|
||||
|
||||
path_radiance_init(L, kernel_data.film.use_light_pass);
|
||||
|
||||
|
@ -496,7 +495,7 @@ ccl_device_inline float kernel_path_integrate(KernelGlobals *kg,
|
|||
if(state.flag & PATH_RAY_CAMERA) {
|
||||
L->debug_data.num_bvh_traversed_nodes += isect.num_traversed_nodes;
|
||||
L->debug_data.num_bvh_traversed_instances += isect.num_traversed_instances;
|
||||
L.->ebug_data.num_bvh_intersections += isect.num_intersections;
|
||||
L->debug_data.num_bvh_intersections += isect.num_intersections;
|
||||
}
|
||||
L->debug_data.num_ray_bounces++;
|
||||
#endif /* __KERNEL_DEBUG__ */
|
||||
|
@ -613,7 +612,7 @@ ccl_device_inline float kernel_path_integrate(KernelGlobals *kg,
|
|||
if(!hit) {
|
||||
/* eval background shader if nothing hit */
|
||||
if(kernel_data.background.transparent && (state.flag & PATH_RAY_CAMERA)) {
|
||||
L_transparent += average(throughput);
|
||||
L->transparent += average(throughput);
|
||||
|
||||
#ifdef __PASSES__
|
||||
if(!(kernel_data.film.pass_flag & PASS_BACKGROUND))
|
||||
|
@ -673,7 +672,7 @@ ccl_device_inline float kernel_path_integrate(KernelGlobals *kg,
|
|||
holdout_weight = shader_holdout_eval(kg, &sd);
|
||||
}
|
||||
/* any throughput is ok, should all be identical here */
|
||||
L_transparent += average(holdout_weight*throughput);
|
||||
L->transparent += average(holdout_weight*throughput);
|
||||
}
|
||||
|
||||
if(sd.object_flag & SD_OBJECT_HOLDOUT_MASK) {
|
||||
|
@ -780,8 +779,6 @@ ccl_device_inline float kernel_path_integrate(KernelGlobals *kg,
|
|||
#ifdef __SHADOW_TRICKS__
|
||||
*is_shadow_catcher = (state.flag & PATH_RAY_SHADOW_CATCHER) != 0;
|
||||
#endif /* __SHADOW_TRICKS__ */
|
||||
|
||||
return 1.0f - L_transparent;
|
||||
}
|
||||
|
||||
ccl_device void kernel_path_trace(KernelGlobals *kg,
|
||||
|
@ -806,11 +803,11 @@ ccl_device void kernel_path_trace(KernelGlobals *kg,
|
|||
bool is_shadow_catcher;
|
||||
|
||||
if(ray.t != 0.0f) {
|
||||
float alpha = kernel_path_integrate(kg, &rng, sample, ray, buffer, &L, &is_shadow_catcher);
|
||||
kernel_write_result(kg, buffer, sample, &L, alpha, is_shadow_catcher);
|
||||
kernel_path_integrate(kg, &rng, sample, ray, buffer, &L, &is_shadow_catcher);
|
||||
kernel_write_result(kg, buffer, sample, &L, is_shadow_catcher);
|
||||
}
|
||||
else {
|
||||
kernel_write_result(kg, buffer, sample, NULL, 0.0f, false);
|
||||
kernel_write_result(kg, buffer, sample, NULL, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -269,17 +269,16 @@ ccl_device void kernel_branched_path_subsurface_scatter(KernelGlobals *kg,
|
|||
}
|
||||
#endif /* __SUBSURFACE__ */
|
||||
|
||||
ccl_device float kernel_branched_path_integrate(KernelGlobals *kg,
|
||||
RNG *rng,
|
||||
int sample,
|
||||
Ray ray,
|
||||
ccl_global float *buffer,
|
||||
PathRadiance *L,
|
||||
bool *is_shadow_catcher)
|
||||
ccl_device void kernel_branched_path_integrate(KernelGlobals *kg,
|
||||
RNG *rng,
|
||||
int sample,
|
||||
Ray ray,
|
||||
ccl_global float *buffer,
|
||||
PathRadiance *L,
|
||||
bool *is_shadow_catcher)
|
||||
{
|
||||
/* initialize */
|
||||
float3 throughput = make_float3(1.0f, 1.0f, 1.0f);
|
||||
float L_transparent = 0.0f;
|
||||
|
||||
path_radiance_init(L, kernel_data.film.use_light_pass);
|
||||
|
||||
|
@ -477,7 +476,7 @@ ccl_device float kernel_branched_path_integrate(KernelGlobals *kg,
|
|||
if(!hit) {
|
||||
/* eval background shader if nothing hit */
|
||||
if(kernel_data.background.transparent) {
|
||||
L_transparent += average(throughput);
|
||||
L->transparent += average(throughput);
|
||||
|
||||
#ifdef __PASSES__
|
||||
if(!(kernel_data.film.pass_flag & PASS_BACKGROUND))
|
||||
|
@ -529,7 +528,7 @@ ccl_device float kernel_branched_path_integrate(KernelGlobals *kg,
|
|||
holdout_weight = shader_holdout_eval(kg, &sd);
|
||||
}
|
||||
/* any throughput is ok, should all be identical here */
|
||||
L_transparent += average(holdout_weight*throughput);
|
||||
L->transparent += average(holdout_weight*throughput);
|
||||
}
|
||||
if(sd.object_flag & SD_OBJECT_HOLDOUT_MASK) {
|
||||
break;
|
||||
|
@ -632,8 +631,6 @@ ccl_device float kernel_branched_path_integrate(KernelGlobals *kg,
|
|||
#ifdef __SHADOW_TRICKS__
|
||||
*is_shadow_catcher = (state.flag & PATH_RAY_SHADOW_CATCHER) != 0;
|
||||
#endif /* __SHADOW_TRICKS__ */
|
||||
|
||||
return 1.0f - L_transparent;
|
||||
}
|
||||
|
||||
ccl_device void kernel_branched_path_trace(KernelGlobals *kg,
|
||||
|
@ -658,11 +655,11 @@ ccl_device void kernel_branched_path_trace(KernelGlobals *kg,
|
|||
bool is_shadow_catcher;
|
||||
|
||||
if(ray.t != 0.0f) {
|
||||
float alpha = kernel_branched_path_integrate(kg, &rng, sample, ray, buffer, &L, &is_shadow_catcher);
|
||||
kernel_write_result(kg, buffer, sample, &L, alpha, is_shadow_catcher);
|
||||
kernel_branched_path_integrate(kg, &rng, sample, ray, buffer, &L, &is_shadow_catcher);
|
||||
kernel_write_result(kg, buffer, sample, &L, is_shadow_catcher);
|
||||
}
|
||||
else {
|
||||
kernel_write_result(kg, buffer, sample, NULL, 0.0f, false);
|
||||
kernel_write_result(kg, buffer, sample, NULL, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -485,6 +485,7 @@ typedef ccl_addr_space struct PathRadiance {
|
|||
int use_light_pass;
|
||||
#endif
|
||||
|
||||
float transparent;
|
||||
float3 emission;
|
||||
#ifdef __PASSES__
|
||||
float3 background;
|
||||
|
|
|
@ -83,7 +83,6 @@ ccl_device void kernel_buffer_update(KernelGlobals *kg,
|
|||
PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
|
||||
ccl_global Ray *ray = &kernel_split_state.ray[ray_index];
|
||||
ccl_global float3 *throughput = &kernel_split_state.throughput[ray_index];
|
||||
ccl_global float *L_transparent = &kernel_split_state.L_transparent[ray_index];
|
||||
RNG rng = kernel_split_state.rng[ray_index];
|
||||
ccl_global float *buffer = kernel_split_params.buffer;
|
||||
|
||||
|
@ -110,7 +109,7 @@ ccl_device void kernel_buffer_update(KernelGlobals *kg,
|
|||
if(IS_STATE(ray_state, ray_index, RAY_UPDATE_BUFFER)) {
|
||||
/* accumulate result in output buffer */
|
||||
bool is_shadow_catcher = (state->flag & PATH_RAY_SHADOW_CATCHER);
|
||||
kernel_write_result(kg, buffer, sample, L, 1.0f - (*L_transparent), is_shadow_catcher);
|
||||
kernel_write_result(kg, buffer, sample, L, is_shadow_catcher);
|
||||
|
||||
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_TO_REGENERATE);
|
||||
}
|
||||
|
@ -139,11 +138,10 @@ ccl_device void kernel_buffer_update(KernelGlobals *kg,
|
|||
kernel_path_trace_setup(kg, rng_state, sample, pixel_x, pixel_y, &rng, ray);
|
||||
|
||||
if(ray->t != 0.0f) {
|
||||
/* Initialize throughput, L_transparent, Ray, PathState;
|
||||
/* Initialize throughput, path radiance, Ray, PathState;
|
||||
* These rays proceed with path-iteration.
|
||||
*/
|
||||
*throughput = make_float3(1.0f, 1.0f, 1.0f);
|
||||
*L_transparent = 0.0f;
|
||||
path_radiance_init(L, kernel_data.film.use_light_pass);
|
||||
path_state_init(kg, &kernel_split_state.sd_DL_shadow[ray_index], state, &rng, sample, ray);
|
||||
#ifdef __SUBSURFACE__
|
||||
|
|
|
@ -162,7 +162,8 @@ ccl_device void kernel_holdout_emission_blurring_pathtermination_ao(
|
|||
holdout_weight = shader_holdout_eval(kg, sd);
|
||||
}
|
||||
/* any throughput is ok, should all be identical here */
|
||||
kernel_split_state.L_transparent[ray_index] += average(holdout_weight*throughput);
|
||||
PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
|
||||
L->transparent += average(holdout_weight*throughput);
|
||||
}
|
||||
if(sd->object_flag & SD_OBJECT_HOLDOUT_MASK) {
|
||||
kernel_split_path_end(kg, ray_index);
|
||||
|
|
|
@ -54,12 +54,11 @@ ccl_device void kernel_indirect_background(KernelGlobals *kg)
|
|||
PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
|
||||
ccl_global Ray *ray = &kernel_split_state.ray[ray_index];
|
||||
ccl_global float3 *throughput = &kernel_split_state.throughput[ray_index];
|
||||
ccl_global float *L_transparent = &kernel_split_state.L_transparent[ray_index];
|
||||
|
||||
if(IS_STATE(ray_state, ray_index, RAY_HIT_BACKGROUND)) {
|
||||
/* eval background shader if nothing hit */
|
||||
if(kernel_data.background.transparent && (state->flag & PATH_RAY_CAMERA)) {
|
||||
*L_transparent = (*L_transparent) + average((*throughput));
|
||||
L->transparent += average((*throughput));
|
||||
#ifdef __PASSES__
|
||||
if(!(kernel_data.film.pass_flag & PASS_BACKGROUND))
|
||||
#endif
|
||||
|
|
|
@ -71,11 +71,10 @@ ccl_device void kernel_path_init(KernelGlobals *kg) {
|
|||
&kernel_split_state.ray[ray_index]);
|
||||
|
||||
if(kernel_split_state.ray[ray_index].t != 0.0f) {
|
||||
/* Initialize throughput, L_transparent, Ray, PathState;
|
||||
/* Initialize throughput, path radiance, Ray, PathState;
|
||||
* These rays proceed with path-iteration.
|
||||
*/
|
||||
kernel_split_state.throughput[ray_index] = make_float3(1.0f, 1.0f, 1.0f);
|
||||
kernel_split_state.L_transparent[ray_index] = 0.0f;
|
||||
path_radiance_init(&kernel_split_state.path_radiance[ray_index], kernel_data.film.use_light_pass);
|
||||
path_state_init(kg,
|
||||
&kernel_split_state.sd_DL_shadow[ray_index],
|
||||
|
|
|
@ -116,7 +116,6 @@ typedef ccl_global struct SplitBranchedState {
|
|||
#define SPLIT_DATA_ENTRIES \
|
||||
SPLIT_DATA_ENTRY(ccl_global RNG, rng, 1) \
|
||||
SPLIT_DATA_ENTRY(ccl_global float3, throughput, 1) \
|
||||
SPLIT_DATA_ENTRY(ccl_global float, L_transparent, 1) \
|
||||
SPLIT_DATA_ENTRY(PathRadiance, path_radiance, 1) \
|
||||
SPLIT_DATA_ENTRY(ccl_global Ray, ray, 1) \
|
||||
SPLIT_DATA_ENTRY(ccl_global PathState, path_state, 1) \
|
||||
|
@ -136,7 +135,6 @@ typedef ccl_global struct SplitBranchedState {
|
|||
#define SPLIT_DATA_ENTRIES_BRANCHED_SHARED \
|
||||
SPLIT_DATA_ENTRY(ccl_global RNG, rng, 1) \
|
||||
SPLIT_DATA_ENTRY(ccl_global float3, throughput, 1) \
|
||||
SPLIT_DATA_ENTRY(ccl_global float, L_transparent, 1) \
|
||||
SPLIT_DATA_ENTRY(PathRadiance, path_radiance, 1) \
|
||||
SPLIT_DATA_ENTRY(ccl_global Ray, ray, 1) \
|
||||
SPLIT_DATA_ENTRY(ccl_global PathState, path_state, 1) \
|
||||
|
|
Loading…
Reference in New Issue