Browse Source

渲染测式 开发

master
yuanjiajia 1 year ago
parent
commit
5222bf944d
  1. 29
      src/utils/MatHelper.php

29
src/utils/MatHelper.php

@ -34,7 +34,26 @@ class MatHelper{
return $floatColor;
}
/**
* 获得 十六进制颜色 同色调 最大亮度
*/
static function colorMaxBrightness($hexColor){
$r = (hexdec(substr($hexColor, 1, 2)));
$g = (hexdec(substr($hexColor, 3, 2)));
$b = (hexdec(substr($hexColor, 5, 2)));
$MaxBrightnessPass = 0;
foreach([$r, $g, $b] as $value){
$MaxBrightnessPass = $value > $MaxBrightnessPass ? $value : $MaxBrightnessPass;
}
$scale = 255 / $MaxBrightnessPass;
$r =dechex(round($r * $scale));
$g =dechex(round($g * $scale));
$b =dechex(round($b * $scale));
return "#{$r}{$g}{$b}";
}
/**
@ -411,9 +430,17 @@ class MatHelper{
$matOriginal->matParams->translucencyColor
));
$material->setBaseColor( self::hex2floatColor(
$matOriginal->matParams->translucencyColor,
self::colorMaxBrightness($matOriginal->matParams->translucencyColor),
1 - $translucencyIntensity
));
// $material->setSpecular(
// self::colorMaxBrightness($matOriginal->matParams->translucencyColor),
// 1 - $translucencyIntensity
// );
// $material->setSpecular_BF(
// self::colorMaxBrightness($matOriginal->matParams->translucencyColor),
// 1 - $translucencyIntensity
// );
$material->setSpecular("0.04 0.04 0.04");
$material->setSpecular_BF("0.04 0.04 0.04");
$material->setUroughness($matOriginal->matParams->roughness ** 2.2);

Loading…
Cancel
Save