Blender渲染
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

163 lines
4.9 KiB

  1. <?php
  2. namespace Blobt\Luxcore\scene\materials;
  3. use Blobt\Luxcore\core\Base;
  4. use Blobt\Luxcore\scene\Scene;
  5. class Glossy extends MaterialsBase
  6. {
  7. const TYPE_GLOSSY = 'glossy2';
  8. /**
  9. * @var string 漫反射颜色,一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名
  10. */
  11. public $kd = "0.7 0.7 0.7";
  12. /**
  13. * @var string 高光反射颜色,如果设置使用了 IOR 参数,此出只能固定为"1 1 1",否则是一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名;
  14. */
  15. public $ks = "0.05 0.05 0.05";
  16. /**
  17. * @var string 吸收颜色,一个小数形式的RGB色值,或是一个textures(贴图数组)中的某个键名
  18. */
  19. public $ka = "0 0 0";
  20. /**
  21. * @var float 吸收颜色深度,一个大于等于0的小数,或是一个textures(贴图数组)中的某个键名
  22. */
  23. public $d = 0;
  24. /**
  25. * @var float U向粗糙度,一个0-0.8的小数,或是一个textures(贴图数组)中的某个键名
  26. */
  27. public $uroughness = 0.05;
  28. /**
  29. * @var float V向粗糙度,一个0-0.8的小数,或是一个textures(贴图数组)中的某个键名
  30. */
  31. public $vroughness = 0.05;
  32. /**
  33. * @var float 菲列尔折射率,如果设置为1-2的一个小数或一个textures(贴图数组)中的某个键名,表示使用这个数值的 IOR 参数,
  34. * 如果设置为"0 0 0",表示不使用 IOR 参数
  35. */
  36. public $index = "0 0 0";
  37. /**
  38. * @var bool TODO:否是使用多弹射,具体作用尚未明确,(默认取值:false)
  39. */
  40. public $multibounce = self::CLOSE;
  41. public function __construct($config = [])
  42. {
  43. $this->type = self::TYPE_GLOSSY;
  44. $this->id = Scene::createID();
  45. Base::__construct($config);
  46. }
  47. public function setUroughness($color)
  48. {
  49. if( is_object($color) )
  50. {
  51. if( $color->registerId != null ) $this->uroughness = $color->registerId;
  52. else
  53. {
  54. throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
  55. }
  56. }
  57. else $this->uroughness = $color;
  58. }
  59. public function setVroughness($color)
  60. {
  61. if( is_object($color) )
  62. {
  63. if( $color->registerId != null ) $this->vroughness = $color->registerId;
  64. else
  65. {
  66. throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
  67. }
  68. }
  69. else $this->vroughness = $color;
  70. }
  71. public function setBaseColor($color)
  72. {
  73. if( is_object($color) )
  74. {
  75. if( $color->registerId != null ) $this->kd = $color->registerId;
  76. else
  77. {
  78. throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
  79. }
  80. }
  81. else $this->kd = $color;
  82. }
  83. public function setSpecular($color)
  84. {
  85. if( is_object($color) )
  86. {
  87. if( $color->registerId != null ) $this->ks = $color->registerId;
  88. else
  89. {
  90. throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
  91. }
  92. }
  93. else $this->ks = $color;
  94. }
  95. public function setAbsorption($color)
  96. {
  97. if( is_object($color) )
  98. {
  99. if( $color->registerId != null ) $this->ka = $color->registerId;
  100. else
  101. {
  102. throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
  103. }
  104. }
  105. else $this->ka = $color;
  106. }
  107. public function setAbsorptionDepht($color)
  108. {
  109. if( is_object($color) )
  110. {
  111. if( $color->registerId != null ) $this->d = $color->registerId;
  112. else
  113. {
  114. throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
  115. }
  116. }
  117. else $this->d = $color;
  118. }
  119. public function setIor($color)
  120. {
  121. if( is_object($color) )
  122. {
  123. if( $color->registerId != null ) $this->index = $color->registerId;
  124. else
  125. {
  126. throw new \Exception("You use an unregistered ".$color->getInstanceClassName()." object for the current property");
  127. }
  128. }
  129. else $this->index = $color;
  130. }
  131. public function openMultiBounce()
  132. {
  133. $this->multibounce = self::OPEN;
  134. }
  135. public function closeMultiBounce()
  136. {
  137. $this->multibounce = self::CLOSE;
  138. }
  139. }
  140. ?>