|
|
@ -264,6 +264,12 @@ class MatHelper{ |
|
|
|
$material->setInteriorIor($matOriginal->matParams->refractionIor); |
|
|
|
$material->setUroughness($matOriginal->matParams->roughness); |
|
|
|
$material->setVroughness($matOriginal->matParams->roughness); |
|
|
|
if($matOriginal->matParams->isFilmEnabled === self::OPEN){ |
|
|
|
$material->setFilmthickness( |
|
|
|
$matOriginal->matParams->filmthickness / 2 |
|
|
|
); |
|
|
|
$material->setFilmior($matOriginal->matParams->filmIor); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//创建一个铺贴对象,使用"uvmapping2d"类型的铺贴对象
|
|
|
@ -363,6 +369,31 @@ class MatHelper{ |
|
|
|
$material->setBumptex($normalTexture); |
|
|
|
} |
|
|
|
|
|
|
|
// 加载镀膜材质纹理
|
|
|
|
if($matOriginal->matParams->isFilmEnabled === self::OPEN && $matOriginal->matParams->filmTexture){ |
|
|
|
$textureUrl = $matOriginal->matParams->filmTexture; |
|
|
|
$textureSavaPath = $cacheFileDir.'/'.basename($textureUrl); |
|
|
|
$textureSavaHandle = fopen($textureSavaPath, "w"); |
|
|
|
(new Client())->get($textureUrl, [RequestOptions::SINK => $textureSavaHandle]); |
|
|
|
|
|
|
|
$fileName = preg_replace('/(\.[^\.]+)$/','',basename($textureSavaPath)); |
|
|
|
$extension = preg_replace('/^('.$fileName.')+/','',basename($textureSavaPath)); |
|
|
|
// 从镀膜材质纹理中 分离 红色通道 作为 镀膜材质强度纹理
|
|
|
|
$filmIntensityTextureSavaPath = $cacheFileDir.'/'.$fileName.'_filmIntensity'.$extension; |
|
|
|
$imagick = new Imagick($textureSavaPath); |
|
|
|
$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); |
|
|
|
|
|
|
|
//TODO: 从镀膜材质纹理中 分离 绿色通道 作为 镀膜材质厚度纹理, 待后续完善
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $material; |
|
|
|
} |
|
|
|