|
@ -195,9 +195,34 @@ class MatHelper{ |
|
|
$material->setClearcoatgloss($subtract); |
|
|
$material->setClearcoatgloss($subtract); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 加载镀膜材质纹理
|
|
|
|
|
|
if($matOriginal->matParams->isFilmEnabled === self::OPEN && $matOriginal->matParams->filmTexture){ |
|
|
|
|
|
$textureUrl = $matOriginal->matParams->filmTexture; |
|
|
|
|
|
$savaTexturePath = $cacheFileDir.'/'.basename($textureUrl); |
|
|
|
|
|
$savaTextureHandle = fopen($savaTexturePath, "w"); |
|
|
|
|
|
(new Client())->get($textureUrl, [RequestOptions::SINK => $savaTextureHandle]); |
|
|
|
|
|
|
|
|
//TODO: 更多贴图通道处理,待后续完善
|
|
|
|
|
|
|
|
|
$fileName = preg_replace('/(\.[^\.]+)$/','',basename($savaTexturePath)); |
|
|
|
|
|
$extension = preg_replace('/^('.$fileName.')+/','',basename($savaTexturePath)); |
|
|
|
|
|
// 从镀膜材质纹理中 分离 红色通道 作为 镀膜材质强度纹理
|
|
|
|
|
|
$filmIntensityTextureSavaPath = $cacheFileDir.'/'.$fileName.'_filmIntensity'.$extension; |
|
|
|
|
|
$imagick = new Imagick($savaTexturePath); |
|
|
|
|
|
$imagick->separateImageChannel(Imagick::CHANNEL_RED); |
|
|
|
|
|
$imagick->setImageCompressionQuality(100); |
|
|
|
|
|
$imagick->writeImage($filmIntensityTextureSavaPath); |
|
|
|
|
|
$filmIntensityTexture = new ImageMap( |
|
|
|
|
|
['file' => $filmIntensityTextureSavaPath] |
|
|
|
|
|
); |
|
|
|
|
|
$filmIntensityTexture->gamma = 1; |
|
|
|
|
|
$filmIntensityTexture->mapping = $mapping; |
|
|
|
|
|
$scene->registerTexture($filmIntensityTexture); |
|
|
|
|
|
$material->setFilmamount($filmIntensityTexture); |
|
|
|
|
|
|
|
|
|
|
|
//TODO: 从清漆涂层纹理中 分离 绿色通道 作为 清漆涂层光泽度纹理, 待后续完善
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: 更多贴图通道处理,待后续完善
|
|
|
return $material; |
|
|
return $material; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|