From 818946a7e76320a8b84674136c9981e52e45f373 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Tue, 14 Jan 2020 18:09:40 +0800 Subject: [PATCH] 1.delete MaterialData.h 2.add StandardMaterial and PBRMaterial --- example/Vulkan/auto_material.cpp | 4 +- inc/hgl/graph/WorldMatrix.h | 2 +- inc/hgl/graph/material/ComboMaterial.h | 4 +- inc/hgl/graph/material/Component.h | 20 ++-- inc/hgl/graph/material/DataSource.h | 20 +++- inc/hgl/graph/material/Material.h | 31 +++++- inc/hgl/graph/material/MaterialData.h | 94 ------------------- inc/hgl/graph/material/PBRMaterial.h | 23 +++++ inc/hgl/graph/material/StandardMaterial.h | 40 ++++++++ inc/hgl/graph/shader/ShaderMaker.h | 4 +- inc/hgl/graph/shader/common.h | 26 ++--- inc/hgl/graph/shader/node/combo_vector.h | 4 +- inc/hgl/graph/shader/node/define.h | 6 +- inc/hgl/graph/shader/node/finished.h | 4 +- inc/hgl/graph/shader/node/node.h | 4 +- inc/hgl/graph/shader/node/op.h | 4 +- inc/hgl/graph/shader/node/split_vector.h | 4 +- inc/hgl/graph/shader/node/texture.h | 4 +- inc/hgl/graph/shader/node/type.h | 4 +- inc/hgl/graph/shader/node/vector.h | 4 +- inc/hgl/graph/shader/node/vertex_input.h | 4 +- inc/hgl/graph/shader/param/in.h | 4 +- inc/hgl/graph/shader/param/out.h | 4 +- inc/hgl/graph/shader/param/param.h | 4 +- inc/hgl/graph/shader/param/type.h | 4 +- inc/hgl/graph/vulkan/VK.h | 8 +- src/RenderDevice/Shader/DefaultShader.cpp | 4 +- src/RenderDevice/Shader/ShaderMaker.cpp | 4 +- src/RenderDevice/Shader/node/combo_vector.cpp | 4 +- .../Shader/node/fin/fin_vertex.cpp | 4 +- src/RenderDevice/Shader/node/shader_node.cpp | 4 +- src/RenderDevice/Shader/node/vertex_input.cpp | 4 +- .../Shader/param/shader_param_in.cpp | 4 +- .../Shader/param/shader_param_type.cpp | 4 +- src/SceneGraph/material/Material.cpp | 4 +- src/SceneGraph/material/MaterialComponent.cpp | 4 +- 36 files changed, 193 insertions(+), 181 deletions(-) delete mode 100644 inc/hgl/graph/material/MaterialData.h create mode 100644 inc/hgl/graph/material/PBRMaterial.h create mode 100644 inc/hgl/graph/material/StandardMaterial.h diff --git a/example/Vulkan/auto_material.cpp b/example/Vulkan/auto_material.cpp index 31f8f81c..eefa9751 100644 --- a/example/Vulkan/auto_material.cpp +++ b/example/Vulkan/auto_material.cpp @@ -4,9 +4,9 @@ using namespace hgl; using namespace hgl::graph; using namespace hgl::graph::shader; -BEGIN_SHADER_NAMESPACE +SHADER_NAMESPACE_BEGIN bool CreateDefaultMaterial(); -END_SHADER_NAMESPACE +SHADER_NAMESPACE_END int main() { diff --git a/inc/hgl/graph/WorldMatrix.h b/inc/hgl/graph/WorldMatrix.h index 33e2a19d..d8ce48ee 100644 --- a/inc/hgl/graph/WorldMatrix.h +++ b/inc/hgl/graph/WorldMatrix.h @@ -11,7 +11,7 @@ namespace hgl * 世界矩阵数据 * @see res/shader/UBO_WorldMatrix.glsl */ - struct alignas(4) WorldMatrix + struct WorldMatrix { Matrix4f ortho; //2D正角视图矩阵 diff --git a/inc/hgl/graph/material/ComboMaterial.h b/inc/hgl/graph/material/ComboMaterial.h index 54676b83..eae8a31a 100644 --- a/inc/hgl/graph/material/ComboMaterial.h +++ b/inc/hgl/graph/material/ComboMaterial.h @@ -3,7 +3,7 @@ #include -BEGIN_MATERIAL_NAMESPACE +MATERIAL_NAMESPACE_BEGIN /** * 简易组合材质
* 提供最简单的材质定义方案 @@ -12,5 +12,5 @@ class ComboMaterial { };//class ComboMaterial -END_MATERIAL_NAMESPACE +MATERIAL_NAMESPACE_END #endif//HGL_GRAPH_COMBO_MATERIAL_INCLUDE diff --git a/inc/hgl/graph/material/Component.h b/inc/hgl/graph/material/Component.h index 09baee6c..a69944e4 100644 --- a/inc/hgl/graph/material/Component.h +++ b/inc/hgl/graph/material/Component.h @@ -3,18 +3,18 @@ #include -#define BEGIN_MATERIAL_NAMESPACE namespace hgl{namespace graph{namespace material{ -#define END_MATERIAL_NAMESPACE }}} +#define MATERIAL_NAMESPACE_BEGIN namespace hgl{namespace graph{namespace material{ +#define MATERIAL_NAMESPACE_END }}} #define MATERIAL_NAMESPACE hgl::graph::material -#define USING_MATERIAL_NAMESPACE using namespace MATERIAL_NAMESPACE; +#define MATERIAL_NAMESPACE_USING using namespace MATERIAL_NAMESPACE; -BEGIN_MATERIAL_NAMESPACE +MATERIAL_NAMESPACE_BEGIN enum class Component { ShadingModel=0, - Color, + BaseColor, Mask, Opacity, Normal, @@ -43,7 +43,7 @@ BEGIN_MATERIAL_NAMESPACE #define MC_BIT_DEFINE(name) name=1<<(uint)Component::name MC_BIT_DEFINE(ShadingModel ), - MC_BIT_DEFINE(Color ), + MC_BIT_DEFINE(BaseColor ), MC_BIT_DEFINE(Mask ), MC_BIT_DEFINE(Opacity ), MC_BIT_DEFINE(Normal ), @@ -96,11 +96,11 @@ BEGIN_MATERIAL_NAMESPACE using ComponentBitsConfig=uint32; - constexpr ComponentBitsConfig MCC_PureColor =uint32(ComponentBit::Color); + constexpr ComponentBitsConfig MCC_PureColor =uint32(ComponentBit::BaseColor); constexpr ComponentBitsConfig MCC_PureNormal =uint32(ComponentBit::Normal); constexpr ComponentBitsConfig MCC_PureOpacity =uint32(ComponentBit::Opacity); - constexpr ComponentBitsConfig MCC_ColorNormal =uint32(ComponentBit::Color)|uint32(ComponentBit::Normal); - constexpr ComponentBitsConfig MCC_CNMR =uint32(ComponentBit::Color)|uint32(ComponentBit::Normal)|uint32(ComponentBit::Metallic)|uint32(ComponentBit::Roughness); + constexpr ComponentBitsConfig MCC_ColorNormal =uint32(ComponentBit::BaseColor)|uint32(ComponentBit::Normal); + constexpr ComponentBitsConfig MCC_CNMR =uint32(ComponentBit::BaseColor)|uint32(ComponentBit::Normal)|uint32(ComponentBit::Metallic)|uint32(ComponentBit::Roughness); struct ComponentConfig { @@ -111,5 +111,5 @@ BEGIN_MATERIAL_NAMESPACE };//struct ComponentConfig const ComponentConfig *GetConfig(const enum class Component c); -END_MATERIAL_NAMESPACE +MATERIAL_NAMESPACE_END #endif//HGL_GRAPH_MATERIAL_COMPONENT_INCLUDE diff --git a/inc/hgl/graph/material/DataSource.h b/inc/hgl/graph/material/DataSource.h index 6db7cde8..41764ed6 100644 --- a/inc/hgl/graph/material/DataSource.h +++ b/inc/hgl/graph/material/DataSource.h @@ -4,7 +4,7 @@ #include #include -BEGIN_MATERIAL_NAMESPACE +MATERIAL_NAMESPACE_BEGIN /** * 数据源 @@ -54,12 +54,22 @@ public: /** * 函数数据源 */ - class DataSourceFunction:public DataSource - { +class DataSourceFunction:public DataSource +{ public: using DataSource::DataSource; - };//class DataSourceFunction:public DataSource +};//class DataSourceFunction:public DataSource + +/** + * 顶点数据源 + */ +class DataSourceVertex:public DataSource +{ +public: + + using DataSource::DataSource; +};//class DataSourceVertex:public DataSource /** * 纹理数据源 @@ -112,5 +122,5 @@ public: using DataSourceTexture::DataSourceTexture; };//class DataSourceTextureCubemapArrays:public DataSourceTexture -END_MATERIAL_NAMESPACE +MATERIAL_NAMESPACE_END #endif//HGL_GRAPH_MATERIAL_DATA_SOURCE_INCLUDE diff --git a/inc/hgl/graph/material/Material.h b/inc/hgl/graph/material/Material.h index c4666bf5..0de48b8d 100644 --- a/inc/hgl/graph/material/Material.h +++ b/inc/hgl/graph/material/Material.h @@ -2,13 +2,16 @@ #define HGL_GRAPH_MATERIAL_INCLUDE #include -BEGIN_MATERIAL_NAMESPACE +#include + +MATERIAL_NAMESPACE_BEGIN enum class BlendMode { Opaque=0, Mask, Alpha, Additive, + Subtractive, Modulate, PreMultiAlpha, // 预计算好一半的Alpha @@ -19,8 +22,30 @@ BEGIN_MATERIAL_NAMESPACE class Material { - BlendMode blend_mode; + UTF8String name; + ComponentBitsConfig comp_cfg; + BlendMode blend_mode; + + bool two_sided=false; + bool wire_frame=false; + + public: + + Material(const UTF8String &n, + const ComponentBitsConfig &cbf, + const BlendMode &bm=BlendMode::Opaque, + const bool ts=false, + const bool wf=false) + { + name=n; + comp_cfg=cbf; + blend_mode=bm; + two_sided=false; + wire_frame=false; + } + + virtual ~Material()=default; };//class Material -END_MATERIAL_NAMESPACE +MATERIAL_NAMESPACE_END #endif//HGL_GRAPH_MATERIAL_INCLUDE diff --git a/inc/hgl/graph/material/MaterialData.h b/inc/hgl/graph/material/MaterialData.h deleted file mode 100644 index 410099f5..00000000 --- a/inc/hgl/graph/material/MaterialData.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef HGL_GRAPH_MATERIAL_DATA_INCLUDE -#define HGL_GRAPH_MATERIAL_DATA_INCLUDE - -#include -#include -#include -namespace hgl -{ - namespace graph - { - struct MaterialTextureData - { - TextureType type=TextureType::None; - - int32 tex_id=-1; - - uint8 uvindex=0; - float blend=0; - uint8 op=0; - uint8 wrap_mode[2]={0,0}; - };//struct MaterialTextureData - - struct MaterialData - { - UTF8String name; - - uint8 tex_count; - - MaterialTextureData *tex_list; - - Set uv_use; - - bool two_sided=false; - uint shading_model=0; - bool wireframe=false; - - uint blend_func; - - float opacity; ///<透明度 - - uint transparency_factor; - - float bump_scaling; - float shininess; - float reflectivity; ///<反射率 - float shininess_strength; - - float refracti; ///<折射率 - - Color4f diffuse; - Color4f ambient; - Color4f specular; - Color4f emission; - Color4f transparent; ///<透明色 - Color4f reflective; ///<反射颜色 - - public: - - MaterialData() - { - tex_count=0; - tex_list=nullptr; - } - - void InitDefaultColor() - { - diffuse.Set(1,1,1,1); - specular.Set(0,0,0,1); - ambient.Set(0.2f,0.2f,0.2f,1.0f); - emission.Set(0,0,0,1); - - shininess=0; - - opacity=1.0f; - refracti=0; - transparent.Set(0,0,0,1); - reflective.Set(1,1,1,1); - } - - void Init(const uint32 tc) - { - tex_count=tc; - - tex_list=new MaterialTextureData[tc]; - } - - ~MaterialData() - { - delete[] tex_list; - } - };//struct MaterialData - }//namespace graph -}//namespace hgl -#endif//HGL_GRAPH_MATERIAL_DATA_INCLUDE diff --git a/inc/hgl/graph/material/PBRMaterial.h b/inc/hgl/graph/material/PBRMaterial.h new file mode 100644 index 00000000..54a38deb --- /dev/null +++ b/inc/hgl/graph/material/PBRMaterial.h @@ -0,0 +1,23 @@ +#ifndef HGL_GRAPH_MATERIAL_PBR_INCLUDE +#define HGL_GRAPH_MATERIAL_PBR_INCLUDE + +#include +MATERIAL_NAMESPACE_BEGIN +/** + * 标准PBR材质
+ * BaseColor/Normal/Metallic/Roughness四个属性必须都有。如未提供,则会使用const方式提供一个数值 + */ +class PBRMaterial:public Material +{ +public: + + PBRMaterial(const UTF8String & n, + const BlendMode & bm =BlendMode::Opaque, + const bool ts =false, + const bool wf =false): + Material(n,MCC_CNMR,bm,ts,wf){} + + virtual ~PBRMaterial()=default; +};//class PBRMaterial:public Material +MATERIAL_NAMESPACE_END +#endif//HGL_GRAPH_MATERIAL_PBR_INCLUDE diff --git a/inc/hgl/graph/material/StandardMaterial.h b/inc/hgl/graph/material/StandardMaterial.h new file mode 100644 index 00000000..f1cd33c0 --- /dev/null +++ b/inc/hgl/graph/material/StandardMaterial.h @@ -0,0 +1,40 @@ +#ifndef HGL_GRAPH_MATERIAL_STANDARD_INCLUDE +#define HGL_GRAPH_MATERIAL_STANDARD_INCLUDE + +#include +MATERIAL_NAMESPACE_BEGIN +/** + * 传统标准材质 + */ +class StandardMaterial:public Material +{ +public: + + enum class DataSource + { + Const, + Param, + Texture, + Vertex, + };// + + struct + { + Component comp; ///<成份 + DataSource source; ///<来源 + DataFormat format; ///<数据格式 + }; + +public: + + StandardMaterial( const UTF8String & n, + const ComponentBitsConfig & cbf, + const BlendMode & bm =BlendMode::Opaque, + const bool ts =false, + const bool wf =false): + Material(n,cbf,bm,ts,wf){} + + virtual ~StandardMaterial()=default; +};//class StandardMaterial:public Material +MATERIAL_NAMESPACE_END +#endif//HGL_GRAPH_MATERIAL_STANDARD_INCLUDE diff --git a/inc/hgl/graph/shader/ShaderMaker.h b/inc/hgl/graph/shader/ShaderMaker.h index 0c307745..9cede1d3 100644 --- a/inc/hgl/graph/shader/ShaderMaker.h +++ b/inc/hgl/graph/shader/ShaderMaker.h @@ -4,7 +4,7 @@ #include #include #include -BEGIN_SHADER_NAMESPACE +SHADER_NAMESPACE_BEGIN using NodeList=List; @@ -75,5 +75,5 @@ public: virtual bool SaveToFile(const OSString &); };//class ShaderMaker -END_SHADER_NAMESPACE +SHADER_NAMESPACE_END #endif//HGL_GRAPH_SHADER_MAKER_INCLUDE diff --git a/inc/hgl/graph/shader/common.h b/inc/hgl/graph/shader/common.h index 2ec670db..30d87f8e 100644 --- a/inc/hgl/graph/shader/common.h +++ b/inc/hgl/graph/shader/common.h @@ -2,26 +2,26 @@ #define HGL_GRAPH_SHADER_COMMON_INCLUDE #define SHADER_NAMESPACE hgl::graph::shader -#define BEGIN_SHADER_NAMESPACE namespace hgl{namespace graph{namespace shader{ -#define END_SHADER_NAMESPACE }}} -#define USING_SHADER_NAMESPACE using SHADER_NAMESPACE; +#define SHADER_NAMESPACE_BEGIN namespace hgl{namespace graph{namespace shader{ +#define SHADER_NAMESPACE_END }}} +#define SHADER_NAMESPACE_USING using SHADER_NAMESPACE; #define SHADER_NODE_NAMESPACE hgl::graph::shader::node -#define BEGIN_SHADER_NODE_NAMESPACE namespace hgl{namespace graph{namespace shader{namespace node{ -#define END_SHADER_NODE_NAMESPACE }}}} -#define USING_SHADER_NODE_NAMESPACE using SHADER_NODE_NAMESPACE; +#define SHADER_NODE_NAMESPACE_BEGIN namespace hgl{namespace graph{namespace shader{namespace node{ +#define SHADER_NODE_NAMESPACE_END }}}} +#define SHADER_NODE_NAMESPACE_USING using SHADER_NODE_NAMESPACE; #define SHADER_PARAM_NAMESPACE hgl::graph::shader::param -#define BEGIN_SHADER_PARAM_NAMESPACE namespace hgl{namespace graph{namespace shader{namespace param{ -#define END_SHADER_PARAM_NAMESPACE }}}} -#define USING_SHADER_PARAM_NAMESPACE using SHADER_PARAM_NAMESPACE; +#define SHADER_PARAM_NAMESPACE_BEGIN namespace hgl{namespace graph{namespace shader{namespace param{ +#define SHADER_PARAM_NAMESPACE_END }}}} +#define SHADER_PARAM_NAMESPACE_USING using SHADER_PARAM_NAMESPACE; -BEGIN_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_BEGIN class Node; -END_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_END -BEGIN_SHADER_PARAM_NAMESPACE +SHADER_PARAM_NAMESPACE_BEGIN class Param; -END_SHADER_PARAM_NAMESPACE +SHADER_PARAM_NAMESPACE_END #endif//HGL_GRAPH_SHADER_COMMON_INCLUDE diff --git a/inc/hgl/graph/shader/node/combo_vector.h b/inc/hgl/graph/shader/node/combo_vector.h index f69bee87..e251c27c 100644 --- a/inc/hgl/graph/shader/node/combo_vector.h +++ b/inc/hgl/graph/shader/node/combo_vector.h @@ -2,7 +2,7 @@ #define HGL_GRAPH_SHADER_NODE_COMBO_VECTOR_INCLUDE #include -BEGIN_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_BEGIN class ComboVector1to2:public Node { param::InputParam *ip_x,*ip_y; @@ -110,5 +110,5 @@ public: bool GenCode(UTF8StringList &) override; };//class ComboVector22to4:public Node -END_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_END #endif//HGL_GRAPH_SHADER_NODE_COMBO_VECTOR_INCLUDE diff --git a/inc/hgl/graph/shader/node/define.h b/inc/hgl/graph/shader/node/define.h index d47b5b29..455401a9 100644 --- a/inc/hgl/graph/shader/node/define.h +++ b/inc/hgl/graph/shader/node/define.h @@ -1,12 +1,14 @@ #ifndef HGL_GRAPH_SHADER_NODE_DEFINE_INCLUDE #define HGL_GRAPH_SHADER_NODE_DEFINE_INCLUDE -BEGIN_SHADER_NODE_NAMESPACE +#include + +SHADER_NODE_NAMESPACE_BEGIN class Bool { public: };//class Bool -END_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_END #endif//HGL_GRAPH_SHADER_NODE_DEFINE_INCLUDE diff --git a/inc/hgl/graph/shader/node/finished.h b/inc/hgl/graph/shader/node/finished.h index ceb8fc27..609de0cd 100644 --- a/inc/hgl/graph/shader/node/finished.h +++ b/inc/hgl/graph/shader/node/finished.h @@ -4,7 +4,7 @@ #include #include -BEGIN_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_BEGIN /** * 最终节点,用于最终结果的一类节点,无输出部分 */ @@ -59,5 +59,5 @@ public: ~FragmentFinished()=default; };//class FragmentFinished:public Finished -END_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_END #endif//HGL_GRAPH_SHADER_NODE_FINISHED_INCLUDE diff --git a/inc/hgl/graph/shader/node/node.h b/inc/hgl/graph/shader/node/node.h index b8373137..38a481e7 100644 --- a/inc/hgl/graph/shader/node/node.h +++ b/inc/hgl/graph/shader/node/node.h @@ -8,7 +8,7 @@ #include #include -BEGIN_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_BEGIN #define SHADER_INPUT_PARAM(mj,name,type) AddInput(mj,#name,SHADER_PARAM_NAMESPACE::ParamType::type); #define SHADER_OUTPUT_PARAM(name,type) AddOutput(#name,SHADER_PARAM_NAMESPACE::ParamType::type); @@ -99,5 +99,5 @@ public: };//template class NativeValue:public Node -END_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_END #endif//HGL_GRAPH_SHADER_NODE_INCLUDE diff --git a/inc/hgl/graph/shader/node/op.h b/inc/hgl/graph/shader/node/op.h index ed01dc8f..c0247806 100644 --- a/inc/hgl/graph/shader/node/op.h +++ b/inc/hgl/graph/shader/node/op.h @@ -2,7 +2,7 @@ #define HGL_GRAPH_SHADER_NODE_OP_INCLUDE #include -BEGIN_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_BEGIN enum class ScalarOpType:uint { Add=0, Sub, Mul, Div, @@ -64,5 +64,5 @@ enum class ColorOpType:uint END_OP_RANGE=HardLight, RANGE_SIZE=(END_OP_RANGE-BEGIN_OP_RANGE)+1 };//enum class ColorOpType:uint -END_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_END #endif//HGL_GRAPH_SHADER_NODE_OP_INCLUDE diff --git a/inc/hgl/graph/shader/node/split_vector.h b/inc/hgl/graph/shader/node/split_vector.h index 53090205..523f2482 100644 --- a/inc/hgl/graph/shader/node/split_vector.h +++ b/inc/hgl/graph/shader/node/split_vector.h @@ -2,7 +2,7 @@ #define HGL_GRAPH_SHADER_NODE_SPLIT_VECTOR_INCLUDE #include -BEGIN_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_BEGIN class SplitVector2to1:public Node { public: @@ -83,5 +83,5 @@ public: SHADER_INPUT_PARAM(true,XYZW,Float4) } };//class SplitVector4to22:public Node -END_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_END #endif//HGL_GRAPH_SHADER_NODE_SPLIT_VECTOR_INCLUDE diff --git a/inc/hgl/graph/shader/node/texture.h b/inc/hgl/graph/shader/node/texture.h index c381e749..d9e4af4a 100644 --- a/inc/hgl/graph/shader/node/texture.h +++ b/inc/hgl/graph/shader/node/texture.h @@ -3,7 +3,7 @@ #include #include -BEGIN_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_BEGIN class texture:public Node { param::ParamType texture_type; @@ -67,5 +67,5 @@ public: SHADER_INPUT_PARAM(false,XYZ,Float3) } };//class TextureCube:public texture -END_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_END #endif//HGL_GRAPH_SHADER_NODE_TEXTURE_INCLUDE diff --git a/inc/hgl/graph/shader/node/type.h b/inc/hgl/graph/shader/node/type.h index 26688e93..8da66878 100644 --- a/inc/hgl/graph/shader/node/type.h +++ b/inc/hgl/graph/shader/node/type.h @@ -3,7 +3,7 @@ #include -BEGIN_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_BEGIN enum class NodeType:int { VertexInput=0, ///<顶点输入流节点 @@ -26,5 +26,5 @@ enum class NodeType:int END_NODE_TYPE_RANGE =Finished, NODE_TYPE_RANGE_SIZE =(END_NODE_TYPE_RANGE-BEGIN_NODE_TYPE_RANGE)+1 };//enum class NodeType -END_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_END #endif//HGL_GRAPH_SHADER_NODE_TYPE_INCLUDE diff --git a/inc/hgl/graph/shader/node/vector.h b/inc/hgl/graph/shader/node/vector.h index 753cf3f7..90437fc3 100644 --- a/inc/hgl/graph/shader/node/vector.h +++ b/inc/hgl/graph/shader/node/vector.h @@ -4,7 +4,7 @@ #include #include -BEGIN_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_BEGIN class Parameter:public Node { param::ParamType param_type; @@ -61,5 +61,5 @@ public: };//class Float4:public Parameter #undef SHADER_PARAMETER_CONSTRUCT_FUNC -END_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_END #endif//HGL_GRAPH_SHADER_NODE_VECTOR_INCLUDE diff --git a/inc/hgl/graph/shader/node/vertex_input.h b/inc/hgl/graph/shader/node/vertex_input.h index c861b2fe..b5735924 100644 --- a/inc/hgl/graph/shader/node/vertex_input.h +++ b/inc/hgl/graph/shader/node/vertex_input.h @@ -2,7 +2,7 @@ #define HGL_GRAPH_SHADER_NODE_VERTEX_INPUT_INCLUDE #include -BEGIN_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_BEGIN /** * 顶点输入流节点 */ @@ -27,5 +27,5 @@ public: bool GetOutputParamName(UTF8String &,const param::OutputParam *) override; };//class VertexInput:public Node -END_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_END #endif//HGL_GRAPH_SHADER_NODE_VERTEX_INPUT_INCLUDE diff --git a/inc/hgl/graph/shader/param/in.h b/inc/hgl/graph/shader/param/in.h index 1369f8d0..c318addb 100644 --- a/inc/hgl/graph/shader/param/in.h +++ b/inc/hgl/graph/shader/param/in.h @@ -5,7 +5,7 @@ #include #include -BEGIN_SHADER_PARAM_NAMESPACE +SHADER_PARAM_NAMESPACE_BEGIN /** * 输入参数定义 @@ -51,5 +51,5 @@ public: virtual bool Check(){return(must_join?join_param:true);} ///<检测当前节点是否可用 };//class InputParam:public Param -END_SHADER_PARAM_NAMESPACE +SHADER_PARAM_NAMESPACE_END #endif//#ifndef HGL_GRAPH_SHADER_PARAM_INPUT_INCLUDE diff --git a/inc/hgl/graph/shader/param/out.h b/inc/hgl/graph/shader/param/out.h index ec3d10ff..45bbf188 100644 --- a/inc/hgl/graph/shader/param/out.h +++ b/inc/hgl/graph/shader/param/out.h @@ -3,7 +3,7 @@ #include -BEGIN_SHADER_PARAM_NAMESPACE +SHADER_PARAM_NAMESPACE_BEGIN using namespace hgl; @@ -18,5 +18,5 @@ public: virtual ~OutputParam()=default; };//class OutputParam:public Param -END_SHADER_PARAM_NAMESPACE +SHADER_PARAM_NAMESPACE_END #endif//HGL_GRAPH_SHADER_PARAM_OUTPUT_INCLUDE diff --git a/inc/hgl/graph/shader/param/param.h b/inc/hgl/graph/shader/param/param.h index 5c6e652c..eb5cdbb7 100644 --- a/inc/hgl/graph/shader/param/param.h +++ b/inc/hgl/graph/shader/param/param.h @@ -5,7 +5,7 @@ #include #include -BEGIN_SHADER_PARAM_NAMESPACE +SHADER_PARAM_NAMESPACE_BEGIN /** * 参数定义 */ @@ -27,5 +27,5 @@ public: const UTF8String & GetName()const{return name;} const ParamType GetType()const{return type;} };//class Param -END_SHADER_PARAM_NAMESPACE +SHADER_PARAM_NAMESPACE_END #endif//HGL_GRAPH_SHADER_PARAM_INCLUDE diff --git a/inc/hgl/graph/shader/param/type.h b/inc/hgl/graph/shader/param/type.h index f4943305..6df3e516 100644 --- a/inc/hgl/graph/shader/param/type.h +++ b/inc/hgl/graph/shader/param/type.h @@ -4,7 +4,7 @@ #include #include -BEGIN_SHADER_PARAM_NAMESPACE +SHADER_PARAM_NAMESPACE_BEGIN /** * 参数类型 */ @@ -84,5 +84,5 @@ enum class ParamType };//enum class ParamType const char *GetTypename(const ParamType); -END_SHADER_PARAM_NAMESPACE +SHADER_PARAM_NAMESPACE_END #endif//HGL_GRAPH_SHADER_PARAM_TYPE_INCLUDE diff --git a/inc/hgl/graph/vulkan/VK.h b/inc/hgl/graph/vulkan/VK.h index 5fe5b36a..194eaf1e 100644 --- a/inc/hgl/graph/vulkan/VK.h +++ b/inc/hgl/graph/vulkan/VK.h @@ -65,7 +65,13 @@ enum class ShaderStage Compute =VK_SHADER_STAGE_COMPUTE_BIT };//enum class ShaderStage -struct alignas(4) PushConstant +/** + * max-lengths: + * + 256 bytes: nvidia,arm + 128 bytes: amd,intel,powervr,adreno + */ +struct PushConstant { Matrix4f local_to_world; Matrix3f normal; diff --git a/src/RenderDevice/Shader/DefaultShader.cpp b/src/RenderDevice/Shader/DefaultShader.cpp index d694fd57..2f6abed8 100644 --- a/src/RenderDevice/Shader/DefaultShader.cpp +++ b/src/RenderDevice/Shader/DefaultShader.cpp @@ -7,7 +7,7 @@ #include #include -BEGIN_SHADER_NAMESPACE +SHADER_NAMESPACE_BEGIN namespace { namespace InlineShader @@ -106,4 +106,4 @@ bool CreateDefaultMaterial() return(true); } -END_SHADER_NAMESPACE +SHADER_NAMESPACE_END diff --git a/src/RenderDevice/Shader/ShaderMaker.cpp b/src/RenderDevice/Shader/ShaderMaker.cpp index a416474d..fef6cffe 100644 --- a/src/RenderDevice/Shader/ShaderMaker.cpp +++ b/src/RenderDevice/Shader/ShaderMaker.cpp @@ -19,7 +19,7 @@ */ -BEGIN_SHADER_NAMESPACE +SHADER_NAMESPACE_BEGIN namespace { @@ -286,4 +286,4 @@ bool ShaderMaker::SaveToFile(const OSString &filename) delete tos; return(true); } -END_SHADER_NAMESPACE +SHADER_NAMESPACE_END diff --git a/src/RenderDevice/Shader/node/combo_vector.cpp b/src/RenderDevice/Shader/node/combo_vector.cpp index db559bfd..e6a8f81d 100644 --- a/src/RenderDevice/Shader/node/combo_vector.cpp +++ b/src/RenderDevice/Shader/node/combo_vector.cpp @@ -1,6 +1,6 @@ #include -BEGIN_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_BEGIN bool ComboVector1to2::GenOutputParamCode(UTF8StringList &sl) { UTF8String name_x,name_y; @@ -31,4 +31,4 @@ bool ComboVector1to3::GenOutputParamCode(UTF8StringList &sl) return(true); } -END_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_END diff --git a/src/RenderDevice/Shader/node/fin/fin_vertex.cpp b/src/RenderDevice/Shader/node/fin/fin_vertex.cpp index b8b7aed3..58923108 100644 --- a/src/RenderDevice/Shader/node/fin/fin_vertex.cpp +++ b/src/RenderDevice/Shader/node/fin/fin_vertex.cpp @@ -1,6 +1,6 @@ #include -BEGIN_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_BEGIN bool VertexFinished::GenCode(UTF8StringList &sl) { if(!Finished::GenCode(sl)) @@ -14,4 +14,4 @@ bool VertexFinished::GenCode(UTF8StringList &sl) sl.Add("gl_Position="+name+";"); return(true); } -END_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_END diff --git a/src/RenderDevice/Shader/node/shader_node.cpp b/src/RenderDevice/Shader/node/shader_node.cpp index cbfdac62..234d6e8a 100644 --- a/src/RenderDevice/Shader/node/shader_node.cpp +++ b/src/RenderDevice/Shader/node/shader_node.cpp @@ -1,6 +1,6 @@ #include -BEGIN_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_BEGIN param::InputParam *Node::AddInput(bool mj,const UTF8String &n,const param::ParamType &pt) { param::InputParam *ip=new param::InputParam(mj,n,pt); @@ -170,4 +170,4 @@ bool Node::GenCode(UTF8StringList &sl) return(true); } -END_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_END diff --git a/src/RenderDevice/Shader/node/vertex_input.cpp b/src/RenderDevice/Shader/node/vertex_input.cpp index b6fbf8aa..181a91ca 100644 --- a/src/RenderDevice/Shader/node/vertex_input.cpp +++ b/src/RenderDevice/Shader/node/vertex_input.cpp @@ -1,6 +1,6 @@ #include -BEGIN_SHADER_NODE_NAMESPACE +SHADER_NODE_NAMESPACE_BEGIN bool VertexInput::GetOutputParamName(UTF8String &result,const param::OutputParam *op) { if(!op||!IsOutput(op)) @@ -9,4 +9,4 @@ bool VertexInput::GetOutputParamName(UTF8String &result,const param::OutputParam result=op->GetName(); return(true); } -END_SHADER_NODE_NAMESPACE \ No newline at end of file +SHADER_NODE_NAMESPACE_END \ No newline at end of file diff --git a/src/RenderDevice/Shader/param/shader_param_in.cpp b/src/RenderDevice/Shader/param/shader_param_in.cpp index a7848149..24c316b6 100644 --- a/src/RenderDevice/Shader/param/shader_param_in.cpp +++ b/src/RenderDevice/Shader/param/shader_param_in.cpp @@ -1,7 +1,7 @@ #include #include -BEGIN_SHADER_PARAM_NAMESPACE +SHADER_PARAM_NAMESPACE_BEGIN bool InputParam::Join(node::Node *n,param::OutputParam *op) { if(!n||!op)return(false); @@ -17,4 +17,4 @@ bool InputParam::Join(node::Node *n,param::OutputParam *op) return(true); } -END_SHADER_PARAM_NAMESPACE +SHADER_PARAM_NAMESPACE_END diff --git a/src/RenderDevice/Shader/param/shader_param_type.cpp b/src/RenderDevice/Shader/param/shader_param_type.cpp index 28f04a32..0fea5d2c 100644 --- a/src/RenderDevice/Shader/param/shader_param_type.cpp +++ b/src/RenderDevice/Shader/param/shader_param_type.cpp @@ -1,6 +1,6 @@ #include -BEGIN_SHADER_PARAM_NAMESPACE +SHADER_PARAM_NAMESPACE_BEGIN const char *GetTypename(const ParamType pt) { constexpr char *name[]= @@ -83,4 +83,4 @@ const char *GetTypename(const ParamType pt) return name[size_t(pt)-size_t(ParamType::BEGIN_RANGE)]; } -END_SHADER_PARAM_NAMESPACE \ No newline at end of file +SHADER_PARAM_NAMESPACE_END \ No newline at end of file diff --git a/src/SceneGraph/material/Material.cpp b/src/SceneGraph/material/Material.cpp index 9f113f88..fc7b540a 100644 --- a/src/SceneGraph/material/Material.cpp +++ b/src/SceneGraph/material/Material.cpp @@ -3,7 +3,7 @@ #include #include -BEGIN_MATERIAL_NAMESPACE +MATERIAL_NAMESPACE_BEGIN //bool LoadMaterialFile(MaterialData &md,const OSString &filename)//,Texture **tex_list) //{ // io::FileInputStream fis; @@ -61,4 +61,4 @@ BEGIN_MATERIAL_NAMESPACE // return(true); //} -END_MATERIAL_NAMESPACE +MATERIAL_NAMESPACE_END diff --git a/src/SceneGraph/material/MaterialComponent.cpp b/src/SceneGraph/material/MaterialComponent.cpp index 2b845f8e..5d75b2ca 100644 --- a/src/SceneGraph/material/MaterialComponent.cpp +++ b/src/SceneGraph/material/MaterialComponent.cpp @@ -1,6 +1,6 @@ #include -BEGIN_MATERIAL_NAMESPACE +MATERIAL_NAMESPACE_BEGIN namespace { constexpr ComponentConfig material_component_config_list[]= @@ -39,4 +39,4 @@ BEGIN_MATERIAL_NAMESPACE return material_component_config_list+(uint)c; } -END_MATERIAL_NAMESPACE +MATERIAL_NAMESPACE_END