Compare commits
5 Commits
73027ffd9a
...
709c8be94d
Author | SHA1 | Date | |
---|---|---|---|
709c8be94d | |||
660d8fff6d | |||
0fbe85290b | |||
0c3cc5a320 | |||
3057fc7b6f |
2
CMCore
2
CMCore
@ -1 +1 @@
|
|||||||
Subproject commit 333bec0a122a962d0b7c55948a73ead6052ae9d2
|
Subproject commit c5b37f98353441520374011020dbe63c17796a4d
|
@ -1 +1 @@
|
|||||||
Subproject commit 23d74ac1676929b97d3292524a1457d0b3fb0419
|
Subproject commit 5009069a3081d458f41f21f30236e3afebf1fd8a
|
@ -1,6 +1,6 @@
|
|||||||
// RayPicking
|
// RayPicking
|
||||||
|
|
||||||
#include"VulkanAppFramework.h"
|
#include<hgl/WorkManager.h>
|
||||||
#include<hgl/filesystem/FileSystem.h>
|
#include<hgl/filesystem/FileSystem.h>
|
||||||
#include<hgl/graph/InlineGeometry.h>
|
#include<hgl/graph/InlineGeometry.h>
|
||||||
#include<hgl/graph/VKRenderResource.h>
|
#include<hgl/graph/VKRenderResource.h>
|
||||||
@ -26,7 +26,7 @@ static float lumiance_data[2]={1,1};
|
|||||||
static Color4f white_color(1,1,1,1);
|
static Color4f white_color(1,1,1,1);
|
||||||
static Color4f yellow_color(1,1,0,1);
|
static Color4f yellow_color(1,1,0,1);
|
||||||
|
|
||||||
class TestApp:public SceneAppFramework
|
class TestApp:public WorkObject
|
||||||
{
|
{
|
||||||
Color4f color;
|
Color4f color;
|
||||||
|
|
||||||
@ -51,12 +51,11 @@ private:
|
|||||||
|
|
||||||
bool InitMaterialAndPipeline()
|
bool InitMaterialAndPipeline()
|
||||||
{
|
{
|
||||||
mtl::Material3DCreateConfig cfg(device->GetDevAttr(),"VertexLuminance2D",PrimitiveType::Lines);
|
mtl::Material3DCreateConfig cfg(PrimitiveType::Lines);
|
||||||
|
|
||||||
cfg.local_to_world=true;
|
cfg.local_to_world=true;
|
||||||
|
|
||||||
{
|
{
|
||||||
cfg.mtl_name="VertexLuminance2D"; //注意必须用不同名字,未来改名材质文件名+cfg hash名
|
|
||||||
cfg.position_format=VAT_VEC2;
|
cfg.position_format=VAT_VEC2;
|
||||||
|
|
||||||
mtl_plane_grid=db->LoadMaterial("Std3D/VertexLum3D",&cfg);
|
mtl_plane_grid=db->LoadMaterial("Std3D/VertexLum3D",&cfg);
|
||||||
@ -74,7 +73,6 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
cfg.mtl_name="VertexLuminance3D"; //注意必须用不同名字,未来改名材质文件名+cfg hash名
|
|
||||||
cfg.position_format=VAT_VEC3;
|
cfg.position_format=VAT_VEC3;
|
||||||
|
|
||||||
mtl_line=db->LoadMaterial("Std3D/VertexLum3D",&cfg);
|
mtl_line=db->LoadMaterial("Std3D/VertexLum3D",&cfg);
|
||||||
@ -92,7 +90,7 @@ private:
|
|||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Mesh *Add(Primitive *r,MaterialInstance *mi,Pipeline *p)
|
Mesh *Add(SceneNode *parent_node,Primitive *r,MaterialInstance *mi,Pipeline *p)
|
||||||
{
|
{
|
||||||
Mesh *ri=db->CreateMesh(r,mi,p);
|
Mesh *ri=db->CreateMesh(r,mi,p);
|
||||||
|
|
||||||
@ -102,7 +100,7 @@ private:
|
|||||||
return(nullptr);
|
return(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
render_root.Add(new SceneNode(ri));
|
parent_node->Add(new SceneNode(ri));
|
||||||
|
|
||||||
return ri;
|
return ri;
|
||||||
}
|
}
|
||||||
@ -112,7 +110,7 @@ private:
|
|||||||
using namespace inline_geometry;
|
using namespace inline_geometry;
|
||||||
|
|
||||||
{
|
{
|
||||||
PrimitiveCreater pc(device,mi_plane_grid->GetVIL());
|
auto pc=GetPrimitiveCreater(mi_plane_grid);
|
||||||
|
|
||||||
struct PlaneGridCreateInfo pgci;
|
struct PlaneGridCreateInfo pgci;
|
||||||
|
|
||||||
@ -122,19 +120,19 @@ private:
|
|||||||
pgci.lum=128;
|
pgci.lum=128;
|
||||||
pgci.sub_lum=196;
|
pgci.sub_lum=196;
|
||||||
|
|
||||||
prim_plane_grid=CreatePlaneGrid2D(&pc,&pgci);
|
prim_plane_grid=CreatePlaneGrid2D(pc,&pgci);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
PrimitiveCreater pc(device,mtl_line->GetDefaultVIL());
|
auto pc=GetPrimitiveCreater(mtl_line);
|
||||||
|
|
||||||
if(!pc.Init("Line",2))
|
if(!pc->Init("Line",2))
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
if(!pc.WriteVAB(VAN::Position, VF_V3F,position_data))return(false);
|
if(!pc->WriteVAB(VAN::Position, VF_V3F,position_data))return(false);
|
||||||
if(!pc.WriteVAB(VAN::Luminance,VF_V1F,lumiance_data))return(false);
|
if(!pc->WriteVAB(VAN::Luminance,VF_V1F,lumiance_data))return(false);
|
||||||
|
|
||||||
prim_line=pc.Create();
|
prim_line=pc->Create();
|
||||||
|
|
||||||
prim_line_vab_map=prim_line->GetVABMap(VAN::Position);
|
prim_line_vab_map=prim_line->GetVABMap(VAN::Position);
|
||||||
}
|
}
|
||||||
@ -144,32 +142,31 @@ private:
|
|||||||
|
|
||||||
bool InitScene()
|
bool InitScene()
|
||||||
{
|
{
|
||||||
Add(prim_plane_grid,mi_plane_grid,pipeline_plane_grid);
|
SceneNode *scene_root=GetSceneRoot(); //取得缺省场景根节点
|
||||||
Add(prim_line,mi_line,pipeline_line);
|
|
||||||
|
|
||||||
camera->pos=Vector3f(32,32,32);
|
Add(scene_root,prim_plane_grid,mi_plane_grid,pipeline_plane_grid);
|
||||||
|
Add(scene_root,prim_line,mi_line,pipeline_line);
|
||||||
|
|
||||||
|
CameraControl *camera_control=GetCameraControl();
|
||||||
|
|
||||||
|
camera_control->SetPosition(Vector3f(32,32,32));
|
||||||
camera_control->SetTarget(Vector3f(0,0,0));
|
camera_control->SetTarget(Vector3f(0,0,0));
|
||||||
camera_control->Refresh();
|
|
||||||
|
|
||||||
render_root.RefreshMatrix();
|
|
||||||
render_list->Expend(&render_root);
|
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
using WorkObject::WorkObject;
|
||||||
|
|
||||||
~TestApp()
|
~TestApp()
|
||||||
{
|
{
|
||||||
SAFE_CLEAR(prim_plane_grid);
|
SAFE_CLEAR(prim_plane_grid);
|
||||||
SAFE_CLEAR(prim_line);
|
SAFE_CLEAR(prim_line);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Init(uint w,uint h)
|
bool Init() override
|
||||||
{
|
{
|
||||||
if(!SceneAppFramework::Init(w,h))
|
|
||||||
return(false);
|
|
||||||
|
|
||||||
if(!InitMaterialAndPipeline())
|
if(!InitMaterialAndPipeline())
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
@ -182,23 +179,28 @@ public:
|
|||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuildCommandBuffer(uint32 index) override
|
void Tick(double) override
|
||||||
{
|
{
|
||||||
const CameraInfo *ci=GetCameraInfo();
|
Vector2i mouse_position;
|
||||||
const ViewportInfo *vi=GetViewportInfo();
|
|
||||||
|
|
||||||
ray.Set(GetMouseCoord(),ci,vi); //设置射线查询的屏幕坐标点
|
if(!GetMouseCoord(&mouse_position))
|
||||||
|
return;
|
||||||
|
|
||||||
|
CameraControl *camera_control=GetCameraControl();
|
||||||
|
|
||||||
|
const CameraInfo *ci=camera_control->GetCameraInfo();
|
||||||
|
const ViewportInfo *vi=camera_control->GetViewportInfo();
|
||||||
|
|
||||||
|
ray.Set(mouse_position,ci,vi); //设置射线查询的屏幕坐标点
|
||||||
|
|
||||||
const Vector3f pos=ray.ClosestPoint(Vector3f(0,0,0)); //求射线上与点(0,0,0)最近的点的坐标
|
const Vector3f pos=ray.ClosestPoint(Vector3f(0,0,0)); //求射线上与点(0,0,0)最近的点的坐标
|
||||||
|
|
||||||
prim_line_vab_map->Write(&pos, //更新VAB上这个点的位置
|
prim_line_vab_map->Write(&pos, //更新VAB上这个点的位置
|
||||||
1); //这里的1代表的数据数量,不是字节数
|
1); //这里的1代表的数据数量,不是字节数
|
||||||
|
|
||||||
SceneAppFramework::BuildCommandBuffer(index);
|
|
||||||
}
|
}
|
||||||
};//class TestApp:public CameraAppFramework
|
};//class TestApp:public CameraAppFramework
|
||||||
|
|
||||||
int main(int,char **)
|
int os_main(int,os_char **)
|
||||||
{
|
{
|
||||||
return RunApp<TestApp>(1280,720);
|
return RunFramework<TestApp>(OS_TEXT("RayPicking"),1280,720);
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,8 @@ namespace hgl
|
|||||||
graph::Camera * GetCamera (){return renderer->GetCamera();}
|
graph::Camera * GetCamera (){return renderer->GetCamera();}
|
||||||
graph::CameraControl * GetCameraControl (){return render_framework->GetDefaultCameraControl();}
|
graph::CameraControl * GetCameraControl (){return render_framework->GetDefaultCameraControl();}
|
||||||
|
|
||||||
|
bool GetMouseCoord (Vector2i *mc)const{return render_framework->GetMouseCoord(mc);}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
const bool IsDestroy ()const{return destroy_flag;}
|
const bool IsDestroy ()const{return destroy_flag;}
|
||||||
@ -94,6 +96,14 @@ namespace hgl
|
|||||||
return db->CreateMaterialInstance(mtl_name,mci,vil_cfg);
|
return db->CreateMaterialInstance(mtl_name,mci,vil_cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AutoDelete<graph::PrimitiveCreater> GetPrimitiveCreater(graph::Material *mtl)
|
||||||
|
{
|
||||||
|
if(!mtl)
|
||||||
|
return(nullptr);
|
||||||
|
|
||||||
|
return(new graph::PrimitiveCreater(GetDevice(),mtl->GetDefaultVIL()));
|
||||||
|
}
|
||||||
|
|
||||||
AutoDelete<graph::PrimitiveCreater> GetPrimitiveCreater(graph::MaterialInstance *mi)
|
AutoDelete<graph::PrimitiveCreater> GetPrimitiveCreater(graph::MaterialInstance *mi)
|
||||||
{
|
{
|
||||||
if(!mi)
|
if(!mi)
|
||||||
|
@ -11,4 +11,18 @@ namespace hgl::graph
|
|||||||
|
|
||||||
ENUM_CLASS_RANGE(NDC,Ortho)
|
ENUM_CLASS_RANGE(NDC,Ortho)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
constexpr const char *CoordinateSystem2DName[]=
|
||||||
|
{
|
||||||
|
"NDC",
|
||||||
|
"0to1",
|
||||||
|
"Ortho"
|
||||||
|
};
|
||||||
|
|
||||||
|
inline const char *GetCoordinateSystem2DName(const enum class CoordinateSystem2D &cs)
|
||||||
|
{
|
||||||
|
RANGE_CHECK_RETURN_NULLPTR(cs)
|
||||||
|
|
||||||
|
return CoordinateSystem2DName[size_t(cs)];
|
||||||
|
}
|
||||||
}//namespace hgl::graph
|
}//namespace hgl::graph
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include<hgl/graph/module/GraphModuleManager.h>
|
#include<hgl/graph/module/GraphModuleManager.h>
|
||||||
#include<hgl/graph/RenderList.h>
|
#include<hgl/graph/RenderList.h>
|
||||||
#include<hgl/graph/CameraControl.h>
|
#include<hgl/graph/CameraControl.h>
|
||||||
|
#include<hgl/io/event/MouseEvent.h>
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
|
|
||||||
@ -62,7 +63,7 @@ protected: //RenderContext,未来合并成一个RenderContext结构
|
|||||||
|
|
||||||
protected: //InputEvent
|
protected: //InputEvent
|
||||||
|
|
||||||
ObjectList<io::InputEvent> input_event;
|
io::MouseEvent *mouse_event=nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -92,6 +93,17 @@ public:
|
|||||||
CameraControl * GetDefaultCameraControl (){return default_camera_control;}
|
CameraControl * GetDefaultCameraControl (){return default_camera_control;}
|
||||||
Renderer * GetDefaultRenderer (){return default_renderer;}
|
Renderer * GetDefaultRenderer (){return default_renderer;}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
bool GetMouseCoord(Vector2i *mc)const
|
||||||
|
{
|
||||||
|
if(!mouse_event||!mc)
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
*mc=mouse_event->GetMouseCoord();
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RenderFramework(const OSString &);
|
RenderFramework(const OSString &);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include<hgl/graph/mtl/MaterialLibrary.h>
|
#include<hgl/graph/mtl/MaterialLibrary.h>
|
||||||
#include<hgl/graph/mtl/MaterialConfig.h>
|
#include<hgl/graph/mtl/MaterialCreateConfig.h>
|
||||||
#include<hgl/graph/CoordinateSystem.h>
|
#include<hgl/graph/CoordinateSystem.h>
|
||||||
#include<hgl/graph/VertexAttrib.h>
|
#include<hgl/graph/VertexAttrib.h>
|
||||||
|
|
||||||
@ -51,6 +51,8 @@ public:
|
|||||||
|
|
||||||
return off;
|
return off;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const AnsiString ToHashString() override;
|
||||||
};//struct Material2DCreateConfig:public MaterialCreateConfig
|
};//struct Material2DCreateConfig:public MaterialCreateConfig
|
||||||
|
|
||||||
DEFINE_MATERIAL_FACTORY_CLASS(VertexColor2D, const Material2DCreateConfig)
|
DEFINE_MATERIAL_FACTORY_CLASS(VertexColor2D, const Material2DCreateConfig)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include<hgl/graph/mtl/MaterialLibrary.h>
|
#include<hgl/graph/mtl/MaterialLibrary.h>
|
||||||
#include<hgl/graph/mtl/MaterialConfig.h>
|
#include<hgl/graph/mtl/MaterialCreateConfig.h>
|
||||||
#include<hgl/graph/CoordinateSystem.h>
|
#include<hgl/graph/CoordinateSystem.h>
|
||||||
#include<hgl/graph/VertexAttrib.h>
|
#include<hgl/graph/VertexAttrib.h>
|
||||||
|
|
||||||
@ -49,6 +49,8 @@ public:
|
|||||||
|
|
||||||
return off;
|
return off;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const AnsiString ToHashString() override;
|
||||||
};//struct Material3DCreateConfig:public MaterialCreateConfig
|
};//struct Material3DCreateConfig:public MaterialCreateConfig
|
||||||
|
|
||||||
DEFINE_MATERIAL_FACTORY_CLASS(VertexColor3D, const Material3DCreateConfig);
|
DEFINE_MATERIAL_FACTORY_CLASS(VertexColor3D, const Material3DCreateConfig);
|
||||||
|
@ -52,5 +52,7 @@ public:
|
|||||||
|
|
||||||
return off;
|
return off;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual const AnsiString ToHashString();
|
||||||
};//struct MaterialCreateConfig
|
};//struct MaterialCreateConfig
|
||||||
STD_MTL_NAMESPACE_END
|
STD_MTL_NAMESPACE_END
|
@ -6,7 +6,7 @@
|
|||||||
#include<hgl/shadergen/ShaderCreateInfoFragment.h>
|
#include<hgl/shadergen/ShaderCreateInfoFragment.h>
|
||||||
#include<hgl/shadergen/ShaderCreateInfoMap.h>
|
#include<hgl/shadergen/ShaderCreateInfoMap.h>
|
||||||
#include<hgl/graph/RenderTargetOutputConfig.h>
|
#include<hgl/graph/RenderTargetOutputConfig.h>
|
||||||
#include<hgl/graph/mtl/MaterialConfig.h>
|
#include<hgl/graph/mtl/MaterialCreateConfig.h>
|
||||||
#include<hgl/graph/mtl/ShaderBufferSource.h>
|
#include<hgl/graph/mtl/ShaderBufferSource.h>
|
||||||
#include<hgl/graph/VKSamplerType.h>
|
#include<hgl/graph/VKSamplerType.h>
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ bool RenderFramework::Init(uint w,uint h)
|
|||||||
|
|
||||||
void RenderFramework::CreateDefaultRenderer()
|
void RenderFramework::CreateDefaultRenderer()
|
||||||
{
|
{
|
||||||
input_event.Clear();
|
mouse_event=nullptr;
|
||||||
|
|
||||||
SAFE_CLEAR(default_renderer)
|
SAFE_CLEAR(default_renderer)
|
||||||
|
|
||||||
@ -160,6 +160,8 @@ void RenderFramework::CreateDefaultRenderer()
|
|||||||
this->Join(cmc);
|
this->Join(cmc);
|
||||||
|
|
||||||
default_camera_control=fpcc;
|
default_camera_control=fpcc;
|
||||||
|
|
||||||
|
mouse_event=cmc;
|
||||||
}
|
}
|
||||||
|
|
||||||
default_renderer->SetCameraControl(default_camera_control);
|
default_renderer->SetCameraControl(default_camera_control);
|
||||||
@ -186,11 +188,6 @@ void RenderFramework::Tick()
|
|||||||
{
|
{
|
||||||
if(default_camera_control)
|
if(default_camera_control)
|
||||||
{
|
{
|
||||||
for(auto *ie:input_event)
|
|
||||||
{
|
|
||||||
ie->Update();
|
|
||||||
}
|
|
||||||
|
|
||||||
default_camera_control->Refresh();
|
default_camera_control->Refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,9 @@
|
|||||||
#include<hgl/shadergen/ShaderDescriptorInfo.h>
|
#include<hgl/shadergen/ShaderDescriptorInfo.h>
|
||||||
#include<hgl/type/ActiveMemoryBlockManager.h>
|
#include<hgl/type/ActiveMemoryBlockManager.h>
|
||||||
|
|
||||||
|
#include<hgl/graph/mtl/Material2DCreateConfig.h>
|
||||||
|
#include<hgl/graph/mtl/Material3DCreateConfig.h>
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#include"VKPipelineLayoutData.h"
|
#include"VKPipelineLayoutData.h"
|
||||||
#endif//_DEBUG
|
#endif//_DEBUG
|
||||||
@ -187,7 +190,10 @@ Material *RenderResource::LoadMaterial(const AnsiString &mtl_name,mtl::Material2
|
|||||||
AutoDelete<mtl::MaterialCreateInfo> mci=mtl::LoadMaterialFromFile(device->GetDevAttr(),mtl_name,cfg);
|
AutoDelete<mtl::MaterialCreateInfo> mci=mtl::LoadMaterialFromFile(device->GetDevAttr(),mtl_name,cfg);
|
||||||
|
|
||||||
//这里直接用这个mtl_name有些不太对,因为同一个材质,也有可能因为不同的cfg会有不同的版本,所以这里不能直接使用mtl_name.目前只是做一个暂时方案
|
//这里直接用这个mtl_name有些不太对,因为同一个材质,也有可能因为不同的cfg会有不同的版本,所以这里不能直接使用mtl_name.目前只是做一个暂时方案
|
||||||
return this->CreateMaterial(mtl_name,mci);
|
|
||||||
|
AnsiString hash_name=mtl_name+"?"+cfg->ToHashString();
|
||||||
|
|
||||||
|
return this->CreateMaterial(hash_name,mci);
|
||||||
}
|
}
|
||||||
|
|
||||||
Material *RenderResource::LoadMaterial(const AnsiString &mtl_name,mtl::Material3DCreateConfig *cfg)
|
Material *RenderResource::LoadMaterial(const AnsiString &mtl_name,mtl::Material3DCreateConfig *cfg)
|
||||||
@ -195,6 +201,9 @@ Material *RenderResource::LoadMaterial(const AnsiString &mtl_name,mtl::Material3
|
|||||||
AutoDelete<mtl::MaterialCreateInfo> mci=mtl::LoadMaterialFromFile(device->GetDevAttr(),mtl_name,cfg);
|
AutoDelete<mtl::MaterialCreateInfo> mci=mtl::LoadMaterialFromFile(device->GetDevAttr(),mtl_name,cfg);
|
||||||
|
|
||||||
//这里直接用这个mtl_name有些不太对,因为同一个材质,也有可能因为不同的cfg会有不同的版本,所以这里不能直接使用mtl_name.目前只是做一个暂时方案
|
//这里直接用这个mtl_name有些不太对,因为同一个材质,也有可能因为不同的cfg会有不同的版本,所以这里不能直接使用mtl_name.目前只是做一个暂时方案
|
||||||
return this->CreateMaterial(mtl_name,mci);
|
|
||||||
|
AnsiString hash_name=mtl_name+"?"+cfg->ToHashString();
|
||||||
|
|
||||||
|
return this->CreateMaterial(hash_name,mci);
|
||||||
}
|
}
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
|
@ -76,9 +76,10 @@ SET(STD_MTL_3D_SOURCE_FILES ${STD_MTL_HEADER_PATH}/Material3DCreateConfig.h
|
|||||||
3d/M_Gizmo3D.cpp
|
3d/M_Gizmo3D.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(STD_MTL_SOURCE ${STD_MTL_HEADER_PATH}/MaterialConfig.h
|
SET(STD_MTL_SOURCE ${STD_MTL_HEADER_PATH}/MaterialCreateConfig.h
|
||||||
${STD_MTL_HEADER_PATH}/StdMaterial.h
|
${STD_MTL_HEADER_PATH}/StdMaterial.h
|
||||||
${STD_MTL_HEADER_PATH}/ShaderBufferSource.h
|
${STD_MTL_HEADER_PATH}/ShaderBufferSource.h
|
||||||
|
MaterialCreateConfig.cpp
|
||||||
StandardMaterial.cpp
|
StandardMaterial.cpp
|
||||||
MaterialFileData.h
|
MaterialFileData.h
|
||||||
MaterialFileLoader.cpp)
|
MaterialFileLoader.cpp)
|
||||||
|
72
src/ShaderGen/MaterialCreateConfig.cpp
Normal file
72
src/ShaderGen/MaterialCreateConfig.cpp
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#include<hgl/graph/mtl/Material2DCreateConfig.h>
|
||||||
|
#include<hgl/graph/mtl/Material3DCreateConfig.h>
|
||||||
|
#include<hgl/graph/VertexAttrib.h>
|
||||||
|
|
||||||
|
STD_MTL_NAMESPACE_BEGIN
|
||||||
|
const AnsiString MaterialCreateConfig::ToHashString()
|
||||||
|
{
|
||||||
|
AnsiString hash;
|
||||||
|
|
||||||
|
char str[16];
|
||||||
|
char *p=str;
|
||||||
|
|
||||||
|
*p='M';++p;
|
||||||
|
|
||||||
|
if(material_instance){*p='I';++p;}
|
||||||
|
|
||||||
|
*p='_';++p;
|
||||||
|
|
||||||
|
*p='0'+rt_output.color;++p;
|
||||||
|
|
||||||
|
if(rt_output.depth){*p='D';++p;}
|
||||||
|
if(rt_output.stencil){*p='S';++p;}
|
||||||
|
|
||||||
|
*p='_';++p;
|
||||||
|
|
||||||
|
if(shader_stage_flag_bit&VK_SHADER_STAGE_VERTEX_BIT){*p='V';++p;}
|
||||||
|
if(shader_stage_flag_bit&VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT){*p='T';++p;} //tc/te有一个就行了
|
||||||
|
if(shader_stage_flag_bit&VK_SHADER_STAGE_GEOMETRY_BIT){*p='G';++p;}
|
||||||
|
if(shader_stage_flag_bit&VK_SHADER_STAGE_FRAGMENT_BIT){*p='F';++p;}
|
||||||
|
if(shader_stage_flag_bit&VK_SHADER_STAGE_COMPUTE_BIT){*p='C';++p;}
|
||||||
|
if(shader_stage_flag_bit&VK_SHADER_STAGE_MESH_BIT_EXT){*p='M';++p;} //mesh/task有一个就行了
|
||||||
|
*p='_';++p;
|
||||||
|
|
||||||
|
*p=0;
|
||||||
|
|
||||||
|
hash=p;
|
||||||
|
hash+=GetPrimName(prim);
|
||||||
|
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
const AnsiString Material2DCreateConfig::ToHashString()
|
||||||
|
{
|
||||||
|
AnsiString hash=MaterialCreateConfig::ToHashString();
|
||||||
|
|
||||||
|
hash+=GetCoordinateSystem2DName(coordinate_system);
|
||||||
|
|
||||||
|
if(local_to_world)
|
||||||
|
hash+="_L2W";
|
||||||
|
|
||||||
|
hash+="_";
|
||||||
|
hash+=GetVertexAttribName(&position_format);
|
||||||
|
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
const AnsiString Material3DCreateConfig::ToHashString()
|
||||||
|
{
|
||||||
|
AnsiString hash=MaterialCreateConfig::ToHashString();
|
||||||
|
|
||||||
|
if(camera)
|
||||||
|
hash+="_Camera";
|
||||||
|
|
||||||
|
if(local_to_world)
|
||||||
|
hash+="_L2W";
|
||||||
|
|
||||||
|
hash+="_";
|
||||||
|
hash+=GetVertexAttribName(&position_format);
|
||||||
|
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
STD_MTL_NAMESPACE_END
|
@ -1,4 +1,4 @@
|
|||||||
#include<hgl/graph/mtl/MaterialConfig.h>
|
#include<hgl/graph/mtl/MaterialCreateConfig.h>
|
||||||
#include<hgl/graph/mtl/Material2DCreateConfig.h>
|
#include<hgl/graph/mtl/Material2DCreateConfig.h>
|
||||||
#include<hgl/graph/mtl/Material3DCreateConfig.h>
|
#include<hgl/graph/mtl/Material3DCreateConfig.h>
|
||||||
#include<hgl/graph/VKShaderStage.h>
|
#include<hgl/graph/VKShaderStage.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user