Browse Source

渲染测式 案例 开发

master
yuanjiajia 1 year ago
parent
commit
2120ba0b6f
  1. 25
      src/utils/MatHelper.php

25
src/utils/MatHelper.php

@ -8,6 +8,7 @@ use Blobt\Luxcore\scene\texture\procedural\ImageMap;
use Blobt\Luxcore\scene\texture\transform\NormalMap; use Blobt\Luxcore\scene\texture\transform\NormalMap;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use GuzzleHttp\RequestOptions; use GuzzleHttp\RequestOptions;
use Imagick;
class MatHelper{ class MatHelper{
@ -73,15 +74,23 @@ class MatHelper{
$textureHandle = fopen($textureSavaPath, "w"); $textureHandle = fopen($textureSavaPath, "w");
(new Client())->get($textureUrl, [RequestOptions::SINK => $textureHandle]); (new Client())->get($textureUrl, [RequestOptions::SINK => $textureHandle]);
$metallicTexture = new ImageMap(
['file' => $textureSavaPath]
$metalnessTextureSavaPath = $downloadDir.'metalness_'.basename($textureUrl);
$metalnessTexture = new Imagick($textureSavaPath);
$metalnessTexture->separateImageChannel(Imagick::CHANNEL_BLUE);
$metalnessTexture->writeImage($metalnessTextureSavaPath);
$metalnessTexture = new ImageMap(
['file' => $metalnessTextureSavaPath]
); );
$metallicTexture->mapping = $mapping;
$scene->registerTexture($metallicTexture);
$material->setMetallic($metallicTexture);
$metalnessTexture->mapping = $mapping;
$scene->registerTexture($metalnessTexture);
$material->setMetallic($metalnessTexture);
$roughnessTextureSavaPath = $downloadDir.'roughness'.basename($textureUrl);
$roughnessTexture = new Imagick($textureSavaPath);
$roughnessTexture->separateImageChannel(Imagick::CHANNEL_BLUE);
$roughnessTexture->writeImage($roughnessTextureSavaPath);
$roughnessTexture = new ImageMap( $roughnessTexture = new ImageMap(
['file' => $textureSavaPath]
['file' => $roughnessTextureSavaPath]
); );
$roughnessTexture->mapping = $mapping; $roughnessTexture->mapping = $mapping;
$scene->registerTexture($roughnessTexture); $scene->registerTexture($roughnessTexture);
@ -106,7 +115,7 @@ class MatHelper{
$material->setBumptex($normalTexture); $material->setBumptex($normalTexture);
} }
//TODO: 更多通道贴图处理,待后续完善
//TODO: 更多贴图通道处理,待后续完善
return $material; return $material;
} }

Loading…
Cancel
Save