| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2013-08-18 14:16:15 +00:00
										 |  |  |  * Copyright 2011-2013 Blender Foundation | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2013-08-18 14:16:15 +00:00
										 |  |  |  * Licensed under the Apache License, Version 2.0 (the "License"); | 
					
						
							|  |  |  |  * you may not use this file except in compliance with the License. | 
					
						
							|  |  |  |  * You may obtain a copy of the License at | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2013-08-18 14:16:15 +00:00
										 |  |  |  * http://www.apache.org/licenses/LICENSE-2.0
 | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2013-08-18 14:16:15 +00:00
										 |  |  |  * Unless required by applicable law or agreed to in writing, software | 
					
						
							|  |  |  |  * distributed under the License is distributed on an "AS IS" BASIS, | 
					
						
							|  |  |  |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
					
						
							|  |  |  |  * See the License for the specific language governing permissions and | 
					
						
							| 
									
										
										
										
											2014-12-25 02:50:24 +01:00
										 |  |  |  * limitations under the License. | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | CCL_NAMESPACE_BEGIN | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* BSDF Eval
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * BSDF evaluation result, split per BSDF type. This is used to accumulate | 
					
						
							|  |  |  |  * render passes separately. */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-11 09:33:18 +02:00
										 |  |  | ccl_device float3 shader_bsdf_transparency(KernelGlobals *kg, const ShaderData *sd); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-16 00:17:10 +01:00
										 |  |  | ccl_device_inline void bsdf_eval_init(BsdfEval *eval, | 
					
						
							|  |  |  |                                       ClosureType type, | 
					
						
							|  |  |  |                                       float3 value, | 
					
						
							|  |  |  |                                       int use_light_pass) | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  | { | 
					
						
							|  |  |  | #ifdef __PASSES__
 | 
					
						
							|  |  |  |   eval->use_light_pass = use_light_pass; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |   if (eval->use_light_pass) { | 
					
						
							|  |  |  |     eval->diffuse = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							|  |  |  |     eval->glossy = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							|  |  |  |     eval->transmission = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							|  |  |  |     eval->transparent = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							| 
									
										
										
										
											2020-02-14 12:20:12 +01:00
										 |  |  |     eval->volume = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |     if (type == CLOSURE_BSDF_TRANSPARENT_ID) | 
					
						
							|  |  |  |       eval->transparent = value; | 
					
						
							| 
									
										
										
										
											2020-02-14 12:20:12 +01:00
										 |  |  |     else if (CLOSURE_IS_BSDF_DIFFUSE(type) || CLOSURE_IS_BSDF_BSSRDF(type)) | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |       eval->diffuse = value; | 
					
						
							|  |  |  |     else if (CLOSURE_IS_BSDF_GLOSSY(type)) | 
					
						
							|  |  |  |       eval->glossy = value; | 
					
						
							| 
									
										
										
										
											2013-08-03 13:12:09 +00:00
										 |  |  |     else if (CLOSURE_IS_BSDF_TRANSMISSION(type)) | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |       eval->transmission = value; | 
					
						
							| 
									
										
										
										
											2014-09-05 16:17:24 +02:00
										 |  |  |     else if (CLOSURE_IS_PHASE(type)) | 
					
						
							| 
									
										
										
										
											2020-02-14 12:20:12 +01:00
										 |  |  |       eval->volume = value; | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |   } | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2016-09-14 20:09:37 +02:00
										 |  |  |   { | 
					
						
							|  |  |  |     eval->diffuse = value; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-02-09 14:19:01 +01:00
										 |  |  | #ifdef __SHADOW_TRICKS__
 | 
					
						
							|  |  |  |   eval->sum_no_mis = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 14:19:01 +01:00
										 |  |  | ccl_device_inline void bsdf_eval_accum(BsdfEval *eval, | 
					
						
							|  |  |  |                                        ClosureType type, | 
					
						
							|  |  |  |                                        float3 value, | 
					
						
							|  |  |  |                                        float mis_weight) | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-02-09 14:19:01 +01:00
										 |  |  | #ifdef __SHADOW_TRICKS__
 | 
					
						
							|  |  |  |   eval->sum_no_mis += value; | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  |   value *= mis_weight; | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  | #ifdef __PASSES__
 | 
					
						
							|  |  |  |   if (eval->use_light_pass) { | 
					
						
							| 
									
										
										
										
											2020-02-14 12:20:12 +01:00
										 |  |  |     if (CLOSURE_IS_BSDF_DIFFUSE(type) || CLOSURE_IS_BSDF_BSSRDF(type)) | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |       eval->diffuse += value; | 
					
						
							|  |  |  |     else if (CLOSURE_IS_BSDF_GLOSSY(type)) | 
					
						
							|  |  |  |       eval->glossy += value; | 
					
						
							| 
									
										
										
										
											2013-08-03 13:12:09 +00:00
										 |  |  |     else if (CLOSURE_IS_BSDF_TRANSMISSION(type)) | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |       eval->transmission += value; | 
					
						
							| 
									
										
										
										
											2014-09-05 16:17:24 +02:00
										 |  |  |     else if (CLOSURE_IS_PHASE(type)) | 
					
						
							| 
									
										
										
										
											2020-02-14 12:20:12 +01:00
										 |  |  |       eval->volume += value; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |     /* skipping transparent, this function is used by for eval(), will be zero then */ | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2016-09-14 20:09:37 +02:00
										 |  |  |   { | 
					
						
							|  |  |  |     eval->diffuse += value; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-16 00:17:10 +01:00
										 |  |  | ccl_device_inline bool bsdf_eval_is_zero(BsdfEval *eval) | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  | { | 
					
						
							|  |  |  | #ifdef __PASSES__
 | 
					
						
							|  |  |  |   if (eval->use_light_pass) { | 
					
						
							|  |  |  |     return is_zero(eval->diffuse) && is_zero(eval->glossy) && is_zero(eval->transmission) && | 
					
						
							| 
									
										
										
										
											2020-02-14 12:20:12 +01:00
										 |  |  |            is_zero(eval->transparent) && is_zero(eval->volume); | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |   } | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2016-09-14 20:09:37 +02:00
										 |  |  |   { | 
					
						
							|  |  |  |     return is_zero(eval->diffuse); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 14:19:01 +01:00
										 |  |  | ccl_device_inline void bsdf_eval_mis(BsdfEval *eval, float value) | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  | { | 
					
						
							|  |  |  | #ifdef __PASSES__
 | 
					
						
							|  |  |  |   if (eval->use_light_pass) { | 
					
						
							|  |  |  |     eval->diffuse *= value; | 
					
						
							|  |  |  |     eval->glossy *= value; | 
					
						
							|  |  |  |     eval->transmission *= value; | 
					
						
							| 
									
										
										
										
											2020-02-14 12:20:12 +01:00
										 |  |  |     eval->volume *= value; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |     /* skipping transparent, this function is used by for eval(), will be zero then */ | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2016-09-14 20:09:37 +02:00
										 |  |  |   { | 
					
						
							|  |  |  |     eval->diffuse *= value; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 14:19:01 +01:00
										 |  |  | ccl_device_inline void bsdf_eval_mul(BsdfEval *eval, float value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | #ifdef __SHADOW_TRICKS__
 | 
					
						
							|  |  |  |   eval->sum_no_mis *= value; | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  |   bsdf_eval_mis(eval, value); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-29 23:47:30 +02:00
										 |  |  | ccl_device_inline void bsdf_eval_mul3(BsdfEval *eval, float3 value) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-02-09 14:19:01 +01:00
										 |  |  | #ifdef __SHADOW_TRICKS__
 | 
					
						
							|  |  |  |   eval->sum_no_mis *= value; | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2016-10-29 23:47:30 +02:00
										 |  |  | #ifdef __PASSES__
 | 
					
						
							|  |  |  |   if (eval->use_light_pass) { | 
					
						
							|  |  |  |     eval->diffuse *= value; | 
					
						
							|  |  |  |     eval->glossy *= value; | 
					
						
							|  |  |  |     eval->transmission *= value; | 
					
						
							| 
									
										
										
										
											2020-02-14 12:20:12 +01:00
										 |  |  |     eval->volume *= value; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-29 23:47:30 +02:00
										 |  |  |     /* skipping transparent, this function is used by for eval(), will be zero then */ | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |     eval->diffuse *= value; | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  |   eval->diffuse *= value; | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 14:19:01 +01:00
										 |  |  | ccl_device_inline float3 bsdf_eval_sum(const BsdfEval *eval) | 
					
						
							| 
									
										
										
										
											2016-10-29 23:47:30 +02:00
										 |  |  | { | 
					
						
							|  |  |  | #ifdef __PASSES__
 | 
					
						
							|  |  |  |   if (eval->use_light_pass) { | 
					
						
							| 
									
										
										
										
											2020-02-14 12:20:12 +01:00
										 |  |  |     return eval->diffuse + eval->glossy + eval->transmission + eval->volume; | 
					
						
							| 
									
										
										
										
											2016-10-29 23:47:30 +02:00
										 |  |  |   } | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  |     return eval->diffuse; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  | /* Path Radiance
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * We accumulate different render passes separately. After summing at the end | 
					
						
							| 
									
										
										
										
											2014-08-02 16:53:52 +10:00
										 |  |  |  * to get the combined result, it should be identical. We definite directly | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |  * visible as the first non-transparent hit, while indirectly visible are the | 
					
						
							|  |  |  |  * bounces after that. */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-08 21:19:37 +01:00
										 |  |  | ccl_device_inline void path_radiance_init(KernelGlobals *kg, PathRadiance *L) | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  | { | 
					
						
							|  |  |  |   /* clear all */ | 
					
						
							|  |  |  | #ifdef __PASSES__
 | 
					
						
							| 
									
										
										
										
											2019-12-08 21:19:37 +01:00
										 |  |  |   L->use_light_pass = kernel_data.film.use_light_pass; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-08 21:19:37 +01:00
										 |  |  |   if (kernel_data.film.use_light_pass) { | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |     L->indirect = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							|  |  |  |     L->direct_emission = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |     L->color_diffuse = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							|  |  |  |     L->color_glossy = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							|  |  |  |     L->color_transmission = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |     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); | 
					
						
							| 
									
										
										
										
											2020-02-14 12:20:12 +01:00
										 |  |  |     L->direct_volume = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |     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); | 
					
						
							| 
									
										
										
										
											2020-02-14 12:20:12 +01:00
										 |  |  |     L->indirect_volume = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-12 23:15:58 +02:00
										 |  |  |     L->transparent = 0.0f; | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |     L->emission = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							|  |  |  |     L->background = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							| 
									
										
										
										
											2012-02-28 16:45:08 +00:00
										 |  |  |     L->ao = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							| 
									
										
										
										
											2020-09-22 16:35:50 +02:00
										 |  |  |     L->shadow = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							| 
									
										
										
										
											2013-06-07 12:45:26 +00:00
										 |  |  |     L->mist = 0.0f; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-23 03:57:27 +02:00
										 |  |  |     L->state.diffuse = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							|  |  |  |     L->state.glossy = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							|  |  |  |     L->state.transmission = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							| 
									
										
										
										
											2020-02-14 12:20:12 +01:00
										 |  |  |     L->state.volume = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							| 
									
										
										
										
											2017-08-23 03:57:27 +02:00
										 |  |  |     L->state.direct = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |   } | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2016-09-14 20:09:37 +02:00
										 |  |  |   { | 
					
						
							| 
									
										
										
										
											2017-08-12 23:15:58 +02:00
										 |  |  |     L->transparent = 0.0f; | 
					
						
							| 
									
										
										
										
											2016-09-14 20:09:37 +02:00
										 |  |  |     L->emission = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-02-09 14:19:01 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef __SHADOW_TRICKS__
 | 
					
						
							|  |  |  |   L->path_total = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							|  |  |  |   L->path_total_shaded = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							| 
									
										
										
										
											2017-07-18 09:25:58 +02:00
										 |  |  |   L->shadow_background_color = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							|  |  |  |   L->shadow_throughput = 0.0f; | 
					
						
							| 
									
										
										
										
											2017-08-11 09:33:18 +02:00
										 |  |  |   L->shadow_transparency = 1.0f; | 
					
						
							| 
									
										
										
										
											2017-08-28 13:33:37 +02:00
										 |  |  |   L->has_shadow_catcher = 0; | 
					
						
							| 
									
										
										
										
											2017-02-09 14:19:01 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2017-05-07 14:40:58 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef __DENOISING_FEATURES__
 | 
					
						
							|  |  |  |   L->denoising_normal = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							|  |  |  |   L->denoising_albedo = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							|  |  |  |   L->denoising_depth = 0.0f; | 
					
						
							| 
									
										
										
										
											2017-08-12 21:07:55 +02:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef __KERNEL_DEBUG__
 | 
					
						
							|  |  |  |   L->debug_data.num_bvh_traversed_nodes = 0; | 
					
						
							|  |  |  |   L->debug_data.num_bvh_traversed_instances = 0; | 
					
						
							|  |  |  |   L->debug_data.num_bvh_intersections = 0; | 
					
						
							|  |  |  |   L->debug_data.num_ray_bounces = 0; | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-23 03:57:27 +02:00
										 |  |  | ccl_device_inline void path_radiance_bsdf_bounce(KernelGlobals *kg, | 
					
						
							|  |  |  |                                                  PathRadianceState *L_state, | 
					
						
							|  |  |  |                                                  ccl_addr_space float3 *throughput, | 
					
						
							|  |  |  |                                                  BsdfEval *bsdf_eval, | 
					
						
							|  |  |  |                                                  float bsdf_pdf, | 
					
						
							|  |  |  |                                                  int bounce, | 
					
						
							|  |  |  |                                                  int bsdf_label) | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  | { | 
					
						
							|  |  |  |   float inverse_pdf = 1.0f / bsdf_pdf; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef __PASSES__
 | 
					
						
							| 
									
										
										
										
											2017-08-23 03:57:27 +02:00
										 |  |  |   if (kernel_data.film.use_light_pass) { | 
					
						
							| 
									
										
										
										
											2012-03-20 16:16:17 +00:00
										 |  |  |     if (bounce == 0 && !(bsdf_label & LABEL_TRANSPARENT)) { | 
					
						
							|  |  |  |       /* first on directly visible surface */ | 
					
						
							|  |  |  |       float3 value = *throughput * inverse_pdf; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-23 03:57:27 +02:00
										 |  |  |       L_state->diffuse = bsdf_eval->diffuse * value; | 
					
						
							|  |  |  |       L_state->glossy = bsdf_eval->glossy * value; | 
					
						
							|  |  |  |       L_state->transmission = bsdf_eval->transmission * value; | 
					
						
							| 
									
										
										
										
											2020-02-14 12:20:12 +01:00
										 |  |  |       L_state->volume = bsdf_eval->volume * value; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-14 12:20:12 +01:00
										 |  |  |       *throughput = L_state->diffuse + L_state->glossy + L_state->transmission + L_state->volume; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-23 03:57:27 +02:00
										 |  |  |       L_state->direct = *throughput; | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							| 
									
										
										
										
											2012-03-20 16:16:17 +00:00
										 |  |  |       /* transparent bounce before first hit, or indirectly visible through BSDF */ | 
					
						
							| 
									
										
										
										
											2016-10-29 23:47:30 +02:00
										 |  |  |       float3 sum = (bsdf_eval_sum(bsdf_eval) + bsdf_eval->transparent) * inverse_pdf; | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |       *throughput *= sum; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |   } | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2016-09-14 20:09:37 +02:00
										 |  |  |   { | 
					
						
							|  |  |  |     *throughput *= bsdf_eval->diffuse * inverse_pdf; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-08 21:19:37 +01:00
										 |  |  | #ifdef __CLAMP_SAMPLE__
 | 
					
						
							|  |  |  | ccl_device_forceinline void path_radiance_clamp(KernelGlobals *kg, float3 *L, int bounce) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   float limit = (bounce > 0) ? kernel_data.integrator.sample_clamp_indirect : | 
					
						
							|  |  |  |                                kernel_data.integrator.sample_clamp_direct; | 
					
						
							|  |  |  |   float sum = reduce_add(fabs(*L)); | 
					
						
							|  |  |  |   if (sum > limit) { | 
					
						
							|  |  |  |     *L *= limit / sum; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ccl_device_forceinline void path_radiance_clamp_throughput(KernelGlobals *kg, | 
					
						
							|  |  |  |                                                            float3 *L, | 
					
						
							|  |  |  |                                                            float3 *throughput, | 
					
						
							|  |  |  |                                                            int bounce) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   float limit = (bounce > 0) ? kernel_data.integrator.sample_clamp_indirect : | 
					
						
							|  |  |  |                                kernel_data.integrator.sample_clamp_direct; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   float sum = reduce_add(fabs(*L)); | 
					
						
							|  |  |  |   if (sum > limit) { | 
					
						
							|  |  |  |     float clamp_factor = limit / sum; | 
					
						
							|  |  |  |     *L *= clamp_factor; | 
					
						
							|  |  |  |     *throughput *= clamp_factor; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ccl_device_inline void path_radiance_accum_emission(KernelGlobals *kg, | 
					
						
							|  |  |  |                                                     PathRadiance *L, | 
					
						
							| 
									
										
										
										
											2017-08-28 13:33:37 +02:00
										 |  |  |                                                     ccl_addr_space PathState *state, | 
					
						
							|  |  |  |                                                     float3 throughput, | 
					
						
							|  |  |  |                                                     float3 value) | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-08-28 13:33:37 +02:00
										 |  |  | #ifdef __SHADOW_TRICKS__
 | 
					
						
							|  |  |  |   if (state->flag & PATH_RAY_SHADOW_CATCHER) { | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-08 21:19:37 +01:00
										 |  |  |   float3 contribution = throughput * value; | 
					
						
							|  |  |  | #ifdef __CLAMP_SAMPLE__
 | 
					
						
							|  |  |  |   path_radiance_clamp(kg, &contribution, state->bounce - 1); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  | #ifdef __PASSES__
 | 
					
						
							|  |  |  |   if (L->use_light_pass) { | 
					
						
							| 
									
										
										
										
											2017-08-28 13:33:37 +02:00
										 |  |  |     if (state->bounce == 0) | 
					
						
							| 
									
										
										
										
											2019-12-08 21:19:37 +01:00
										 |  |  |       L->emission += contribution; | 
					
						
							| 
									
										
										
										
											2017-08-28 13:33:37 +02:00
										 |  |  |     else if (state->bounce == 1) | 
					
						
							| 
									
										
										
										
											2019-12-08 21:19:37 +01:00
										 |  |  |       L->direct_emission += contribution; | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |     else | 
					
						
							| 
									
										
										
										
											2019-12-08 21:19:37 +01:00
										 |  |  |       L->indirect += contribution; | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |   } | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2016-09-14 20:09:37 +02:00
										 |  |  |   { | 
					
						
							| 
									
										
										
										
											2019-12-08 21:19:37 +01:00
										 |  |  |     L->emission += contribution; | 
					
						
							| 
									
										
										
										
											2016-09-14 20:09:37 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-08 21:19:37 +01:00
										 |  |  | ccl_device_inline void path_radiance_accum_ao(KernelGlobals *kg, | 
					
						
							|  |  |  |                                               PathRadiance *L, | 
					
						
							| 
									
										
										
										
											2017-05-07 14:40:58 +02:00
										 |  |  |                                               ccl_addr_space PathState *state, | 
					
						
							| 
									
										
										
										
											2017-02-09 14:19:01 +01:00
										 |  |  |                                               float3 throughput, | 
					
						
							|  |  |  |                                               float3 alpha, | 
					
						
							|  |  |  |                                               float3 bsdf, | 
					
						
							| 
									
										
										
										
											2017-05-07 14:40:58 +02:00
										 |  |  |                                               float3 ao) | 
					
						
							| 
									
										
										
										
											2012-02-28 16:45:08 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-08-21 12:04:40 +02:00
										 |  |  | #ifdef __PASSES__
 | 
					
						
							| 
									
										
										
										
											2018-08-20 16:09:17 +02:00
										 |  |  |   /* Store AO pass. */ | 
					
						
							|  |  |  |   if (L->use_light_pass && state->bounce == 0) { | 
					
						
							|  |  |  |     L->ao += alpha * throughput * ao; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-08-21 12:04:40 +02:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-08-20 16:09:17 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-28 13:33:37 +02:00
										 |  |  | #ifdef __SHADOW_TRICKS__
 | 
					
						
							| 
									
										
										
										
											2018-08-20 16:09:17 +02:00
										 |  |  |   /* For shadow catcher, accumulate ratio. */ | 
					
						
							| 
									
										
										
										
											2017-08-28 13:33:37 +02:00
										 |  |  |   if (state->flag & PATH_RAY_STORE_SHADOW_INFO) { | 
					
						
							|  |  |  |     float3 light = throughput * bsdf; | 
					
						
							|  |  |  |     L->path_total += light; | 
					
						
							|  |  |  |     L->path_total_shaded += ao * light; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (state->flag & PATH_RAY_SHADOW_CATCHER) { | 
					
						
							|  |  |  |       return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-08 21:19:37 +01:00
										 |  |  |   float3 contribution = throughput * bsdf * ao; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-28 16:45:08 +00:00
										 |  |  | #ifdef __PASSES__
 | 
					
						
							|  |  |  |   if (L->use_light_pass) { | 
					
						
							| 
									
										
										
										
											2017-05-07 14:40:58 +02:00
										 |  |  |     if (state->bounce == 0) { | 
					
						
							| 
									
										
										
										
											2018-08-20 16:09:17 +02:00
										 |  |  |       /* Directly visible lighting. */ | 
					
						
							| 
									
										
										
										
											2019-12-08 21:19:37 +01:00
										 |  |  |       L->direct_diffuse += contribution; | 
					
						
							| 
									
										
										
										
											2012-02-28 16:45:08 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							| 
									
										
										
										
											2018-08-20 16:09:17 +02:00
										 |  |  |       /* Indirectly visible lighting after BSDF bounce. */ | 
					
						
							| 
									
										
										
										
											2019-12-08 21:19:37 +01:00
										 |  |  |       L->indirect += contribution; | 
					
						
							| 
									
										
										
										
											2012-02-28 16:45:08 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2016-09-14 20:09:37 +02:00
										 |  |  |   { | 
					
						
							| 
									
										
										
										
											2019-12-08 21:19:37 +01:00
										 |  |  |     L->emission += contribution; | 
					
						
							| 
									
										
										
										
											2016-09-14 20:09:37 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-02-09 14:19:01 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ccl_device_inline void path_radiance_accum_total_ao(PathRadiance *L, | 
					
						
							| 
									
										
										
										
											2017-05-07 14:40:58 +02:00
										 |  |  |                                                     ccl_addr_space PathState *state, | 
					
						
							| 
									
										
										
										
											2017-02-09 14:19:01 +01:00
										 |  |  |                                                     float3 throughput, | 
					
						
							|  |  |  |                                                     float3 bsdf) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | #ifdef __SHADOW_TRICKS__
 | 
					
						
							| 
									
										
										
										
											2017-05-07 14:40:58 +02:00
										 |  |  |   if (state->flag & PATH_RAY_STORE_SHADOW_INFO) { | 
					
						
							|  |  |  |     L->path_total += throughput * bsdf; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-02-09 14:19:01 +01:00
										 |  |  | #else
 | 
					
						
							|  |  |  |   (void)L; | 
					
						
							| 
									
										
										
										
											2017-05-07 14:40:58 +02:00
										 |  |  |   (void)state; | 
					
						
							| 
									
										
										
										
											2017-02-09 14:19:01 +01:00
										 |  |  |   (void)throughput; | 
					
						
							|  |  |  |   (void)bsdf; | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2012-02-28 16:45:08 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-08 21:19:37 +01:00
										 |  |  | ccl_device_inline void path_radiance_accum_light(KernelGlobals *kg, | 
					
						
							|  |  |  |                                                  PathRadiance *L, | 
					
						
							| 
									
										
										
										
											2017-05-07 14:40:58 +02:00
										 |  |  |                                                  ccl_addr_space PathState *state, | 
					
						
							|  |  |  |                                                  float3 throughput, | 
					
						
							|  |  |  |                                                  BsdfEval *bsdf_eval, | 
					
						
							|  |  |  |                                                  float3 shadow, | 
					
						
							|  |  |  |                                                  float shadow_fac, | 
					
						
							|  |  |  |                                                  bool is_lamp) | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-08-28 13:33:37 +02:00
										 |  |  | #ifdef __SHADOW_TRICKS__
 | 
					
						
							|  |  |  |   if (state->flag & PATH_RAY_STORE_SHADOW_INFO) { | 
					
						
							|  |  |  |     float3 light = throughput * bsdf_eval->sum_no_mis; | 
					
						
							|  |  |  |     L->path_total += light; | 
					
						
							|  |  |  |     L->path_total_shaded += shadow * light; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (state->flag & PATH_RAY_SHADOW_CATCHER) { | 
					
						
							|  |  |  |       return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-08 21:19:37 +01:00
										 |  |  |   float3 shaded_throughput = throughput * shadow; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  | #ifdef __PASSES__
 | 
					
						
							|  |  |  |   if (L->use_light_pass) { | 
					
						
							| 
									
										
										
										
											2019-12-08 21:19:37 +01:00
										 |  |  |     /* Compute the clamping based on the total contribution.
 | 
					
						
							|  |  |  |      * The resulting scale is then be applied to all individual components. */ | 
					
						
							|  |  |  |     float3 full_contribution = shaded_throughput * bsdf_eval_sum(bsdf_eval); | 
					
						
							|  |  |  | #  ifdef __CLAMP_SAMPLE__
 | 
					
						
							|  |  |  |     path_radiance_clamp_throughput(kg, &full_contribution, &shaded_throughput, state->bounce); | 
					
						
							|  |  |  | #  endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-07 14:40:58 +02:00
										 |  |  |     if (state->bounce == 0) { | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |       /* directly visible lighting */ | 
					
						
							| 
									
										
										
										
											2019-12-08 21:19:37 +01:00
										 |  |  |       L->direct_diffuse += shaded_throughput * bsdf_eval->diffuse; | 
					
						
							|  |  |  |       L->direct_glossy += shaded_throughput * bsdf_eval->glossy; | 
					
						
							|  |  |  |       L->direct_transmission += shaded_throughput * bsdf_eval->transmission; | 
					
						
							| 
									
										
										
										
											2020-02-14 12:20:12 +01:00
										 |  |  |       L->direct_volume += shaded_throughput * bsdf_eval->volume; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-28 10:39:21 +00:00
										 |  |  |       if (is_lamp) { | 
					
						
							| 
									
										
										
										
											2020-09-22 16:35:50 +02:00
										 |  |  |         L->shadow += shadow * shadow_fac; | 
					
						
							| 
									
										
										
										
											2012-03-28 10:39:21 +00:00
										 |  |  |       } | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |       /* indirectly visible lighting after BSDF bounce */ | 
					
						
							| 
									
										
										
										
											2019-12-08 21:19:37 +01:00
										 |  |  |       L->indirect += full_contribution; | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2016-09-14 20:09:37 +02:00
										 |  |  |   { | 
					
						
							| 
									
										
										
										
											2019-12-08 21:19:37 +01:00
										 |  |  |     float3 contribution = shaded_throughput * bsdf_eval->diffuse; | 
					
						
							|  |  |  |     path_radiance_clamp(kg, &contribution, state->bounce); | 
					
						
							|  |  |  |     L->emission += contribution; | 
					
						
							| 
									
										
										
										
											2016-09-14 20:09:37 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-02-09 14:19:01 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ccl_device_inline void path_radiance_accum_total_light(PathRadiance *L, | 
					
						
							| 
									
										
										
										
											2017-05-07 14:40:58 +02:00
										 |  |  |                                                        ccl_addr_space PathState *state, | 
					
						
							| 
									
										
										
										
											2017-02-09 14:19:01 +01:00
										 |  |  |                                                        float3 throughput, | 
					
						
							|  |  |  |                                                        const BsdfEval *bsdf_eval) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | #ifdef __SHADOW_TRICKS__
 | 
					
						
							| 
									
										
										
										
											2017-05-07 14:40:58 +02:00
										 |  |  |   if (state->flag & PATH_RAY_STORE_SHADOW_INFO) { | 
					
						
							|  |  |  |     L->path_total += throughput * bsdf_eval->sum_no_mis; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-02-09 14:19:01 +01:00
										 |  |  | #else
 | 
					
						
							|  |  |  |   (void)L; | 
					
						
							| 
									
										
										
										
											2017-05-07 14:40:58 +02:00
										 |  |  |   (void)state; | 
					
						
							| 
									
										
										
										
											2017-02-09 14:19:01 +01:00
										 |  |  |   (void)throughput; | 
					
						
							|  |  |  |   (void)bsdf_eval; | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-08 21:19:37 +01:00
										 |  |  | ccl_device_inline void path_radiance_accum_background(KernelGlobals *kg, | 
					
						
							|  |  |  |                                                       PathRadiance *L, | 
					
						
							| 
									
										
										
										
											2017-08-11 09:33:18 +02:00
										 |  |  |                                                       ccl_addr_space PathState *state, | 
					
						
							|  |  |  |                                                       float3 throughput, | 
					
						
							|  |  |  |                                                       float3 value) | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-08-28 13:33:37 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef __SHADOW_TRICKS__
 | 
					
						
							|  |  |  |   if (state->flag & PATH_RAY_STORE_SHADOW_INFO) { | 
					
						
							|  |  |  |     L->path_total += throughput * value; | 
					
						
							|  |  |  |     L->path_total_shaded += throughput * value * L->shadow_transparency; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (state->flag & PATH_RAY_SHADOW_CATCHER) { | 
					
						
							|  |  |  |       return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-08 21:19:37 +01:00
										 |  |  |   float3 contribution = throughput * value; | 
					
						
							|  |  |  | #ifdef __CLAMP_SAMPLE__
 | 
					
						
							|  |  |  |   path_radiance_clamp(kg, &contribution, state->bounce - 1); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  | #ifdef __PASSES__
 | 
					
						
							|  |  |  |   if (L->use_light_pass) { | 
					
						
							| 
									
										
										
										
											2018-01-11 20:03:31 +01:00
										 |  |  |     if (state->flag & PATH_RAY_TRANSPARENT_BACKGROUND) | 
					
						
							| 
									
										
										
										
											2019-12-08 21:19:37 +01:00
										 |  |  |       L->background += contribution; | 
					
						
							| 
									
										
										
										
											2017-02-09 14:19:01 +01:00
										 |  |  |     else if (state->bounce == 1) | 
					
						
							| 
									
										
										
										
											2019-12-08 21:19:37 +01:00
										 |  |  |       L->direct_emission += contribution; | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |     else | 
					
						
							| 
									
										
										
										
											2019-12-08 21:19:37 +01:00
										 |  |  |       L->indirect += contribution; | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |   } | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2016-09-14 20:09:37 +02:00
										 |  |  |   { | 
					
						
							| 
									
										
										
										
											2019-12-08 21:19:37 +01:00
										 |  |  |     L->emission += contribution; | 
					
						
							| 
									
										
										
										
											2016-09-14 20:09:37 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-02-09 14:19:01 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-07 14:40:58 +02:00
										 |  |  | #ifdef __DENOISING_FEATURES__
 | 
					
						
							| 
									
										
										
										
											2020-01-21 04:45:51 +01:00
										 |  |  |   L->denoising_albedo += state->denoising_feature_weight * state->denoising_feature_throughput * | 
					
						
							|  |  |  |                          value; | 
					
						
							| 
									
										
										
										
											2017-05-07 14:40:58 +02:00
										 |  |  | #endif /* __DENOISING_FEATURES__ */
 | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-28 13:33:37 +02:00
										 |  |  | ccl_device_inline void path_radiance_accum_transparent(PathRadiance *L, | 
					
						
							|  |  |  |                                                        ccl_addr_space PathState *state, | 
					
						
							|  |  |  |                                                        float3 throughput) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   L->transparent += average(throughput); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef __SHADOW_TRICKS__
 | 
					
						
							|  |  |  | ccl_device_inline void path_radiance_accum_shadowcatcher(PathRadiance *L, | 
					
						
							|  |  |  |                                                          float3 throughput, | 
					
						
							|  |  |  |                                                          float3 background) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   L->shadow_throughput += average(throughput); | 
					
						
							|  |  |  |   L->shadow_background_color += throughput * background; | 
					
						
							|  |  |  |   L->has_shadow_catcher = 1; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-16 00:17:10 +01:00
										 |  |  | ccl_device_inline void path_radiance_sum_indirect(PathRadiance *L) | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-01-15 20:13:19 +00:00
										 |  |  | #ifdef __PASSES__
 | 
					
						
							| 
									
										
										
										
											2013-01-15 19:17:51 +00:00
										 |  |  |   /* this division is a bit ugly, but means we only have to keep track of
 | 
					
						
							|  |  |  |    * only a single throughput further along the path, here we recover just | 
					
						
							| 
									
										
										
										
											2013-08-03 21:45:57 +00:00
										 |  |  |    * the indirect path that is not influenced by any particular BSDF type */ | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |   if (L->use_light_pass) { | 
					
						
							| 
									
										
										
										
											2017-08-23 03:57:27 +02:00
										 |  |  |     L->direct_emission = safe_divide_color(L->direct_emission, L->state.direct); | 
					
						
							|  |  |  |     L->direct_diffuse += L->state.diffuse * L->direct_emission; | 
					
						
							|  |  |  |     L->direct_glossy += L->state.glossy * L->direct_emission; | 
					
						
							|  |  |  |     L->direct_transmission += L->state.transmission * L->direct_emission; | 
					
						
							| 
									
										
										
										
											2020-02-14 12:20:12 +01:00
										 |  |  |     L->direct_volume += L->state.volume * L->direct_emission; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-23 03:57:27 +02:00
										 |  |  |     L->indirect = safe_divide_color(L->indirect, L->state.direct); | 
					
						
							|  |  |  |     L->indirect_diffuse += L->state.diffuse * L->indirect; | 
					
						
							|  |  |  |     L->indirect_glossy += L->state.glossy * L->indirect; | 
					
						
							|  |  |  |     L->indirect_transmission += L->state.transmission * L->indirect; | 
					
						
							| 
									
										
										
										
											2020-02-14 12:20:12 +01:00
										 |  |  |     L->indirect_volume += L->state.volume * L->indirect; | 
					
						
							| 
									
										
										
										
											2013-01-15 19:17:51 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2013-01-15 20:13:19 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2013-01-15 19:17:51 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-16 00:17:10 +01:00
										 |  |  | ccl_device_inline void path_radiance_reset_indirect(PathRadiance *L) | 
					
						
							| 
									
										
										
										
											2013-01-15 19:17:51 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-01-15 20:13:19 +00:00
										 |  |  | #ifdef __PASSES__
 | 
					
						
							| 
									
										
										
										
											2013-01-15 19:17:51 +00:00
										 |  |  |   if (L->use_light_pass) { | 
					
						
							| 
									
										
										
										
											2017-08-23 03:57:27 +02:00
										 |  |  |     L->state.diffuse = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							|  |  |  |     L->state.glossy = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							|  |  |  |     L->state.transmission = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							| 
									
										
										
										
											2020-02-14 12:20:12 +01:00
										 |  |  |     L->state.volume = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							| 
									
										
										
										
											2013-01-15 19:17:51 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     L->direct_emission = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							|  |  |  |     L->indirect = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2013-01-15 20:13:19 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2013-01-15 19:17:51 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-02 15:59:12 +05:00
										 |  |  | ccl_device_inline void path_radiance_copy_indirect(PathRadiance *L, const PathRadiance *L_src) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | #ifdef __PASSES__
 | 
					
						
							|  |  |  |   if (L->use_light_pass) { | 
					
						
							| 
									
										
										
										
											2017-08-23 03:57:27 +02:00
										 |  |  |     L->state = L_src->state; | 
					
						
							| 
									
										
										
										
											2015-12-02 15:59:12 +05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     L->direct_emission = L_src->direct_emission; | 
					
						
							|  |  |  |     L->indirect = L_src->indirect; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-28 13:33:37 +02:00
										 |  |  | #ifdef __SHADOW_TRICKS__
 | 
					
						
							|  |  |  | ccl_device_inline void path_radiance_sum_shadowcatcher(KernelGlobals *kg, | 
					
						
							|  |  |  |                                                        PathRadiance *L, | 
					
						
							|  |  |  |                                                        float3 *L_sum, | 
					
						
							|  |  |  |                                                        float *alpha) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   /* Calculate current shadow of the path. */ | 
					
						
							|  |  |  |   float path_total = average(L->path_total); | 
					
						
							|  |  |  |   float shadow; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-06 17:27:34 +05:00
										 |  |  |   if (UNLIKELY(!isfinite_safe(path_total))) { | 
					
						
							|  |  |  |     kernel_assert(!"Non-finite total radiance along the path"); | 
					
						
							|  |  |  |     shadow = 0.0f; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   else if (path_total == 0.0f) { | 
					
						
							| 
									
										
										
										
											2017-08-28 13:33:37 +02:00
										 |  |  |     shadow = L->shadow_transparency; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   else { | 
					
						
							|  |  |  |     float path_total_shaded = average(L->path_total_shaded); | 
					
						
							|  |  |  |     shadow = path_total_shaded / path_total; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-28 13:33:37 +02:00
										 |  |  |   /* Calculate final light sum and transparency for shadow catcher object. */ | 
					
						
							|  |  |  |   if (kernel_data.background.transparent) { | 
					
						
							|  |  |  |     *alpha -= L->shadow_throughput * shadow; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   else { | 
					
						
							|  |  |  |     L->shadow_background_color *= shadow; | 
					
						
							|  |  |  |     *L_sum += L->shadow_background_color; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ccl_device_inline float3 path_radiance_clamp_and_sum(KernelGlobals *kg, | 
					
						
							|  |  |  |                                                      PathRadiance *L, | 
					
						
							|  |  |  |                                                      float *alpha) | 
					
						
							| 
									
										
										
										
											2013-01-15 19:17:51 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-06-13 19:07:48 +02:00
										 |  |  |   float3 L_sum; | 
					
						
							| 
									
										
										
										
											2014-02-11 17:44:21 +01:00
										 |  |  |   /* Light Passes are used */ | 
					
						
							| 
									
										
										
										
											2013-01-15 19:17:51 +00:00
										 |  |  | #ifdef __PASSES__
 | 
					
						
							| 
									
										
										
										
											2015-06-13 19:07:48 +02:00
										 |  |  |   float3 L_direct, L_indirect; | 
					
						
							| 
									
										
										
										
											2013-01-15 19:17:51 +00:00
										 |  |  |   if (L->use_light_pass) { | 
					
						
							|  |  |  |     path_radiance_sum_indirect(L); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-14 12:20:12 +01:00
										 |  |  |     L_direct = L->direct_diffuse + L->direct_glossy + L->direct_transmission + L->direct_volume + | 
					
						
							|  |  |  |                L->emission; | 
					
						
							| 
									
										
										
										
											2014-09-05 16:17:24 +02:00
										 |  |  |     L_indirect = L->indirect_diffuse + L->indirect_glossy + L->indirect_transmission + | 
					
						
							| 
									
										
										
										
											2020-02-14 12:20:12 +01:00
										 |  |  |                  L->indirect_volume; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-11 12:18:10 +01:00
										 |  |  |     if (!kernel_data.background.transparent) | 
					
						
							|  |  |  |       L_direct += L->background; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-11 17:44:21 +01:00
										 |  |  |     L_sum = L_direct + L_indirect; | 
					
						
							|  |  |  |     float sum = fabsf((L_sum).x) + fabsf((L_sum).y) + fabsf((L_sum).z); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-11 17:44:21 +01:00
										 |  |  |     /* Reject invalid value */ | 
					
						
							| 
									
										
										
										
											2017-03-24 15:22:27 +01:00
										 |  |  |     if (!isfinite_safe(sum)) { | 
					
						
							| 
									
										
										
										
											2016-02-18 01:13:07 +01:00
										 |  |  |       kernel_assert(!"Non-finite sum in path_radiance_clamp_and_sum!"); | 
					
						
							| 
									
										
										
										
											2014-02-11 17:44:21 +01:00
										 |  |  |       L_sum = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-11 17:44:21 +01:00
										 |  |  |       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); | 
					
						
							| 
									
										
										
										
											2020-02-14 12:20:12 +01:00
										 |  |  |       L->direct_volume = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-11 17:44:21 +01:00
										 |  |  |       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); | 
					
						
							| 
									
										
										
										
											2020-02-14 12:20:12 +01:00
										 |  |  |       L->indirect_volume = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-11 17:44:21 +01:00
										 |  |  |       L->emission = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-11 17:44:21 +01:00
										 |  |  |   /* No Light Passes */ | 
					
						
							| 
									
										
										
											
												Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
  Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
											
										 
											2012-01-25 17:23:52 +00:00
										 |  |  |   else | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2016-09-14 20:09:37 +02:00
										 |  |  |   { | 
					
						
							|  |  |  |     L_sum = L->emission; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-28 13:33:37 +02:00
										 |  |  |     /* Reject invalid value */ | 
					
						
							|  |  |  |     float sum = fabsf((L_sum).x) + fabsf((L_sum).y) + fabsf((L_sum).z); | 
					
						
							|  |  |  |     if (!isfinite_safe(sum)) { | 
					
						
							|  |  |  |       kernel_assert(!"Non-finite final sum in path_radiance_clamp_and_sum!"); | 
					
						
							|  |  |  |       L_sum = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-09-14 20:09:37 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-28 13:33:37 +02:00
										 |  |  |   /* Compute alpha. */ | 
					
						
							|  |  |  |   *alpha = 1.0f - L->transparent; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-28 13:33:37 +02:00
										 |  |  |   /* Add shadow catcher contributions. */ | 
					
						
							|  |  |  | #ifdef __SHADOW_TRICKS__
 | 
					
						
							|  |  |  |   if (L->has_shadow_catcher) { | 
					
						
							|  |  |  |     path_radiance_sum_shadowcatcher(kg, L, &L_sum, alpha); | 
					
						
							| 
									
										
										
										
											2016-02-18 01:13:07 +01:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-08-28 13:33:37 +02:00
										 |  |  | #endif /* __SHADOW_TRICKS__ */
 | 
					
						
							| 
									
										
										
										
											2012-04-05 15:17:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-11 17:44:21 +01:00
										 |  |  |   return L_sum; | 
					
						
							| 
									
										
										
										
											2012-04-05 15:17:45 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-07 14:40:58 +02:00
										 |  |  | ccl_device_inline void path_radiance_split_denoising(KernelGlobals *kg, | 
					
						
							|  |  |  |                                                      PathRadiance *L, | 
					
						
							|  |  |  |                                                      float3 *noisy, | 
					
						
							|  |  |  |                                                      float3 *clean) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | #ifdef __PASSES__
 | 
					
						
							|  |  |  |   kernel_assert(L->use_light_pass); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-07 14:40:58 +02:00
										 |  |  |   *clean = L->emission + L->background; | 
					
						
							| 
									
										
										
										
											2020-02-14 12:20:12 +01:00
										 |  |  |   *noisy = L->direct_volume + L->indirect_volume; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-07 14:40:58 +02:00
										 |  |  | #  define ADD_COMPONENT(flag, component) \
 | 
					
						
							|  |  |  |     if (kernel_data.film.denoising_flags & flag) \ | 
					
						
							|  |  |  |       *clean += component; \ | 
					
						
							|  |  |  |     else \ | 
					
						
							|  |  |  |       *noisy += component; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-07 14:40:58 +02:00
										 |  |  |   ADD_COMPONENT(DENOISING_CLEAN_DIFFUSE_DIR, L->direct_diffuse); | 
					
						
							|  |  |  |   ADD_COMPONENT(DENOISING_CLEAN_DIFFUSE_IND, L->indirect_diffuse); | 
					
						
							|  |  |  |   ADD_COMPONENT(DENOISING_CLEAN_GLOSSY_DIR, L->direct_glossy); | 
					
						
							|  |  |  |   ADD_COMPONENT(DENOISING_CLEAN_GLOSSY_IND, L->indirect_glossy); | 
					
						
							|  |  |  |   ADD_COMPONENT(DENOISING_CLEAN_TRANSMISSION_DIR, L->direct_transmission); | 
					
						
							|  |  |  |   ADD_COMPONENT(DENOISING_CLEAN_TRANSMISSION_IND, L->indirect_transmission); | 
					
						
							|  |  |  | #  undef ADD_COMPONENT
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  |   *noisy = L->emission; | 
					
						
							|  |  |  |   *clean = make_float3(0.0f, 0.0f, 0.0f); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-28 13:33:37 +02:00
										 |  |  | #ifdef __SHADOW_TRICKS__
 | 
					
						
							|  |  |  |   if (L->has_shadow_catcher) { | 
					
						
							|  |  |  |     *noisy += L->shadow_background_color; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-07 14:40:58 +02:00
										 |  |  |   *noisy = ensure_finite3(*noisy); | 
					
						
							|  |  |  |   *clean = ensure_finite3(*clean); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-28 13:33:37 +02:00
										 |  |  | ccl_device_inline void path_radiance_accum_sample(PathRadiance *L, PathRadiance *L_sample) | 
					
						
							| 
									
										
										
										
											2014-01-02 19:05:07 -02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-05-29 21:34:05 -04:00
										 |  |  | #ifdef __SPLIT_KERNEL__
 | 
					
						
							|  |  |  | #  define safe_float3_add(f, v) \
 | 
					
						
							|  |  |  |     do { \ | 
					
						
							|  |  |  |       ccl_global float *p = (ccl_global float *)(&(f)); \ | 
					
						
							|  |  |  |       atomic_add_and_fetch_float(p + 0, (v).x); \ | 
					
						
							|  |  |  |       atomic_add_and_fetch_float(p + 1, (v).y); \ | 
					
						
							|  |  |  |       atomic_add_and_fetch_float(p + 2, (v).z); \ | 
					
						
							|  |  |  |     } while (0) | 
					
						
							| 
									
										
										
										
											2017-08-28 13:33:37 +02:00
										 |  |  | #  define safe_float_add(f, v) atomic_add_and_fetch_float(&(f), (v))
 | 
					
						
							| 
									
										
										
										
											2017-05-29 21:34:05 -04:00
										 |  |  | #else
 | 
					
						
							|  |  |  | #  define safe_float3_add(f, v) (f) += (v)
 | 
					
						
							| 
									
										
										
										
											2017-08-28 13:33:37 +02:00
										 |  |  | #  define safe_float_add(f, v) (f) += (v)
 | 
					
						
							| 
									
										
										
										
											2017-05-29 21:34:05 -04:00
										 |  |  | #endif /* __SPLIT_KERNEL__ */
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-11 16:36:18 +02:00
										 |  |  | #ifdef __PASSES__
 | 
					
						
							| 
									
										
										
										
											2017-08-28 13:33:37 +02:00
										 |  |  |   safe_float3_add(L->direct_diffuse, L_sample->direct_diffuse); | 
					
						
							|  |  |  |   safe_float3_add(L->direct_glossy, L_sample->direct_glossy); | 
					
						
							|  |  |  |   safe_float3_add(L->direct_transmission, L_sample->direct_transmission); | 
					
						
							| 
									
										
										
										
											2020-02-14 12:20:12 +01:00
										 |  |  |   safe_float3_add(L->direct_volume, L_sample->direct_volume); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-28 13:33:37 +02:00
										 |  |  |   safe_float3_add(L->indirect_diffuse, L_sample->indirect_diffuse); | 
					
						
							|  |  |  |   safe_float3_add(L->indirect_glossy, L_sample->indirect_glossy); | 
					
						
							|  |  |  |   safe_float3_add(L->indirect_transmission, L_sample->indirect_transmission); | 
					
						
							| 
									
										
										
										
											2020-02-14 12:20:12 +01:00
										 |  |  |   safe_float3_add(L->indirect_volume, L_sample->indirect_volume); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-28 13:33:37 +02:00
										 |  |  |   safe_float3_add(L->background, L_sample->background); | 
					
						
							|  |  |  |   safe_float3_add(L->ao, L_sample->ao); | 
					
						
							|  |  |  |   safe_float3_add(L->shadow, L_sample->shadow); | 
					
						
							|  |  |  |   safe_float_add(L->mist, L_sample->mist); | 
					
						
							| 
									
										
										
										
											2017-05-29 21:34:05 -04:00
										 |  |  | #endif /* __PASSES__ */
 | 
					
						
							| 
									
										
										
										
											2017-08-28 13:33:37 +02:00
										 |  |  |   safe_float3_add(L->emission, L_sample->emission); | 
					
						
							| 
									
										
										
										
											2017-05-29 21:34:05 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-28 13:33:37 +02:00
										 |  |  | #undef safe_float_add
 | 
					
						
							| 
									
										
										
										
											2017-05-29 21:34:05 -04:00
										 |  |  | #undef safe_float3_add
 | 
					
						
							| 
									
										
										
										
											2014-01-02 19:05:07 -02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 14:19:01 +01:00
										 |  |  | CCL_NAMESPACE_END |