2022-02-11 13:53:21 +01:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
2013-07-31 20:56:32 +00:00
|
|
|
*
|
2022-02-11 13:53:21 +01:00
|
|
|
* Adapted from Open Shading Language
|
2013-07-31 20:56:32 +00:00
|
|
|
* Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al.
|
|
|
|
|
* All Rights Reserved.
|
|
|
|
|
*
|
2022-02-11 13:53:21 +01:00
|
|
|
* Modifications Copyright 2011-2022 Blender Foundation. */
|
2013-07-31 20:56:32 +00:00
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
2013-07-31 20:56:32 +00:00
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
/* Multiple importance sampling utilities. */
|
2013-07-31 20:56:32 +00:00
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
ccl_device float balance_heuristic(float a, float b)
|
2013-07-31 20:56:32 +00:00
|
|
|
{
|
2021-10-24 14:19:19 +02:00
|
|
|
return (a) / (a + b);
|
|
|
|
|
}
|
2013-07-31 20:56:32 +00:00
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
ccl_device float balance_heuristic_3(float a, float b, float c)
|
|
|
|
|
{
|
|
|
|
|
return (a) / (a + b + c);
|
|
|
|
|
}
|
2013-07-31 20:56:32 +00:00
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
ccl_device float power_heuristic(float a, float b)
|
|
|
|
|
{
|
|
|
|
|
return (a * a) / (a * a + b * b);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ccl_device float power_heuristic_3(float a, float b, float c)
|
|
|
|
|
{
|
|
|
|
|
return (a * a) / (a * a + b * b + c * c);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ccl_device float max_heuristic(float a, float b)
|
|
|
|
|
{
|
|
|
|
|
return (a > b) ? 1.0f : 0.0f;
|
2013-07-31 20:56:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|