|
|
@ -60,10 +60,10 @@ $taskCamera = $taskScene->camera; |
|
|
|
/** |
|
|
|
* 创建 Luxcore 材质 |
|
|
|
*/ |
|
|
|
function createLuxcoreMat($matOriginal, $textureScaleU, $textureScaleV, $downloadDir, $scene){ |
|
|
|
function createLuxcoreMat($matOriginal, $textureScaleU, $textureScaleV, $cacheFileDir, $scene){ |
|
|
|
switch($matOriginal->renderType){ |
|
|
|
case 1: |
|
|
|
return MatHelper::createMatOfDisney($matOriginal, $textureScaleU, $textureScaleV, $downloadDir, $scene); |
|
|
|
return MatHelper::createMatOfDisney($matOriginal, $textureScaleU, $textureScaleV, $cacheFileDir, $scene); |
|
|
|
case 2: |
|
|
|
return; |
|
|
|
case 3: |
|
|
@ -217,7 +217,7 @@ $scene->registerObjects($obj); |
|
|
|
|
|
|
|
// 二、添加要渲染的模型
|
|
|
|
foreach($taskModel->childsParams as $childParams){ |
|
|
|
$downloadDir = $sceneTemplatePath.'/cacheFiles/'; |
|
|
|
$cacheFileDir = $sceneTemplatePath.'/cacheFiles'; |
|
|
|
$material = null; |
|
|
|
$matOriginal = (function ($childParams){ |
|
|
|
if(is_object($childParams->customMat)){ |
|
|
@ -232,14 +232,14 @@ foreach($taskModel->childsParams as $childParams){ |
|
|
|
if(is_object($matOriginal)){ |
|
|
|
$textureScaleU = $taskModel->uvScale*(MAT_STANDARD_SIZE/$matOriginal->width); |
|
|
|
$textureScaleV = $taskModel->uvScale*(MAT_STANDARD_SIZE/$matOriginal->height); |
|
|
|
$material = createLuxcoreMat($matOriginal, $textureScaleU, $textureScaleV, $downloadDir, $scene); |
|
|
|
$material = createLuxcoreMat($matOriginal, $textureScaleU, $textureScaleV, $cacheFileDir, $scene); |
|
|
|
}else{ |
|
|
|
$material = new Disney(); |
|
|
|
$material->setBaseColor('1 1 1'); |
|
|
|
} |
|
|
|
$scene->registerMaterial($material); |
|
|
|
|
|
|
|
$plyFileSavaPath = $downloadDir.basename($childParams->childPlyFile); |
|
|
|
$plyFileSavaPath = $cacheFileDir.basename($childParams->childPlyFile); |
|
|
|
$plyFileHandle = fopen($plyFileSavaPath, "w"); |
|
|
|
(new Client())->get($childParams->childPlyFile, [RequestOptions::SINK => $plyFileHandle]); |
|
|
|
$obj = new Objects(); |
|
|
@ -339,7 +339,7 @@ $render .= $sceneCfg; |
|
|
|
|
|
|
|
|
|
|
|
// 图像输出设置
|
|
|
|
$imageOutPath = $sceneTemplatePath.'/imageOut'; |
|
|
|
$imageOutDir = $sceneTemplatePath.'/imageOut'; |
|
|
|
$film = new Film(); |
|
|
|
|
|
|
|
$filter = new Filter(); |
|
|
@ -353,10 +353,10 @@ $film->heigth = 4096; |
|
|
|
|
|
|
|
$img = new Image(); |
|
|
|
$img->effect = [new Pretreatment(),new ToneMapLinear(),new CammaCorrection()]; |
|
|
|
$film->addImage($img, $imageOutPath); |
|
|
|
$film->addImage($img, $imageOutDir); |
|
|
|
|
|
|
|
$film->addImage(new Image(['type' => Image::TYPE_OBJECT_ID]), $imageOutPath); |
|
|
|
$film->addImage(new Image(['type' => Image::TYPE_RGBA]), $imageOutPath); |
|
|
|
$film->addImage(new Image(['type' => Image::TYPE_OBJECT_ID]), $imageOutDir); |
|
|
|
$film->addImage(new Image(['type' => Image::TYPE_RGBA]), $imageOutDir); |
|
|
|
|
|
|
|
$img = new Image(); |
|
|
|
// $img->effect[] = new NoiseReducerOIDN();
|
|
|
@ -369,18 +369,22 @@ $img->effect[] = new BackgroundImg( |
|
|
|
] |
|
|
|
); |
|
|
|
$img->effect[] = new CammaCorrection(); |
|
|
|
$film->addImage($img, $imageOutPath); |
|
|
|
$film->addImage($img, $imageOutDir); |
|
|
|
$render .= $film; |
|
|
|
|
|
|
|
|
|
|
|
// 五、输出场景文件 scene.scn,及渲染文件 render.cfg
|
|
|
|
$cfgPath = $sceneTemplatePath . "/render.cfg"; |
|
|
|
$scenePath = $sceneTemplatePath . "/scene.scn"; |
|
|
|
$logPath = $sceneTemplatePath . "/log/render.log"; |
|
|
|
|
|
|
|
echo $scene; |
|
|
|
$handle = fopen( $sceneTemplatePath . "/scene.scn",'w+'); |
|
|
|
$handle = fopen( $scenePath,'w+'); |
|
|
|
fwrite($handle,$scene); |
|
|
|
fclose($handle); |
|
|
|
|
|
|
|
echo $render ; |
|
|
|
$handle = fopen( $sceneTemplatePath . "/render.cfg",'w+'); |
|
|
|
$handle = fopen( $cfgPath,'w+'); |
|
|
|
fwrite($handle,$render); |
|
|
|
fclose($handle); |
|
|
|
|
|
|
@ -388,10 +392,6 @@ fclose($handle); |
|
|
|
|
|
|
|
|
|
|
|
// 六、启动渲染器
|
|
|
|
$cfgPath = $sceneTemplatePath . "/render.cfg"; |
|
|
|
$scenePath = $sceneTemplatePath . "/scene.scn"; |
|
|
|
$logPath = $sceneTemplatePath . "/log/render.log"; |
|
|
|
|
|
|
|
$cmd = "luxcoreconsole -o " . $cfgPath . " -f " . $scenePath . " 1>" . $logPath . " 2>&1"; |
|
|
|
echo "\n".$cmd."\n"; |
|
|
|
$output; |
|
|
|