Browse Source

渲染测式 开发

master
yuanjiajia 1 year ago
parent
commit
00e72f145c
  1. 27
      src/utils/MatHelper.php

27
src/utils/MatHelper.php

@ -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;
} }

Loading…
Cancel
Save