little codes
This commit is contained in:
parent
dc3d7b7792
commit
c355f96f9b
@ -1,4 +1,4 @@
|
||||
// BlinnPhong direction light
|
||||
// BlinnPhong direction light
|
||||
|
||||
#include"VulkanAppFramework.h"
|
||||
#include<hgl/filesystem/FileSystem.h>
|
||||
@ -64,6 +64,9 @@ private:
|
||||
mtl_sun_light=db->LoadMaterial("Std3D/BlinnPhong/SunLightPureColor",&cfg);
|
||||
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);
|
||||
if(!mi_sphere)return(false);
|
||||
|
||||
|
@ -1,22 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/mtl/StdMaterial.h>
|
||||
#include<hgl/graph/mtl/ShaderBuffer.h>
|
||||
#include<hgl/math/Vector.h>
|
||||
|
||||
namespace hgl
|
||||
STD_MTL_NAMESPACE_BEGIN
|
||||
namespace blinnphong
|
||||
{
|
||||
namespace graph
|
||||
struct SunLight
|
||||
{
|
||||
namespace mtl
|
||||
{
|
||||
namespace blinnphong
|
||||
{
|
||||
struct SunLight
|
||||
{
|
||||
Vector3f direction;
|
||||
Vector3f color;
|
||||
};//struct SunLight
|
||||
}//namespace blinnphong
|
||||
}//namespace mtl
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
Vector3f direction;
|
||||
Vector3f color;
|
||||
};//struct SunLight
|
||||
|
||||
constexpr const ShaderBufferSource SBS_SunLight=
|
||||
{
|
||||
"SunLight",
|
||||
"sun",
|
||||
|
||||
R"(
|
||||
vec3 direction;
|
||||
vec3 color;
|
||||
)"
|
||||
};
|
||||
}//namespace blinnphong
|
||||
STD_MTL_NAMESPACE_END
|
||||
|
24
inc/hgl/graph/mtl/UniformBuffer.h
Normal file
24
inc/hgl/graph/mtl/UniformBuffer.h
Normal 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
|
@ -36,7 +36,8 @@ SOURCE_GROUP("GLSL Compiler" FILES ${GLSL_COMPILER_SOURCE})
|
||||
|
||||
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
|
||||
common/MFCommon.h
|
||||
common/MFGetPosition.h
|
||||
|
Loading…
x
Reference in New Issue
Block a user