Browse Source

渲染测式 案例 开发

master
yuanjiajia 1 year ago
parent
commit
4af7ea8da4
  1. 66
      examples/renderTest.php
  2. 27
      src/scene/render/Film.php
  3. 20
      src/scene/render/Image.php

66
examples/renderTest.php

@ -274,42 +274,13 @@ $scene->registerCamera($camera);
// 四、设置渲染参数 // 四、设置渲染参数
// // gpu 渲染
// $render = '';
// $renderEngine = new RenderEngine();
// $render .= $renderEngine;
// $openCL = new OpenCL();
// $render .= $openCL;
// $lightStrategy = new LightStrategy();
// $render .= $lightStrategy;
// $path = new Path();
// $render .= $path;
// $sampler = new Sampler();
// $render .= $sampler;
// $filesaver = new FileSaver();
// $render .= $filesaver;
// $batch = new Batch();
// $batch->haltspp = 200;
// // $batch->halttime = 2000;
// $render .= $batch;
// $sceneCfg = new render\Scene();
// $render .= $sceneCfg;
// cpu 渲染
// gpu 渲染
$render = ''; $render = '';
$renderEngine = new RenderEngine(); $renderEngine = new RenderEngine();
$renderEngine->type = RenderEngine::TYPE_PATHCPU;
$render .= $renderEngine; $render .= $renderEngine;
$native = new Native();
$render .= $native;
$openCL = new OpenCL();
$render .= $openCL;
$lightStrategy = new LightStrategy(); $lightStrategy = new LightStrategy();
$render .= $lightStrategy; $render .= $lightStrategy;
@ -321,7 +292,6 @@ $sampler = new Sampler();
$render .= $sampler; $render .= $sampler;
$filesaver = new FileSaver(); $filesaver = new FileSaver();
$filesaver->renderengineType = FileSaver::TYPE_PATHCPU;
$render .= $filesaver; $render .= $filesaver;
$batch = new Batch(); $batch = new Batch();
@ -332,6 +302,36 @@ $render .= $batch;
$sceneCfg = new render\Scene(); $sceneCfg = new render\Scene();
$render .= $sceneCfg; $render .= $sceneCfg;
// // cpu 渲染
// $render = '';
// $renderEngine = new RenderEngine();
// $renderEngine->type = RenderEngine::TYPE_PATHCPU;
// $render .= $renderEngine;
// $native = new Native();
// $render .= $native;
// $lightStrategy = new LightStrategy();
// $render .= $lightStrategy;
// $path = new Path();
// $render .= $path;
// $sampler = new Sampler();
// $render .= $sampler;
// $filesaver = new FileSaver();
// $filesaver->renderengineType = FileSaver::TYPE_PATHCPU;
// $render .= $filesaver;
// $batch = new Batch();
// $batch->haltspp = 200;
// // $batch->halttime = 2000;
// $render .= $batch;
// $sceneCfg = new render\Scene();
// $render .= $sceneCfg;
// 图像输出设置 // 图像输出设置
$imageOutPath = $sceneTemplatePath.'/imageOut'; $imageOutPath = $sceneTemplatePath.'/imageOut';
$film = new Film(); $film = new Film();

27
src/scene/render/Film.php

@ -70,21 +70,32 @@ class Film extends BaseCfg
public function addImage(object $object, $outDir) public function addImage(object $object, $outDir)
{ {
$i = -1; $i = -1;
if($object->type == Image::TYPE_RGB_IMAGEPIPELINE)
{
foreach($this->outputs as $value)
{
if($object->type == Image::TYPE_RGB_IMAGEPIPELINE){
foreach($this->outputs as $value){
$i = $value->index > $i ? $value->index : $i; $i = $value->index > $i ? $value->index : $i;
} }
$object->index = $i + 1; $object->index = $i + 1;
if ($object->effect != null)
{
if ($object->effect != null){
$this->imagepipelines[ sprintf("%03d",$object->index) ] = $object->effect; $this->imagepipelines[ sprintf("%03d",$object->index) ] = $object->effect;
$object->effect = null; $object->effect = null;
} }
$object->filename = "{$outDir}/{$object->type}_{$object->index}.png";
if(!$object->filename){
$object->filename = "{$object->type}_{$object->index}.png";
}
}else{
if(!$object->filename){
if( in_array($object->type,Image::PNG ) ){
$object->filename = "{$object->type}.png";
}
else if ( in_array($object->type,Image::EXR) ){
$object->filename = "{$object->type}.exr";
}
else{
$object->filename = "{$object->type}.jpg";
}
}
} }
$object->filename = "{$outDir}/{$object->filename}";
$this->outputs[] = $object; $this->outputs[] = $object;
} }

20
src/scene/render/Image.php

@ -147,23 +147,19 @@ class Image extends BaseCfg
*/ */
public function __construct($config = []) public function __construct($config = [])
{ {
Base::__construct($config); Base::__construct($config);
if( in_array($this->type,self::PNG ) )
{
$this->filename = "./DemoScene/{$this->type}.png";
if(!$this->filename){
if( in_array($this->type,self::PNG ) ){
$this->filename = "{$this->type}.png";
} }
else if ( in_array($this->type,self::EXR) )
{
$this->filename = "./DemoScene/{$this->type}.exr";
else if ( in_array($this->type,self::EXR) ){
$this->filename = "{$this->type}.exr";
}
else{
$this->filename = "{$this->type}.jpg";
} }
else
{
$this->filename = "./DemoScene/{$this->type}.jpg";
} }
} }
} }
?> ?>
Loading…
Cancel
Save