Browse Source

渲染测式 开发

master
yuanjiajia 1 year ago
parent
commit
58a644acf1
  1. 24
      src/utils/MatHelper.php

24
src/utils/MatHelper.php

@ -516,7 +516,6 @@ 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) {
// 获取每个像素色值;
@ -525,17 +524,17 @@ class MatHelper{
$g = $value["g"];
$b = $value["b"];
$a = $value["a"];
$brightness = 0;
foreach([$r,$g,$b] as $value){
$brightness = $value > $brightness ? $value : $brightness;
}
$gain = 0;
if($brightness !== 0){
$gain = ((255-$brightness) / $brightness) * ($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));
// $brightness = 0;
// foreach([$r,$g,$b] as $value){
// $brightness = $value > $brightness ? $value : $brightness;
// }
// $gain = 0;
// if($brightness !== 0){
// $gain = ((255-$brightness) / $brightness) * ($translucencyIntensity ** (1/2.2));
// }
$r = round($r * (1-$translucencyIntensity));
$g = round($g * (1-$translucencyIntensity));
$b = round($b * (1-$translucencyIntensity));
$rgbaColor = "rgba({$r}, {$g}, {$b}, {$a})";
$pixel->setColor($rgbaColor);
// $hexColor = self::rgbToHexColor("rgb({$value["r"]}, {$value["g"]}, {$value["b"]})");
@ -546,7 +545,6 @@ class MatHelper{
}
$imageIterator->syncIterator();
}
echo date("Y-m-d H:i:s")."\n";
$imagick->setImageCompressionQuality(100);
$imagick->writeImage($diffuseReflectionTextureSavaPath);
$diffuseReflectionTexture = new ImageMap(

Loading…
Cancel
Save