diff options
author | Brecht Van Lommel <brecht@blender.org> | 2021-10-21 18:42:15 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2021-10-26 15:56:43 +0300 |
commit | 75704091fccb92774790f6451efe4e1d00174dad (patch) | |
tree | c011d5301dd2755c704320bf3a244dff47f5e9d0 /intern/cycles/kernel/integrator | |
parent | eb1fed9d60a03cc5f9e648a1efaf89019bc2d8bd (diff) |
Cycles: add additive AO support through Fast GI settings
Add a Fast GI Method, either Replace for the existing behavior, or Add
to add ambient occlusion like the old world settings.
This replaces the old Ambient Occlusion settings in the world properties.
Diffstat (limited to 'intern/cycles/kernel/integrator')
-rw-r--r-- | intern/cycles/kernel/integrator/integrator_shade_surface.h | 31 | ||||
-rw-r--r-- | intern/cycles/kernel/integrator/integrator_shadow_state_template.h | 5 |
2 files changed, 25 insertions, 11 deletions
diff --git a/intern/cycles/kernel/integrator/integrator_shade_surface.h b/intern/cycles/kernel/integrator/integrator_shade_surface.h index 3724b05c6b0..2a0bf4a3046 100644 --- a/intern/cycles/kernel/integrator/integrator_shade_surface.h +++ b/intern/cycles/kernel/integrator/integrator_shade_surface.h @@ -325,17 +325,25 @@ ccl_device_forceinline bool integrate_surface_volume_only_bounce(IntegratorState #endif #if defined(__AO__) -ccl_device_forceinline void integrate_surface_ao_pass( - KernelGlobals kg, - IntegratorState state, - ccl_private const ShaderData *ccl_restrict sd, - ccl_private const RNGState *ccl_restrict rng_state, - ccl_global float *ccl_restrict render_buffer) +ccl_device_forceinline void integrate_surface_ao(KernelGlobals kg, + IntegratorState state, + ccl_private const ShaderData *ccl_restrict sd, + ccl_private const RNGState *ccl_restrict + rng_state, + ccl_global float *ccl_restrict render_buffer) { + if (!(kernel_data.kernel_features & KERNEL_FEATURE_AO_ADDITIVE) && + !(INTEGRATOR_STATE(state, path, flag) & PATH_RAY_CAMERA)) { + return; + } + float bsdf_u, bsdf_v; path_state_rng_2D(kg, rng_state, PRNG_BSDF_U, &bsdf_u, &bsdf_v); - const float3 ao_N = shader_bsdf_ao_normal(kg, sd); + float3 ao_N; + const float3 ao_weight = shader_bsdf_ao( + kg, sd, kernel_data.integrator.ao_additive_factor, &ao_N); + float3 ao_D; float ao_pdf; sample_cos_hemisphere(ao_N, bsdf_u, bsdf_v, &ao_D, &ao_pdf); @@ -379,6 +387,10 @@ ccl_device_forceinline void integrate_surface_ao_pass( INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, bounce) = bounce; INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, transparent_bounce) = transparent_bounce; INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, throughput) = throughput; + + if (kernel_data.kernel_features & KERNEL_FEATURE_AO_ADDITIVE) { + INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, unshadowed_throughput) = ao_weight; + } } #endif /* defined(__AO__) */ @@ -487,10 +499,9 @@ ccl_device bool integrate_surface(KernelGlobals kg, #if defined(__AO__) /* Ambient occlusion pass. */ - if ((kernel_data.film.pass_ao != PASS_UNUSED) && - (INTEGRATOR_STATE(state, path, flag) & PATH_RAY_CAMERA)) { + if (kernel_data.kernel_features & KERNEL_FEATURE_AO) { PROFILING_EVENT(PROFILING_SHADE_SURFACE_AO); - integrate_surface_ao_pass(kg, state, &sd, &rng_state, render_buffer); + integrate_surface_ao(kg, state, &sd, &rng_state, render_buffer); } #endif diff --git a/intern/cycles/kernel/integrator/integrator_shadow_state_template.h b/intern/cycles/kernel/integrator/integrator_shadow_state_template.h index bc35b644ee1..1fbadde2642 100644 --- a/intern/cycles/kernel/integrator/integrator_shadow_state_template.h +++ b/intern/cycles/kernel/integrator/integrator_shadow_state_template.h @@ -42,7 +42,10 @@ KERNEL_STRUCT_MEMBER(shadow_path, uint32_t, flag, KERNEL_FEATURE_PATH_TRACING) /* Throughput. */ KERNEL_STRUCT_MEMBER(shadow_path, float3, throughput, KERNEL_FEATURE_PATH_TRACING) /* Throughput for shadow pass. */ -KERNEL_STRUCT_MEMBER(shadow_path, float3, unshadowed_throughput, KERNEL_FEATURE_SHADOW_PASS) +KERNEL_STRUCT_MEMBER(shadow_path, + float3, + unshadowed_throughput, + KERNEL_FEATURE_SHADOW_PASS | KERNEL_FEATURE_AO_ADDITIVE) /* Ratio of throughput to distinguish diffuse and glossy render passes. */ KERNEL_STRUCT_MEMBER(shadow_path, float3, diffuse_glossy_ratio, KERNEL_FEATURE_LIGHT_PASSES) /* Number of intersections found by ray-tracing. */ |