Browse Source

修改了“Base.php”、“BaseCfg.php”、“RenderEngine.php”、“Sampler.php”、“StringHelper.php”五个类文件,和示例文件;新增“Film.php”、“Filter.php”、“NoiseEstimation.php”三个类文件

master
yuanjiajia 3 years ago
parent
commit
a821e1d754
  1. 19
      examples/print.php
  2. 5
      src/core/Base.php
  3. 24
      src/scene/BaseCfg.php
  4. 139
      src/scene/Film.php
  5. 40
      src/scene/Filter.php
  6. 21
      src/scene/NoiseEstimation.php
  7. 5
      src/scene/RenderEngine.php
  8. 12
      src/scene/Sampler.php
  9. 51
      src/utils/StringHelper.php

19
examples/print.php

@ -1,10 +1,11 @@
<?php <?php
namespace Blobt\Luxcore\scene;
include dirname(dirname(__FILE__)) . "/vendor/autoload.php";
namespace Blobt\Luxcore\scene;
include dirname(dirname(__FILE__)) . "/vendor/autoload.php";
/*
//设置打印渲染引擎的配置参数 //设置打印渲染引擎的配置参数
$renderEngine = new RenderEngine(); $renderEngine = new RenderEngine();
@ -22,11 +23,21 @@ echo $native;
$path = new Path(['glossinessthreshold' => 0.999]); $path = new Path(['glossinessthreshold' => 0.999]);
echo $path; echo $path;
//设置打印 采样器 配置参数 //设置打印 采样器 配置参数
$sampler = new Sampler(['imagemutationrate' => 0.888]); $sampler = new Sampler(['imagemutationrate' => 0.888]);
$sampler->random->overlapping = 32; $sampler->random->overlapping = 32;
echo $sampler; echo $sampler;
*/
$film = new Film();
echo "$film\n";
$film->outputs[3]['index'] = '中国最牛';
echo $film;
?> ?>

5
src/core/Base.php

@ -5,11 +5,6 @@ namespace Blobt\Luxcore\core;
class Base class Base
{ {
//打开或关闭
const OPEN = true;
const CLOSE = false;
/** /**
* 实现自动配置 * 实现自动配置
*/ */

24
src/scene/BaseCfg.php

@ -1,13 +1,25 @@
<?php <?php
namespace Blobt\Luxcore\scene; namespace Blobt\Luxcore\scene;
use Blobt\Luxcore\core\Base; use Blobt\Luxcore\core\Base;
use Blobt\Luxcore\utils\StringHelper; use Blobt\Luxcore\utils\StringHelper;
class BaseCfg extends Base class BaseCfg extends Base
{ {
//打开或关闭
const OPEN = true;
const CLOSE = false;
public function __toString() public function __toString()
{ {
return $this->toString(); return $this->toString();
@ -18,6 +30,7 @@ class BaseCfg extends Base
$object = new \ReflectionClass($this); $object = new \ReflectionClass($this);
$properties = $object->getProperties(); $properties = $object->getProperties();
//var_dump($properties);
//获取类名 -> 去除命名空间 -> 转成全小写 //获取类名 -> 去除命名空间 -> 转成全小写
@ -58,10 +71,18 @@ class BaseCfg extends Base
else if(is_null($value)) else if(is_null($value))
{ {
$ret .= "{$className}.{$name} = \"null\"\n"; $ret .= "{$className}.{$name} = \"null\"\n";
} else if(is_float($value))
}
else if(is_float($value))
{ {
$ret .= "{$className}.{$name} = {$value}\n"; $ret .= "{$className}.{$name} = {$value}\n";
} }
else if(is_array($value))
{
foreach(StringHelper::arrayToString($value) as $value)
{
$ret .= "{$className}.{$name}.{$value}\n";
}
}
else else
{ {
$ret .= "{$className}.{$name} = \"unknow type\"\n"; $ret .= "{$className}.{$name} = \"unknow type\"\n";
@ -69,4 +90,5 @@ class BaseCfg extends Base
} }
return $ret; return $ret;
} }
} }

139
src/scene/Film.php

@ -0,0 +1,139 @@
<?php
namespace Blobt\Luxcore\scene;
use Blobt\Luxcore\core\Base;
class Film extends BaseCfg
{
/**
* @var object 一个 NoiseEstimation类 的实例对象
*/
public $noiseEstimation;
/**
* @var object 一个 Filter类 的实例对象
*/
public $filter;
/**
* 渲染图像的宽度,单位像素(取值:大于0的整数)
*/
public $width = 1920;
/**
* 渲染图像的高度,单位像素(取值:大于0的整数)
*/
public $heigth = 1080;
/**
* @var bool TODO:具体作用尚不明确(取值:true)
*/
public $openclEnable = 1;
/**
* @var integer TODO:具体作用尚不明确(取值:0)
*/
public $openclDevice = 0;
/**
* @var array 渲染图像后期处理配置参数
*/
public $imagepipelines;
/**
* @var array 图像输出的配置参数
*/
public $outputs;
/**
* 实例 PathDepth类、HybridBackforWard类的两个对象,初始化数组“$imagepipelines”;
*/
public function __construct($config = [])
{
$this->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);
}
}

40
src/scene/Filter.php

@ -0,0 +1,40 @@
<?php
namespace Blobt\Luxcore\scene;
use Blobt\Luxcore\core\Base;
class Filter extends BaseCfg
{
const TYPE_NONE = 'NONE';
const TYPE_BLACKMANHARRIS = 'BLACKMANHARRIS';
const TYPE_MITCHELL_SS = 'MITCHELL_SS';
const TYPE_GAUSSIAN = 'GAUSSIAN';
const TYPE_SINC = 'SINC';
const TYPE_CATMULLROM = 'CATMULLROM';
/**
* @var string 使用何种抗锯齿类型
*/
public $type = self::TYPE_NONE;
/**
* @var float 边缘抗锯齿宽度,单位像素(取值:大于0的数浮点数)
*/
public $width = 1.5;
/**
* 高斯类型抗锯齿过滤器的透明度(取值:0.10-10的浮点数)
*/
public $gaussianAlpha = 2;
/**
* TODO:具体作用尚不明确,(取值:0.10-8的浮点数)
*/
public $sincTau = 1;
}
?>

21
src/scene/NoiseEstimation.php

@ -0,0 +1,21 @@
<?php
namespace Blobt\Luxcore\scene;
use Blobt\Luxcore\core\Base;
class NoiseEstimation extends BaseCfg
{
/**
* @var integer TODO:具体作用尚不明确,(大于0的整数)
*/
public $warmup = 8;
/**
* @var integer TODO:具体作用尚不明确,(取值:大于等于16的整数)
*/
public $step = 32;
}
?>

5
src/scene/RenderEngine.php

@ -15,4 +15,9 @@ class RenderEngine extends BaseCfg
*/ */
public $type = self::TYPE_PATHGPU; public $type = self::TYPE_PATHGPU;
/**
* @var float 随机种子(取值:大于0的整数)
*/
public $seed = 1;
} }

12
src/scene/Sampler.php

@ -10,7 +10,7 @@ class Sampler extends BaseCfg
const TYPE_SOBOL = 'SOBOL'; const TYPE_SOBOL = 'SOBOL';
const TYPE_METROPOLIS = 'METROPOLIS'; const TYPE_METROPOLIS = 'METROPOLIS';
const TYPE_RANDOM = 'RANDOM'; const TYPE_RANDOM = 'RANDOM';
const TYPE_TILEPATHSAMPLER = 'TILEPATHSAMPLER';
@ -21,10 +21,18 @@ class Sampler extends BaseCfg
public $type = self::TYPE_SOBOL; public $type = self::TYPE_SOBOL;
/** /**
* @var object 一个 Random类 Sobol类 的实例对象
* @var object 一个 sobol类 的实例对象
*/ */
public $sobol; public $sobol;
/**
* @var object 一个 random类 的实例对象
*/
public $random; public $random;
/**
* @var object 一个 metropolis类 的实例对象
*/
public $metropolis; public $metropolis;

51
src/utils/StringHelper.php

@ -55,4 +55,55 @@ class StringHelper
return preg_split("/(?=[A-Z])/", $str); 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;
}
} }
?>
Loading…
Cancel
Save