Browse Source

新增四个纹理相关类文件,修改了“print.php”类文件,其他文件修改了构造函数,解决嵌套类同名属性初始化时,会得到相同值的问题

master
yuanjiajia 3 years ago
parent
commit
4193e93bae
  1. 68
      examples/print.php
  2. 1
      src/scene/light/LigthBase.php
  3. 7
      src/scene/materials/Disney.php
  4. 2
      src/scene/materials/Glass.php
  5. 4
      src/scene/materials/Glossy.php
  6. 13
      src/scene/materials/Metal.php
  7. 2
      src/scene/materials/Mix.php
  8. 2
      src/scene/materials/NullMaterial.php
  9. 2
      src/scene/materials/Roughmatte.php
  10. 0
      src/scene/materials/emission/Emission.php
  11. 0
      src/scene/materials/emission/Visibility.php
  12. 5
      src/scene/objects/Objects.php
  13. 8
      src/scene/render/Batch.php
  14. 16
      src/scene/render/Film.php
  15. 9
      src/scene/render/Path.php
  16. 2
      src/scene/render/Sampler.php
  17. 7
      src/scene/render/cache/LightStrategy.php
  18. 9
      src/scene/render/cache/PhotonGI.php
  19. 79
      src/scene/texture/map/Clouds.php
  20. 14
      src/scene/texture/map/ImageMap.php
  21. 105
      src/scene/texture/mapping/Mapping.php
  22. 52
      src/scene/texture/mapping/Triplanar.php
  23. 38
      src/scene/texture/transform/NormalMap.php

68
examples/print.php

@ -4,6 +4,7 @@
namespace Blobt\Luxcore\scene;
use Blobt\Luxcore\scene\materials;
use Blobt\Luxcore\scene\materials\Emission;
use Blobt\Luxcore\scene\objects;
use Blobt\Luxcore\scene\render;
use Blobt\Luxcore\scene\texture;
@ -15,44 +16,43 @@ include dirname(dirname(__FILE__)) . "/vendor/autoload.php";
echo '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>渲染配置参数>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>';
echo "\n\n\n\n";
/*
//设置打印 渲染引擎 的配置参数
$renderEngine = new RenderEngine();
$renderEngine = new render\RenderEngine();
echo $renderEngine;
//设置打印GPU渲染设备的配置参数
$openCL = new OpenCL();
$openCL = new render\OpenCL();
echo $openCL;
//设置打印光线跟踪的配置参数
$path = new Path();
$path = new render\Path( new render\PathDepth( ['total'=>24,'glossy'=>12] ) );
echo $path;
//设置打印 采样器 配置参数
$sampler = new Sampler();
$sampler = new render\Sampler();
echo $sampler;
//设置打印 灯光策略 配置参数
$lightStrategy = new LightStrategy();
$lightStrategy = new render\LightStrategy();
echo $lightStrategy;
//设置打印 文件储存格式 配置参数
$filesaver = new FileSaver();
$filesaver = new render\FileSaver();
echo $filesaver;
//设置打印 渲染终止 配置参数
$batch = new Batch();
$batch = new render\Batch();
echo $batch;
//设置打印 场景属性 配置参数
$scene = new Scene();
$scene = new render\Scene();
echo $scene;
//设置打印 “胶片” 配置参数
$film = new render\Film();//添加一个胶片,
$film = new render\Film( new render\NoiseEstimation(),new render\Filter() );//添加一个胶片,
$img = new render\Image();
$img->effect = [new render\effect\Pretreatment(),new render\effect\ToneMapLinear(),new render\effect\CammaCorrection()];
@ -68,7 +68,6 @@ $film->addImage($img);
echo $film;
*/
@ -84,26 +83,39 @@ $scene = new Scene();//创建一个场景,
//添加第一个模型
$obj = new objects\Objects( [ 'ply' => 'mesh-10086.ply','appliedtransformation' => '1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1' ] ); //创建一个的模型
$baseColor = new texture\map\Clouds( new texture\mapping\Mapping() );
$bump = new texture\map\ImageMap( new texture\mapping\Mapping() );
$ior = new texture\map\ImageMap( new texture\mapping\Mapping() );
$bumpMap = new texture\ImageMap();
$baseColorMap = new texture\ImageMap();
$metallicMap = new texture\ImageMap();
$baseColor = $scene->addTexture($baseColor);
$bump = $scene->addTexture($bump);
$ior = $scene->addTexture($ior);
$material1 = new materials\Disney(); //创建一个 Disney 材质
$material2 = new materials\Metal(); //创建一个 Metal 材质
$material1 = $scene->addMaterial($material1); //将材质存入材质数组,并获得其键名
$material2 = $scene->addMaterial($material2); //将材质存入材质数组,并获得其键名
$disney = new materials\Disney(); //创建一个 Disney 材质
$disney->setBaseColor($baseColor);
$disney->setBumptex($bump);
$disney->setFilmior($ior);
$disney = $scene->addMaterial($disney); //将材质存入材质数组,并获得其键名
$mix = new materials\Mix(); //创建 Mix 材质,
$mix->material1 = $material1; //为材质通道1 指定一个键名
$mix->material2 = $material2; //为材质通道2 指定一个键名
$mix->amount = 0.6; //指定混合系数为 0.6
$mix = $scene->addMaterial($mix); //将材质存入材质数组,并获得其键名
$obj = new objects\Objects( [ 'ply' => 'mesh-10086.ply','appliedtransformation' => '1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1' ] ); //创建一个的模型,
$obj->material = $mix; //为模型的材属性 指定一个键名
$metal = new materials\Metal(); //创建一个 Metal 材质
$metal->setRefraction($baseColor);
$metal->setBumptex($bump);
$metal = $scene->addMaterial($metal); //将材质存入材质数组,并获得其键名
$scene->addObjects($obj); //将模型添加到场景中
$mix = new materials\Mix(); //创建 Mix 材质,
$mix->setMaterial1($disney); //为材质通道1 指定一个键名
$mix->setMaterial2($metal); //为材质通道2 指定一个键名
$mix->setAmount($baseColor); //指定混合系数为 0.6
$mix = $scene->addMaterial($mix); //将材质存入材质数组,并获得其键名
$obj->setMaterial($mix) ; //为模型的材属性 指定一个键名
$scene->addObjects($obj); //将模型添加到场景中
/*
@ -113,8 +125,10 @@ $obj = new objects\Objects( [ 'ply' => 'mesh-119.ply','appliedtransformation' =>
$obj->material = new materials\Metal( ['fresnel' => "2517393611944Fresnel"] ); //为模型创建一个 金属 类型的材质
$scene->addObject($obj); //将模型添加到场景中
*/
echo $scene;
?>

1
src/scene/light/LigthBase.php

@ -8,7 +8,6 @@ use Blobt\Luxcore\core\Base;
class LightBase extends BaseCfg
{
public function __construct($config = [])
{
$this->id = Scene::createID();

7
src/scene/materials/Disney.php

@ -95,12 +95,14 @@ class Disney extends MaterialsBase
*/
public $bumptex;
/**
* @param $emissio
* @param $visibility
*/
public function __construct($config = [])
{
$this->type = self::TYPE_DISNEY;
$this->id = Scene::createID();
$this->emissionCfg = new Emission($config);
$this->visibility = new Visibility($config);
Base::__construct($config);
}
@ -189,7 +191,6 @@ class Disney extends MaterialsBase
$this->bumptex = $color;
}
}
?>

2
src/scene/materials/Glass.php

@ -81,8 +81,6 @@ class Glass extends MaterialsBase
{
$this->type = self::TYPE_GLASS;
$this->id = Scene::createID();
$this->emissionCfg = new Emission($config);
$this->visibility = new Visibility($config);
Base::__construct($config);
}

4
src/scene/materials/Glossy.php

@ -69,8 +69,6 @@ class Glossy extends MaterialsBase
{
$this->type = self::TYPE_GLOSSY;
$this->id = Scene::createID();
$this->emissionCfg = new Emission($config);
$this->visibility = new Visibility($config);
Base::__construct($config);
}
@ -133,7 +131,7 @@ class Glossy extends MaterialsBase
{
$this->multibounce = false;
}
}
?>

13
src/scene/materials/Metal.php

@ -9,6 +9,11 @@ class Metal extends MaterialsBase
const TYPE_METAL = 'matal';
/**
* @var string 反射颜色,一个小数色值,或是一个textures(贴图数组)中的某个键名
*/
public $kr = '0.7 0.7 0.7';
/**
* @var string 菲列尔参数,一个textures(贴图数组)中的某个键名,只能是“fresnelconst(预设的菲列尔参数)”、
* “fresnelcolor(颜色的菲列尔)”两个类型的帖图。
@ -44,11 +49,15 @@ class Metal extends MaterialsBase
{
$this->type = self::TYPE_METAL;
$this->id = Scene::createID();
$this->emissionCfg = new Emission($config);
$this->visibility = new Visibility($config);
Base::__construct($config);
}
public function setRefraction($color)
{
$this->kr = $color;
}
public function setFresnel($color)
{
$this->fresnel = $color;

2
src/scene/materials/Mix.php

@ -32,8 +32,6 @@ class Mix extends MaterialsBase
{
$this->type = self::TYPE_MIX;
$this->id = Scene::createID();
$this->emissionCfg = new Emission($config);
$this->visibility = new Visibility($config);
Base::__construct($config);
}

2
src/scene/materials/NullMaterial.php

@ -28,8 +28,6 @@ class NullMaterial extends MaterialsBase
{
$this->type = self::TYPE_NULL;
$this->id = Scene::createID();
$this->emissionCfg = new Emission($config);
$this->visibility = new Visibility($config);
Base::__construct($config);
}

2
src/scene/materials/Roughmatte.php

@ -38,8 +38,6 @@ class Roughmatte extends MaterialsBase
{
$this->type = self::TYPE_ROUGHMATTE;
$this->id = Scene::createID();
$this->emissionCfg = new Emission($config);
$this->visibility = new Visibility($config);
Base::__construct($config);
}

src/scene/materials/Emission.php → src/scene/materials/emission/Emission.php

src/scene/materials/Visibility.php → src/scene/materials/emission/Visibility.php

5
src/scene/objects/Objects.php

@ -39,6 +39,11 @@ class Objects extends BaseCfg
Base::__construct($config);
}
public function setMaterial($material)
{
$this->material = $material;
}
}
?>

8
src/scene/render/Batch.php

@ -18,7 +18,7 @@ class Batch extends BaseCfg
public $halttime = 0;
/**
* @var float 噪波阈值,(取值:浮点型色值)
* @var float 噪波阈值,(取值:浮点型色值),如果需要使噪波阈值,这里需要设一个参数,默认为0.02
*/
public $haltthreshold;
@ -27,12 +27,6 @@ class Batch extends BaseCfg
*/
public $haltthresholdcfg;
public function useNoiseThreshold($config= [])
{
$this->haltthresholdcfg = new HaltThresHold($config);
$this->haltthreshold = 0.02;
}
}
?>

16
src/scene/render/Film.php

@ -54,16 +54,14 @@ class Film extends BaseCfg
public $outputs = [];
/**
* 实例 NoiseEstimation类、filter类的两个对象,配置渲染器默认的输出参数”;
* @param object $noiseEstimation 必须传入一个 NoiseEstimationod类对象
* @param object $filter 如果需要设置推荐一个默认的参数,则同时传入一个 Filter类对象
*/
public function __construct($config = [])
{
$this->noiseEstimation = new NoiseEstimation($config);
$this->filter = new Filter($config);
Base::__construct($config);
public function __construct( NoiseEstimation $noiseEstimation,Filter $filter = null,$config = [])
{
$this->noiseEstimation = $noiseEstimation;
$this->filter = $filter;
Base::__construct($config);
}
public function addImage( object $object )

9
src/scene/render/Path.php

@ -43,12 +43,13 @@ class Path extends BaseCfg
/**
* 实例 PathDepth类、HybridBackforWard类的两个对象
* @param object $pathDepth 必须传入一个 PathDepth类对象
* @param object $hybridBackforWard 如果需要设置推荐一个默认的参数,则同时传入一个 HybridBackforWard类对象
*/
public function __construct($config = [])
public function __construct(PathDepth $pathDepth,HybridBackforWard $hybridBackforWard = null,$config = [])
{
$this->pathDepth = new PathDepth($config);
$this->hybridBackforWard= new HybridBackforWard($config);
$this->pathDepth = $pathDepth;
$this->hybridBackforWard= $hybridBackforWard;
Base::__construct($config);
}

2
src/scene/render/Sampler.php

@ -38,7 +38,7 @@ class Sampler extends BaseCfg
*/
public function __construct($config = [])
{
$this->sobol = new Sobol($config);
$this->sobol = new Sobol();
Base::__construct($config);
}

7
src/scene/render/cache/LightStrategy.php

@ -38,10 +38,13 @@ class LightStrategy extends render\LightStrategy
*/
public $entry;
public function __construct($config = [])
/**
* @param object $entry 必须传入一个 Entry类对象
*/
public function __construct(Entry $entry,$config = [])
{
$this->type = self::TYPE_DLS_CACHE;
$this->entry = new Entry($config);
$this->entry = $entry;
Base::__construct($config);
}

9
src/scene/render/cache/PhotonGI.php

@ -38,12 +38,13 @@ class PhotonGI extends BaseCfg
public $caustic;
/**
* 实例 Indirect 类、Caustic类的两个对象
* @param object $indirect 必须传入一个 Indirect类对象
* @param object $caustic 必须传入一个 Caustic类对象
*/
public function __construct($config = [])
public function __construct(Indirect $indirect,Caustic $caustic,$config = [])
{
$this->indirect = new Indirect($config);
$this->caustic = new Caustic($config);
$this->indirect = $indirect;
$this->caustic = $caustic;
Base::__construct($config);
}

79
src/scene/texture/map/Clouds.php

@ -0,0 +1,79 @@
<?php
namespace Blobt\Luxcore\scene\texture\map;
use Blobt\Luxcore\scene\texture\TextureBase;
use Blobt\Luxcore\scene\Scene;
use Blobt\Luxcore\core\Base;
use Blobt\Luxcore\scene\texture\mapping\Mapping;
class Clouds extends TextureBase
{
/**
* 程序贴图的类型
*/
const TYPE_BLENDER_CLOUDS = 'blender_clouds';
/**
* 噪波的 柔和 锐利 类型
*/
const TYPE_SOFT_NOISE = 'soft_noise';
const TYPE_HARD_NOISE = 'hard_noise';
/**
* 噪波 基本效果 类型
*/
const TYPE_BLENDER_ORIGINAL = 'blender_original';
const TYPE_ORIGINAL_PERLIN = 'original_perlin';
const TYPE_IMPROVED_PERLIN = 'oimproved_perlin';
const TYPE_VORONOI_F1 = 'voronoi_f1';
const TYPE_VORONOI_F2 = 'voronoi_f2';
const TYPE_VORONOI_F3 = 'voronoi_f3';
const TYPE_VORONOI_F4 = 'voronoi_f4';
const TYPE_VORONOI_CRACKLE = 'voronoi_crackle';
const TYPE_CELL_NOISE = 'cell_noise';
/**
* @var string 噪波的 柔和 锐利 类型,(取值:soft_noise或hard_noise)
*/
public $noisetype = self::TYPE_SOFT_NOISE;
/**
* @var string 噪波 基本效果 类型,取值是一个属于 基本效果 的字符串常量
*/
public $noisebasis = self::TYPE_BLENDER_ORIGINAL;
/**
* @var float 噪波大小,单位跟随系统,(取值:大于0的小数)
*/
public $noisesize = 0.25;
/**
* @var integer 噪波深度,(取值:0-10的整数)
*/
public $noisedepth = 2;
/**
* @var float 亮度,(取值:大于等于0的小数)
*/
public $bright = 1;
/**
* @var float 对比度,(取值:大于等于0的小数)
*/
public $contrast = 1;
/**
* @param $mapping 必须传入一个 Mapping类对象
*/
public function __construct(Mapping $mapping,$config = [])
{
$this->id = Scene::createID();
$this->mapping = $mapping;
$this->type = self::TYPE_BLENDER_CLOUDS;
Base::__construct($config);
}
}
?>

src/scene/texture/ImageMap.php → src/scene/texture/map/ImageMap.php

105
src/scene/texture/mapping/Mapping.php

@ -6,36 +6,121 @@ use Blobt\Luxcore\scene\BaseCfg;
class Mapping extends BaseCfg
{
/**
* 以模型的UV坐标,调整贴图变换参数的类型
*/
const TYPE_UVMAPPING2D = 'uvmapping2d';
/**
* 以模型的UV坐标,调整贴图随机变换参数的类型
*/
const TYPE_UVRANDOMMAPPING2D = 'uvrandommapping2d';
/**
* 以模型的本地坐标,调整贴图三维变换参数的类型
*/
const TYPE_LOCALMAPPING3D = 'localmapping3d';
/**
* 以世界坐标,调整贴图三维变换参数的类型
*/
const TYPE_GLOBALMAPPING3D = 'globalmapping3d';
/**
* 以模型的本地坐标,调整贴图三维随机变换参数的类型
*/
const TYPE_LOCALRANDOMMAPPING3D = 'localrandommapping3d';
/**
* 以模型的UV坐标,调整贴图三维变换参数的类型
*/
const TYPE_UVMAPPING3D = 'uvmapping3d';
/**
* @var string 铺贴类型
*/
public $type;
//当坐标为UV时,以下参数才可设以置和输出
/**
* @var integer UV通道,只有当坐标为UV时,参数才可设以置和输出
*/
public $uvindex;
//当铺贴类型属于随机时,以下参数才可设以置和输出
/**
* @var integer 当前贴图的ID号(取值:大于0的整数)
* @var string 随机种子类型,当铺贴类型为随机时,参数才可设以置和输出
*/
public $id;
public $seedType;
/**
* @var string 贴图缩放参数
* @var integer 当随机种类型为 object_id_offset时,可以设置为大于等于的整数,否则只能为0,当铺贴类型为随机时,参数才可设以置和输出
*/
public $uvscale = '1 -1';
public $objectidoffsetValue;
/**
* @var string 贴图偏移参数
* @var integer TODO:具体作用尚未明确,(固定取值:0),当铺贴类型为随机时,参数才可设以置和输出
*/
public $uvdelta = '0 1';
public $triangleaovIndex;
//当铺贴类型属于二维时,以下参数才可设以置和输出
/**
* @var integer TODO:具体作用尚未明确,(固定取值:1),当铺贴类型为二维且随机时,参数才可设以置和输出
*/
public $uvscaleUniform;
/**
* @var string 贴图缩放参数,取值为 大于等于0 的小数,当铺贴类型为随机时,需要为两个轴方指定最大和最小值,如 ‘1 100 1 50
*/
public $uvscale;
/**
* @var string 贴图偏移参数,取值为 一个自然数,正负号决定其偏移方向,当铺贴类型为随机时,需要为两个轴方指定最大和最小值,如 ‘1 100 1 50
*/
public $uvdelta;
/**
* @var float 贴图旋转参数,取值为 0到小于360 的小数,当铺贴类型为随机时,需要指定为最大和最小值,如 ‘1 100
*/
public $rotation;
//当铺贴类型属于三维时,以下参数才可设以置和输出
/**
* @var string 贴图位置变换参数,只有当铺贴类型为三维且时,才可以设置和输出此参数
*/
public $transformation;
//当铺贴类型属于 三维 且 随机 且 非VU坐标 时,以下参数才可设以置和输出
/**
* @var float 三个轴向的旋转参数,取值为 0到小于360 的小数,当最小值与最大值相等时,则关闭此三项参数的随机功能
*/
public $xrotation;
public $yrotation;
public $zrotation;
/**
* @var bool 指定是否等比缩放
*/
public $xyzscaleUniform;
/**
* @var float 贴图旋转参数
* @var float 三个轴向的缩放参数,取值为 大于等于0 的小数,当最小值与最大值相等时,则关闭此三项参数的随机功能
*/
public $rotation = 0;
public $xscale;
public $yscale;
public $zscale;
/**
* @var integer UV通道
* @var float 三个轴向的偏移参数,取值为 一个自然数,正负号决定其偏移方向,当最小值与最大值相等时,则关闭此三项参数的随机功能
*/
public $uvindex = 0;
public $xtranslate;
public $ytranslate;
public $ztranslate;
}

52
src/scene/texture/mapping/Triplanar.php

@ -0,0 +1,52 @@
<?php
namespace Blobt\Luxcore\scene\texture\mapping;
use Blobt\Luxcore\scene\texture\TextureBase;
use Blobt\Luxcore\scene\Scene;
use Blobt\Luxcore\core\Base;
class Triplanar extends TextureBase
{
const TYPE_TRIPLANAR = 'triplanar';
/**
* @var string 一个textures(贴图数组)中的某个键名
*/
public $texture1;
/**
* @var string 一个textures(贴图数组)中的某个键名
*/
public $texture2;
/**
* @var string 一个textures(贴图数组)中的某个键名
*/
public $texture3;
/**
* @var bool 是否为凹凸贴图模式
*/
public $uvlessbumpmapEnable = 1;
/**
* @var object 铺贴参数,一个Mapping类对象
*/
public $mapping;
/**
* @param $mapping 必须传入一个 Mapping类对象
*/
public function __construct(Mapping $mapping,$config = [])
{
$this->id = Scene::createID();
$this->mapping = $mapping;
$this->type = self::TYPE_TRIPLANAR;
Base::__construct($config);
}
}
?>

38
src/scene/texture/transform/NormalMap.php

@ -0,0 +1,38 @@
<?php
namespace Blobt\Luxcore\scene\texture\transform;
use Blobt\Luxcore\scene\texture\TextureBase;
use Blobt\Luxcore\scene\Scene;
use Blobt\Luxcore\core\Base;
use Blobt\Luxcore\scene\texture\mapping\Mapping;
class ImageMap extends TextureBase
{
const TYPE_NORMALMAP = 'normalmap';
/**
* @var string 一个textures(贴图数组)中的某个键名
*/
public $texture;
/**
* @var integer TODO: 具体作用尚未明确,(固定取值:1)
*/
public $scale = 1;
/**
* @param $mapping 必须传入一个 Mapping类对象
*/
public function __construct(Mapping $mapping,$config = [])
{
$this->id = Scene::createID();
$this->mapping = $mapping;
$this->type = self::TYPE_NORMALMAP;
Base::__construct($config);
}
}
?>
Loading…
Cancel
Save