[Bf-blender-cvs] [171c4e982f7] master: Cycles: use AO factor to let user adjust intensity of AO bounces.

Brecht Van Lommel noreply at git.blender.org
Wed Oct 25 21:49:31 CEST 2017


Commit: 171c4e982f7b6c93b534a48cfe8aba73dec78030
Author: Brecht Van Lommel
Date:   Wed Oct 25 21:07:44 2017 +0200
Branches: master
https://developer.blender.org/rB171c4e982f7b6c93b534a48cfe8aba73dec78030

Cycles: use AO factor to let user adjust intensity of AO bounces.

We are already using the AO distance, so might as well offer this extra
control over the intensity. Useful when an interior scene is supposed to
be significantly darker than the background shader.

===================================================================

M	intern/cycles/blender/blender_shader.cpp
M	intern/cycles/kernel/kernel_path.h
M	intern/cycles/kernel/kernel_types.h
M	intern/cycles/render/background.cpp
M	intern/cycles/render/integrator.cpp

===================================================================

diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index bdbab1006c0..cd6c9f319db 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -1289,11 +1289,8 @@ void BlenderSync::sync_world(bool update_all)
 			/* AO */
 			BL::WorldLighting b_light = b_world.light_settings();
 
-			if(b_light.use_ambient_occlusion())
-				background->ao_factor = b_light.ao_factor();
-			else
-				background->ao_factor = 0.0f;
-
+			background->use_ao = b_light.use_ambient_occlusion();
+			background->ao_factor = b_light.ao_factor();
 			background->ao_distance = b_light.distance();
 
 			/* visibility */
@@ -1309,6 +1306,7 @@ void BlenderSync::sync_world(bool update_all)
 			background->visibility = visibility;
 		}
 		else {
+			background->use_ao = false;
 			background->ao_factor = 0.0f;
 			background->ao_distance = FLT_MAX;
 		}
@@ -1330,7 +1328,7 @@ void BlenderSync::sync_world(bool update_all)
 		background->transparent = b_scene.render().alpha_mode() == BL::RenderSettings::alpha_mode_TRANSPARENT;
 
 	background->use_shader = render_layer.use_background_shader;
-	background->use_ao = render_layer.use_background_ao;
+	background->use_ao = background->use_ao && render_layer.use_background_ao;
 
 	if(background->modified(prevbackground))
 		background->tag_update(scene);
diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h
index 652777a77a0..e664a2e9dbd 100644
--- a/intern/cycles/kernel/kernel_path.h
+++ b/intern/cycles/kernel/kernel_path.h
@@ -145,6 +145,12 @@ ccl_device_forceinline void kernel_path_background(
 			return;
 	}
 
+	/* When using the ao bounces approximation, adjust background
+	 * shader intensity with ao factor. */
+	if(path_state_ao_bounce(kg, state)) {
+		throughput *= kernel_data.background.ao_bounces_factor;
+	}
+
 #ifdef __BACKGROUND__
 	/* sample background shader */
 	float3 L_background = indirect_background(kg, emission_sd, state, ray);
diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h
index 2ae003227dc..49ec6d97f28 100644
--- a/intern/cycles/kernel/kernel_types.h
+++ b/intern/cycles/kernel/kernel_types.h
@@ -1214,7 +1214,8 @@ typedef struct KernelBackground {
 	/* ambient occlusion */
 	float ao_factor;
 	float ao_distance;
-	float ao_pad1, ao_pad2;
+	float ao_bounces_factor;
+	float ao_pad;
 } KernelBackground;
 static_assert_align(KernelBackground, 16);
 
diff --git a/intern/cycles/render/background.cpp b/intern/cycles/render/background.cpp
index 930debe1e33..3ed96732b14 100644
--- a/intern/cycles/render/background.cpp
+++ b/intern/cycles/render/background.cpp
@@ -74,14 +74,9 @@ void Background::device_update(Device *device, DeviceScene *dscene, Scene *scene
 	/* set shader index and transparent option */
 	KernelBackground *kbackground = &dscene->data.background;
 
-	if(use_ao) {
-		kbackground->ao_factor = ao_factor;
-		kbackground->ao_distance = ao_distance;
-	}
-	else {
-		kbackground->ao_factor = 0.0f;
-		kbackground->ao_distance = FLT_MAX;
-	}
+	kbackground->ao_factor = (use_ao)? ao_factor: 0.0f;
+	kbackground->ao_bounces_factor = ao_factor;
+	kbackground->ao_distance = ao_distance;
 
 	kbackground->transparent = transparent;
 	kbackground->surface_shader = scene->shader_manager->get_shader_id(bg_shader);
diff --git a/intern/cycles/render/integrator.cpp b/intern/cycles/render/integrator.cpp
index 33c3dac9e81..0dc1a9aa053 100644
--- a/intern/cycles/render/integrator.cpp
+++ b/intern/cycles/render/integrator.cpp
@@ -15,6 +15,7 @@
  */
 
 #include "device/device.h"
+#include "render/background.h"
 #include "render/integrator.h"
 #include "render/film.h"
 #include "render/light.h"



More information about the Bf-blender-cvs mailing list