|
|
@ -8,6 +8,7 @@ use Blobt\Luxcore\scene\texture\procedural\ImageMap; |
|
|
|
use Blobt\Luxcore\scene\texture\transform\NormalMap; |
|
|
|
use GuzzleHttp\Client; |
|
|
|
use GuzzleHttp\RequestOptions; |
|
|
|
use Imagick; |
|
|
|
|
|
|
|
class MatHelper{ |
|
|
|
|
|
|
@ -73,15 +74,23 @@ class MatHelper{ |
|
|
|
$textureHandle = fopen($textureSavaPath, "w"); |
|
|
|
(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( |
|
|
|
['file' => $textureSavaPath] |
|
|
|
['file' => $roughnessTextureSavaPath] |
|
|
|
); |
|
|
|
$roughnessTexture->mapping = $mapping; |
|
|
|
$scene->registerTexture($roughnessTexture); |
|
|
@ -106,7 +115,7 @@ class MatHelper{ |
|
|
|
$material->setBumptex($normalTexture); |
|
|
|
} |
|
|
|
|
|
|
|
//TODO: 更多通道贴图处理,待后续完善
|
|
|
|
//TODO: 更多贴图通道处理,待后续完善
|
|
|
|
|
|
|
|
return $material; |
|
|
|
} |
|
|
|