From a8209105010cee5e8b53786c939576b3e9d928cf Mon Sep 17 00:00:00 2001 From: yuanjiajia <1139393632@qq.com> Date: Wed, 19 Jan 2022 17:41:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E5=9B=9B=E4=B8=AA?= =?UTF-8?q?=E7=B1=BB=E6=96=87=E4=BB=B6Sampler=E3=80=81Sobol=E3=80=81Random?= =?UTF-8?q?=E3=80=81Metropolis=EF=BC=9B=E4=BF=AE=E6=94=B9=E4=BA=86print.ph?= =?UTF-8?q?p;=E5=85=B6=E4=BB=96=E9=83=A8=E5=88=86=E6=96=87=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BA=86=E6=B3=A8=E9=87=8A=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/print.php | 7 +++++ src/core/Base.php | 7 +++++ src/scene/BaseCfg.php | 26 ++++++++++++----- src/scene/HybridBackforWard.php | 4 --- src/scene/Metropolis.php | 26 +++++++++++++++++ src/scene/OpenCL.php | 9 ++---- src/scene/Path.php | 9 +++--- src/scene/Random.php | 52 +++++++++++++++++++++++++++++++++ src/scene/Sampler.php | 43 +++++++++++++++++++++++++++ src/scene/Sobol.php | 51 ++++++++++++++++++++++++++++++++ 10 files changed, 211 insertions(+), 23 deletions(-) create mode 100644 src/scene/Metropolis.php create mode 100644 src/scene/Random.php create mode 100644 src/scene/Sampler.php create mode 100644 src/scene/Sobol.php diff --git a/examples/print.php b/examples/print.php index 7b004ac..5aa2ccf 100644 --- a/examples/print.php +++ b/examples/print.php @@ -22,4 +22,11 @@ echo $native; $path = new Path(['glossinessthreshold' => 0.999]); echo $path; + + +//设置打印 采样器 配置参数 +$sampler = new Sampler(['imagemutationrate' => 0.888]); +$sampler->random->overlapping = 32; +echo $sampler; + ?> diff --git a/src/core/Base.php b/src/core/Base.php index 3afd41a..ff525d3 100644 --- a/src/core/Base.php +++ b/src/core/Base.php @@ -4,6 +4,12 @@ namespace Blobt\Luxcore\core; class Base { + + + //打开或关闭 + const OPEN = true; + const CLOSE = false; + /** * 实现自动配置 */ @@ -15,4 +21,5 @@ class Base } } } + } diff --git a/src/scene/BaseCfg.php b/src/scene/BaseCfg.php index 68ad050..a9b96ea 100644 --- a/src/scene/BaseCfg.php +++ b/src/scene/BaseCfg.php @@ -38,20 +38,32 @@ class BaseCfg extends Base $name = implode(".", array_map('strtolower', StringHelper::camelStrToArray($name))); $value = $item->getValue($this); - if (is_string($value)) { + if (is_string($value)) + { $ret .= "{$className}.{$name} = \"{$value}\"\n"; - } else if (is_integer($value)) { + } + else if (is_integer($value)) + { $ret .= "{$className}.{$name} = {$value}\n"; - } else if (is_bool($value)) { + } + else if (is_bool($value)) + { $value = $value ? 1 : 0; $ret .= "{$className}.{$name} = {$value}\n"; - } else if (is_object($value) && $value instanceof BaseCfg) { + } + else if (is_object($value) && $value instanceof BaseCfg) + { $ret .= $value->toString($className); - } else if(is_null($value)){ + } + else if(is_null($value)) + { $ret .= "{$className}.{$name} = \"null\"\n"; - } else if(is_float($value)){ + } else if(is_float($value)) + { $ret .= "{$className}.{$name} = {$value}\n"; - }else{ + } + else + { $ret .= "{$className}.{$name} = \"unknow type\"\n"; } } diff --git a/src/scene/HybridBackforWard.php b/src/scene/HybridBackforWard.php index 5287dc2..7fbcc25 100644 --- a/src/scene/HybridBackforWard.php +++ b/src/scene/HybridBackforWard.php @@ -5,10 +5,6 @@ namespace Blobt\Luxcore\scene; class HybridBackforWard extends BaseCfg { - //打开或关闭 - const OPEN = true; - const CLOSE = false; - /** * @var bool 是否开启 自适应光线跟踪 参数设置 */ diff --git a/src/scene/Metropolis.php b/src/scene/Metropolis.php new file mode 100644 index 0000000..ea6c371 --- /dev/null +++ b/src/scene/Metropolis.php @@ -0,0 +1,26 @@ + diff --git a/src/scene/OpenCL.php b/src/scene/OpenCL.php index f99fb07..76a1d14 100644 --- a/src/scene/OpenCL.php +++ b/src/scene/OpenCL.php @@ -4,19 +4,14 @@ namespace Blobt\Luxcore\scene; class OpenCL extends BaseCfg { - - - //打开或关闭 - const OPEN = 1; - const CLOSE = 0; /** - * @var integral 是否使用cpu渲染,默认是 + * @var bool 是否使用cpu渲染,默认是 */ public $cpuUse = self::CLOSE; /** - * @var integral 是否使用gpu渲染,默认否 + * @var bool 是否使用gpu渲染,默认否 */ public $gpuUse = self::OPEN; diff --git a/src/scene/Path.php b/src/scene/Path.php index 22a1b5f..7044a28 100644 --- a/src/scene/Path.php +++ b/src/scene/Path.php @@ -6,11 +6,6 @@ use Blobt\Luxcore\core\Base; class Path extends BaseCfg { - - //打开或关闭 - const OPEN = true; - const CLOSE = false; - /** * @var object 存储一个 PathDepth类 对象 */ @@ -31,6 +26,10 @@ class Path extends BaseCfg */ public $clampingVarianceMaxvalue = 1000; + /** + * @var integer $maxdepth 当渲染引擎为 BIDIR 时,光线跟踪的最大深度(取值:大于0的整数) + */ + public $maxdepth = 10; /** * 实例 PathDepth类、HybridBackforWard类的两个对象 diff --git a/src/scene/Random.php b/src/scene/Random.php new file mode 100644 index 0000000..33609a1 --- /dev/null +++ b/src/scene/Random.php @@ -0,0 +1,52 @@ + diff --git a/src/scene/Sampler.php b/src/scene/Sampler.php new file mode 100644 index 0000000..5c1349e --- /dev/null +++ b/src/scene/Sampler.php @@ -0,0 +1,43 @@ +sobol = new Sobol($config); + $this->random = new Random($config); + $this->metropolis = new Metropolis($config); + Base::__construct($config); + } + +} diff --git a/src/scene/Sobol.php b/src/scene/Sobol.php new file mode 100644 index 0000000..911a589 --- /dev/null +++ b/src/scene/Sobol.php @@ -0,0 +1,51 @@ + \ No newline at end of file