From a821e1d754a991f9efa6d6ae221c3c0dccf47eb4 Mon Sep 17 00:00:00 2001 From: yuanjiajia <1139393632@qq.com> Date: Wed, 9 Feb 2022 18:37:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E2=80=9CBase.php?= =?UTF-8?q?=E2=80=9D=E3=80=81=E2=80=9CBaseCfg.php=E2=80=9D=E3=80=81?= =?UTF-8?q?=E2=80=9CRenderEngine.php=E2=80=9D=E3=80=81=E2=80=9CSampler.php?= =?UTF-8?q?=E2=80=9D=E3=80=81=E2=80=9CStringHelper.php=E2=80=9D=E4=BA=94?= =?UTF-8?q?=E4=B8=AA=E7=B1=BB=E6=96=87=E4=BB=B6=EF=BC=8C=E5=92=8C=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B=E6=96=87=E4=BB=B6=EF=BC=9B=E6=96=B0=E5=A2=9E=E2=80=9C?= =?UTF-8?q?Film.php=E2=80=9D=E3=80=81=E2=80=9CFilter.php=E2=80=9D=E3=80=81?= =?UTF-8?q?=E2=80=9CNoiseEstimation.php=E2=80=9D=E4=B8=89=E4=B8=AA?= =?UTF-8?q?=E7=B1=BB=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/print.php | 19 ++++- src/core/Base.php | 5 -- src/scene/BaseCfg.php | 24 +++++- src/scene/Film.php | 139 ++++++++++++++++++++++++++++++++++ src/scene/Filter.php | 40 ++++++++++ src/scene/NoiseEstimation.php | 21 +++++ src/scene/RenderEngine.php | 5 ++ src/scene/Sampler.php | 12 ++- src/utils/StringHelper.php | 51 +++++++++++++ 9 files changed, 304 insertions(+), 12 deletions(-) create mode 100644 src/scene/Film.php create mode 100644 src/scene/Filter.php create mode 100644 src/scene/NoiseEstimation.php diff --git a/examples/print.php b/examples/print.php index 5aa2ccf..41683ea 100644 --- a/examples/print.php +++ b/examples/print.php @@ -1,10 +1,11 @@ 0.999]); echo $path; - - //设置打印 采样器 配置参数 $sampler = new Sampler(['imagemutationrate' => 0.888]); $sampler->random->overlapping = 32; echo $sampler; +*/ + +$film = new Film(); + +echo "$film\n"; + +$film->outputs[3]['index'] = '中国最牛'; + +echo $film; + + + ?> diff --git a/src/core/Base.php b/src/core/Base.php index ff525d3..9b2a5fe 100644 --- a/src/core/Base.php +++ b/src/core/Base.php @@ -4,11 +4,6 @@ namespace Blobt\Luxcore\core; class Base { - - - //打开或关闭 - const OPEN = true; - const CLOSE = false; /** * 实现自动配置 diff --git a/src/scene/BaseCfg.php b/src/scene/BaseCfg.php index a9b96ea..9191c71 100644 --- a/src/scene/BaseCfg.php +++ b/src/scene/BaseCfg.php @@ -1,13 +1,25 @@ toString(); @@ -18,6 +30,7 @@ class BaseCfg extends Base $object = new \ReflectionClass($this); $properties = $object->getProperties(); + //var_dump($properties); //获取类名 -> 去除命名空间 -> 转成全小写 @@ -58,10 +71,18 @@ class BaseCfg extends Base 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 if(is_array($value)) + { + foreach(StringHelper::arrayToString($value) as $value) + { + $ret .= "{$className}.{$name}.{$value}\n"; + } + } else { $ret .= "{$className}.{$name} = \"unknow type\"\n"; @@ -69,4 +90,5 @@ class BaseCfg extends Base } return $ret; } + } diff --git a/src/scene/Film.php b/src/scene/Film.php new file mode 100644 index 0000000..81a274d --- /dev/null +++ b/src/scene/Film.php @@ -0,0 +1,139 @@ +noiseEstimation = new NoiseEstimation($config); + $this->filter = new Filter($config); + + $this->imagepipelines = array( + '000' =>array( + '0' => array( + 'type' => "NOP", + ), + '1' => array( + 'type' => "TONEMAP_LINEAR", + 'scales' => 1 + ), + '2' => array( + 'type' => "GAMMA_CORRECTION", + 'value' => 2.2 + ), + 'radiancescales' => array( + '0' => array( + 'enabled' => 1, + 'globalscale' => 1, + 'rgbscale' => '1 1 1' + ) + ) + ), + + '001' =>array( + '0' => array( + 'type' => "BCD_DENOISER", + 'scales' => 3, + 'histdistthresh' => 1, + 'patchradius' => 1, + 'searchwindowradius' => 6, + 'filterspikes' => 0 + ), + '1' => array( + 'type' => "NOP" + ), + '2' => array( + 'type' => "TONEMAP_LINEAR", + 'scales' => 1 + ), + '3' => array( + 'type' => "GAMMA_CORRECTION", + 'value' => 2.2 + ), + 'radiancescales' => array( + '0' => array( + 'enabled' => 1, + 'globalscale' => 1, + 'rgbscale' => '0.99 0.5 0.8' + ) + ) + ) + ); + + + $this->outputs = array( + '0' => array( + 'type' => 'RGB_IMAGEPIPELINE', + 'index' => 0, + 'filename' => 'RGB_IMAGEPIPELINE_0.png' + ), + + '1' => array( + 'type' => 'ALBEDO', + 'filename' => 'ALBEDO.exr' + ), + + '2' => array( + 'type' => 'AVG_SHADING_NORMAL', + 'filename' => 'AVG_SHADING_NORMAL.exr' + ), + + '3' => array( + 'type' => 'RGB_IMAGEPIPELINE', + 'index' => 1, + 'filename' => 'RGB_IMAGEPIPELINE_1.png' + ) + ); + + Base::__construct($config); + } + +} diff --git a/src/scene/Filter.php b/src/scene/Filter.php new file mode 100644 index 0000000..f9222ff --- /dev/null +++ b/src/scene/Filter.php @@ -0,0 +1,40 @@ + diff --git a/src/scene/NoiseEstimation.php b/src/scene/NoiseEstimation.php new file mode 100644 index 0000000..ae64bf7 --- /dev/null +++ b/src/scene/NoiseEstimation.php @@ -0,0 +1,21 @@ + diff --git a/src/scene/RenderEngine.php b/src/scene/RenderEngine.php index 5a49732..569e1f4 100644 --- a/src/scene/RenderEngine.php +++ b/src/scene/RenderEngine.php @@ -15,4 +15,9 @@ class RenderEngine extends BaseCfg */ public $type = self::TYPE_PATHGPU; + /** + * @var float 随机种子(取值:大于0的整数) + */ + public $seed = 1; + } diff --git a/src/scene/Sampler.php b/src/scene/Sampler.php index 5c1349e..42ecb9b 100644 --- a/src/scene/Sampler.php +++ b/src/scene/Sampler.php @@ -10,7 +10,7 @@ class Sampler extends BaseCfg const TYPE_SOBOL = 'SOBOL'; const TYPE_METROPOLIS = 'METROPOLIS'; const TYPE_RANDOM = 'RANDOM'; - const TYPE_TILEPATHSAMPLER = 'TILEPATHSAMPLER'; + @@ -21,10 +21,18 @@ class Sampler extends BaseCfg public $type = self::TYPE_SOBOL; /** - * @var object 一个 Random类 或 Sobol类 的实例对象 + * @var object 一个 sobol类 的实例对象 */ public $sobol; + + /** + * @var object 一个 random类 的实例对象 + */ public $random; + + /** + * @var object 一个 metropolis类 的实例对象 + */ public $metropolis; diff --git a/src/utils/StringHelper.php b/src/utils/StringHelper.php index c89a6c7..2722d6a 100644 --- a/src/utils/StringHelper.php +++ b/src/utils/StringHelper.php @@ -55,4 +55,55 @@ class StringHelper return preg_split("/(?=[A-Z])/", $str); } + + + /** + * 将多维数组的每个值,与他的键名连接成一个字符串,并将每个字串,存入一个一维数组,并将该数组返回 + */ + static public function arrayToString(&$tempArr) + { + static $retStr = []; + static $tempStr = []; + static $i = 0; + + if( $i < 0 )//检查递归函数是 被外部调用还是 还是函数内部调用 + { + $i = 0; + $retStr = []; + $tempStr = []; + } + + foreach($tempArr as $key => $value) + { + if(is_array($value)) + { + $tempStr[$i] = "{$key}."; + $i++; + self::arrayToString($value); + } + else if( is_string($value) ) + { + if( mb_ereg('^[0-9]+$',str_replace('.','',str_replace(' ','',$value))) ) + { + $tempStr[$i] = "{$key} = {$value}"; + } + else + { + $tempStr[$i] = "{$key} = \"{$value}\""; + } + $retStr[] = implode($tempStr); + } + else + { + $tempStr[$i] = "{$key} = {$value}"; + $retStr[] = implode($tempStr); + } + + } + $tempStr[$i] = null; + $i--; + return $retStr; + } + } +?>