little codes

This commit is contained in:
hyzboy 2024-03-06 13:54:05 +08:00
parent dc3d7b7792
commit c355f96f9b
4 changed files with 50 additions and 18 deletions

View File

@ -1,4 +1,4 @@
// BlinnPhong direction light // BlinnPhong direction light
#include"VulkanAppFramework.h" #include"VulkanAppFramework.h"
#include<hgl/filesystem/FileSystem.h> #include<hgl/filesystem/FileSystem.h>
@ -64,6 +64,9 @@ private:
mtl_sun_light=db->LoadMaterial("Std3D/BlinnPhong/SunLightPureColor",&cfg); mtl_sun_light=db->LoadMaterial("Std3D/BlinnPhong/SunLightPureColor",&cfg);
if(!mtl_sun_light)return(false); if(!mtl_sun_light)return(false);
mtl_sun_light->BindUBO(DescriptorSetType::Global,"sun",sun_data,sizeof(sun_data)); //恢复SUN.UBO或是使用内嵌SUN定义也行
//恢复SUN.UBO的意义是让引擎支持读取外部UBO配置文件
mi_sphere=db->CreateMaterialInstance(mtl_sun_light); mi_sphere=db->CreateMaterialInstance(mtl_sun_light);
if(!mi_sphere)return(false); if(!mi_sphere)return(false);

View File

@ -1,22 +1,26 @@
#pragma once #pragma once
#include<hgl/graph/mtl/StdMaterial.h> #include<hgl/graph/mtl/StdMaterial.h>
#include<hgl/graph/mtl/ShaderBuffer.h>
#include<hgl/math/Vector.h> #include<hgl/math/Vector.h>
STD_MTL_NAMESPACE_BEGIN
namespace hgl namespace blinnphong
{ {
namespace graph struct SunLight
{ {
namespace mtl Vector3f direction;
{ Vector3f color;
namespace blinnphong };//struct SunLight
{
struct SunLight constexpr const ShaderBufferSource SBS_SunLight=
{ {
Vector3f direction; "SunLight",
Vector3f color; "sun",
};//struct SunLight
}//namespace blinnphong R"(
}//namespace mtl vec3 direction;
}//namespace graph vec3 color;
}//namespace hgl )"
};
}//namespace blinnphong
STD_MTL_NAMESPACE_END

View File

@ -0,0 +1,24 @@
#pragma once
#include<hgl/graph/mtl/StdMaterial.h>
#include<hgl/graph/mtl/ShaderBuffer.h>
STD_MTL_NAMESPACE_BEGIN
/**
* UBO的基类
*/
class UniformBuffer
{
private:
ShaderBufferSource *sbs;
public:
virtual const AnsiString &GetStructName ()const{return sbs->struct_name;} ///<取得结构名称
virtual const AnsiString &GetDefaultValueName ()const{return sbs->name;} ///<取得默认变量名称
virtual const AnsiString &GetShaderCodes ()const{return sbs->codes;} ///<取得Shader代码
};//class UniformBuffer
STD_MTL_NAMESPACE_END

View File

@ -36,7 +36,8 @@ SOURCE_GROUP("GLSL Compiler" FILES ${GLSL_COMPILER_SOURCE})
set(STD_MTL_HEADER_PATH ${ROOT_INCLUDE_PATH}/hgl/graph/mtl) set(STD_MTL_HEADER_PATH ${ROOT_INCLUDE_PATH}/hgl/graph/mtl)
SET(SHADERGEN_COMMON_FILES ${STD_MTL_HEADER_PATH}/UBOCommon.h SET(SHADERGEN_COMMON_FILES ${STD_MTL_HEADER_PATH}/UniformBuffer.h
${STD_MTL_HEADER_PATH}/UBOCommon.h
${STD_MTL_HEADER_PATH}/SamplerName.h ${STD_MTL_HEADER_PATH}/SamplerName.h
common/MFCommon.h common/MFCommon.h
common/MFGetPosition.h common/MFGetPosition.h