preparing RenderFramework
This commit is contained in:
73
inc/hgl/graph/LightingModel.h
Normal file
73
inc/hgl/graph/LightingModel.h
Normal file
@@ -0,0 +1,73 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
enum class LightingModel:uint8
|
||||
{
|
||||
Unlit,
|
||||
|
||||
Gizmo, ///<Gizmo专用(Blinnphong的特定版本,内置假的太阳光方向、高光系数等,使其不需要外部UBO传入)
|
||||
|
||||
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)
|
||||
};//enum class LightingModel:uint8
|
||||
|
||||
constexpr const char *LightingModelName[]=
|
||||
{
|
||||
"Unlit",
|
||||
|
||||
"Gizmo",
|
||||
|
||||
"Blinnphong",
|
||||
|
||||
"FakePBR",
|
||||
"MicroPBR",
|
||||
|
||||
"WebPBR",
|
||||
"FilamentPBR",
|
||||
"AMDPBR",
|
||||
|
||||
"BlenderPBR"
|
||||
};
|
||||
|
||||
/**
|
||||
* 天光来源
|
||||
*/
|
||||
enum class SkyLightSource:uint8
|
||||
{
|
||||
PureColor, ///<纯色
|
||||
GradientColor, ///<过渡色
|
||||
Cubemap, ///<立方体贴图
|
||||
IBL, ///<IBL立方体贴图
|
||||
|
||||
ENUM_CLASS_RANGE(PureColor,IBL)
|
||||
};//enum class SkyLightSource:uint8
|
||||
|
||||
/**
|
||||
* 环境光来源
|
||||
*/
|
||||
enum class AmbientLightSource:uint8
|
||||
{
|
||||
PureColor, ///<纯色
|
||||
|
||||
Distance, ///<距离(用于显示深邃场景,比如峡谷、深井、管道,越远越黑。理论等同AO)
|
||||
|
||||
LightProbe, ///<光线探针(也许也是Cubemap,也许不是)
|
||||
|
||||
Cubemap, ///<本地Cubemap
|
||||
|
||||
};//enum class AmbientLightSource:uint8
|
||||
|
||||
VK_NAMESPACE_END
|
120
inc/hgl/graph/RenderFramework.h
Normal file
120
inc/hgl/graph/RenderFramework.h
Normal file
@@ -0,0 +1,120 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/type/List.h>
|
||||
#include<hgl/graph/ViewportInfo.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
class RenderModule;
|
||||
|
||||
/**
|
||||
* 光照剔除模式
|
||||
*/
|
||||
enum class LightingCullingMode
|
||||
{
|
||||
None, ///<不剔除
|
||||
|
||||
/*
|
||||
* 基于Tile的剔除模式
|
||||
* 按屏幕XY坐标划分成多个Tile,再配合znear/zfar形成一个Volume。所有光源和Volume计算相交性
|
||||
*/
|
||||
Tile, ///<瓦片剔除
|
||||
|
||||
/**
|
||||
* 基于Tile的剔除模式的改进型
|
||||
* 同Tile方法,得出Tile后,再通过Compute Shader遍历Tile内所有象素,得出当前Tile的最远z值和最近z值。
|
||||
* 根据XY与zNear/zFar得出一个Volume,计算所有光源与Volume相交性。
|
||||
*/
|
||||
TileVolume, ///<瓦片体积剔除
|
||||
|
||||
/**
|
||||
* 基于Tile的剔除模式的改进型
|
||||
* 同TileVolume方法得出Volume后,再将Volume按深度划分成多个Volume。
|
||||
* 剔除掉没有象素的Volume,再将剩下的Volume与光源计算相交性。
|
||||
*/
|
||||
Cluster, ///<集簇剔除
|
||||
|
||||
ENUM_CLASS_RANGE(None,Cluster)
|
||||
};//enum class LightingCullingMode
|
||||
|
||||
enum class RenderingMode
|
||||
{
|
||||
Forward, ///<前向渲染
|
||||
|
||||
Deferred, ///<延迟渲染
|
||||
|
||||
ENUM_CLASS_RANGE(Forward,Deferred)
|
||||
};//enum class RenderingMode
|
||||
|
||||
|
||||
enum class RenderPhase
|
||||
{
|
||||
PreRender, ///<渲染前
|
||||
|
||||
Physics, ///<物理
|
||||
Anim, ///<动画前
|
||||
|
||||
Depth, ///<渲染深度(一般用于Early-Z pass)
|
||||
|
||||
GBuffer, ///<生成GBuffer
|
||||
|
||||
Transparent, ///<渲染透明物件
|
||||
|
||||
PostProcess, ///<后处理
|
||||
|
||||
Submit, ///<提交指令队列
|
||||
Present, ///<呈现
|
||||
|
||||
ENUM_CLASS_RANGE(PreRender,Present)
|
||||
};//enum class RenderPhase
|
||||
|
||||
/**
|
||||
* 渲染框架
|
||||
*/
|
||||
class RenderFramework
|
||||
{
|
||||
ObjectList<RenderModule> module_list;
|
||||
|
||||
protected:
|
||||
|
||||
ViewportInfo viewport_info;
|
||||
|
||||
int swap_chain_count =0;
|
||||
|
||||
protected:
|
||||
|
||||
GPUDevice * device =nullptr;
|
||||
RenderPass * device_render_pass =nullptr;
|
||||
RTSwapchain * default_rt =nullptr;
|
||||
|
||||
RenderCmdBuffer ** render_cmd_buffers =nullptr;
|
||||
|
||||
private:
|
||||
|
||||
uint64 frame_count =0;
|
||||
|
||||
public:
|
||||
|
||||
const uint64 GetFrameCount ()const noexcept{return frame_count;} ///<取得当前帧数
|
||||
void RestartFrameCount ()noexcept{frame_count=0;} ///<重新开始统计帧数
|
||||
|
||||
public:
|
||||
|
||||
NO_COPY_NO_MOVE(RenderFramework)
|
||||
|
||||
RenderFramework(){}
|
||||
virtual ~RenderFramework()=default;
|
||||
|
||||
/**
|
||||
* @pragma delta_time 本帧时间间隔
|
||||
*/
|
||||
virtual void Update(const double delta_time){}
|
||||
|
||||
virtual void BeginFrame(){}; ///<开始当前帧
|
||||
virtual void EndFrame(){}; ///<当前帧结束
|
||||
|
||||
virtual void MainLoop(); ///<主循环
|
||||
};//class RenderFramework
|
||||
|
||||
VK_NAMESPACE_END
|
66
inc/hgl/graph/RenderModule.h
Normal file
66
inc/hgl/graph/RenderModule.h
Normal file
@@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/type/Size2.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
class RenderCmdBuffer;
|
||||
|
||||
/**
|
||||
* 渲染模块基类
|
||||
*/
|
||||
class RenderModule
|
||||
{
|
||||
OSString module_name;
|
||||
|
||||
VkExtent2D current_extent;
|
||||
|
||||
bool module_enable;
|
||||
bool module_ready;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void SetModuleEnable(bool e){module_enable=e;}
|
||||
virtual void SetModuleReady(bool r){module_ready=r;}
|
||||
|
||||
public:
|
||||
|
||||
const OSString &GetModuleName()const{return module_name;}
|
||||
|
||||
const bool IsEnable ()const noexcept{return module_enable;}
|
||||
const bool IsReady ()const noexcept{return module_ready;}
|
||||
|
||||
public:
|
||||
|
||||
NO_COPY_NO_MOVE(RenderModule)
|
||||
|
||||
RenderModule(const OSString &name)
|
||||
{
|
||||
module_name=name;
|
||||
}
|
||||
|
||||
virtual ~RenderModule()=default;
|
||||
|
||||
virtual bool Init(){return true;}
|
||||
|
||||
virtual void Execute(const double,RenderCmdBuffer *){}
|
||||
|
||||
virtual void OnResize(const VkExtent2D &ext){current_extent=ext;}
|
||||
virtual void OnFocusLost(){}
|
||||
|
||||
virtual void OnPreFrame(){}
|
||||
virtual void OnPostFrame(){}
|
||||
};//class RenderModule
|
||||
|
||||
template<typename T> RenderModule *Create()
|
||||
{
|
||||
return new T();
|
||||
}
|
||||
|
||||
typedef RenderModule *(*RenderModuleCreateFunc)();
|
||||
|
||||
bool RegistryRenderModule(const OSString &,RenderModuleCreateFunc);
|
||||
RenderModule *GetRenderModule(const OSString &);
|
||||
|
||||
VK_NAMESPACE_END
|
39
inc/hgl/graph/component/Component.h
Normal file
39
inc/hgl/graph/component/Component.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/type/TypeInfo.h>
|
||||
#include<hgl/graph/VK.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
class SceneNode;
|
||||
|
||||
class SceneComponentData
|
||||
{
|
||||
};//class SceneComponentData
|
||||
|
||||
class SceneComponentManager;
|
||||
|
||||
class SceneComponent
|
||||
{
|
||||
SceneComponentManager *manager;
|
||||
|
||||
SceneNode *owner;
|
||||
|
||||
public:
|
||||
|
||||
SceneComponentManager *GetManager()const{return manager;}
|
||||
|
||||
SceneNode *GetOwner()const{return owner;}
|
||||
|
||||
virtual const size_t GetTypeHash()=0;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
};//class SceneComponent
|
||||
|
||||
class SceneComponentManager
|
||||
{
|
||||
};//class SceneComponentManager
|
||||
|
||||
VK_NAMESPACE_END
|
39
inc/hgl/graph/component/SceneComponent.h
Normal file
39
inc/hgl/graph/component/SceneComponent.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/type/TypeInfo.h>
|
||||
#include<hgl/graph/VK.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
class SceneNode;
|
||||
|
||||
class ComponentData
|
||||
{
|
||||
};//class ComponentData
|
||||
|
||||
class ComponentManager;
|
||||
|
||||
class Component
|
||||
{
|
||||
ComponentManager *manager;
|
||||
|
||||
SceneNode *owner;
|
||||
|
||||
public:
|
||||
|
||||
ComponentManager *GetManager()const{return manager;}
|
||||
|
||||
SceneNode *GetOwner()const{return owner;}
|
||||
|
||||
virtual const size_t GetTypeHash()=0;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
};//class Component
|
||||
|
||||
class ComponentManager
|
||||
{
|
||||
};//class ComponentManager
|
||||
|
||||
VK_NAMESPACE_END
|
63
inc/hgl/graph/deferred/GBufferFormat.h
Normal file
63
inc/hgl/graph/deferred/GBufferFormat.h
Normal file
@@ -0,0 +1,63 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
/
|
||||
|
||||
|
||||
//Material models from Google Filament
|
||||
//@see https://google.github.io/filament/Materials.html
|
||||
|
||||
enum class MaterialModels:uint8
|
||||
{
|
||||
Unlit=0,
|
||||
Lit,
|
||||
Subsurface,
|
||||
Cloth,
|
||||
};
|
||||
|
||||
struct GBufferFormat
|
||||
{
|
||||
VkFormat ShadingModel; ///<着色模式
|
||||
|
||||
VkFormat BaseColor; ///<颜色缓冲区格式
|
||||
VkFormat Depth; ///<深度缓冲区格式
|
||||
VkFormat Stencil; ///<模板缓冲区格式
|
||||
|
||||
VkFormat Normal; ///<法线缓冲区格式
|
||||
|
||||
VkFormat Metallic; ///<金属度
|
||||
VkFormat Roughness; ///<粗糙度(glossiness)
|
||||
VkFormat Reflectance; ///<反射率(Specular for non-metals)
|
||||
|
||||
VkFormat ClearCoat;
|
||||
VkFormat ClearCoatRoughness;
|
||||
VkFormat Anisotropy;
|
||||
|
||||
VkFormat Emissive; ///<自发光
|
||||
VkFormat AmbientOcclusion; ///<环境光遮蔽
|
||||
|
||||
VkFormat MotionVector; ///<运动向量
|
||||
};//struct GBufferFormat
|
||||
|
||||
void InitGBufferFormat(GBufferFormat &bf)
|
||||
{
|
||||
bf.BaseColor =PF_A2BGR10UN;
|
||||
|
||||
bf.Depth =PF_D24UN_S8U;
|
||||
bf.Stencil =PF_D24UN_S8U;
|
||||
|
||||
bf.Normal =PF_RG8UN;
|
||||
|
||||
bf.MetallicRoughness=PF_RG8UN;
|
||||
|
||||
bf.Emissive =PF_A2BGR10UN;
|
||||
bf.AmbientOcclusion =PF_R8UN;
|
||||
|
||||
bf.MotionVector =PF_RG16SN;
|
||||
}
|
||||
|
||||
VK_NAMESPACE_END
|
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VKNamespace.h>
|
||||
#include<hgl/graph/StaticMeshLODPolicy.h>
|
||||
#include<hgl/graph/mesh/StaticMeshLODPolicy.h>
|
||||
#include<hgl/graph/ShadowPolicy.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
17
inc/hgl/graph/mesh/StaticMeshNode.h
Normal file
17
inc/hgl/graph/mesh/StaticMeshNode.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/SceneNode.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
class StaticMeshNode:public SceneNode
|
||||
{
|
||||
StaticMesh *sm;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
};//class StaticMeshNode
|
||||
|
||||
VK_NAMESPACE_END
|
@@ -5,56 +5,6 @@
|
||||
#include<hgl/graph/VertexAttrib.h>
|
||||
|
||||
STD_MTL_NAMESPACE_BEGIN
|
||||
enum class LightingModel:uint8
|
||||
{
|
||||
Unlit,
|
||||
|
||||
Gizmo, ///<Gizmo专用(Blinnphong的特定版本,内置假的太阳光方向、高光系数等,使其不需要外部UBO传入)
|
||||
|
||||
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, ///<纯色
|
||||
Simplest, ///<极简(一行代码)
|
||||
Cubemap, ///<立方体贴图
|
||||
IBL, ///<IBL立方体贴图
|
||||
|
||||
ENUM_CLASS_RANGE(PureColor,IBL)
|
||||
};
|
||||
|
||||
struct Material3DCreateConfig:public MaterialCreateConfig
|
||||
{
|
||||
|
Reference in New Issue
Block a user