|
|
@ -516,18 +516,34 @@ class MatHelper{ |
|
|
|
$diffuseReflectionTextureSavaPath = $cacheFileDir.'/'.$fileName.'_diffuseReflection'.$extension; |
|
|
|
$imagick = new Imagick($textureSavaPath); |
|
|
|
$imageIterator = $imagick->getPixelIterator(); |
|
|
|
echo date("Y-m-d H:i:s")."\n"; |
|
|
|
foreach ($imageIterator as $row => $pixels) { |
|
|
|
foreach ($pixels as $column => $pixel) { |
|
|
|
// 获取每个像素色值;
|
|
|
|
$value = $pixel->getColor(); |
|
|
|
$hexColor = self::rgbToHexColor("rgb({$value["r"]}, {$value["g"]}, {$value["b"]})"); |
|
|
|
$hexColor = self::colorMaxBrightness($hexColor,$translucencyIntensity ** (1/2.2)); |
|
|
|
$hexaColor = $hexColor . dechex(round($value["a"] * 255)); |
|
|
|
$rgbaColor = self::hexaToRgbaColor($hexaColor, 1 - $translucencyIntensity); |
|
|
|
$r = $value["r"]; |
|
|
|
$g = $value["g"]; |
|
|
|
$b = $value["b"]; |
|
|
|
$a = $value["a"]; |
|
|
|
$maxBrightness = 0; |
|
|
|
foreach([$r,$g,$b] as $value){ |
|
|
|
$maxBrightness = $value > $maxBrightness ? $value : $maxBrightness; |
|
|
|
} |
|
|
|
$gain = ((255-$maxBrightness) / $maxBrightness) * ($translucencyIntensity ** (1/2.2)); |
|
|
|
$r = round(($r + $r * $gain) * (1-$translucencyIntensity)); |
|
|
|
$g = round(($g + $g * $gain) * (1-$translucencyIntensity)); |
|
|
|
$b = round(($b + $b * $gain) * (1-$translucencyIntensity)); |
|
|
|
$rgbaColor = "rgba({$r}, {$g}, {$b}, {$a})"; |
|
|
|
$pixel->setColor($rgbaColor); |
|
|
|
// $hexColor = self::rgbToHexColor("rgb({$value["r"]}, {$value["g"]}, {$value["b"]})");
|
|
|
|
// $hexColor = self::colorMaxBrightness($hexColor,$translucencyIntensity ** (1/2.2));
|
|
|
|
// $hexaColor = $hexColor . dechex(round($value["a"] * 255));
|
|
|
|
// $rgbaColor = self::hexaToRgbaColor($hexaColor, 1 - $translucencyIntensity);
|
|
|
|
// $pixel->setColor($rgbaColor);
|
|
|
|
} |
|
|
|
$imageIterator->syncIterator(); |
|
|
|
} |
|
|
|
echo date("Y-m-d H:i:s")."\n"; |
|
|
|
$imagick->setImageCompressionQuality(100); |
|
|
|
$imagick->writeImage($diffuseReflectionTextureSavaPath); |
|
|
|
$diffuseReflectionTexture = new ImageMap( |
|
|
|