[Bf-blender-cvs] [cdd1d5a] master: Cycles: Initial support for volume ray visibility.

Thomas Dinges noreply at git.blender.org
Fri Sep 5 16:17:50 CEST 2014


Commit: cdd1d5a93c432ddbee8a8e578b0c28781aef71da
Author: Thomas Dinges
Date:   Fri Sep 5 16:17:24 2014 +0200
Branches: master
https://developer.blender.org/rBcdd1d5a93c432ddbee8a8e578b0c28781aef71da

Cycles: Initial support for volume ray visibility.

This adds a new "Volume Scatter" option to the "Ray Visibility" panels and can be used to e.g. exclude lamps from having an influence on the volume. See release logs for an example: http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.72/Cycles

Differential revision: https://developer.blender.org/D771

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

M	intern/cycles/blender/addon/properties.py
M	intern/cycles/blender/addon/ui.py
M	intern/cycles/blender/blender_object.cpp
M	intern/cycles/blender/blender_shader.cpp
M	intern/cycles/kernel/kernel_accumulate.h
M	intern/cycles/kernel/kernel_emission.h
M	intern/cycles/kernel/kernel_types.h
M	intern/cycles/render/background.cpp
M	intern/cycles/render/light.cpp
M	intern/cycles/render/light.h

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

diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index 59e60a9..f3885b4 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -731,6 +731,11 @@ class CyclesVisibilitySettings(bpy.types.PropertyGroup):
                 description="Object visibility for shadow rays",
                 default=True,
                 )
+        cls.scatter = BoolProperty(
+                name="Volume Scatter",
+                description="Object visibility for volume scatter rays",
+                default=True,
+                )
 
     @classmethod
     def unregister(cls):
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index aab9f83..198926e 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -618,6 +618,7 @@ class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel):
         flow.prop(visibility, "diffuse")
         flow.prop(visibility, "glossy")
         flow.prop(visibility, "transmission")
+        flow.prop(visibility, "scatter")
 
         if ob.type != 'LAMP':
             flow.prop(visibility, "shadow")
@@ -897,6 +898,7 @@ class CyclesWorld_PT_ray_visibility(CyclesButtonsPanel, Panel):
         flow.prop(visibility, "diffuse")
         flow.prop(visibility, "glossy")
         flow.prop(visibility, "transmission")
+        flow.prop(visibility, "scatter")
 
 
 class CyclesWorld_PT_settings(CyclesButtonsPanel, Panel):
diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp
index 94dec0b..1e07c5f 100644
--- a/intern/cycles/blender/blender_object.cpp
+++ b/intern/cycles/blender/blender_object.cpp
@@ -82,6 +82,7 @@ static uint object_ray_visibility(BL::Object b_ob)
 	flag |= get_boolean(cvisibility, "glossy")? PATH_RAY_GLOSSY: 0;
 	flag |= get_boolean(cvisibility, "transmission")? PATH_RAY_TRANSMIT: 0;
 	flag |= get_boolean(cvisibility, "shadow")? PATH_RAY_SHADOW: 0;
+	flag |= get_boolean(cvisibility, "scatter")? PATH_RAY_VOLUME_SCATTER: 0;
 
 	return flag;
 }
@@ -172,6 +173,7 @@ void BlenderSync::sync_light(BL::Object b_parent, int persistent_id[OBJECT_PERSI
 	light->use_diffuse = (visibility & PATH_RAY_DIFFUSE) != 0;
 	light->use_glossy = (visibility & PATH_RAY_GLOSSY) != 0;
 	light->use_transmission = (visibility & PATH_RAY_TRANSMIT) != 0;
+	light->use_scatter = (visibility & PATH_RAY_VOLUME_SCATTER) != 0;
 
 	/* tag */
 	light->tag_update(scene);
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index 193eb69..7752c1c 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -1071,6 +1071,7 @@ void BlenderSync::sync_world(bool update_all)
 			visibility |= get_boolean(cvisibility, "diffuse")? PATH_RAY_DIFFUSE: 0;
 			visibility |= get_boolean(cvisibility, "glossy")? PATH_RAY_GLOSSY: 0;
 			visibility |= get_boolean(cvisibility, "transmission")? PATH_RAY_TRANSMIT: 0;
+			visibility |= get_boolean(cvisibility, "scatter")? PATH_RAY_VOLUME_SCATTER: 0;
 
 			background->visibility = visibility;
 		}
diff --git a/intern/cycles/kernel/kernel_accumulate.h b/intern/cycles/kernel/kernel_accumulate.h
index 5b2233f..f493b38 100644
--- a/intern/cycles/kernel/kernel_accumulate.h
+++ b/intern/cycles/kernel/kernel_accumulate.h
@@ -32,6 +32,7 @@ ccl_device_inline void bsdf_eval_init(BsdfEval *eval, ClosureType type, float3 v
 		eval->transmission = make_float3(0.0f, 0.0f, 0.0f);
 		eval->transparent = make_float3(0.0f, 0.0f, 0.0f);
 		eval->subsurface = make_float3(0.0f, 0.0f, 0.0f);
+		eval->scatter = make_float3(0.0f, 0.0f, 0.0f);
 
 		if(type == CLOSURE_BSDF_TRANSPARENT_ID)
 			eval->transparent = value;
@@ -43,6 +44,8 @@ ccl_device_inline void bsdf_eval_init(BsdfEval *eval, ClosureType type, float3 v
 			eval->transmission = value;
 		else if(CLOSURE_IS_BSDF_BSSRDF(type))
 			eval->subsurface = value;
+		else if(CLOSURE_IS_PHASE(type))
+			eval->scatter = value;
 	}
 	else
 		eval->diffuse = value;
@@ -55,7 +58,7 @@ ccl_device_inline void bsdf_eval_accum(BsdfEval *eval, ClosureType type, float3
 {
 #ifdef __PASSES__
 	if(eval->use_light_pass) {
-		if(CLOSURE_IS_BSDF_DIFFUSE(type) || CLOSURE_IS_PHASE(type))
+		if(CLOSURE_IS_BSDF_DIFFUSE(type))
 			eval->diffuse += value;
 		else if(CLOSURE_IS_BSDF_GLOSSY(type))
 			eval->glossy += value;
@@ -63,6 +66,8 @@ ccl_device_inline void bsdf_eval_accum(BsdfEval *eval, ClosureType type, float3
 			eval->transmission += value;
 		else if(CLOSURE_IS_BSDF_BSSRDF(type))
 			eval->subsurface += value;
+		else if(CLOSURE_IS_PHASE(type))
+			eval->scatter += value;
 
 		/* skipping transparent, this function is used by for eval(), will be zero then */
 	}
@@ -81,7 +86,8 @@ ccl_device_inline bool bsdf_eval_is_zero(BsdfEval *eval)
 			&& is_zero(eval->glossy)
 			&& is_zero(eval->transmission)
 			&& is_zero(eval->transparent)
-			&& is_zero(eval->subsurface);
+			&& is_zero(eval->subsurface)
+			&& is_zero(eval->scatter);
 	}
 	else
 		return is_zero(eval->diffuse);
@@ -98,6 +104,7 @@ ccl_device_inline void bsdf_eval_mul(BsdfEval *eval, float3 value)
 		eval->glossy *= value;
 		eval->transmission *= value;
 		eval->subsurface *= value;
+		eval->scatter *= value;
 
 		/* skipping transparent, this function is used by for eval(), will be zero then */
 	}
@@ -130,21 +137,25 @@ ccl_device_inline void path_radiance_init(PathRadiance *L, int use_light_pass)
 		L->color_glossy = make_float3(0.0f, 0.0f, 0.0f);
 		L->color_transmission = make_float3(0.0f, 0.0f, 0.0f);
 		L->color_subsurface = make_float3(0.0f, 0.0f, 0.0f);
+		L->color_scatter = make_float3(0.0f, 0.0f, 0.0f);
 
 		L->direct_diffuse = make_float3(0.0f, 0.0f, 0.0f);
 		L->direct_glossy = make_float3(0.0f, 0.0f, 0.0f);
 		L->direct_transmission = make_float3(0.0f, 0.0f, 0.0f);
 		L->direct_subsurface = make_float3(0.0f, 0.0f, 0.0f);
+		L->direct_scatter = make_float3(0.0f, 0.0f, 0.0f);
 
 		L->indirect_diffuse = make_float3(0.0f, 0.0f, 0.0f);
 		L->indirect_glossy = make_float3(0.0f, 0.0f, 0.0f);
 		L->indirect_transmission = make_float3(0.0f, 0.0f, 0.0f);
 		L->indirect_subsurface = make_float3(0.0f, 0.0f, 0.0f);
+		L->indirect_scatter = make_float3(0.0f, 0.0f, 0.0f);
 
 		L->path_diffuse = make_float3(0.0f, 0.0f, 0.0f);
 		L->path_glossy = make_float3(0.0f, 0.0f, 0.0f);
 		L->path_transmission = make_float3(0.0f, 0.0f, 0.0f);
 		L->path_subsurface = make_float3(0.0f, 0.0f, 0.0f);
+		L->path_scatter = make_float3(0.0f, 0.0f, 0.0f);
 
 		L->emission = make_float3(0.0f, 0.0f, 0.0f);
 		L->background = make_float3(0.0f, 0.0f, 0.0f);
@@ -174,14 +185,16 @@ ccl_device_inline void path_radiance_bsdf_bounce(PathRadiance *L, float3 *throug
 			L->path_glossy = bsdf_eval->glossy*value;
 			L->path_transmission = bsdf_eval->transmission*value;
 			L->path_subsurface = bsdf_eval->subsurface*value;
+			L->path_scatter = bsdf_eval->scatter*value;
 
-			*throughput = L->path_diffuse + L->path_glossy + L->path_transmission + L->path_subsurface;
+			*throughput = L->path_diffuse + L->path_glossy + L->path_transmission + L->path_subsurface + L->path_scatter;
 			
 			L->direct_throughput = *throughput;
 		}
 		else {
 			/* transparent bounce before first hit, or indirectly visible through BSDF */
-			float3 sum = (bsdf_eval->diffuse + bsdf_eval->glossy + bsdf_eval->transmission + bsdf_eval->transparent + bsdf_eval->subsurface)*inverse_pdf;
+			float3 sum = (bsdf_eval->diffuse + bsdf_eval->glossy + bsdf_eval->transmission + bsdf_eval->transparent +
+						  bsdf_eval->subsurface + bsdf_eval->scatter) * inverse_pdf;
 			*throughput *= sum;
 		}
 	}
@@ -241,6 +254,7 @@ ccl_device_inline void path_radiance_accum_light(PathRadiance *L, float3 through
 			L->direct_glossy += throughput*bsdf_eval->glossy*shadow;
 			L->direct_transmission += throughput*bsdf_eval->transmission*shadow;
 			L->direct_subsurface += throughput*bsdf_eval->subsurface*shadow;
+			L->direct_scatter += throughput*bsdf_eval->scatter*shadow;
 
 			if(is_lamp) {
 				L->shadow.x += shadow.x*shadow_fac;
@@ -250,7 +264,7 @@ ccl_device_inline void path_radiance_accum_light(PathRadiance *L, float3 through
 		}
 		else {
 			/* indirectly visible lighting after BSDF bounce */
-			float3 sum = bsdf_eval->diffuse + bsdf_eval->glossy + bsdf_eval->transmission + bsdf_eval->subsurface;
+			float3 sum = bsdf_eval->diffuse + bsdf_eval->glossy + bsdf_eval->transmission + bsdf_eval->subsurface + bsdf_eval->scatter;
 			L->indirect += throughput*sum*shadow;
 		}
 	}
@@ -291,12 +305,14 @@ ccl_device_inline void path_radiance_sum_indirect(PathRadiance *L)
 		L->direct_glossy += L->path_glossy*L->direct_emission;
 		L->direct_transmission += L->path_transmission*L->direct_emission;
 		L->direct_subsurface += L->path_subsurface*L->direct_emission;
+		L->direct_scatter += L->path_scatter*L->direct_emission;
 
 		L->indirect = safe_divide_color(L->indirect, L->direct_throughput);
 		L->indirect_diffuse += L->path_diffuse*L->indirect;
 		L->indirect_glossy += L->path_glossy*L->indirect;
 		L->indirect_transmission += L->path_transmission*L->indirect;
 		L->indirect_subsurface += L->path_subsurface*L->indirect;
+		L->indirect_scatter += L->path_scatter*L->indirect;
 	}
 #endif
 }
@@ -309,6 +325,7 @@ ccl_device_inline void path_radiance_reset_indirect(PathRadiance *L)
 		L->path_glossy = make_float3(0.0f, 0.0f, 0.0f);
 		L->path_transmission = make_float3(0.0f, 0.0f, 0.0f);
 		L->path_subsurface = make_float3(0.0f, 0.0f, 0.0f);
+		L->path_scatter = make_float3(0.0f, 0.0f, 0.0f);
 
 		L->direct_emission = make_float3(0.0f, 0.0f, 0.0f);
 		L->indirect = make_float3(0.0f, 0.0f, 0.0f);
@@ -327,8 +344,8 @@ ccl_device_inline float3 path_radiance_clamp_and_sum(KernelGlobals *kg, PathRadi
 	if(L->use_light_pass) {
 		path_radiance_sum_indirect(L);
 
-		L_direct = L->direct_diffuse + L->direct_glossy + L->direct_transmission + L->direct_subsurface + L->emission;
-		L_indirect = L->indirect_diffuse + L->indirect_glossy + L->indirect_transmission + L->indirect_subsurface;
+		L_direct = L->direct_diffuse + L->direct_glossy + L->direct_transmission + L->direct_subsurface + L->direct_scatter + L->emission;
+		L_indirect = L->indirect_diffuse + L->indirect_gl

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list