|
@ -18,6 +18,19 @@ class MatHelper{ |
|
|
const OPEN = 1 | true; |
|
|
const OPEN = 1 | true; |
|
|
const CLOSE = 0 | false; |
|
|
const CLOSE = 0 | false; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 十六进制颜色 转换为 浮点数颜色 |
|
|
|
|
|
*/ |
|
|
|
|
|
static function hex2floatColor($hexColor, $scale = 1){ |
|
|
|
|
|
$floatColor = ''; |
|
|
|
|
|
$hexColor = trim($hexColor); |
|
|
|
|
|
$r = (hexdec(substr($hexColor, 1, 2))/255) ** 2.2 * $scale; |
|
|
|
|
|
$g = (hexdec(substr($hexColor, 3, 2))/255) ** 2.2 * $scale; |
|
|
|
|
|
$b = (hexdec(substr($hexColor, 5, 2))/255) ** 2.2 * $scale; |
|
|
|
|
|
$floatColor = "$r $g $b"; |
|
|
|
|
|
return $floatColor; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 创建一个 Disney 的材质 |
|
|
* 创建一个 Disney 的材质 |
|
|
*/ |
|
|
*/ |
|
@ -64,8 +77,8 @@ class MatHelper{ |
|
|
if($matOriginal->matParams->albedoTexture){ |
|
|
if($matOriginal->matParams->albedoTexture){ |
|
|
$textureUrl = $matOriginal->matParams->albedoTexture; |
|
|
$textureUrl = $matOriginal->matParams->albedoTexture; |
|
|
$textureSavaPath = $cacheFileDir.'/'.basename($textureUrl); |
|
|
$textureSavaPath = $cacheFileDir.'/'.basename($textureUrl); |
|
|
$textureHandle = fopen($textureSavaPath, "w"); |
|
|
|
|
|
(new Client())->get($textureUrl, [RequestOptions::SINK => $textureHandle]); |
|
|
|
|
|
|
|
|
$textureSavaHandle = fopen($textureSavaPath, "w"); |
|
|
|
|
|
(new Client())->get($textureUrl, [RequestOptions::SINK => $textureSavaHandle]); |
|
|
|
|
|
|
|
|
$albedoTexture = new ImageMap( |
|
|
$albedoTexture = new ImageMap( |
|
|
['file' => $textureSavaPath] |
|
|
['file' => $textureSavaPath] |
|
@ -77,19 +90,19 @@ class MatHelper{ |
|
|
|
|
|
|
|
|
// 加载金属度纹理、粗糙度纹理
|
|
|
// 加载金属度纹理、粗糙度纹理
|
|
|
if($matOriginal->matParams->metallicTexture){ |
|
|
if($matOriginal->matParams->metallicTexture){ |
|
|
$metallicTextureUrl = $matOriginal->matParams->metallicTexture; |
|
|
|
|
|
$metallicTextureSavaPath = $cacheFileDir.'/'.basename($metallicTextureUrl); |
|
|
|
|
|
$metallicTextureHandle = fopen($metallicTextureSavaPath, "w"); |
|
|
|
|
|
(new Client())->get($metallicTextureUrl, [RequestOptions::SINK => $metallicTextureHandle]); |
|
|
|
|
|
|
|
|
$textureUrl = $matOriginal->matParams->metallicTexture; |
|
|
|
|
|
$textureSavaPath = $cacheFileDir.'/'.basename($textureUrl); |
|
|
|
|
|
$textureSavaHandle = fopen($textureSavaPath, "w"); |
|
|
|
|
|
(new Client())->get($textureUrl, [RequestOptions::SINK => $textureSavaHandle]); |
|
|
|
|
|
|
|
|
$fileName = preg_replace('/(\.[^\.]+)$/','',basename($metallicTextureUrl)); |
|
|
|
|
|
$extension = preg_replace('/^('.$fileName.')+/','',basename($metallicTextureUrl)); |
|
|
|
|
|
|
|
|
$fileName = preg_replace('/(\.[^\.]+)$/','',basename($textureSavaPath)); |
|
|
|
|
|
$extension = preg_replace('/^('.$fileName.')+/','',basename($textureSavaPath)); |
|
|
// 从金属纹理中 分离 蓝色通道 作为 金属度纹理
|
|
|
// 从金属纹理中 分离 蓝色通道 作为 金属度纹理
|
|
|
$metalnessTextureSavaPath = $cacheFileDir.'/'.$fileName.'_metalness'.$extension; |
|
|
$metalnessTextureSavaPath = $cacheFileDir.'/'.$fileName.'_metalness'.$extension; |
|
|
$metalnessTexture = new Imagick($metallicTextureSavaPath); |
|
|
|
|
|
$metalnessTexture->separateImageChannel(Imagick::CHANNEL_BLUE); |
|
|
|
|
|
$metalnessTexture->setImageCompressionQuality(100); |
|
|
|
|
|
$metalnessTexture->writeImage($metalnessTextureSavaPath); |
|
|
|
|
|
|
|
|
$imagick = new Imagick($textureSavaPath); |
|
|
|
|
|
$imagick->separateImageChannel(Imagick::CHANNEL_BLUE); |
|
|
|
|
|
$imagick->setImageCompressionQuality(100); |
|
|
|
|
|
$imagick->writeImage($metalnessTextureSavaPath); |
|
|
$metalnessTexture = new ImageMap( |
|
|
$metalnessTexture = new ImageMap( |
|
|
['file' => $metalnessTextureSavaPath] |
|
|
['file' => $metalnessTextureSavaPath] |
|
|
); |
|
|
); |
|
@ -99,10 +112,10 @@ class MatHelper{ |
|
|
$material->setMetallic($metalnessTexture); |
|
|
$material->setMetallic($metalnessTexture); |
|
|
// 从金属纹理中 分离 绿色通道 作为 粗糙度纹理
|
|
|
// 从金属纹理中 分离 绿色通道 作为 粗糙度纹理
|
|
|
$roughnessTextureSavaPath = $cacheFileDir.'/'.$fileName.'_roughness'.$extension; |
|
|
$roughnessTextureSavaPath = $cacheFileDir.'/'.$fileName.'_roughness'.$extension; |
|
|
$roughnessTexture = new Imagick($metallicTextureSavaPath); |
|
|
|
|
|
$roughnessTexture->separateImageChannel(Imagick::CHANNEL_GREEN); |
|
|
|
|
|
$roughnessTexture->setImageCompressionQuality(100); |
|
|
|
|
|
$roughnessTexture->writeImage($roughnessTextureSavaPath); |
|
|
|
|
|
|
|
|
$imagick = new Imagick($textureSavaPath); |
|
|
|
|
|
$imagick->separateImageChannel(Imagick::CHANNEL_GREEN); |
|
|
|
|
|
$imagick->setImageCompressionQuality(100); |
|
|
|
|
|
$imagick->writeImage($roughnessTextureSavaPath); |
|
|
$roughnessTexture = new ImageMap( |
|
|
$roughnessTexture = new ImageMap( |
|
|
['file' => $roughnessTextureSavaPath] |
|
|
['file' => $roughnessTextureSavaPath] |
|
|
); |
|
|
); |
|
@ -116,14 +129,14 @@ class MatHelper{ |
|
|
if($matOriginal->matParams->bumpTexture){ |
|
|
if($matOriginal->matParams->bumpTexture){ |
|
|
$textureUrl = $matOriginal->matParams->bumpTexture; |
|
|
$textureUrl = $matOriginal->matParams->bumpTexture; |
|
|
$textureSavaPath = $cacheFileDir.'/'.basename($textureUrl); |
|
|
$textureSavaPath = $cacheFileDir.'/'.basename($textureUrl); |
|
|
$textureHandle = fopen($textureSavaPath, "w"); |
|
|
|
|
|
(new Client())->get($textureUrl, [RequestOptions::SINK => $textureHandle]); |
|
|
|
|
|
|
|
|
$textureSavaHandle = fopen($textureSavaPath, "w"); |
|
|
|
|
|
(new Client())->get($textureUrl, [RequestOptions::SINK => $textureSavaHandle]); |
|
|
|
|
|
|
|
|
// 因为 LuxCore 使用 opengl 规范的法线纹理格式,与 babylon 使用的 DirectX 不同,
|
|
|
// 因为 LuxCore 使用 opengl 规范的法线纹理格式,与 babylon 使用的 DirectX 不同,
|
|
|
// 所以这里需要反转 G 通道色值,以保证法线纹理应用效果与 babylon 一致。
|
|
|
// 所以这里需要反转 G 通道色值,以保证法线纹理应用效果与 babylon 一致。
|
|
|
$fileName = preg_replace('/(\.[^\.]+)$/','',basename($textureSavaPath)); |
|
|
$fileName = preg_replace('/(\.[^\.]+)$/','',basename($textureSavaPath)); |
|
|
$extension = preg_replace('/^('.$fileName.')+/','',basename($textureSavaPath)); |
|
|
$extension = preg_replace('/^('.$fileName.')+/','',basename($textureSavaPath)); |
|
|
$textureInvertGPath = $cacheFileDir.'/'.$fileName.'_InvertG'.$extension; |
|
|
|
|
|
|
|
|
$textureInvertSavaGPath = $cacheFileDir.'/'.$fileName.'_InvertG'.$extension; |
|
|
$imagick = new Imagick($textureSavaPath); |
|
|
$imagick = new Imagick($textureSavaPath); |
|
|
$imageIterator = $imagick->getPixelIterator(); |
|
|
$imageIterator = $imagick->getPixelIterator(); |
|
|
foreach ($imageIterator as $row => $pixels) { |
|
|
foreach ($imageIterator as $row => $pixels) { |
|
@ -140,10 +153,10 @@ class MatHelper{ |
|
|
$imageIterator->syncIterator(); |
|
|
$imageIterator->syncIterator(); |
|
|
} |
|
|
} |
|
|
$imagick->setImageCompressionQuality(100); |
|
|
$imagick->setImageCompressionQuality(100); |
|
|
$imagick->writeImage($textureInvertGPath); |
|
|
|
|
|
|
|
|
$imagick->writeImage($textureInvertSavaGPath); |
|
|
|
|
|
|
|
|
$bumpTexture = new ImageMap( |
|
|
$bumpTexture = new ImageMap( |
|
|
['file' => $textureInvertGPath] |
|
|
|
|
|
|
|
|
['file' => $textureInvertSavaGPath] |
|
|
); |
|
|
); |
|
|
$bumpTexture->gamma = 1; |
|
|
$bumpTexture->gamma = 1; |
|
|
$bumpTexture->mapping = $mapping; |
|
|
$bumpTexture->mapping = $mapping; |
|
@ -159,15 +172,15 @@ class MatHelper{ |
|
|
// 加载清漆涂层纹理
|
|
|
// 加载清漆涂层纹理
|
|
|
if($matOriginal->matParams->isClearCoatEnabled === self::OPEN && $matOriginal->matParams->clearCoatTexture){ |
|
|
if($matOriginal->matParams->isClearCoatEnabled === self::OPEN && $matOriginal->matParams->clearCoatTexture){ |
|
|
$textureUrl = $matOriginal->matParams->clearCoatTexture; |
|
|
$textureUrl = $matOriginal->matParams->clearCoatTexture; |
|
|
$savaTexturePath = $cacheFileDir.'/'.basename($textureUrl); |
|
|
|
|
|
$savaTextureHandle = fopen($savaTexturePath, "w"); |
|
|
|
|
|
(new Client())->get($textureUrl, [RequestOptions::SINK => $savaTextureHandle]); |
|
|
|
|
|
|
|
|
$textureSavaPath = $cacheFileDir.'/'.basename($textureUrl); |
|
|
|
|
|
$textureSavaHandle = fopen($textureSavaPath, "w"); |
|
|
|
|
|
(new Client())->get($textureUrl, [RequestOptions::SINK => $textureSavaHandle]); |
|
|
|
|
|
|
|
|
$fileName = preg_replace('/(\.[^\.]+)$/','',basename($savaTexturePath)); |
|
|
|
|
|
$extension = preg_replace('/^('.$fileName.')+/','',basename($savaTexturePath)); |
|
|
|
|
|
|
|
|
$fileName = preg_replace('/(\.[^\.]+)$/','',basename($textureSavaPath)); |
|
|
|
|
|
$extension = preg_replace('/^('.$fileName.')+/','',basename($textureSavaPath)); |
|
|
// 从清漆涂层纹理中 分离 红色通道 作为 清漆涂层强度纹理
|
|
|
// 从清漆涂层纹理中 分离 红色通道 作为 清漆涂层强度纹理
|
|
|
$coatIntensityTextureSavaPath = $cacheFileDir.'/'.$fileName.'_coatIntensity'.$extension; |
|
|
$coatIntensityTextureSavaPath = $cacheFileDir.'/'.$fileName.'_coatIntensity'.$extension; |
|
|
$imagick = new Imagick($savaTexturePath); |
|
|
|
|
|
|
|
|
$imagick = new Imagick($textureSavaPath); |
|
|
$imagick->separateImageChannel(Imagick::CHANNEL_RED); |
|
|
$imagick->separateImageChannel(Imagick::CHANNEL_RED); |
|
|
$imagick->setImageCompressionQuality(100); |
|
|
$imagick->setImageCompressionQuality(100); |
|
|
$imagick->writeImage($coatIntensityTextureSavaPath); |
|
|
$imagick->writeImage($coatIntensityTextureSavaPath); |
|
@ -180,7 +193,7 @@ class MatHelper{ |
|
|
$material->setClearcoat($coatIntensityTexture); |
|
|
$material->setClearcoat($coatIntensityTexture); |
|
|
// 从清漆涂层纹理中 分离 绿色通道 作为 清漆涂层光泽度纹理
|
|
|
// 从清漆涂层纹理中 分离 绿色通道 作为 清漆涂层光泽度纹理
|
|
|
$coatGlossTextureSavaPath = $cacheFileDir.'/'.$fileName.'_coatGloss'.$extension; |
|
|
$coatGlossTextureSavaPath = $cacheFileDir.'/'.$fileName.'_coatGloss'.$extension; |
|
|
$imagick = new Imagick($savaTexturePath); |
|
|
|
|
|
|
|
|
$imagick = new Imagick($textureSavaPath); |
|
|
$imagick->separateImageChannel(Imagick::CHANNEL_GREEN); |
|
|
$imagick->separateImageChannel(Imagick::CHANNEL_GREEN); |
|
|
$imagick->setImageCompressionQuality(100); |
|
|
$imagick->setImageCompressionQuality(100); |
|
|
$imagick->writeImage($coatGlossTextureSavaPath); |
|
|
$imagick->writeImage($coatGlossTextureSavaPath); |
|
@ -201,15 +214,15 @@ class MatHelper{ |
|
|
// 加载镀膜材质纹理
|
|
|
// 加载镀膜材质纹理
|
|
|
if($matOriginal->matParams->isFilmEnabled === self::OPEN && $matOriginal->matParams->filmTexture){ |
|
|
if($matOriginal->matParams->isFilmEnabled === self::OPEN && $matOriginal->matParams->filmTexture){ |
|
|
$textureUrl = $matOriginal->matParams->filmTexture; |
|
|
$textureUrl = $matOriginal->matParams->filmTexture; |
|
|
$savaTexturePath = $cacheFileDir.'/'.basename($textureUrl); |
|
|
|
|
|
$savaTextureHandle = fopen($savaTexturePath, "w"); |
|
|
|
|
|
(new Client())->get($textureUrl, [RequestOptions::SINK => $savaTextureHandle]); |
|
|
|
|
|
|
|
|
$textureSavaPath = $cacheFileDir.'/'.basename($textureUrl); |
|
|
|
|
|
$textureSavaHandle = fopen($textureSavaPath, "w"); |
|
|
|
|
|
(new Client())->get($textureUrl, [RequestOptions::SINK => $textureSavaHandle]); |
|
|
|
|
|
|
|
|
$fileName = preg_replace('/(\.[^\.]+)$/','',basename($savaTexturePath)); |
|
|
|
|
|
$extension = preg_replace('/^('.$fileName.')+/','',basename($savaTexturePath)); |
|
|
|
|
|
|
|
|
$fileName = preg_replace('/(\.[^\.]+)$/','',basename($textureSavaPath)); |
|
|
|
|
|
$extension = preg_replace('/^('.$fileName.')+/','',basename($textureSavaPath)); |
|
|
// 从镀膜材质纹理中 分离 红色通道 作为 镀膜材质强度纹理
|
|
|
// 从镀膜材质纹理中 分离 红色通道 作为 镀膜材质强度纹理
|
|
|
$filmIntensityTextureSavaPath = $cacheFileDir.'/'.$fileName.'_filmIntensity'.$extension; |
|
|
$filmIntensityTextureSavaPath = $cacheFileDir.'/'.$fileName.'_filmIntensity'.$extension; |
|
|
$imagick = new Imagick($savaTexturePath); |
|
|
|
|
|
|
|
|
$imagick = new Imagick($textureSavaPath); |
|
|
$imagick->separateImageChannel(Imagick::CHANNEL_RED); |
|
|
$imagick->separateImageChannel(Imagick::CHANNEL_RED); |
|
|
$imagick->setImageCompressionQuality(100); |
|
|
$imagick->setImageCompressionQuality(100); |
|
|
$imagick->writeImage($filmIntensityTextureSavaPath); |
|
|
$imagick->writeImage($filmIntensityTextureSavaPath); |
|
@ -262,8 +275,8 @@ class MatHelper{ |
|
|
if($matOriginal->matParams->refractivityTexture){ |
|
|
if($matOriginal->matParams->refractivityTexture){ |
|
|
$textureUrl = $matOriginal->matParams->refractivityTexture; |
|
|
$textureUrl = $matOriginal->matParams->refractivityTexture; |
|
|
$textureSavaPath = $cacheFileDir.'/'.basename($textureUrl); |
|
|
$textureSavaPath = $cacheFileDir.'/'.basename($textureUrl); |
|
|
$textureHandle = fopen($textureSavaPath, "w"); |
|
|
|
|
|
(new Client())->get($textureUrl, [RequestOptions::SINK => $textureHandle]); |
|
|
|
|
|
|
|
|
$textureSavaHandle = fopen($textureSavaPath, "w"); |
|
|
|
|
|
(new Client())->get($textureUrl, [RequestOptions::SINK => $textureSavaHandle]); |
|
|
|
|
|
|
|
|
$imageMap = new ImageMap( |
|
|
$imageMap = new ImageMap( |
|
|
['file' => $textureSavaPath] |
|
|
['file' => $textureSavaPath] |
|
@ -275,16 +288,16 @@ class MatHelper{ |
|
|
|
|
|
|
|
|
// 加载金属度纹理、粗糙度纹理
|
|
|
// 加载金属度纹理、粗糙度纹理
|
|
|
if($matOriginal->matParams->metallicTexture){ |
|
|
if($matOriginal->matParams->metallicTexture){ |
|
|
$metallicTextureUrl = $matOriginal->matParams->metallicTexture; |
|
|
|
|
|
$metallicTextureSavaPath = $cacheFileDir.'/'.basename($metallicTextureUrl); |
|
|
|
|
|
$metallicTextureHandle = fopen($metallicTextureSavaPath, "w"); |
|
|
|
|
|
(new Client())->get($metallicTextureUrl, [RequestOptions::SINK => $metallicTextureHandle]); |
|
|
|
|
|
|
|
|
$textureUrl = $matOriginal->matParams->metallicTexture; |
|
|
|
|
|
$textureSavaPath = $cacheFileDir.'/'.basename($textureUrl); |
|
|
|
|
|
$textureSavaHandle = fopen($textureSavaPath, "w"); |
|
|
|
|
|
(new Client())->get($textureUrl, [RequestOptions::SINK => $textureSavaHandle]); |
|
|
|
|
|
|
|
|
$fileName = preg_replace('/(\.[^\.]+)$/','',basename($metallicTextureSavaPath)); |
|
|
|
|
|
$extension = preg_replace('/^('.$fileName.')+/','',basename($metallicTextureSavaPath)); |
|
|
|
|
|
|
|
|
$fileName = preg_replace('/(\.[^\.]+)$/','',basename($textureSavaPath)); |
|
|
|
|
|
$extension = preg_replace('/^('.$fileName.')+/','',basename($textureSavaPath)); |
|
|
// 从金属纹理中 分离 绿色通道 作为 粗糙度纹理
|
|
|
// 从金属纹理中 分离 绿色通道 作为 粗糙度纹理
|
|
|
$roughnessTextureSavaPath = $cacheFileDir.'/'.$fileName.'_roughness'.$extension; |
|
|
$roughnessTextureSavaPath = $cacheFileDir.'/'.$fileName.'_roughness'.$extension; |
|
|
$imagick = new Imagick($metallicTextureSavaPath); |
|
|
|
|
|
|
|
|
$imagick = new Imagick($textureSavaPath); |
|
|
$imagick->separateImageChannel(Imagick::CHANNEL_GREEN); |
|
|
$imagick->separateImageChannel(Imagick::CHANNEL_GREEN); |
|
|
$imagick->setImageCompressionQuality(100); |
|
|
$imagick->setImageCompressionQuality(100); |
|
|
$imagick->writeImage($roughnessTextureSavaPath); |
|
|
$imagick->writeImage($roughnessTextureSavaPath); |
|
@ -337,8 +350,8 @@ class MatHelper{ |
|
|
// if($matOriginal->matParams->translucencyTexture){
|
|
|
// if($matOriginal->matParams->translucencyTexture){
|
|
|
// $textureUrl = $matOriginal->matParams->translucencyTexture;
|
|
|
// $textureUrl = $matOriginal->matParams->translucencyTexture;
|
|
|
// $textureSavaPath = $cacheFileDir.'/'.basename($textureUrl);
|
|
|
// $textureSavaPath = $cacheFileDir.'/'.basename($textureUrl);
|
|
|
// $textureHandle = fopen($textureSavaPath, "w");
|
|
|
|
|
|
// (new Client())->get($textureUrl, [RequestOptions::SINK => $textureHandle]);
|
|
|
|
|
|
|
|
|
// $textureSavaHandle = fopen($textureSavaPath, "w");
|
|
|
|
|
|
// (new Client())->get($textureUrl, [RequestOptions::SINK => $textureSavaHandle]);
|
|
|
|
|
|
|
|
|
// $imageMap = new ImageMap(
|
|
|
// $imageMap = new ImageMap(
|
|
|
// ['file' => $textureSavaPath]
|
|
|
// ['file' => $textureSavaPath]
|
|
@ -350,16 +363,16 @@ class MatHelper{ |
|
|
|
|
|
|
|
|
// 加载金属度纹理、粗糙度纹理
|
|
|
// 加载金属度纹理、粗糙度纹理
|
|
|
if($matOriginal->matParams->metallicTexture){ |
|
|
if($matOriginal->matParams->metallicTexture){ |
|
|
$metallicTextureUrl = $matOriginal->matParams->metallicTexture; |
|
|
|
|
|
$metallicTextureSavaPath = $cacheFileDir.'/'.basename($metallicTextureUrl); |
|
|
|
|
|
$metallicTextureHandle = fopen($metallicTextureSavaPath, "w"); |
|
|
|
|
|
(new Client())->get($metallicTextureUrl, [RequestOptions::SINK => $metallicTextureHandle]); |
|
|
|
|
|
|
|
|
$textureUrl = $matOriginal->matParams->metallicTexture; |
|
|
|
|
|
$textureSavaPath = $cacheFileDir.'/'.basename($textureUrl); |
|
|
|
|
|
$textureSavaHandle = fopen($textureSavaPath, "w"); |
|
|
|
|
|
(new Client())->get($textureUrl, [RequestOptions::SINK => $textureSavaHandle]); |
|
|
|
|
|
|
|
|
$fileName = preg_replace('/(\.[^\.]+)$/','',basename($metallicTextureSavaPath)); |
|
|
|
|
|
$extension = preg_replace('/^('.$fileName.')+/','',basename($metallicTextureSavaPath)); |
|
|
|
|
|
|
|
|
$fileName = preg_replace('/(\.[^\.]+)$/','',basename($textureSavaPath)); |
|
|
|
|
|
$extension = preg_replace('/^('.$fileName.')+/','',basename($textureSavaPath)); |
|
|
// 从金属纹理中 分离 绿色通道 作为 粗糙度纹理
|
|
|
// 从金属纹理中 分离 绿色通道 作为 粗糙度纹理
|
|
|
$roughnessTextureSavaPath = $cacheFileDir.'/'.$fileName.'_roughness'.$extension; |
|
|
$roughnessTextureSavaPath = $cacheFileDir.'/'.$fileName.'_roughness'.$extension; |
|
|
$imagick = new Imagick($metallicTextureSavaPath); |
|
|
|
|
|
|
|
|
$imagick = new Imagick($textureSavaPath); |
|
|
$imagick->separateImageChannel(Imagick::CHANNEL_GREEN); |
|
|
$imagick->separateImageChannel(Imagick::CHANNEL_GREEN); |
|
|
$imagick->setImageCompressionQuality(100); |
|
|
$imagick->setImageCompressionQuality(100); |
|
|
$imagick->writeImage($roughnessTextureSavaPath); |
|
|
$imagick->writeImage($roughnessTextureSavaPath); |
|
@ -385,19 +398,6 @@ class MatHelper{ |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 十六进制颜色 转换为 浮点数颜色 |
|
|
|
|
|
*/ |
|
|
|
|
|
static function hex2floatColor($hexColor, $scale = 1){ |
|
|
|
|
|
$floatColor = ''; |
|
|
|
|
|
$hexColor = trim($hexColor); |
|
|
|
|
|
$r = (hexdec(substr($hexColor, 1, 2))/255) ** 2.2 * $scale; |
|
|
|
|
|
$g = (hexdec(substr($hexColor, 3, 2))/255) ** 2.2 * $scale; |
|
|
|
|
|
$b = (hexdec(substr($hexColor, 5, 2))/255) ** 2.2 * $scale; |
|
|
|
|
|
$floatColor = "$r $g $b"; |
|
|
|
|
|
return $floatColor; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
?>
|
|
|
?>
|