2023-09-27 20:31:46 +08:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include<hgl/graph/mtl/MaterialConfig.h>
|
|
|
|
|
#include<hgl/graph/CoordinateSystem.h>
|
|
|
|
|
#include<hgl/graph/VertexAttrib.h>
|
|
|
|
|
|
|
|
|
|
STD_MTL_NAMESPACE_BEGIN
|
2024-06-25 01:17:47 +08:00
|
|
|
|
enum class LightingModel:uint8
|
|
|
|
|
{
|
|
|
|
|
Unlit,
|
|
|
|
|
|
2024-06-26 01:50:55 +08:00
|
|
|
|
Gizmo, ///<Gizmo专用(Blinnphong的特定版本,内置假的太阳光方向、高光系数等,使其不需要外部UBO传入)
|
2024-06-25 01:17:47 +08:00
|
|
|
|
|
|
|
|
|
Blinnphong, ///<Blinnphong光照模型
|
|
|
|
|
|
|
|
|
|
FakePBR, ///<假PBR(使用Blinnphong+HalfLambert模拟)
|
|
|
|
|
MicroPBR, ///<微型PBR(只有BaseColor/Normal/Metallic/Roughness四个基础数据的PBR)
|
|
|
|
|
|
|
|
|
|
WebPBR, ///<Khronos为WebGL提供的PBR
|
|
|
|
|
FilamentPBR, ///<Filament引擎所使用的PBR
|
|
|
|
|
AMDPBR, ///<AMD Caulrdon框架所使用的PBR
|
|
|
|
|
|
|
|
|
|
BlenderPBR, ///<Blender所使用的PBR
|
|
|
|
|
|
|
|
|
|
ENUM_CLASS_RANGE(Unlit,BlenderPBR)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
constexpr const char *LightingModelName[]=
|
|
|
|
|
{
|
|
|
|
|
"Unlit",
|
|
|
|
|
|
|
|
|
|
"Gizmo",
|
|
|
|
|
|
|
|
|
|
"Blinnphong",
|
|
|
|
|
|
|
|
|
|
"FakePBR",
|
|
|
|
|
"MicroPBR",
|
|
|
|
|
|
|
|
|
|
"WebPBR",
|
|
|
|
|
"FilamentPBR",
|
|
|
|
|
"AMDPBR",
|
|
|
|
|
|
|
|
|
|
"BlenderPBR"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 天光来源
|
|
|
|
|
*/
|
|
|
|
|
enum class SkyLightSource:uint8
|
|
|
|
|
{
|
|
|
|
|
PureColor, ///<纯色
|
2024-06-26 01:50:55 +08:00
|
|
|
|
Simplest, ///<极简(一行代码)
|
2024-06-25 01:17:47 +08:00
|
|
|
|
Cubemap, ///<立方体贴图
|
|
|
|
|
IBL, ///<IBL立方体贴图
|
|
|
|
|
|
|
|
|
|
ENUM_CLASS_RANGE(PureColor,IBL)
|
|
|
|
|
};
|
|
|
|
|
|
2023-09-27 20:31:46 +08:00
|
|
|
|
struct Material3DCreateConfig:public MaterialCreateConfig
|
|
|
|
|
{
|
2023-09-28 17:41:45 +08:00
|
|
|
|
bool camera; ///<包含摄像机矩阵信息
|
|
|
|
|
|
2023-09-27 20:31:46 +08:00
|
|
|
|
bool local_to_world; ///<包含LocalToWorld矩阵
|
|
|
|
|
|
2024-06-18 01:28:53 +08:00
|
|
|
|
VAType position_format; ///<position格式
|
2023-09-27 20:31:46 +08:00
|
|
|
|
|
2023-09-28 15:03:34 +08:00
|
|
|
|
// bool reverse_depth; ///<使用反向深度
|
|
|
|
|
|
2023-09-27 20:31:46 +08:00
|
|
|
|
public:
|
|
|
|
|
|
2024-05-25 22:47:26 +08:00
|
|
|
|
Material3DCreateConfig(const GPUDeviceAttribute *da,const AnsiString &name,const Prim &p):MaterialCreateConfig(da,name,p)
|
2023-09-27 20:31:46 +08:00
|
|
|
|
{
|
|
|
|
|
rt_output.color=1; //输出一个颜色
|
|
|
|
|
rt_output.depth=true; //不输出深度
|
|
|
|
|
rt_output.stencil=false; //不输出stencil
|
|
|
|
|
|
2023-09-28 17:41:45 +08:00
|
|
|
|
camera=true;
|
2023-09-27 20:31:46 +08:00
|
|
|
|
local_to_world=false;
|
|
|
|
|
|
|
|
|
|
position_format=VAT_VEC3;
|
2023-09-28 15:03:34 +08:00
|
|
|
|
|
|
|
|
|
// reverse_depth=false;
|
2023-09-27 20:31:46 +08:00
|
|
|
|
}
|
2023-10-12 14:59:39 +08:00
|
|
|
|
|
|
|
|
|
int Comp(const Material3DCreateConfig &cfg)const
|
|
|
|
|
{
|
|
|
|
|
int off=MaterialCreateConfig::Comp(cfg);
|
|
|
|
|
|
|
|
|
|
if(off)return off;
|
|
|
|
|
|
|
|
|
|
off=camera-cfg.camera;
|
|
|
|
|
if(off)return off;
|
|
|
|
|
|
|
|
|
|
off=local_to_world-cfg.local_to_world;
|
|
|
|
|
if(off)return off;
|
|
|
|
|
|
|
|
|
|
off=position_format.Comp(cfg.position_format);
|
|
|
|
|
|
|
|
|
|
return off;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CompOperator(const Material3DCreateConfig &,Comp)
|
2023-09-27 20:31:46 +08:00
|
|
|
|
};//struct Material3DCreateConfig:public MaterialCreateConfig
|
|
|
|
|
|
2023-09-28 15:03:34 +08:00
|
|
|
|
MaterialCreateInfo *CreateVertexColor3D(const Material3DCreateConfig *);
|
2023-09-28 18:13:51 +08:00
|
|
|
|
MaterialCreateInfo *CreateVertexLuminance3D(const Material3DCreateConfig *);
|
2024-06-16 23:49:23 +08:00
|
|
|
|
|
2024-06-26 01:50:55 +08:00
|
|
|
|
MaterialCreateInfo *CreateMaterialGizmo3D(const Material3DCreateConfig *cfg);
|
|
|
|
|
|
2024-06-16 23:49:23 +08:00
|
|
|
|
struct BillboardMaterialCreateConfig:public Material3DCreateConfig
|
|
|
|
|
{
|
|
|
|
|
bool fixed_size; ///<固定大小(指像素尺寸)
|
|
|
|
|
|
|
|
|
|
Vector2u pixel_size; ///<像素尺寸
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
using Material3DCreateConfig::Material3DCreateConfig;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
MaterialCreateInfo *CreateBillboard2D(mtl::BillboardMaterialCreateConfig *);
|
2023-10-10 14:49:33 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 从文件加载材质
|
|
|
|
|
* @param mtl_name 材质名称
|
|
|
|
|
* @param cfg 材质创建参数
|
|
|
|
|
* @return 材质创建信息
|
|
|
|
|
*/
|
|
|
|
|
MaterialCreateInfo *LoadMaterialFromFile(const AnsiString &name,Material3DCreateConfig *cfg);
|
2023-09-27 20:31:46 +08:00
|
|
|
|
STD_MTL_NAMESPACE_END
|