Browse Source

渲染测式 案例

master
yuanjiajia 1 year ago
parent
commit
45d888969a
  1. 162
      examples/renderTest.php
  2. BIN
      sceneTemplate/map/SD-037.exr
  3. BIN
      sceneTemplate/map/env.png
  4. BIN
      sceneTemplate/map/方形阴影遮照.png
  5. BIN
      sceneTemplate/map/纯白242.png
  6. BIN
      sceneTemplate/ply/FaceLight000.ply
  7. BIN
      sceneTemplate/ply/FaceLight001.ply
  8. BIN
      sceneTemplate/ply/FaceLight002.ply
  9. BIN
      sceneTemplate/ply/FaceLight003.ply
  10. BIN
      sceneTemplate/ply/FaceLight004.ply
  11. BIN
      sceneTemplate/ply/FaceLight005.ply
  12. BIN
      sceneTemplate/ply/FaceLight006.ply
  13. BIN
      sceneTemplate/ply/ground.ply
  14. 2
      src/scene/materials/MaterialsBase.php

162
examples/renderTest.php

@ -7,17 +7,169 @@ use GuzzleHttp\Client;
include dirname(dirname(__FILE__)) . "/vendor/autoload.php"; include dirname(dirname(__FILE__)) . "/vendor/autoload.php";
const OPEN = true;
const CLOSE = false;
// 创建一个场景
// $scene = new Scene();
$client = new Client(); $client = new Client();
$response = $client->get("deep3d.backend-api.dev.com/test/render-task"); $response = $client->get("deep3d.backend-api.dev.com/test/render-task");
$resContents = $response->getBody()->getContents(); $resContents = $response->getBody()->getContents();
$resData = json_decode($resContents); $resData = json_decode($resContents);
print_r($resData->data->scene);
// 创建一个场景;
$scene = new Scene();
// 一、创建光场:
// 1、创建 面片光001
$materials = new materials\Matte();
$materials->setBaseColor('0 0 0');
$materials->setTransparencyShadow('1 1 1');
$materials->setEmission('1 1 1');
$scene->registerMaterial($materials);
$obj = new objects\Objects();
$obj->ply = './ply/FaceLight001.ply';
$obj->setMaterial($materials);
$scene->registerObjects($obj);
// 2、创建 面片光002
$materials = new materials\Matte();
$materials->setBaseColor('0 0 0');
$materials->setTransparencyShadow('1 1 1');
$materials->setEmission('0 0 0');
$materials->emissionCfg = new lights\Emission([
'gain' => "30 30 30",
]);
$scene->registerMaterial($materials);
$obj = new objects\Objects();
$obj->ply = './ply/FaceLight002.ply';
$obj->setMaterial($materials);
$scene->registerObjects($obj);
// 3、创建 面片光003
$materials = new materials\Matte();
$materials->setBaseColor('0 0 0');
$materials->setTransparencyShadow('1 1 1');
$materials->setEmission('1 1 1');
$materials->emissionCfg = new lights\Emission([
'gain' => "50 50 50",
]);
$scene->registerMaterial($materials);
$obj = new objects\Objects();
$obj->ply = './ply/FaceLight003.ply';
$obj->setMaterial($materials);
$scene->registerObjects($obj);
// 4、创建 面片光004
$materials = new materials\Matte();
$materials->setBaseColor('0 0 0');
$materials->setTransparencyShadow('1 1 1');
$materials->setEmission('0 0 0');
$materials->emissionCfg = new lights\Emission([
'gain' => "4 4 4",
]);
$scene->registerMaterial($materials);
$obj = new objects\Objects();
$obj->ply = './ply/FaceLight004.ply';
$obj->setMaterial($materials);
$scene->registerObjects($obj);
// 5、创建 面片光005
$materials = new materials\Matte();
$materials->setBaseColor('0 0 0');
$materials->setTransparencyShadow('1 1 1');
$materials->setEmission('1 1 1');
$materials->emissionCfg = new lights\Emission([
'gain' => "10 10 10",
]);
$scene->registerMaterial($materials);
$obj = new objects\Objects();
$obj->ply = './ply/FaceLight005.ply';
$obj->setMaterial($materials);
$scene->registerObjects($obj);
// 6、创建 面片光006
$materials = new materials\Matte();
$materials->setBaseColor('0 0 0');
$materials->setTransparencyShadow('1 1 1');
$materials->setEmission('1 1 1');
$materials->emissionCfg = new lights\Emission([
'gain' => "8 8 8",
'mapfile' => "./map/SD-037.exr",
'gamma' => 1,
'storage' => "float"
]);
$scene->registerMaterial($materials);
$obj = new objects\Objects();
$obj->ply = './ply/FaceLight006.ply';
$obj->setMaterial($materials);
$scene->registerObjects($obj);
// 7、创建 面片光000
$materials = new materials\Matte();
$materials->setBaseColor('0 0 0');
$materials->setTransparencyShadow('1 1 1');
$materials->setEmission('1 1 1');
$materials->emissionCfg = new lights\Emission([
'gain' => "3.3 3.3 3.3",
]);
$scene->registerMaterial($materials);
$obj = new objects\Objects();
$obj->ply = './ply/FaceLight000.ply';
$obj->setMaterial($materials);
$scene->registerObjects($obj);
// 8、创建环境光
$light = new lights\env\HdrImage([
'gain' => "1.25 1.25 1.25",
'transformation' => "0.1736481 -0.9848078 0 0 -0.9848078 -0.1736481 0 0 0 0 1 0 0 0 0 1",
'file' => "./map/env.png",
'gamma' => 1,
'storage' => "byte"
]);
$light->id = 0;
$scene->registerLight($light);
// 9、创建地面模型
$mapping = new texture\mapping\Mapping();
$mapping->useUVMapping2d(0, "0", "0.4 -0.966", "0.3 0.983");
$texture = new texture\procedural\ImageMap([
'file' => "./map/方形阴影遮照.png",
'gain' => 0.6,
'gamma' => 1,
]);
$texture->mapping = $mapping;
$scene->registerTexture($texture);
$materials = new materials\Disney([
'shadowcatcherEnable' => OPEN,
'photongiEnable' => CLOSE
]);
$materials->setBaseColor('1 1 1');
$materials->setTransparencyFront($texture);
$materials->setTransparencyBack($texture);
$scene->registerMaterial($materials);
$obj = new objects\Objects();
$obj->ply = './ply/ground.ply';
$obj->setMaterial($materials);
$scene->registerObjects($obj);
// 二、添加要渲染的模型
$loadModel = $resData->data->scene->model;
$loadCamera = $resData->data->scene->camera;
foreach($loadModel->childsParams as $childParams){
print_r($childParams);
}
?> ?>

BIN
sceneTemplate/map/SD-037.exr

BIN
sceneTemplate/map/env.png

After

Width: 4000  |  Height: 2000  |  Size: 716 KiB

BIN
sceneTemplate/map/方形阴影遮照.png

After

Width: 3000  |  Height: 3000  |  Size: 70 KiB

BIN
sceneTemplate/map/纯白242.png

After

Width: 268  |  Height: 268  |  Size: 3.1 KiB

BIN
sceneTemplate/ply/FaceLight000.ply

BIN
sceneTemplate/ply/FaceLight001.ply

BIN
sceneTemplate/ply/FaceLight002.ply

BIN
sceneTemplate/ply/FaceLight003.ply

BIN
sceneTemplate/ply/FaceLight004.ply

BIN
sceneTemplate/ply/FaceLight005.ply

BIN
sceneTemplate/ply/FaceLight006.ply

BIN
sceneTemplate/ply/ground.ply

2
src/scene/materials/MaterialsBase.php

@ -18,7 +18,7 @@ class MaterialsBase extends BaseCfg
const TYPE_METAL = 'metal2'; //金属度流程的金属材质 const TYPE_METAL = 'metal2'; //金属度流程的金属材质
const TYPE_MIRROR = 'mirror'; //镜面材质,金属度
const TYPE_MIRROR = 'mirror'; //镜面材质,金属度流程

Loading…
Cancel
Save