|
@ -69,13 +69,16 @@ class MatHelper{ |
|
|
$material->setBaseColor($albedoTexture); |
|
|
$material->setBaseColor($albedoTexture); |
|
|
} |
|
|
} |
|
|
if($matOriginal->matParams->metallicTexture){ |
|
|
if($matOriginal->matParams->metallicTexture){ |
|
|
$textureUrl = $matOriginal->matParams->metallicTexture; |
|
|
|
|
|
$textureSavaPath = $downloadDir.basename($textureUrl); |
|
|
|
|
|
$textureHandle = fopen($textureSavaPath, "w"); |
|
|
|
|
|
(new Client())->get($textureUrl, [RequestOptions::SINK => $textureHandle]); |
|
|
|
|
|
|
|
|
|
|
|
$metalnessTextureSavaPath = $downloadDir.'metalness_'.basename($textureUrl); |
|
|
|
|
|
$metalnessTexture = new Imagick($textureSavaPath); |
|
|
|
|
|
|
|
|
$metallicTextureUrl = $matOriginal->matParams->metallicTexture; |
|
|
|
|
|
$metallicTextureSavaPath = $downloadDir.basename($metallicTextureUrl); |
|
|
|
|
|
$metallicTextureHandle = fopen($metallicTextureSavaPath, "w"); |
|
|
|
|
|
(new Client())->get($metallicTextureUrl, [RequestOptions::SINK => $metallicTextureHandle]); |
|
|
|
|
|
|
|
|
|
|
|
$fileName = preg_replace('/(\.[^\.]+)$/','',basename($metallicTextureUrl)); |
|
|
|
|
|
$suffixName = preg_replace('/^('.$fileName.')+/','',basename($metallicTextureUrl)); |
|
|
|
|
|
// 从金属纹理中 分离 蓝色通道 作为 金属度纹理
|
|
|
|
|
|
$metalnessTextureSavaPath = $downloadDir.$fileName.'_metalness'.$suffixName; |
|
|
|
|
|
$metalnessTexture = new Imagick($metallicTextureSavaPath); |
|
|
$metalnessTexture->separateImageChannel(Imagick::CHANNEL_BLUE); |
|
|
$metalnessTexture->separateImageChannel(Imagick::CHANNEL_BLUE); |
|
|
$metalnessTexture->writeImage($metalnessTextureSavaPath); |
|
|
$metalnessTexture->writeImage($metalnessTextureSavaPath); |
|
|
$metalnessTexture = new ImageMap( |
|
|
$metalnessTexture = new ImageMap( |
|
@ -84,10 +87,10 @@ class MatHelper{ |
|
|
$metalnessTexture->mapping = $mapping; |
|
|
$metalnessTexture->mapping = $mapping; |
|
|
$scene->registerTexture($metalnessTexture); |
|
|
$scene->registerTexture($metalnessTexture); |
|
|
$material->setMetallic($metalnessTexture); |
|
|
$material->setMetallic($metalnessTexture); |
|
|
|
|
|
|
|
|
$roughnessTextureSavaPath = $downloadDir.'roughness'.basename($textureUrl); |
|
|
|
|
|
$roughnessTexture = new Imagick($textureSavaPath); |
|
|
|
|
|
$roughnessTexture->separateImageChannel(Imagick::CHANNEL_BLUE); |
|
|
|
|
|
|
|
|
// 从金属纹理中 分离 绿色通道 作为 粗糙度纹理
|
|
|
|
|
|
$roughnessTextureSavaPath = $downloadDir.$fileName.'_roughness'.$suffixName; |
|
|
|
|
|
$roughnessTexture = new Imagick($metallicTextureSavaPath); |
|
|
|
|
|
$roughnessTexture->separateImageChannel(Imagick::CHANNEL_GREEN); |
|
|
$roughnessTexture->writeImage($roughnessTextureSavaPath); |
|
|
$roughnessTexture->writeImage($roughnessTextureSavaPath); |
|
|
$roughnessTexture = new ImageMap( |
|
|
$roughnessTexture = new ImageMap( |
|
|
['file' => $roughnessTextureSavaPath] |
|
|
['file' => $roughnessTextureSavaPath] |
|
|