增加MaterialCreateConfig::ToHashString函数,用于在未来生成区分同一材质不同配置的字串
This commit is contained in:
parent
0c3cc5a320
commit
0fbe85290b
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#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/VertexAttrib.h>
|
||||
|
||||
@ -51,6 +51,8 @@ public:
|
||||
|
||||
return off;
|
||||
}
|
||||
|
||||
const AnsiString ToHashString() override;
|
||||
};//struct Material2DCreateConfig:public MaterialCreateConfig
|
||||
|
||||
DEFINE_MATERIAL_FACTORY_CLASS(VertexColor2D, const Material2DCreateConfig)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#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/VertexAttrib.h>
|
||||
|
||||
@ -49,6 +49,8 @@ public:
|
||||
|
||||
return off;
|
||||
}
|
||||
|
||||
const AnsiString ToHashString() override;
|
||||
};//struct Material3DCreateConfig:public MaterialCreateConfig
|
||||
|
||||
DEFINE_MATERIAL_FACTORY_CLASS(VertexColor3D, const Material3DCreateConfig);
|
||||
|
@ -52,5 +52,7 @@ public:
|
||||
|
||||
return off;
|
||||
}
|
||||
|
||||
virtual const AnsiString ToHashString();
|
||||
};//struct MaterialCreateConfig
|
||||
STD_MTL_NAMESPACE_END
|
@ -6,7 +6,7 @@
|
||||
#include<hgl/shadergen/ShaderCreateInfoFragment.h>
|
||||
#include<hgl/shadergen/ShaderCreateInfoMap.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/VKSamplerType.h>
|
||||
|
||||
|
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
|
Loading…
x
Reference in New Issue
Block a user