Browse Source

渲染测式 案例 开发

master
yuanjiajia 1 year ago
parent
commit
cd26b79484
  1. 6
      .gitignore
  2. 52
      examples/renderTest.php
  3. 64
      sceneTemplate/render.cfg
  4. 1
      sceneTemplate/render.log
  5. 2072
      sceneTemplate/scene.scn

6
.gitignore

@ -38,3 +38,9 @@ vendor.zip
/vagrant /vagrant
composer.lock composer.lock
/sceneTemplate/cacheFiles
# /sceneTemplate/render.cfg
# /sceneTemplate/render.log
# /sceneTemplate/scene.scn

52
examples/renderTest.php

@ -4,8 +4,10 @@
namespace Blobt\Luxcore\scene; namespace Blobt\Luxcore\scene;
use Blobt\Luxcore\scene\objects\Objects;
use Blobt\Luxcore\utils\MatHelper; use Blobt\Luxcore\utils\MatHelper;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use GuzzleHttp\RequestOptions;
include dirname(dirname(__FILE__)) . "/vendor/autoload.php"; include dirname(dirname(__FILE__)) . "/vendor/autoload.php";
@ -60,7 +62,7 @@ $material->setBaseColor('0 0 0');
$material->setTransparencyShadow('1 1 1'); $material->setTransparencyShadow('1 1 1');
$material->setEmission('1 1 1'); $material->setEmission('1 1 1');
$scene->registerMaterial($material); $scene->registerMaterial($material);
$obj = new objects\Objects();
$obj = new Objects();
$obj->ply = './ply/FaceLight001.ply'; $obj->ply = './ply/FaceLight001.ply';
$obj->setMaterial($material); $obj->setMaterial($material);
$scene->registerObjects($obj); $scene->registerObjects($obj);
@ -74,7 +76,7 @@ $material->emissionCfg = new lights\Emission([
'gain' => "30 30 30", 'gain' => "30 30 30",
]); ]);
$scene->registerMaterial($material); $scene->registerMaterial($material);
$obj = new objects\Objects();
$obj = new Objects();
$obj->ply = './ply/FaceLight002.ply'; $obj->ply = './ply/FaceLight002.ply';
$obj->setMaterial($material); $obj->setMaterial($material);
$scene->registerObjects($obj); $scene->registerObjects($obj);
@ -88,7 +90,7 @@ $material->emissionCfg = new lights\Emission([
'gain' => "50 50 50", 'gain' => "50 50 50",
]); ]);
$scene->registerMaterial($material); $scene->registerMaterial($material);
$obj = new objects\Objects();
$obj = new Objects();
$obj->ply = './ply/FaceLight003.ply'; $obj->ply = './ply/FaceLight003.ply';
$obj->setMaterial($material); $obj->setMaterial($material);
$scene->registerObjects($obj); $scene->registerObjects($obj);
@ -102,7 +104,7 @@ $material->emissionCfg = new lights\Emission([
'gain' => "4 4 4", 'gain' => "4 4 4",
]); ]);
$scene->registerMaterial($material); $scene->registerMaterial($material);
$obj = new objects\Objects();
$obj = new Objects();
$obj->ply = './ply/FaceLight004.ply'; $obj->ply = './ply/FaceLight004.ply';
$obj->setMaterial($material); $obj->setMaterial($material);
$scene->registerObjects($obj); $scene->registerObjects($obj);
@ -116,7 +118,7 @@ $material->emissionCfg = new lights\Emission([
'gain' => "10 10 10", 'gain' => "10 10 10",
]); ]);
$scene->registerMaterial($material); $scene->registerMaterial($material);
$obj = new objects\Objects();
$obj = new Objects();
$obj->ply = './ply/FaceLight005.ply'; $obj->ply = './ply/FaceLight005.ply';
$obj->setMaterial($material); $obj->setMaterial($material);
$scene->registerObjects($obj); $scene->registerObjects($obj);
@ -133,7 +135,7 @@ $material->emissionCfg = new lights\Emission([
'storage' => "float" 'storage' => "float"
]); ]);
$scene->registerMaterial($material); $scene->registerMaterial($material);
$obj = new objects\Objects();
$obj = new Objects();
$obj->ply = './ply/FaceLight006.ply'; $obj->ply = './ply/FaceLight006.ply';
$obj->setMaterial($material); $obj->setMaterial($material);
$scene->registerObjects($obj); $scene->registerObjects($obj);
@ -147,7 +149,7 @@ $material->emissionCfg = new lights\Emission([
'gain' => "3.3 3.3 3.3", 'gain' => "3.3 3.3 3.3",
]); ]);
$scene->registerMaterial($material); $scene->registerMaterial($material);
$obj = new objects\Objects();
$obj = new Objects();
$obj->ply = './ply/FaceLight000.ply'; $obj->ply = './ply/FaceLight000.ply';
$obj->setMaterial($material); $obj->setMaterial($material);
$scene->registerObjects($obj); $scene->registerObjects($obj);
@ -181,7 +183,7 @@ $material->setBaseColor('1 1 1');
$material->setTransparencyFront($texture); $material->setTransparencyFront($texture);
$material->setTransparencyBack($texture); $material->setTransparencyBack($texture);
$scene->registerMaterial($material); $scene->registerMaterial($material);
$obj = new objects\Objects();
$obj = new Objects();
$obj->ply = './ply/ground.ply'; $obj->ply = './ply/ground.ply';
$obj->setMaterial($material); $obj->setMaterial($material);
$scene->registerObjects($obj); $scene->registerObjects($obj);
@ -201,7 +203,7 @@ foreach($taskModel->childsParams as $childParams){
})($childParams); })($childParams);
$textureScaleU = $taskModel->uvScale*(MAT_STANDARD_SIZE/$matOriginal->width); $textureScaleU = $taskModel->uvScale*(MAT_STANDARD_SIZE/$matOriginal->width);
$textureScaleV = $taskModel->uvScale*(MAT_STANDARD_SIZE/$matOriginal->height); $textureScaleV = $taskModel->uvScale*(MAT_STANDARD_SIZE/$matOriginal->height);
if(is_object($matOriginal)){
if(false){
$material = createLuxcoreMat($matOriginal, $textureScaleU, $textureScaleV, $scene); $material = createLuxcoreMat($matOriginal, $textureScaleU, $textureScaleV, $scene);
}else{ }else{
$material = new materials\Disney(); $material = new materials\Disney();
@ -209,8 +211,12 @@ foreach($taskModel->childsParams as $childParams){
} }
$scene->registerMaterial($material); $scene->registerMaterial($material);
$obj = new objects\Objects();
$obj->ply = $childParams->childPlyFile;
$plyFileSavaPath = $sceneTemplatePath.'/cacheFiles/'.basename($childParams->childPlyFile);
$plyFileHandle = fopen($plyFileSavaPath, "w");
(new Client())->get($childParams->childPlyFile, [RequestOptions::SINK => $plyFileHandle]);
$obj = new Objects();
$obj->ply = $plyFileSavaPath;
$obj->setMaterial($material); $obj->setMaterial($material);
$scene->registerObjects($obj); $scene->registerObjects($obj);
} }
@ -302,19 +308,19 @@ fclose($handle);
// 六、启动渲染器
$cfgPath = $sceneTemplatePath . "/render.cfg";
$scenePath = $sceneTemplatePath . "/scene.scn";
$logPath = $sceneTemplatePath . "/render.log";
// // 六、启动渲染器
// $cfgPath = $sceneTemplatePath . "/render.cfg";
// $scenePath = $sceneTemplatePath . "/scene.scn";
// $logPath = $sceneTemplatePath . "/render.log";
$cmd = "luxcoreconsole -o " . $cfgPath . " -f " . $scenePath . " 1>" . $logPath . " 2>&1";
echo "\n".$cmd."\n";
$output;
$returnVar;
exec($cmd,$output,$returnVar);
// $cmd = "luxcoreconsole -o " . $cfgPath . " -f " . $scenePath . " 1>" . $logPath . " 2>&1";
// echo "\n".$cmd."\n";
// $output;
// $returnVar;
// exec($cmd,$output,$returnVar);
if( $returnVar == 127 ){
throw new \Exception("Please install the luxcorerender bin file in the system directory correctly,Or add to the system environment variable");
}
// if( $returnVar == 127 ){
// throw new \Exception("Please install the luxcorerender bin file in the system directory correctly,Or add to the system environment variable");
// }
?> ?>

64
sceneTemplate/render.cfg

@ -1,64 +0,0 @@
renderengine.type = PATHOCL
renderengine.seed = 1
opencl.cpu.use = 0
opencl.gpu.use = 1
opencl.devices.select = 1
path.pathdepth.total = 16
path.pathdepth.diffuse = 8
path.pathdepth.glossy = 8
path.pathdepth.specular = 8
path.hybridbackforward.enable = 1
path.hybridbackforward.partition = 0
path.hybridbackforward.glossinessthreshold = 0.05
path.forceblackbackground.enable = 1
path.clamping.variance.maxvalue = 1000
sampler.type = SOBOL
sampler.sobol.overlapping = 32
sampler.sobol.super.sampling = 1
sampler.sobol.tile.size = 16
sampler.sobol.bucket.size = 1
sampler.sobol.adaptive.strength = 0.9
lightstrategy.type = LOG_POWER
filesaver.format = TXT
filesaver.renderengine.type = PATHGPU
batch.haltspp = 1000
batch.halttime = 0
scene.file = scene.scn
scene.epsilon.min = 1.0E-5
scene.epsilon.max = 0.1
film.width = 3000
film.heigth = 3000
film.opencl.enable = 1
film.opencl.device = 0
film.noiseestimation.warmup = 8
film.noiseestimation.step = 32
film.filter.type = NONE
film.filter.width = 1.5
film.imagepipelines.000.0.type = NOP
film.imagepipelines.000.1.type = TONEMAP_LINEAR
film.imagepipelines.000.1.scale = 1
film.imagepipelines.000.2.type = GAMMA_CORRECTION
film.imagepipelines.000.2.value = 2.2
film.imagepipelines.001.0.type = INTEL_OIDN
film.imagepipelines.001.0.oidnmemory = 6000
film.imagepipelines.001.0.sharpness = 0
film.imagepipelines.001.1.type = NOP
film.imagepipelines.001.2.type = TONEMAP_LINEAR
film.imagepipelines.001.2.scale = 1
film.imagepipelines.001.3.type = PREMULTIPLY_ALPHA
film.imagepipelines.001.4.type = BACKGROUND_IMG
film.imagepipelines.001.4.file = ./map/纯白242.png
film.imagepipelines.001.4.gamma = 2.2
film.imagepipelines.001.4.storage = byte
film.imagepipelines.001.5.type = GAMMA_CORRECTION
film.imagepipelines.001.5.value = 2.2
film.outputs.0.type = RGB_IMAGEPIPELINE
film.outputs.0.filename = ./DemoScene/RGB_IMAGEPIPELINE_0.png
film.outputs.0.index = 0
film.outputs.1.type = OBJECT_ID
film.outputs.1.filename = ./DemoScene/OBJECT_ID.png
film.outputs.2.type = RGBA
film.outputs.2.filename = ./DemoScene/RGBA.exr
film.outputs.3.type = RGB_IMAGEPIPELINE
film.outputs.3.filename = ./DemoScene/RGB_IMAGEPIPELINE_1.png
film.outputs.3.index = 1

1
sceneTemplate/render.log

@ -1 +0,0 @@
sh: 1: luxcoreconsole: not found

2072
sceneTemplate/scene.scn
File diff suppressed because it is too large
View File

Loading…
Cancel
Save