清除旧的Shader处理代码
This commit is contained in:
parent
9c5f60f513
commit
3440db869a
@ -1 +1 @@
|
||||
Subproject commit 35058b7f881c2a2ad00bf21c083aa88a70277864
|
||||
Subproject commit 47599c77c46034c1cd78dbb93ba5f5495c27b185
|
@ -1 +0,0 @@
|
||||
Subproject commit fd5aa3ad51ece55a1b51fe6bfb271db6844ae291
|
@ -1 +1 @@
|
||||
Subproject commit 16397c1849c2b180bc7fe1e5ef103ba03a8990d5
|
||||
Subproject commit ab0dcdc3216115d039c51cc5b02ca23cd3db3fba
|
@ -1 +1 @@
|
||||
Subproject commit 2cf939e8c37494922ca2991902a0fe50baa2eaea
|
||||
Subproject commit 9be589598595963f94ba264d7b416d0533421106
|
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
PROJECT(ULRE)
|
||||
|
||||
@ -33,10 +33,6 @@ SET(ULRE CMCore
|
||||
ULRE.RenderDevice.Vulkan
|
||||
ULRE.SceneGraph
|
||||
MathGeoLib
|
||||
spirv-cross-core
|
||||
SPIRV
|
||||
glslang
|
||||
OGLCompiler
|
||||
${JSONCPP_LIBRARY}
|
||||
${RENDER_LIBRARY}
|
||||
${Vulkan_LIBRARIES})
|
||||
@ -46,22 +42,6 @@ include_directories(${ULRE_3RDPTY_ROOT_PATH}/NvTriStrip)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc)
|
||||
|
||||
SET(ROOT_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/inc)
|
||||
SET(SPIRV_CROSS_PATH ${ULRE_3RDPTY_ROOT_PATH}/SPIRV-Cross)
|
||||
|
||||
include_directories(${SPIRV_CROSS_PATH})
|
||||
add_subdirectory(${SPIRV_CROSS_PATH})
|
||||
|
||||
macro(glslang_pch SRCS PCHCPP)
|
||||
message("use null [glslang_pch] macro")
|
||||
endmacro()
|
||||
|
||||
include_directories(${SPIRV_CROSS_PATH}/external/glslang/glslang/Public)
|
||||
add_subdirectory(${SPIRV_CROSS_PATH}/external/glslang/glslang)
|
||||
|
||||
include_directories(${SPIRV_CROSS_PATH}/external/glslang)
|
||||
add_subdirectory(${SPIRV_CROSS_PATH}/external/glslang/SPIRV)
|
||||
|
||||
add_subdirectory(${SPIRV_CROSS_PATH}/external/glslang/OGLCompilersDLL)
|
||||
|
||||
SET(ULRE_RUNTIME_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
|
@ -1,16 +0,0 @@
|
||||
#ifndef HGL_GRAPH_COMBO_MATERIAL_INCLUDE
|
||||
#define HGL_GRAPH_COMBO_MATERIAL_INCLUDE
|
||||
|
||||
#include<hgl/graph/material/Material.h>
|
||||
|
||||
MATERIAL_NAMESPACE_BEGIN
|
||||
/**
|
||||
* 简易组合材质<br>
|
||||
* 提供最简单的材质定义方案
|
||||
*/
|
||||
class ComboMaterial
|
||||
{
|
||||
|
||||
};//class ComboMaterial
|
||||
MATERIAL_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_COMBO_MATERIAL_INCLUDE
|
@ -1,115 +0,0 @@
|
||||
#ifndef HGL_GRAPH_MATERIAL_COMPONENT_INCLUDE
|
||||
#define HGL_GRAPH_MATERIAL_COMPONENT_INCLUDE
|
||||
|
||||
#include<hgl/type/DataType.h>
|
||||
|
||||
#define MATERIAL_NAMESPACE_BEGIN namespace hgl{namespace graph{namespace material{
|
||||
#define MATERIAL_NAMESPACE_END }}}
|
||||
|
||||
#define MATERIAL_NAMESPACE hgl::graph::material
|
||||
#define MATERIAL_NAMESPACE_USING using namespace MATERIAL_NAMESPACE;
|
||||
|
||||
MATERIAL_NAMESPACE_BEGIN
|
||||
enum class Component
|
||||
{
|
||||
ShadingModel=0,
|
||||
|
||||
BaseColor,
|
||||
Mask,
|
||||
Opacity,
|
||||
Normal,
|
||||
|
||||
Metallic,
|
||||
Roughness,
|
||||
|
||||
Emissive,
|
||||
Refraction,
|
||||
|
||||
AO,
|
||||
SSS,
|
||||
Height,
|
||||
|
||||
RIM,
|
||||
ClearCoat,
|
||||
Anisotropy,
|
||||
|
||||
BEGIN_RANGE =ShadingModel,
|
||||
END_RANGE =Anisotropy,
|
||||
RANGE_SIZE =END_RANGE-BEGIN_RANGE+1,
|
||||
};//enum class Component
|
||||
|
||||
enum class ComponentBit
|
||||
{
|
||||
#define MC_BIT_DEFINE(name) name=1<<(uint)Component::name
|
||||
MC_BIT_DEFINE(ShadingModel ),
|
||||
|
||||
MC_BIT_DEFINE(BaseColor ),
|
||||
MC_BIT_DEFINE(Mask ),
|
||||
MC_BIT_DEFINE(Opacity ),
|
||||
MC_BIT_DEFINE(Normal ),
|
||||
|
||||
MC_BIT_DEFINE(Metallic ),
|
||||
MC_BIT_DEFINE(Roughness ),
|
||||
|
||||
MC_BIT_DEFINE(Emissive ),
|
||||
MC_BIT_DEFINE(Refraction ),
|
||||
|
||||
MC_BIT_DEFINE(AO ),
|
||||
MC_BIT_DEFINE(SSS ),
|
||||
MC_BIT_DEFINE(Height ),
|
||||
|
||||
MC_BIT_DEFINE(RIM ),
|
||||
MC_BIT_DEFINE(ClearCoat ),
|
||||
MC_BIT_DEFINE(Anisotropy ),
|
||||
#undef MC_BIT_DEFINE
|
||||
};//enum class ComponentBit
|
||||
|
||||
enum class ComponentDataType
|
||||
{
|
||||
Bool=0,
|
||||
Float,
|
||||
Double,
|
||||
Int,
|
||||
Uint,
|
||||
};//enum class ComponentDataType
|
||||
|
||||
enum class DataFormat
|
||||
{
|
||||
NONE=0,
|
||||
|
||||
#define MATERIAL_DATA_FORMAT_DEFINE(short_name,type) type =((uint(ComponentDataType::type)<<4)|1), \
|
||||
Vector##2##short_name =((uint(ComponentDataType::type)<<4)|2), \
|
||||
Vector##3##short_name =((uint(ComponentDataType::type)<<4)|3), \
|
||||
Vector##4##short_name =((uint(ComponentDataType::type)<<4)|4)
|
||||
|
||||
MATERIAL_DATA_FORMAT_DEFINE(b,Bool ),
|
||||
MATERIAL_DATA_FORMAT_DEFINE(f,Float ),
|
||||
MATERIAL_DATA_FORMAT_DEFINE(d,Double),
|
||||
MATERIAL_DATA_FORMAT_DEFINE(i,Int ),
|
||||
MATERIAL_DATA_FORMAT_DEFINE(u,Uint ),
|
||||
|
||||
#undef MATERIAL_DATA_FORMAT_DEFINE
|
||||
};//enum class DataFormat
|
||||
|
||||
inline const ComponentDataType GetFormatBaseType (const DataFormat &df){return ComponentDataType(uint(df)>>4);}
|
||||
inline const uint GetFormatChannels (const DataFormat &df){return uint(df)&7;}
|
||||
|
||||
using ComponentBitsConfig=uint32;
|
||||
|
||||
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::BaseColor)|uint32(ComponentBit::Normal);
|
||||
constexpr ComponentBitsConfig MCC_CNMR =uint32(ComponentBit::BaseColor)|uint32(ComponentBit::Normal)|uint32(ComponentBit::Metallic)|uint32(ComponentBit::Roughness);
|
||||
|
||||
struct ComponentConfig
|
||||
{
|
||||
Component comp; ///<成份ID
|
||||
ComponentDataType type; ///<数据类型
|
||||
uint channels; ///<通道数
|
||||
bool LinearColorspace; ///<是要求线性颜色空间
|
||||
};//struct ComponentConfig
|
||||
|
||||
const ComponentConfig *GetConfig(const Component c);
|
||||
MATERIAL_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_MATERIAL_COMPONENT_INCLUDE
|
@ -1,126 +0,0 @@
|
||||
#ifndef HGL_GRAPH_MATERIAL_DATA_SOURCE_INCLUDE
|
||||
#define HGL_GRAPH_MATERIAL_DATA_SOURCE_INCLUDE
|
||||
|
||||
#include<hgl/graph/material/Material.h>
|
||||
#include<hgl/type/BaseString.h>
|
||||
|
||||
MATERIAL_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* 数据源
|
||||
*/
|
||||
class DataSource
|
||||
{
|
||||
DataFormat format;
|
||||
|
||||
public:
|
||||
|
||||
const ComponentDataType GetDataType()const{return GetFormatBaseType(format);} ///<获取数据基本类型
|
||||
const uint GetChannels()const{return GetFormatChannels(format);} ///<获取数据通道数量
|
||||
|
||||
public:
|
||||
|
||||
DataSource() {format=DataFormat::NONE;}
|
||||
DataSource(const DataFormat &df){format=df;}
|
||||
virtual ~DataSource()=default;
|
||||
|
||||
public:
|
||||
|
||||
virtual bool GenDefine(UTF8String &){return false;} ///<产生define代码
|
||||
};//class DataSource
|
||||
|
||||
/**
|
||||
* 固定值数据源
|
||||
*/
|
||||
class DataSourceConst:public DataSource
|
||||
{
|
||||
public:
|
||||
|
||||
using DataSource::DataSource;
|
||||
|
||||
virtual bool GenDefine(UTF8String &)=0; ///<产生define代码
|
||||
};//class DataSourceConst:public DataSource
|
||||
|
||||
/**
|
||||
* Uniform 数据源
|
||||
*/
|
||||
class DataSourceUniform:public DataSource
|
||||
{
|
||||
public:
|
||||
|
||||
using DataSource::DataSource;
|
||||
};//class DataSourceUniform:public DataSource
|
||||
|
||||
/**
|
||||
* 函数数据源
|
||||
*/
|
||||
class DataSourceFunction:public DataSource
|
||||
{
|
||||
public:
|
||||
|
||||
using DataSource::DataSource;
|
||||
};//class DataSourceFunction:public DataSource
|
||||
|
||||
/**
|
||||
* 顶点数据源
|
||||
*/
|
||||
class DataSourceVertex:public DataSource
|
||||
{
|
||||
public:
|
||||
|
||||
using DataSource::DataSource;
|
||||
};//class DataSourceVertex:public DataSource
|
||||
|
||||
/**
|
||||
* 纹理数据源
|
||||
*/
|
||||
class DataSourceTexture:public DataSource
|
||||
{
|
||||
public:
|
||||
|
||||
using DataSource::DataSource;
|
||||
};//class DataSourceTexture:public DataSource
|
||||
|
||||
class DataSourceTexture1D:public DataSourceTexture
|
||||
{
|
||||
public:
|
||||
|
||||
using DataSourceTexture::DataSourceTexture;
|
||||
};//class DataSourceTexture1D:public DataSourceTexture
|
||||
|
||||
class DataSourceTexture1DArrays:public DataSourceTexture
|
||||
{
|
||||
public:
|
||||
|
||||
using DataSourceTexture::DataSourceTexture;
|
||||
};//class DataSourceTexture1DArrays:public DataSourceTexture
|
||||
|
||||
class DataSourceTexture2D:public DataSourceTexture
|
||||
{
|
||||
public:
|
||||
|
||||
using DataSourceTexture::DataSourceTexture;
|
||||
};//class DataSourceTexture2D:public DataSourceTexture
|
||||
|
||||
class DataSourceTexture2DArrays:public DataSourceTexture
|
||||
{
|
||||
public:
|
||||
|
||||
using DataSourceTexture::DataSourceTexture;
|
||||
};//class DataSourceTexture2DArrays:public DataSourceTexture
|
||||
|
||||
class DataSourceTextureCubemap:public DataSourceTexture
|
||||
{
|
||||
public:
|
||||
|
||||
using DataSourceTexture::DataSourceTexture;
|
||||
};//class DataSourceTextureCubemap:public DataSourceTexture
|
||||
|
||||
class DataSourceTextureCubemapArrays:public DataSourceTexture
|
||||
{
|
||||
public:
|
||||
|
||||
using DataSourceTexture::DataSourceTexture;
|
||||
};//class DataSourceTextureCubemapArrays:public DataSourceTexture
|
||||
MATERIAL_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_MATERIAL_DATA_SOURCE_INCLUDE
|
@ -1,79 +0,0 @@
|
||||
#ifndef HGL_GRAPH_SHADER_MAKER_INCLUDE
|
||||
#define HGL_GRAPH_SHADER_MAKER_INCLUDE
|
||||
|
||||
#include<hgl/graph/shader/node/finished.h>
|
||||
#include<hgl/graph/shader/node/vertex_input.h>
|
||||
#include<hgl/type/StringList.h>
|
||||
SHADER_NAMESPACE_BEGIN
|
||||
|
||||
using NodeList=List<node::Node *>;
|
||||
|
||||
enum class API
|
||||
{
|
||||
OpenGLCore,
|
||||
OpenGLES,
|
||||
Vulkan
|
||||
};
|
||||
|
||||
/**
|
||||
* 缺省绑定号
|
||||
*/
|
||||
enum class ShaderDefaultBinding
|
||||
{
|
||||
WorldMatrix=0,
|
||||
};
|
||||
|
||||
class ShaderMaker
|
||||
{
|
||||
protected:
|
||||
|
||||
API api;
|
||||
uint api_version;
|
||||
|
||||
UTF8StringList shader_source;
|
||||
|
||||
protected:
|
||||
|
||||
node::VertexInput *vi_node;
|
||||
node::Finished *fin_node;
|
||||
|
||||
List<node::Node *> node_stack;
|
||||
|
||||
protected:
|
||||
|
||||
NodeList node_list[(size_t)node::NodeType::NODE_TYPE_RANGE_SIZE];
|
||||
|
||||
uint in_location=0;
|
||||
uint out_location=0;
|
||||
uint binding=0;
|
||||
|
||||
protected:
|
||||
|
||||
virtual bool MakeHeader();
|
||||
virtual bool MakeVertexInput();
|
||||
virtual void MakeConstValue(const NodeList &);
|
||||
virtual void MakeScalarValue(const NodeList &);
|
||||
virtual void MakeTextureInput(const NodeList &);
|
||||
virtual void MakeUBOInput(const NodeList &);
|
||||
virtual void MakeOutput();
|
||||
virtual void MakeFinished();
|
||||
|
||||
public:
|
||||
|
||||
ShaderMaker(const API &a,const uint av,node::Finished *fn,node::VertexInput *vi=nullptr)
|
||||
{
|
||||
api=a;
|
||||
api_version=av;
|
||||
|
||||
fin_node=fn;
|
||||
vi_node=vi;
|
||||
}
|
||||
virtual ~ShaderMaker()=default;
|
||||
|
||||
virtual bool Check();
|
||||
virtual bool Make();
|
||||
|
||||
virtual bool SaveToFile(const OSString &);
|
||||
};//class ShaderMaker
|
||||
SHADER_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_SHADER_MAKER_INCLUDE
|
@ -1,27 +0,0 @@
|
||||
#ifndef HGL_GRAPH_SHADER_COMMON_INCLUDE
|
||||
#define HGL_GRAPH_SHADER_COMMON_INCLUDE
|
||||
|
||||
#define SHADER_NAMESPACE hgl::graph::shader
|
||||
#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 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 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;
|
||||
|
||||
SHADER_NODE_NAMESPACE_BEGIN
|
||||
class Node;
|
||||
SHADER_NODE_NAMESPACE_END
|
||||
|
||||
SHADER_PARAM_NAMESPACE_BEGIN
|
||||
class Param;
|
||||
SHADER_PARAM_NAMESPACE_END
|
||||
|
||||
#endif//HGL_GRAPH_SHADER_COMMON_INCLUDE
|
@ -1,17 +0,0 @@
|
||||
#ifndef HGL_GRAPH_GLSL2SPV_INCLUDE
|
||||
#define HGL_GRAPH_GLSL2SPV_INCLUDE
|
||||
|
||||
#include<vulkan/vulkan.h>
|
||||
#include<vector>
|
||||
#include<hgl/type/BaseString.h>
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
void InitDefaultShaderBuildResource(); ///<初始化glsl2spv数值限定
|
||||
|
||||
bool GLSL2SPV(const VkShaderStageFlagBits shader_type,const char *shader_source,std::vector<uint32> &spirv,UTF8String &log,UTF8String &debug_log);
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
#endif//HGL_GRAPH_GLSL2SPV_INCLUDE
|
@ -1,114 +0,0 @@
|
||||
#ifndef HGL_GRAPH_SHADER_NODE_COMBO_VECTOR_INCLUDE
|
||||
#define HGL_GRAPH_SHADER_NODE_COMBO_VECTOR_INCLUDE
|
||||
|
||||
#include<hgl/graph/shader/node/node.h>
|
||||
SHADER_NODE_NAMESPACE_BEGIN
|
||||
class ComboVector1to2:public Node
|
||||
{
|
||||
param::InputParam *ip_x,*ip_y;
|
||||
param::OutputParam *op_xy;
|
||||
|
||||
public:
|
||||
|
||||
ComboVector1to2():Node(NodeType::ComboVector,"ComboVector1to2")
|
||||
{
|
||||
ip_x=SHADER_INPUT_PARAM(false,X,Float1)
|
||||
ip_y=SHADER_INPUT_PARAM(false,Y,Float1)
|
||||
|
||||
op_xy=SHADER_OUTPUT_PARAM(XY,Float2)
|
||||
}
|
||||
|
||||
bool GenOutputParamCode(UTF8StringList &)override;
|
||||
//bool GenCode(UTF8StringList &) override;
|
||||
};//class ComboVector1to2:public Node
|
||||
|
||||
class ComboVector1to3:public Node
|
||||
{
|
||||
param::InputParam *ip_x,*ip_y,*ip_z;
|
||||
param::OutputParam *op_xyz;
|
||||
|
||||
public:
|
||||
|
||||
ComboVector1to3():Node(NodeType::ComboVector,"ComboVector1to3")
|
||||
{
|
||||
ip_x=SHADER_INPUT_PARAM(false,X,Float1)
|
||||
ip_y=SHADER_INPUT_PARAM(false,Y,Float1)
|
||||
ip_z=SHADER_INPUT_PARAM(false,Z,Float1)
|
||||
|
||||
op_xyz=SHADER_OUTPUT_PARAM(XYZ,Float3)
|
||||
}
|
||||
|
||||
bool GenOutputParamCode(UTF8StringList &)override;
|
||||
};//class ComboVector1to3:public Node
|
||||
|
||||
class ComboVector1to4:public Node
|
||||
{
|
||||
param::InputParam *ip_x,*ip_y,*ip_z,*ip_w;
|
||||
|
||||
public:
|
||||
|
||||
ComboVector1to4():Node(NodeType::ComboVector,"ComboVector1to4")
|
||||
{
|
||||
ip_x=SHADER_INPUT_PARAM(false,X,Float1)
|
||||
ip_y=SHADER_INPUT_PARAM(false,Y,Float1)
|
||||
ip_z=SHADER_INPUT_PARAM(false,Z,Float1)
|
||||
ip_w=SHADER_INPUT_PARAM(false,W,Float1)
|
||||
|
||||
SHADER_OUTPUT_PARAM(XYZW,Float4)
|
||||
}
|
||||
|
||||
bool GenCode(UTF8StringList &) override;
|
||||
};//class ComboVector1to4:public Node
|
||||
|
||||
class ComboVector12to3:public Node
|
||||
{
|
||||
param::InputParam *ip_xy,*ip_z;
|
||||
|
||||
public:
|
||||
|
||||
ComboVector12to3():Node(NodeType::ComboVector,"ComboVector12to3")
|
||||
{
|
||||
ip_xy=SHADER_INPUT_PARAM(false,XY,Float2)
|
||||
ip_z =SHADER_INPUT_PARAM(false,Z,Float1)
|
||||
|
||||
SHADER_OUTPUT_PARAM(XYZ,Float3)
|
||||
}
|
||||
|
||||
bool GenCode(UTF8StringList &) override;
|
||||
};//class ComboVector2to3:public Node
|
||||
|
||||
class ComboVector13to4:public Node
|
||||
{
|
||||
param::InputParam *ip_xyz,*ip_w;
|
||||
|
||||
public:
|
||||
|
||||
ComboVector13to4():Node(NodeType::ComboVector,"ComboVector13to4")
|
||||
{
|
||||
ip_xyz=SHADER_INPUT_PARAM(false,XYZ,Float3)
|
||||
ip_w =SHADER_INPUT_PARAM(false,W,Float1)
|
||||
|
||||
SHADER_OUTPUT_PARAM(XYZW,Float4)
|
||||
}
|
||||
|
||||
bool GenCode(UTF8StringList &) override;
|
||||
};//class ComboVector13to4:public Node
|
||||
|
||||
class ComboVector22to4:public Node
|
||||
{
|
||||
param::InputParam *ip_xy,*ip_zw;
|
||||
|
||||
public:
|
||||
|
||||
ComboVector22to4():Node(NodeType::ComboVector,"ComboVector22to4")
|
||||
{
|
||||
ip_xy=SHADER_INPUT_PARAM(false,XY,Float2)
|
||||
ip_zw=SHADER_INPUT_PARAM(false,ZW,Float2)
|
||||
|
||||
SHADER_OUTPUT_PARAM(XYZW,Float4)
|
||||
}
|
||||
|
||||
bool GenCode(UTF8StringList &) override;
|
||||
};//class ComboVector22to4:public Node
|
||||
SHADER_NODE_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_SHADER_NODE_COMBO_VECTOR_INCLUDE
|
@ -1,14 +0,0 @@
|
||||
#ifndef HGL_GRAPH_SHADER_NODE_DEFINE_INCLUDE
|
||||
#define HGL_GRAPH_SHADER_NODE_DEFINE_INCLUDE
|
||||
|
||||
#include<hgl/graph/shader/common.h>
|
||||
|
||||
SHADER_NODE_NAMESPACE_BEGIN
|
||||
class Bool
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
};//class Bool
|
||||
SHADER_NODE_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_SHADER_NODE_DEFINE_INCLUDE
|
@ -1,63 +0,0 @@
|
||||
#ifndef HGL_GRAPH_SHADER_NODE_FINISHED_INCLUDE
|
||||
#define HGL_GRAPH_SHADER_NODE_FINISHED_INCLUDE
|
||||
|
||||
#include<hgl/graph/shader/node/node.h>
|
||||
#include<hgl/graph/shader/param/in.h>
|
||||
|
||||
SHADER_NODE_NAMESPACE_BEGIN
|
||||
/**
|
||||
* 最终节点,用于最终结果的一类节点,无输出部分
|
||||
*/
|
||||
class Finished:public Node
|
||||
{
|
||||
public:
|
||||
|
||||
Finished(const UTF8String &n):Node(NodeType::Finished,n){}
|
||||
virtual ~Finished()=default;
|
||||
};//class Finished:public Input
|
||||
|
||||
/**
|
||||
* 顶点最终输出节点
|
||||
*/
|
||||
class VertexFinished:public Finished
|
||||
{
|
||||
protected:
|
||||
|
||||
param::InputParam *ip_Position;
|
||||
|
||||
public:
|
||||
|
||||
VertexFinished():Finished("FinVertex")
|
||||
{
|
||||
ip_Position=SHADER_INPUT_PARAM(true,Position, Float3)
|
||||
|
||||
SHADER_OUTPUT_PARAM(FragmentPosition,Float3)
|
||||
SHADER_OUTPUT_PARAM(FragmentTexCoord,Float2)
|
||||
}
|
||||
|
||||
~VertexFinished()=default;
|
||||
|
||||
bool GenCode(UTF8StringList &)override;
|
||||
};//class VertexFinished:public FinishedNode
|
||||
|
||||
/**
|
||||
* 片段最终输出节点
|
||||
*/
|
||||
class FragmentFinished:public Finished
|
||||
{
|
||||
public:
|
||||
|
||||
FragmentFinished():Finished("FinFragment")
|
||||
{
|
||||
SHADER_INPUT_PARAM(false,BaseColor, Float3)
|
||||
SHADER_INPUT_PARAM(false,Normal, Float3)
|
||||
SHADER_INPUT_PARAM(false,Metallic, Float1)
|
||||
SHADER_INPUT_PARAM(false,Roughness, Float1)
|
||||
SHADER_INPUT_PARAM(false,Opacity, Float1)
|
||||
SHADER_INPUT_PARAM(false,DepthOffset, Float1)
|
||||
}
|
||||
|
||||
~FragmentFinished()=default;
|
||||
};//class FragmentFinished:public Finished
|
||||
SHADER_NODE_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_SHADER_NODE_FINISHED_INCLUDE
|
@ -1,103 +0,0 @@
|
||||
#ifndef HGL_GRAPH_SHADER_NODE_INCLUDE
|
||||
#define HGL_GRAPH_SHADER_NODE_INCLUDE
|
||||
|
||||
#include<hgl/type/StringList.h>
|
||||
#include<hgl/type/List.h>
|
||||
#include<hgl/type/Map.h>
|
||||
#include<hgl/graph/shader/node/type.h>
|
||||
#include<hgl/graph/shader/param/in.h>
|
||||
#include<hgl/graph/shader/param/out.h>
|
||||
|
||||
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);
|
||||
|
||||
using InputParamList=ObjectList<param::InputParam>;
|
||||
using OutputParamList=ObjectList<param::OutputParam>;
|
||||
using InputParamMapByName=Map<UTF8String,param::InputParam *>;
|
||||
using OutputParamMapByName=Map<UTF8String,param::OutputParam *>;
|
||||
|
||||
/**
|
||||
* Shader 节点是所有Shader的基础,它可以是一个数据转接(纹理或流),也可以是一个纯粹的计算公式
|
||||
*/
|
||||
class Node
|
||||
{
|
||||
NodeType node_type;
|
||||
|
||||
protected:
|
||||
|
||||
UTF8String node_name; ///<节点用户自定义名称
|
||||
|
||||
InputParamList input_params;
|
||||
OutputParamList output_params;
|
||||
|
||||
InputParamMapByName input_params_by_name;
|
||||
OutputParamMapByName output_params_by_name;
|
||||
|
||||
protected:
|
||||
|
||||
virtual bool GenInputParamCode(UTF8StringList &);
|
||||
virtual bool GenOutputParamCode(UTF8StringList &){return true;}
|
||||
|
||||
protected:
|
||||
|
||||
param::InputParam * AddInput (bool mj,const UTF8String &n,const param::ParamType &pt);
|
||||
param::OutputParam *AddOutput (const UTF8String &n,const param::ParamType &pt);
|
||||
|
||||
public:
|
||||
|
||||
param::InputParam * GetInput (const UTF8String &n) ///<根据名称获取输入参数
|
||||
{return GetListObject(input_params_by_name,n);}
|
||||
|
||||
param::OutputParam *GetOutput (const UTF8String &n) ///<根据名称获取输出参数
|
||||
{return GetListObject(output_params_by_name,n);}
|
||||
|
||||
public:
|
||||
|
||||
Node(const NodeType &nt,const UTF8String &n){node_type=nt;node_name=n;}
|
||||
virtual ~Node()=default;
|
||||
|
||||
const NodeType GetNodeType ()const{return node_type;}
|
||||
|
||||
const UTF8String & GetNodeName ()const{return node_name;}
|
||||
void SetNodeName (const UTF8String &n){node_name=n;}
|
||||
|
||||
public: //参数相关
|
||||
|
||||
InputParamList & GetInputParamList (){return input_params;}
|
||||
OutputParamList & GetOutputParamList (){return output_params;}
|
||||
|
||||
virtual bool JoinInput (const UTF8String &,node::Node *,param::OutputParam *);
|
||||
|
||||
virtual bool JoinInput (const UTF8String &,node::Node *); ///<连接一个输入节点(限输入节点只有一个输出参数)
|
||||
|
||||
public: //参数相关
|
||||
|
||||
virtual bool IsOutput(const param::OutputParam *) const;
|
||||
|
||||
virtual bool Check(); ///<检测当前节点是否可用
|
||||
|
||||
virtual bool GetInputParamName(UTF8String &result,const param::InputParam *);
|
||||
virtual bool GetOutputParamName(UTF8String &result,const param::OutputParam *);
|
||||
|
||||
public: //产生代码相关
|
||||
|
||||
virtual bool GenTempValueDefine(UTF8StringList &); ///<产生临时变量定义
|
||||
virtual bool GenCode(UTF8StringList &);
|
||||
};//class Node
|
||||
|
||||
/**
|
||||
* GLSL原生变量
|
||||
*/
|
||||
template<typename T> class NativeValue:public Node
|
||||
{
|
||||
public:
|
||||
|
||||
NativeValue(const NodeType &nt,const UTF8String &n):Node(nt,n){}
|
||||
virtual ~NativeValue()=default;
|
||||
|
||||
|
||||
};//template<typename T> class NativeValue:public Node
|
||||
SHADER_NODE_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_SHADER_NODE_INCLUDE
|
@ -1,68 +0,0 @@
|
||||
#ifndef HGL_GRAPH_SHADER_NODE_OP_INCLUDE
|
||||
#define HGL_GRAPH_SHADER_NODE_OP_INCLUDE
|
||||
|
||||
#include<hgl/graph/shader/node/node.h>
|
||||
SHADER_NODE_NAMESPACE_BEGIN
|
||||
enum class ScalarOpType:uint
|
||||
{
|
||||
Add=0, Sub, Mul, Div,
|
||||
Mod, Pow, Min, Max,
|
||||
Sin, Cos, Atan, Step,
|
||||
|
||||
BEGIN_OP_RANGE=Add,
|
||||
END_OP_RANGE=Step,
|
||||
RANGE_SIZE=(END_OP_RANGE-BEGIN_OP_RANGE)+1
|
||||
};//enum class OpType:uint
|
||||
|
||||
class ScalarOp:public Node
|
||||
{
|
||||
public:
|
||||
};//class ScalarOp:public Node
|
||||
|
||||
class ComboVectorOp1to2:public Node
|
||||
{
|
||||
public:
|
||||
|
||||
ComboVectorOp1to2():Node(NodeType::ComboVector)
|
||||
{
|
||||
SHADER_INPUT_PARAM(false,X,Float1)
|
||||
SHADER_INPUT_PARAM(false,Y,Float1)
|
||||
|
||||
SHADER_OUTPUT_PARAM(XY,Float2)
|
||||
}
|
||||
};//class ComboVectorOp1to2:public Node
|
||||
|
||||
enum class VectorOpType:uint
|
||||
{
|
||||
Add=0, Sub, Mul, Div,
|
||||
Mod, Pow, Min, Max,
|
||||
Cross, Atan, Reflect,Step,
|
||||
|
||||
BEGIN_OP_RANGE=Add,
|
||||
END_OP_RANGE=Step,
|
||||
RANGE_SIZE=(END_OP_RANGE-BEGIN_OP_RANGE)+1
|
||||
};//enum class VectorOpType:uint
|
||||
|
||||
class VectorOp:public Node
|
||||
{
|
||||
public:
|
||||
};//class VectorOp:public Node
|
||||
|
||||
enum class ColorOpType:uint
|
||||
{
|
||||
Screen=0,
|
||||
Difference,
|
||||
Darken,
|
||||
Lighten,
|
||||
Overlay,
|
||||
Dodge,
|
||||
Burn,
|
||||
SoftLight,
|
||||
HardLight,
|
||||
|
||||
BEGIN_OP_RANGE=Screen,
|
||||
END_OP_RANGE=HardLight,
|
||||
RANGE_SIZE=(END_OP_RANGE-BEGIN_OP_RANGE)+1
|
||||
};//enum class ColorOpType:uint
|
||||
SHADER_NODE_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_SHADER_NODE_OP_INCLUDE
|
@ -1,87 +0,0 @@
|
||||
#ifndef HGL_GRAPH_SHADER_NODE_SPLIT_VECTOR_INCLUDE
|
||||
#define HGL_GRAPH_SHADER_NODE_SPLIT_VECTOR_INCLUDE
|
||||
|
||||
#include<hgl/graph/shader/node/node.h>
|
||||
SHADER_NODE_NAMESPACE_BEGIN
|
||||
class SplitVector2to1:public Node
|
||||
{
|
||||
public:
|
||||
|
||||
SplitVector2to1():Node(NodeType::SplitVector)
|
||||
{
|
||||
SHADER_OUTPUT_PARAM(X,Float1)
|
||||
SHADER_OUTPUT_PARAM(Y,Float1)
|
||||
|
||||
SHADER_INPUT_PARAM(true,XY,Float2)
|
||||
}
|
||||
};//class SplitVector2to1:public Node
|
||||
|
||||
class SplitVector3to1:public Node
|
||||
{
|
||||
public:
|
||||
|
||||
SplitVector3to1():Node(NodeType::SplitVector)
|
||||
{
|
||||
SHADER_OUTPUT_PARAM(X,Float1)
|
||||
SHADER_OUTPUT_PARAM(Y,Float1)
|
||||
SHADER_OUTPUT_PARAM(Z,Float1)
|
||||
|
||||
SHADER_INPUT_PARAM(true,XYZ,Float3)
|
||||
}
|
||||
};//class SplitVector3to1:public Node
|
||||
|
||||
class SplitVector4to1:public Node
|
||||
{
|
||||
public:
|
||||
|
||||
SplitVector4to1():Node(NodeType::SplitVector)
|
||||
{
|
||||
SHADER_OUTPUT_PARAM(X,Float1)
|
||||
SHADER_OUTPUT_PARAM(Y,Float1)
|
||||
SHADER_OUTPUT_PARAM(Z,Float1)
|
||||
SHADER_OUTPUT_PARAM(W,Float1)
|
||||
|
||||
SHADER_INPUT_PARAM(true,XYZW,Float4)
|
||||
}
|
||||
};//class SplitVector4to1:public Node
|
||||
|
||||
class SplitVector3to12:public Node
|
||||
{
|
||||
public:
|
||||
|
||||
SplitVector3to12():Node(NodeType::SplitVector)
|
||||
{
|
||||
SHADER_OUTPUT_PARAM(XY,Float2)
|
||||
SHADER_OUTPUT_PARAM(Z,Float1)
|
||||
|
||||
SHADER_INPUT_PARAM(true,XYZ,Float3)
|
||||
}
|
||||
};//class SplitVector2to3:public Node
|
||||
|
||||
class SplitVector4to13:public Node
|
||||
{
|
||||
public:
|
||||
|
||||
SplitVector4to13():Node(NodeType::SplitVector)
|
||||
{
|
||||
SHADER_OUTPUT_PARAM(XYZ,Float3)
|
||||
SHADER_OUTPUT_PARAM(W,Float1)
|
||||
|
||||
SHADER_INPUT_PARAM(true,XYZW,Float4)
|
||||
}
|
||||
};//class SplitVector4to13:public Node
|
||||
|
||||
class SplitVector4to22:public Node
|
||||
{
|
||||
public:
|
||||
|
||||
SplitVector4to22():Node(NodeType::SplitVector)
|
||||
{
|
||||
SHADER_OUTPUT_PARAM(XY,Float2)
|
||||
SHADER_OUTPUT_PARAM(ZW,Float2)
|
||||
|
||||
SHADER_INPUT_PARAM(true,XYZW,Float4)
|
||||
}
|
||||
};//class SplitVector4to22:public Node
|
||||
SHADER_NODE_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_SHADER_NODE_SPLIT_VECTOR_INCLUDE
|
@ -1,71 +0,0 @@
|
||||
#ifndef HGL_GRAPH_SHADER_NODE_TEXTURE_INCLUDE
|
||||
#define HGL_GRAPH_SHADER_NODE_TEXTURE_INCLUDE
|
||||
|
||||
#include<hgl/graph/shader/node/vector.h>
|
||||
#include<hgl/graph/shader/node/node.h>
|
||||
SHADER_NODE_NAMESPACE_BEGIN
|
||||
class texture:public Node
|
||||
{
|
||||
param::ParamType texture_type;
|
||||
|
||||
public:
|
||||
|
||||
texture(const param::ParamType &pt,const UTF8String &n):Node(NodeType::Texture,n)
|
||||
{
|
||||
texture_type=pt;
|
||||
}
|
||||
|
||||
const param::ParamType &GetTextureType()const{return texture_type;}
|
||||
};//class texture:public Node
|
||||
|
||||
class texture1D:public texture
|
||||
{
|
||||
public:
|
||||
|
||||
texture1D():texture(param::ParamType::Texture1D,"texture1d")
|
||||
{
|
||||
SHADER_INPUT_PARAM(false,U,Float1)
|
||||
}
|
||||
};//class texture1D:public texture
|
||||
|
||||
class texture2D:public texture
|
||||
{
|
||||
public:
|
||||
|
||||
texture2D():texture(param::ParamType::Texture2D,"texture2d")
|
||||
{
|
||||
SHADER_INPUT_PARAM(false,UV,Float2)
|
||||
}
|
||||
};//class texture2D:public texture
|
||||
|
||||
class textureRect:public texture
|
||||
{
|
||||
public:
|
||||
|
||||
textureRect():texture(param::ParamType::TextureRect,"textureRect")
|
||||
{
|
||||
SHADER_INPUT_PARAM(false,UV,UInteger2)
|
||||
}
|
||||
};//class textureRect:public texture
|
||||
|
||||
class texture3D:public texture
|
||||
{
|
||||
public:
|
||||
|
||||
texture3D():texture(param::ParamType::Texture3D,"texture3d")
|
||||
{
|
||||
SHADER_INPUT_PARAM(false,UVD,Float3)
|
||||
}
|
||||
};//class texture3D:public texture
|
||||
|
||||
class textureCube:public texture
|
||||
{
|
||||
public:
|
||||
|
||||
textureCube():texture(param::ParamType::TextureCube,"textureCube")
|
||||
{
|
||||
SHADER_INPUT_PARAM(false,XYZ,Float3)
|
||||
}
|
||||
};//class TextureCube:public texture
|
||||
SHADER_NODE_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_SHADER_NODE_TEXTURE_INCLUDE
|
@ -1,30 +0,0 @@
|
||||
#ifndef HGL_GRAPH_SHADER_NODE_TYPE_INCLUDE
|
||||
#define HGL_GRAPH_SHADER_NODE_TYPE_INCLUDE
|
||||
|
||||
#include<hgl/graph/shader/common.h>
|
||||
|
||||
SHADER_NODE_NAMESPACE_BEGIN
|
||||
enum class NodeType:int
|
||||
{
|
||||
VertexInput=0, ///<顶点输入流节点
|
||||
|
||||
ComboVector, ///<向量合成
|
||||
SplitVector, ///<向量折解
|
||||
|
||||
ShaderFunction, ///<shader原生函数
|
||||
|
||||
Const, ///<固定数据输入
|
||||
Param, ///<参数输入
|
||||
|
||||
Texture,
|
||||
UBO,
|
||||
Function,
|
||||
|
||||
Finished, ///<最终节点
|
||||
|
||||
BEGIN_NODE_TYPE_RANGE =VertexInput,
|
||||
END_NODE_TYPE_RANGE =Finished,
|
||||
NODE_TYPE_RANGE_SIZE =(END_NODE_TYPE_RANGE-BEGIN_NODE_TYPE_RANGE)+1
|
||||
};//enum class NodeType
|
||||
SHADER_NODE_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_SHADER_NODE_TYPE_INCLUDE
|
@ -1,65 +0,0 @@
|
||||
#ifndef HGL_GRAPH_SHADER_NODE_VECTOR_INCLUDE
|
||||
#define HGL_GRAPH_SHADER_NODE_VECTOR_INCLUDE
|
||||
|
||||
#include<hgl/graph/shader/param/out.h>
|
||||
#include<hgl/graph/shader/node/node.h>
|
||||
|
||||
SHADER_NODE_NAMESPACE_BEGIN
|
||||
class Parameter:public Node
|
||||
{
|
||||
param::ParamType param_type;
|
||||
|
||||
public:
|
||||
|
||||
Parameter(const param::ParamType &pt,const UTF8String &n):Node(NodeType::Param,n)
|
||||
{
|
||||
param_type=pt;
|
||||
}
|
||||
|
||||
const param::ParamType &GetParamType()const{return param_type;}
|
||||
};//class Parameter:public Node
|
||||
|
||||
#define SHADER_PARAMETER_CONSTRUCT_FUNC(name,value) name():Parameter(param::ParamType::name,#name) \
|
||||
{ \
|
||||
SHADER_OUTPUT_PARAM(value,name) \
|
||||
}
|
||||
|
||||
class Float1:public Parameter
|
||||
{
|
||||
float x;
|
||||
|
||||
public:
|
||||
|
||||
SHADER_PARAMETER_CONSTRUCT_FUNC(Float1,Value)
|
||||
};//class float1:public Parameter
|
||||
|
||||
class Float2:public Parameter
|
||||
{
|
||||
float x,y;
|
||||
|
||||
public:
|
||||
|
||||
SHADER_PARAMETER_CONSTRUCT_FUNC(Float2,XY)
|
||||
};//class float2:public Parameter
|
||||
|
||||
class Float3:public Parameter
|
||||
{
|
||||
float x,y,z;
|
||||
|
||||
public:
|
||||
|
||||
SHADER_PARAMETER_CONSTRUCT_FUNC(Float3,XYZ)
|
||||
};//class Float3:public Parameter
|
||||
|
||||
class Float4:public Parameter
|
||||
{
|
||||
float x,y,z,w;
|
||||
|
||||
public:
|
||||
|
||||
SHADER_PARAMETER_CONSTRUCT_FUNC(Float4,XYZW)
|
||||
};//class Float4:public Parameter
|
||||
|
||||
#undef SHADER_PARAMETER_CONSTRUCT_FUNC
|
||||
SHADER_NODE_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_SHADER_NODE_VECTOR_INCLUDE
|
@ -1,31 +0,0 @@
|
||||
#ifndef HGL_GRAPH_SHADER_NODE_VERTEX_INPUT_INCLUDE
|
||||
#define HGL_GRAPH_SHADER_NODE_VERTEX_INPUT_INCLUDE
|
||||
|
||||
#include<hgl/graph/shader/node/node.h>
|
||||
SHADER_NODE_NAMESPACE_BEGIN
|
||||
/**
|
||||
* 顶点输入流节点
|
||||
*/
|
||||
class VertexInput:public Node
|
||||
{
|
||||
public:
|
||||
|
||||
VertexInput():Node(NodeType::VertexInput,"VertexInput")
|
||||
{
|
||||
}
|
||||
|
||||
param::OutputParam *Add(const UTF8String &n,const param::ParamType &pt)
|
||||
{
|
||||
//未来还要做个数判断之类的
|
||||
|
||||
if(pt<param::ParamType::Float1
|
||||
||pt>param::ParamType::Double4)
|
||||
return(nullptr);
|
||||
|
||||
return AddOutput(n,pt);
|
||||
}
|
||||
|
||||
bool GetOutputParamName(UTF8String &,const param::OutputParam *) override;
|
||||
};//class VertexInput:public Node
|
||||
SHADER_NODE_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_SHADER_NODE_VERTEX_INPUT_INCLUDE
|
@ -1,59 +0,0 @@
|
||||
#ifndef HGL_GRAPH_SHADER_PARAM_INPUT_INCLUDE
|
||||
#define HGL_GRAPH_SHADER_PARAM_INPUT_INCLUDE
|
||||
|
||||
#include<hgl/graph/shader/common.h>
|
||||
#include<hgl/graph/shader/param/out.h>
|
||||
#include<hgl/graph/shader/param/param.h>
|
||||
|
||||
SHADER_PARAM_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* 输入参数定义
|
||||
*/
|
||||
class InputParam:public Param
|
||||
{
|
||||
bool must_join; //是否必须有接入
|
||||
|
||||
protected:
|
||||
|
||||
node::Node *join_node;
|
||||
param::OutputParam *join_param;
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* 可否接入判断,默认只判断类型
|
||||
*/
|
||||
virtual bool JoinCheck(node::Node *n,param::OutputParam *op)
|
||||
{
|
||||
return(op->GetType()==this->GetType());
|
||||
}
|
||||
|
||||
public: //属性
|
||||
|
||||
node::Node * GetJoinNode (){return join_node;} ///<取得接入节点
|
||||
param::OutputParam *GetJoinParam(){return join_param;} ///<取得接入节点参数
|
||||
|
||||
virtual const UTF8String GetDefaultValue()const{return "?";} ///<取得缺省值
|
||||
|
||||
public:
|
||||
|
||||
InputParam(const bool mj,const UTF8String &n,const ParamType &t):Param(n,t)
|
||||
{
|
||||
must_join=mj;
|
||||
join_node=nullptr;
|
||||
join_param=nullptr;
|
||||
}
|
||||
virtual ~InputParam()=default;
|
||||
|
||||
virtual bool Join(node::Node *,param::OutputParam *); ///<增加一个关联节点
|
||||
virtual void Break(){join_node=nullptr;join_param=nullptr;} ///<断开一个关联节点
|
||||
|
||||
virtual bool Check() ///<检测当前节点是否可用
|
||||
{
|
||||
if(must_join&&!join_param)return(false);
|
||||
return true;
|
||||
}
|
||||
};//class InputParam:public Param
|
||||
SHADER_PARAM_NAMESPACE_END
|
||||
#endif//#ifndef HGL_GRAPH_SHADER_PARAM_INPUT_INCLUDE
|
@ -1,22 +0,0 @@
|
||||
#ifndef HGL_GRAPH_SHADER_PARAM_OUTPUT_INCLUDE
|
||||
#define HGL_GRAPH_SHADER_PARAM_OUTPUT_INCLUDE
|
||||
|
||||
#include<hgl/graph/shader/param/param.h>
|
||||
|
||||
SHADER_PARAM_NAMESPACE_BEGIN
|
||||
|
||||
using namespace hgl;
|
||||
|
||||
/**
|
||||
* 输出参数定义
|
||||
*/
|
||||
class OutputParam:public Param
|
||||
{
|
||||
public:
|
||||
|
||||
using Param::Param;
|
||||
virtual ~OutputParam()=default;
|
||||
};//class OutputParam:public Param
|
||||
|
||||
SHADER_PARAM_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_SHADER_PARAM_OUTPUT_INCLUDE
|
@ -1,31 +0,0 @@
|
||||
#ifndef HGL_GRAPH_SHADER_PARAM_INCLUDE
|
||||
#define HGL_GRAPH_SHADER_PARAM_INCLUDE
|
||||
|
||||
#include<hgl/type/BaseString.h>
|
||||
#include<hgl/graph/shader/common.h>
|
||||
#include<hgl/graph/shader/param/type.h>
|
||||
|
||||
SHADER_PARAM_NAMESPACE_BEGIN
|
||||
/**
|
||||
* 参数定义
|
||||
*/
|
||||
class Param
|
||||
{
|
||||
UTF8String name; //参数名称
|
||||
ParamType type; //类型
|
||||
|
||||
public:
|
||||
|
||||
Param(const UTF8String &n,const ParamType &t)
|
||||
{
|
||||
name=n;
|
||||
type=t;
|
||||
}
|
||||
|
||||
virtual ~Param()=default;
|
||||
|
||||
const UTF8String & GetName()const{return name;}
|
||||
const ParamType GetType()const{return type;}
|
||||
};//class Param
|
||||
SHADER_PARAM_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_SHADER_PARAM_INCLUDE
|
@ -1,88 +0,0 @@
|
||||
#ifndef HGL_GRAPH_SHADER_PARAM_TYPE_INCLUDE
|
||||
#define HGL_GRAPH_SHADER_PARAM_TYPE_INCLUDE
|
||||
|
||||
#include<hgl/graph/shader/common.h>
|
||||
#include<hgl/type/BaseString.h>
|
||||
|
||||
SHADER_PARAM_NAMESPACE_BEGIN
|
||||
/**
|
||||
* 参数类型
|
||||
*/
|
||||
enum class ParamType
|
||||
{
|
||||
BOOL=0,
|
||||
FLOAT,DOUBLE,INT,UINT,MATRIX, //不区分1/2/3/4通道数量的类型
|
||||
|
||||
Bool1,
|
||||
Bool2,
|
||||
Bool3,
|
||||
Bool4,
|
||||
|
||||
Float1,
|
||||
Float2,
|
||||
Float3,
|
||||
Float4,
|
||||
|
||||
Integer1,
|
||||
Integer2,
|
||||
Integer3,
|
||||
Integer4,
|
||||
|
||||
UInteger1,
|
||||
UInteger2,
|
||||
UInteger3,
|
||||
UInteger4,
|
||||
|
||||
Double1,
|
||||
Double2,
|
||||
Double3,
|
||||
Double4,
|
||||
|
||||
Matrix2,
|
||||
Matrix3,
|
||||
Matrix4,
|
||||
Matrix3x2,
|
||||
Matrix2x3,
|
||||
Matrix4x2,
|
||||
Matrix2x4,
|
||||
Matrix4x3,
|
||||
Matrix3x4,
|
||||
|
||||
Texture1D,
|
||||
Texture2D,
|
||||
Texture3D,
|
||||
TextureCube,
|
||||
TextureRect,
|
||||
|
||||
Texture1DArray,
|
||||
Texture2DArray,
|
||||
TextureCubeArray,
|
||||
|
||||
Texture1DShadow,
|
||||
Texture2DShadow,
|
||||
TextureCubeShadow,
|
||||
TextureRectShadow,
|
||||
|
||||
Texture1DArrayShadow,
|
||||
Texture2DArrayShadow,
|
||||
TextureCubeArrayShadow,
|
||||
|
||||
Texture2DMultiSample,
|
||||
Texture2DMultiSampleArray,
|
||||
|
||||
TBO,
|
||||
|
||||
ARRAY_1D, //阵列
|
||||
ARRAY_2D, //2D阵列
|
||||
|
||||
UBO, //UBO name
|
||||
NODE, //另一个节点,只可做为输入参数
|
||||
|
||||
BEGIN_RANGE =BOOL,
|
||||
END_RANGE =NODE,
|
||||
RANGE_SIZE =(END_RANGE-BEGIN_RANGE+1)
|
||||
};//enum class ParamType
|
||||
|
||||
const char *GetTypename(const ParamType);
|
||||
SHADER_PARAM_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_SHADER_PARAM_TYPE_INCLUDE
|
@ -1,40 +0,0 @@
|
||||
SET(GRAPH_SHADER_HEADER_PATH ${ROOT_INCLUDE_PATH}/hgl/graph/shader)
|
||||
SET(GRAPH_SHADER_NODE_HEADER_PATH ${GRAPH_SHADER_HEADER_PATH}/node)
|
||||
SET(GRAPH_SHADER_PARAM_HEADER_PATH ${GRAPH_SHADER_HEADER_PATH}/param)
|
||||
|
||||
file(GLOB GRAPH_SHADER_NODE_HEADER_FILES ${GRAPH_SHADER_NODE_HEADER_PATH}/*.h)
|
||||
file(GLOB GRAPH_SHADER_PARAM_HEADER_FILES ${GRAPH_SHADER_PARAM_HEADER_PATH}/*.h)
|
||||
|
||||
file(GLOB GRAPH_SHADER_NODE_SOURCE_FILES FILES node/*.*)
|
||||
file(GLOB GRAPH_SHADER_PARAM_SOURCE_FILES FILES param/*.*)
|
||||
|
||||
file(GLOB GRAPH_SHADER_NODE_FIN_SOURCE_FILES FILES node/fin/*.*)
|
||||
|
||||
SET(GRAPH_SHADER_NODE_FILES ${GRAPH_SHADER_NODE_HEADER_FILES} ${GRAPH_SHADER_NODE_SOURCE_FILES})
|
||||
SET(GRAPH_SHADER_PARAM_FILES ${GRAPH_SHADER_PARAM_HEADER_FILES} ${GRAPH_SHADER_PARAM_SOURCE_FILES})
|
||||
|
||||
source_group("Shader Maker\\Node\\Fin" FILES ${GRAPH_SHADER_NODE_FIN_SOURCE_FILES})
|
||||
source_group("Shader Maker\\Node" FILES ${GRAPH_SHADER_NODE_FILES})
|
||||
source_group("Shader Maker\\Param" FILES ${GRAPH_SHADER_PARAM_FILES})
|
||||
|
||||
SET(GRAPH_SHADER_MAKER_SOURCE ${GRAPH_SHADER_HEADER_PATH}/ShaderMaker.h
|
||||
ShaderMaker.cpp
|
||||
DefaultShader.cpp)
|
||||
|
||||
source_group("Shader Maker" FILES ${GRAPH_SHADER_MAKER_SOURCE})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SET(GRAPH_SPV_SOURCE ${GRAPH_SHADER_HEADER_PATH}/glsl2spv.h
|
||||
glsl2spv.cpp)
|
||||
|
||||
SOURCE_GROUP("SPIR-V" FILES ${GRAPH_SPV_SOURCE})
|
||||
|
||||
add_cm_library(ULRE.Shader "ULRE" ${GRAPH_SHADER_HEADER_PATH}/common.h
|
||||
${GRAPH_SHADER_NODE_FILES}
|
||||
${GRAPH_SHADER_NODE_FIN_SOURCE_FILES}
|
||||
${GRAPH_SHADER_PARAM_FILES}
|
||||
${GRAPH_SHADER_MAKER_SOURCE}
|
||||
${GRAPH_SPV_SOURCE})
|
@ -1,109 +0,0 @@
|
||||
#include<hgl/graph/shader/ShaderMaker.h>
|
||||
#include<hgl/graph/shader/param/in.h>
|
||||
#include<hgl/graph/shader/param/out.h>
|
||||
#include<hgl/graph/shader/node/finished.h>
|
||||
#include<hgl/graph/shader/node/vertex_input.h>
|
||||
#include<hgl/graph/shader/node/vector.h>
|
||||
#include<hgl/graph/shader/node/combo_vector.h>
|
||||
#include<hgl/assets/AssetsSource.h>
|
||||
|
||||
SHADER_NAMESPACE_BEGIN
|
||||
namespace
|
||||
{
|
||||
namespace InlineShader
|
||||
{
|
||||
UTF8String Header;
|
||||
UTF8String UBOWorldMatrix;
|
||||
UTF8String PushConstant;
|
||||
|
||||
UTF8String VSOutputLayout;
|
||||
|
||||
bool Load()
|
||||
{
|
||||
assets::AssetsSource *as=assets::GetSource("shader");
|
||||
|
||||
if(!as)
|
||||
return(false);
|
||||
|
||||
#ifndef USE_MOBILE_SHADER
|
||||
Header =UTF8String(as->Open("header_desktop.glsl"));
|
||||
#else
|
||||
Header =UTF8String(as->Open("header_mobile.glsl"));
|
||||
#endif//
|
||||
|
||||
UBOWorldMatrix =UTF8String(as->Open("UBO_WorldMatrix.glsl"));
|
||||
PushConstant =UTF8String(as->Open("push_constant_3d.glsl"));
|
||||
VSOutputLayout =UTF8String(as->Open("vertex_shader_output_layout.glsl"));
|
||||
|
||||
return(true);
|
||||
}
|
||||
}//namespace InlineShader
|
||||
|
||||
constexpr enum class API DEFAULT_RENDER_API =API::Vulkan;
|
||||
constexpr uint DEFAULT_RENDER_API_VERSION =450;
|
||||
|
||||
#define SHADER_VERTEX_INPUT_STREAM_POSITION_NAME "Position" //<顶点数据输入流,输出参数名称
|
||||
#define SHADER_VERTEX_POSITION_INPUT_PARAM_NAME "Position" //<顶点shader最终节点,输入参数名称
|
||||
|
||||
//**********************************************************************注:它们两个名字一样只是碰巧****************
|
||||
|
||||
bool CreateDefaultVertexShader()
|
||||
{
|
||||
node::VertexFinished vs_fin_node; //创建一个vs最终节点
|
||||
|
||||
node::VertexInput vi; //创建一个顶点输入节点
|
||||
|
||||
param::OutputParam *op=vi.Add( SHADER_VERTEX_INPUT_STREAM_POSITION_NAME, //该节点输出参数名称
|
||||
param::ParamType::Float3); //该节点数据类型
|
||||
|
||||
node::Float1 x,y,z;
|
||||
|
||||
node::ComboVector1to3 cv1to3;
|
||||
|
||||
cv1to3.JoinInput("X",&x);
|
||||
cv1to3.JoinInput("Y",&y);
|
||||
cv1to3.JoinInput("Z",&z);
|
||||
//对接顶点输入节点到VS最终节点
|
||||
vs_fin_node.JoinInput( SHADER_VERTEX_POSITION_INPUT_PARAM_NAME, //最终节点中这个输入参数的名称
|
||||
&cv1to3);
|
||||
// &vi,op); //要接入的节点以及它的输出参数
|
||||
|
||||
ShaderMaker vs_maker( DEFAULT_RENDER_API,
|
||||
DEFAULT_RENDER_API_VERSION,
|
||||
&vs_fin_node,
|
||||
&vi);
|
||||
|
||||
if(!vs_maker.Make())
|
||||
return(false);
|
||||
|
||||
vs_maker.SaveToFile(OS_TEXT("default.vert"));
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool CreateDefaultFragmentVertex()
|
||||
{
|
||||
node::FragmentFinished fs_fin_node;
|
||||
|
||||
ShaderMaker fs_maker( DEFAULT_RENDER_API,
|
||||
DEFAULT_RENDER_API_VERSION,
|
||||
&fs_fin_node);
|
||||
|
||||
if(!fs_maker.Make())
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
}//namespace
|
||||
|
||||
bool CreateDefaultMaterial()
|
||||
{
|
||||
if(!InlineShader::Load())
|
||||
return(false);
|
||||
|
||||
if(!CreateDefaultVertexShader())return(false);
|
||||
if(!CreateDefaultFragmentVertex())return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
SHADER_NAMESPACE_END
|
@ -1,289 +0,0 @@
|
||||
#include<hgl/graph/shader/ShaderMaker.h>
|
||||
#include<hgl/graph/shader/param/in.h>
|
||||
#include<hgl/graph/shader/node/texture.h>
|
||||
#include<hgl/type/Set.h>
|
||||
#include<hgl/log/LogInfo.h>
|
||||
|
||||
#include<hgl/io/FileOutputStream.h>
|
||||
#include<hgl/io/DataOutputStream.h>
|
||||
#include<hgl/io/TextOutputStream.h>
|
||||
|
||||
/*
|
||||
设计概念:
|
||||
|
||||
节点分类:
|
||||
const 直接写在代码中的数值
|
||||
scalr 由UBO传入的数据
|
||||
Texture 纹理
|
||||
|
||||
|
||||
*/
|
||||
|
||||
SHADER_NAMESPACE_BEGIN
|
||||
namespace
|
||||
{
|
||||
|
||||
|
||||
}//namespace
|
||||
|
||||
bool ShaderMaker::Check()
|
||||
{
|
||||
if(!fin_node)
|
||||
return(false);
|
||||
|
||||
Set<node::Node *> post; //完成检测的节点合集
|
||||
Set<node::Node *> prev; //等待检测的节点合集
|
||||
node::Node *cur,*nn;
|
||||
|
||||
node::NodeType type;
|
||||
node::InputParamList *ipl;
|
||||
int i,count;
|
||||
param::InputParam **ip;
|
||||
|
||||
prev.Add(fin_node);
|
||||
|
||||
while(prev.GetEnd(cur))
|
||||
{
|
||||
type=cur->GetNodeType();
|
||||
|
||||
if(type<node::NodeType::BEGIN_NODE_TYPE_RANGE
|
||||
||type>node::NodeType::END_NODE_TYPE_RANGE)
|
||||
{
|
||||
LOG_ERROR(U8_TEXT("node type error!"));
|
||||
return(false);
|
||||
}
|
||||
|
||||
ipl =&(cur->GetInputParamList());
|
||||
count =ipl->GetCount();
|
||||
ip =ipl->GetData();
|
||||
|
||||
for(i=0;i<count;i++)
|
||||
{
|
||||
if(!(*ip)->Check())
|
||||
return(false);
|
||||
|
||||
nn=(*ip)->GetJoinNode();
|
||||
|
||||
if(nn)
|
||||
{
|
||||
if(!post.IsMember(nn)
|
||||
&&!prev.IsMember(nn)
|
||||
&&nn!=cur)
|
||||
{
|
||||
prev.Add(nn);
|
||||
}
|
||||
}
|
||||
|
||||
ip++;
|
||||
}
|
||||
|
||||
node_list[int(type)-int(node::NodeType::BEGIN_NODE_TYPE_RANGE)].Add(cur);
|
||||
prev.Delete(cur);
|
||||
post.Add(cur);
|
||||
node_stack.Add(cur);
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool ShaderMaker::MakeHeader()
|
||||
{
|
||||
if(api==API::Vulkan||api==API::OpenGLCore) shader_source.Add("#version "+UTF8String(api_version)+" core"); else
|
||||
if(api==API::OpenGLES) shader_source.Add("#version "+UTF8String(api_version)+" es"); else
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
|
||||
shader_source.Add("layout(push_constant) uniform PushConstant");
|
||||
shader_source.Add("{");
|
||||
shader_source.Add(" mat4 local_to_world;");
|
||||
shader_source.Add("}pc;");
|
||||
|
||||
shader_source.Add("");
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool ShaderMaker::MakeVertexInput()
|
||||
{
|
||||
if(!vi_node)return(true);
|
||||
|
||||
const node::OutputParamList &op_list=vi_node->GetOutputParamList();
|
||||
|
||||
const uint count=op_list.GetCount();
|
||||
|
||||
if(count<=0)return(false);
|
||||
|
||||
param::OutputParam **op=op_list.GetData();
|
||||
param::ParamType pt;
|
||||
|
||||
for(uint i=0;i<count;i++)
|
||||
{
|
||||
pt=(*op)->GetType();
|
||||
|
||||
shader_source.Add("layout(location="+UTF8String(in_location)+") in "+GetTypename(pt)+" "+(*op)->GetName()+";");
|
||||
|
||||
++op;
|
||||
++in_location;
|
||||
}
|
||||
|
||||
shader_source.Add("");
|
||||
return(true);
|
||||
}
|
||||
|
||||
void ShaderMaker::MakeConstValue(const NodeList &nl)
|
||||
{
|
||||
}
|
||||
|
||||
void ShaderMaker::MakeTextureInput(const NodeList &nl)
|
||||
{
|
||||
const uint count=nl.GetCount();
|
||||
|
||||
if(count<=0)return;
|
||||
|
||||
node::texture **tex_node=(node::texture **)nl.GetData();
|
||||
param::ParamType tt;
|
||||
|
||||
for(uint i=0;i<count;i++)
|
||||
{
|
||||
tt=(*tex_node)->GetTextureType();
|
||||
|
||||
shader_source.Add("layout(binding="+UTF8String(binding)+") uniform "+GetTypename(tt)+" "+(*tex_node)->GetNodeName()+";");
|
||||
|
||||
++tex_node;
|
||||
++binding;
|
||||
}
|
||||
|
||||
shader_source.Add("");
|
||||
}
|
||||
|
||||
void ShaderMaker::MakeScalarValue(const NodeList &nl)
|
||||
{
|
||||
const uint count=nl.GetCount();
|
||||
|
||||
if(count<=0)return;
|
||||
|
||||
shader_source.Add("layout(binding="+UTF8String(binding)+") uniform UserInput");
|
||||
shader_source.Add("{");
|
||||
|
||||
node::texture **tex_node=(node::texture **)nl.GetData();
|
||||
param::ParamType tt;
|
||||
|
||||
for(uint i=0;i<count;i++)
|
||||
{
|
||||
tt=(*tex_node)->GetTextureType();
|
||||
|
||||
shader_source.Add("layout(binding="+UTF8String(binding)+") uniform "+GetTypename(tt)+" "+(*tex_node)->GetNodeName()+";");
|
||||
|
||||
++tex_node;
|
||||
++binding;
|
||||
}
|
||||
shader_source.Add("}");
|
||||
}
|
||||
|
||||
void ShaderMaker::MakeUBOInput(const NodeList &nl)
|
||||
{
|
||||
}
|
||||
|
||||
void ShaderMaker::MakeOutput()
|
||||
{
|
||||
node::OutputParamList &opl=fin_node->GetOutputParamList();
|
||||
|
||||
const uint count=opl.GetCount();
|
||||
|
||||
if(count<=0)return;
|
||||
|
||||
param::OutputParam **op=opl.GetData();
|
||||
param::ParamType pt;
|
||||
|
||||
for(uint i=0;i<count;i++)
|
||||
{
|
||||
pt=(*op)->GetType();
|
||||
|
||||
shader_source.Add("layout(location="+UTF8String(out_location)+") out "+GetTypename(pt)+" "+(*op)->GetName()+";");
|
||||
|
||||
++op;
|
||||
++out_location;
|
||||
}
|
||||
|
||||
shader_source.Add("");
|
||||
}
|
||||
|
||||
void ShaderMaker::MakeFinished()
|
||||
{
|
||||
shader_source.Add("void main()");
|
||||
shader_source.Add("{");
|
||||
{
|
||||
const uint count=node_stack.GetCount();
|
||||
node::Node **cur=node_stack.GetEnd();
|
||||
|
||||
for(uint i=0;i<count;i++)
|
||||
{
|
||||
(*cur)->GenTempValueDefine(shader_source); //临时变量定义
|
||||
|
||||
--cur;
|
||||
}
|
||||
|
||||
shader_source.Add("");
|
||||
|
||||
cur=node_stack.GetEnd();
|
||||
|
||||
for(uint i=0;i<count;i++)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
shader_source.Add("//[begin] auto code of "+(*cur)->GetNodeName());
|
||||
#endif//_DEBUG
|
||||
|
||||
(*cur)->GenCode(shader_source); //产生代码
|
||||
|
||||
#ifdef _DEBUG
|
||||
shader_source.Add("//[end] auto code of "+(*cur)->GetNodeName());
|
||||
shader_source.Add("");
|
||||
#endif//_DEBUG
|
||||
|
||||
--cur;
|
||||
}
|
||||
}
|
||||
shader_source.Add("}");
|
||||
}
|
||||
|
||||
bool ShaderMaker::Make()
|
||||
{
|
||||
shader_source.Clear();
|
||||
node_stack.ClearData();
|
||||
in_location=0;
|
||||
out_location=0;
|
||||
binding=0;
|
||||
|
||||
if(!Check())
|
||||
return(false);
|
||||
|
||||
if(!MakeHeader())return(false);
|
||||
|
||||
MakeConstValue (node_list[uint(node::NodeType::Const )-uint(node::NodeType::BEGIN_NODE_TYPE_RANGE)]);
|
||||
MakeScalarValue (node_list[uint(node::NodeType::Param )-uint(node::NodeType::BEGIN_NODE_TYPE_RANGE)]);
|
||||
MakeTextureInput(node_list[uint(node::NodeType::Texture )-uint(node::NodeType::BEGIN_NODE_TYPE_RANGE)]);
|
||||
MakeUBOInput (node_list[uint(node::NodeType::UBO )-uint(node::NodeType::BEGIN_NODE_TYPE_RANGE)]);
|
||||
|
||||
if(!MakeVertexInput())return(false);
|
||||
|
||||
MakeOutput ();
|
||||
MakeFinished ();
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool ShaderMaker::SaveToFile(const OSString &filename)
|
||||
{
|
||||
io::FileOutputStream fos;
|
||||
|
||||
if(!fos.CreateTrunc(filename))
|
||||
return(false);
|
||||
|
||||
io::TextOutputStream *tos=io::CreateTextOutputStream<char>(&fos);
|
||||
|
||||
tos->WriteText(shader_source);
|
||||
|
||||
delete tos;
|
||||
return(true);
|
||||
}
|
||||
SHADER_NAMESPACE_END
|
@ -1,191 +0,0 @@
|
||||
#include<hgl/graph/shader/glsl2spv.h>
|
||||
#include<SPIRV/GlslangToSpv.h>
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
namespace
|
||||
{
|
||||
static TBuiltInResource default_build_in_resource;
|
||||
|
||||
void init_default_build_in_resource()
|
||||
{
|
||||
default_build_in_resource.maxLights = 32;
|
||||
default_build_in_resource.maxClipPlanes = 6;
|
||||
default_build_in_resource.maxTextureUnits = 32;
|
||||
default_build_in_resource.maxTextureCoords = 32;
|
||||
default_build_in_resource.maxVertexAttribs = 64;
|
||||
default_build_in_resource.maxVertexUniformComponents = 4096;
|
||||
default_build_in_resource.maxVaryingFloats = 64;
|
||||
default_build_in_resource.maxVertexTextureImageUnits = 32;
|
||||
default_build_in_resource.maxCombinedTextureImageUnits = 80;
|
||||
default_build_in_resource.maxTextureImageUnits = 32;
|
||||
default_build_in_resource.maxFragmentUniformComponents = 4096;
|
||||
default_build_in_resource.maxDrawBuffers = 32;
|
||||
default_build_in_resource.maxVertexUniformVectors = 128;
|
||||
default_build_in_resource.maxVaryingVectors = 8;
|
||||
default_build_in_resource.maxFragmentUniformVectors = 16;
|
||||
default_build_in_resource.maxVertexOutputVectors = 16;
|
||||
default_build_in_resource.maxFragmentInputVectors = 15;
|
||||
default_build_in_resource.minProgramTexelOffset = -8;
|
||||
default_build_in_resource.maxProgramTexelOffset = 7;
|
||||
default_build_in_resource.maxClipDistances = 8;
|
||||
default_build_in_resource.maxComputeWorkGroupCountX = 65535;
|
||||
default_build_in_resource.maxComputeWorkGroupCountY = 65535;
|
||||
default_build_in_resource.maxComputeWorkGroupCountZ = 65535;
|
||||
default_build_in_resource.maxComputeWorkGroupSizeX = 1024;
|
||||
default_build_in_resource.maxComputeWorkGroupSizeY = 1024;
|
||||
default_build_in_resource.maxComputeWorkGroupSizeZ = 64;
|
||||
default_build_in_resource.maxComputeUniformComponents = 1024;
|
||||
default_build_in_resource.maxComputeTextureImageUnits = 16;
|
||||
default_build_in_resource.maxComputeImageUniforms = 8;
|
||||
default_build_in_resource.maxComputeAtomicCounters = 8;
|
||||
default_build_in_resource.maxComputeAtomicCounterBuffers = 1;
|
||||
default_build_in_resource.maxVaryingComponents = 60;
|
||||
default_build_in_resource.maxVertexOutputComponents = 64;
|
||||
default_build_in_resource.maxGeometryInputComponents = 64;
|
||||
default_build_in_resource.maxGeometryOutputComponents = 128;
|
||||
default_build_in_resource.maxFragmentInputComponents = 128;
|
||||
default_build_in_resource.maxImageUnits = 8;
|
||||
default_build_in_resource.maxCombinedImageUnitsAndFragmentOutputs = 8;
|
||||
default_build_in_resource.maxCombinedShaderOutputResources = 8;
|
||||
default_build_in_resource.maxImageSamples = 0;
|
||||
default_build_in_resource.maxVertexImageUniforms = 0;
|
||||
default_build_in_resource.maxTessControlImageUniforms = 0;
|
||||
default_build_in_resource.maxTessEvaluationImageUniforms = 0;
|
||||
default_build_in_resource.maxGeometryImageUniforms = 0;
|
||||
default_build_in_resource.maxFragmentImageUniforms = 8;
|
||||
default_build_in_resource.maxCombinedImageUniforms = 8;
|
||||
default_build_in_resource.maxGeometryTextureImageUnits = 16;
|
||||
default_build_in_resource.maxGeometryOutputVertices = 256;
|
||||
default_build_in_resource.maxGeometryTotalOutputComponents = 1024;
|
||||
default_build_in_resource.maxGeometryUniformComponents = 1024;
|
||||
default_build_in_resource.maxGeometryVaryingComponents = 64;
|
||||
default_build_in_resource.maxTessControlInputComponents = 128;
|
||||
default_build_in_resource.maxTessControlOutputComponents = 128;
|
||||
default_build_in_resource.maxTessControlTextureImageUnits = 16;
|
||||
default_build_in_resource.maxTessControlUniformComponents = 1024;
|
||||
default_build_in_resource.maxTessControlTotalOutputComponents = 4096;
|
||||
default_build_in_resource.maxTessEvaluationInputComponents = 128;
|
||||
default_build_in_resource.maxTessEvaluationOutputComponents = 128;
|
||||
default_build_in_resource.maxTessEvaluationTextureImageUnits = 16;
|
||||
default_build_in_resource.maxTessEvaluationUniformComponents = 1024;
|
||||
default_build_in_resource.maxTessPatchComponents = 120;
|
||||
default_build_in_resource.maxPatchVertices = 32;
|
||||
default_build_in_resource.maxTessGenLevel = 64;
|
||||
default_build_in_resource.maxViewports = 16;
|
||||
default_build_in_resource.maxVertexAtomicCounters = 0;
|
||||
default_build_in_resource.maxTessControlAtomicCounters = 0;
|
||||
default_build_in_resource.maxTessEvaluationAtomicCounters = 0;
|
||||
default_build_in_resource.maxGeometryAtomicCounters = 0;
|
||||
default_build_in_resource.maxFragmentAtomicCounters = 8;
|
||||
default_build_in_resource.maxCombinedAtomicCounters = 8;
|
||||
default_build_in_resource.maxAtomicCounterBindings = 1;
|
||||
default_build_in_resource.maxVertexAtomicCounterBuffers = 0;
|
||||
default_build_in_resource.maxTessControlAtomicCounterBuffers = 0;
|
||||
default_build_in_resource.maxTessEvaluationAtomicCounterBuffers = 0;
|
||||
default_build_in_resource.maxGeometryAtomicCounterBuffers = 0;
|
||||
default_build_in_resource.maxFragmentAtomicCounterBuffers = 1;
|
||||
default_build_in_resource.maxCombinedAtomicCounterBuffers = 1;
|
||||
default_build_in_resource.maxAtomicCounterBufferSize = 16384;
|
||||
default_build_in_resource.maxTransformFeedbackBuffers = 4;
|
||||
default_build_in_resource.maxTransformFeedbackInterleavedComponents = 64;
|
||||
default_build_in_resource.maxCullDistances = 8;
|
||||
default_build_in_resource.maxCombinedClipAndCullDistances = 8;
|
||||
default_build_in_resource.maxSamples = 4;
|
||||
default_build_in_resource.maxMeshOutputVerticesNV = 256;
|
||||
default_build_in_resource.maxMeshOutputPrimitivesNV = 512;
|
||||
default_build_in_resource.maxMeshWorkGroupSizeX_NV = 32;
|
||||
default_build_in_resource.maxMeshWorkGroupSizeY_NV = 1;
|
||||
default_build_in_resource.maxMeshWorkGroupSizeZ_NV = 1;
|
||||
default_build_in_resource.maxTaskWorkGroupSizeX_NV = 32;
|
||||
default_build_in_resource.maxTaskWorkGroupSizeY_NV = 1;
|
||||
default_build_in_resource.maxTaskWorkGroupSizeZ_NV = 1;
|
||||
default_build_in_resource.maxMeshViewCountNV = 4;
|
||||
default_build_in_resource.limits.nonInductiveForLoops = 1;
|
||||
default_build_in_resource.limits.whileLoops = 1;
|
||||
default_build_in_resource.limits.doWhileLoops = 1;
|
||||
default_build_in_resource.limits.generalUniformIndexing = 1;
|
||||
default_build_in_resource.limits.generalAttributeMatrixVectorIndexing = 1;
|
||||
default_build_in_resource.limits.generalVaryingIndexing = 1;
|
||||
default_build_in_resource.limits.generalSamplerIndexing = 1;
|
||||
default_build_in_resource.limits.generalVariableIndexing = 1;
|
||||
default_build_in_resource.limits.generalConstantMatrixVectorIndexing = 1;
|
||||
}
|
||||
|
||||
EShLanguage FindLanguage(const VkShaderStageFlagBits shader_type)
|
||||
{
|
||||
switch (shader_type)
|
||||
{
|
||||
case VK_SHADER_STAGE_VERTEX_BIT:
|
||||
return EShLangVertex;
|
||||
|
||||
case VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT:
|
||||
return EShLangTessControl;
|
||||
|
||||
case VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT:
|
||||
return EShLangTessEvaluation;
|
||||
|
||||
case VK_SHADER_STAGE_GEOMETRY_BIT:
|
||||
return EShLangGeometry;
|
||||
|
||||
case VK_SHADER_STAGE_FRAGMENT_BIT:
|
||||
return EShLangFragment;
|
||||
|
||||
case VK_SHADER_STAGE_COMPUTE_BIT:
|
||||
return EShLangCompute;
|
||||
|
||||
default:
|
||||
return EShLangVertex;
|
||||
}
|
||||
}
|
||||
}//namespace
|
||||
|
||||
void InitDefaultShaderBuildResource()
|
||||
{
|
||||
init_default_build_in_resource();
|
||||
}
|
||||
|
||||
bool GLSL2SPV(const VkShaderStageFlagBits shader_type,const char *shader_source,std::vector<uint32> &spirv,UTF8String &log,UTF8String &debug_log)
|
||||
{
|
||||
EShLanguage stage = FindLanguage(shader_type);
|
||||
|
||||
glslang::TShader shader(stage);
|
||||
glslang::TProgram program;
|
||||
|
||||
const char *shaderStrings[1];
|
||||
TBuiltInResource Resources=default_build_in_resource;
|
||||
|
||||
// Enable SPIR-V and Vulkan rules when parsing GLSL
|
||||
EShMessages messages = (EShMessages)(EShMsgSpvRules | EShMsgVulkanRules);
|
||||
|
||||
shaderStrings[0] = shader_source;
|
||||
shader.setStrings(shaderStrings, 1);
|
||||
|
||||
if (!shader.parse(&Resources, 100, false, messages))
|
||||
{
|
||||
puts(shader.getInfoLog());
|
||||
puts(shader.getInfoDebugLog());
|
||||
return false; // something didn't work
|
||||
}
|
||||
|
||||
program.addShader(&shader);
|
||||
|
||||
//
|
||||
// Program-level processing...
|
||||
//
|
||||
|
||||
if (!program.link(messages))
|
||||
{
|
||||
puts(shader.getInfoLog());
|
||||
puts(shader.getInfoDebugLog());
|
||||
fflush(stdout);
|
||||
return false;
|
||||
}
|
||||
|
||||
glslang::GlslangToSpv(*program.getIntermediate(stage),spirv);
|
||||
return(true);
|
||||
}
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
@ -1,34 +0,0 @@
|
||||
#include<hgl/graph/shader/node/combo_vector.h>
|
||||
|
||||
SHADER_NODE_NAMESPACE_BEGIN
|
||||
bool ComboVector1to2::GenOutputParamCode(UTF8StringList &sl)
|
||||
{
|
||||
UTF8String name_x,name_y;
|
||||
UTF8String name_output;
|
||||
|
||||
if(!GetInputParamName(name_x,ip_x))return(false);
|
||||
if(!GetInputParamName(name_y,ip_y))return(false);
|
||||
|
||||
if(!GetOutputParamName(name_output,op_xy))return(false);
|
||||
|
||||
sl.Add(name_output+"=vec2("+name_x+","+name_y+");");
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool ComboVector1to3::GenOutputParamCode(UTF8StringList &sl)
|
||||
{
|
||||
UTF8String name_x,name_y,name_z;
|
||||
UTF8String name_output;
|
||||
|
||||
if(!GetInputParamName(name_x,ip_x))return(false);
|
||||
if(!GetInputParamName(name_y,ip_y))return(false);
|
||||
if(!GetInputParamName(name_z,ip_z))return(false);
|
||||
|
||||
if(!GetOutputParamName(name_output,op_xyz))return(false);
|
||||
|
||||
sl.Add(name_output+"=vec3("+name_x+","+name_y+","+name_z+");");
|
||||
|
||||
return(true);
|
||||
}
|
||||
SHADER_NODE_NAMESPACE_END
|
@ -1,17 +0,0 @@
|
||||
#include<hgl/graph/shader/node/finished.h>
|
||||
|
||||
SHADER_NODE_NAMESPACE_BEGIN
|
||||
bool VertexFinished::GenCode(UTF8StringList &sl)
|
||||
{
|
||||
if(!Finished::GenCode(sl))
|
||||
return(false);
|
||||
|
||||
UTF8String name;
|
||||
|
||||
if(!GetInputParamName(name,ip_Position))
|
||||
return(false);
|
||||
|
||||
sl.Add("gl_Position="+name+";");
|
||||
return(true);
|
||||
}
|
||||
SHADER_NODE_NAMESPACE_END
|
@ -1,173 +0,0 @@
|
||||
#include<hgl/graph/shader/node/node.h>
|
||||
|
||||
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);
|
||||
|
||||
input_params.Add(ip);
|
||||
|
||||
input_params_by_name.Add(n,ip);
|
||||
|
||||
return ip;
|
||||
}
|
||||
|
||||
param::OutputParam *Node::AddOutput(const UTF8String &n,const param::ParamType &pt)
|
||||
{
|
||||
param::OutputParam *op=new param::OutputParam(n,pt);
|
||||
|
||||
output_params.Add(op);
|
||||
|
||||
output_params_by_name.Add(n,op);
|
||||
|
||||
return op;
|
||||
}
|
||||
|
||||
bool Node::JoinInput(const UTF8String ¶m_name,node::Node *n,param::OutputParam *op)
|
||||
{
|
||||
if(param_name.IsEmpty()||!n||!op)
|
||||
return(false);
|
||||
|
||||
if(!n->IsOutput(op))
|
||||
return(false);
|
||||
|
||||
param::InputParam *ip=GetInput(param_name);
|
||||
|
||||
if(!ip)
|
||||
return(false);
|
||||
|
||||
return ip->Join(n,op);
|
||||
}
|
||||
|
||||
bool Node::JoinInput(const UTF8String ¶m_name,node::Node *n)
|
||||
{
|
||||
if(param_name.IsEmpty()||!n)
|
||||
return(false);
|
||||
|
||||
node::OutputParamList &opl=n->GetOutputParamList();
|
||||
|
||||
if(opl.GetCount()!=1)
|
||||
return(false);
|
||||
|
||||
param::OutputParam *op=*(opl.GetBegin());
|
||||
|
||||
param::InputParam *ip=GetInput(param_name);
|
||||
|
||||
if(!ip)
|
||||
return(false);
|
||||
|
||||
return ip->Join(n,op);
|
||||
}
|
||||
|
||||
bool Node::IsOutput(const param::OutputParam *op) const
|
||||
{
|
||||
if(!op)return(false);
|
||||
|
||||
return output_params.IsExist(op);
|
||||
}
|
||||
|
||||
bool Node::Check()
|
||||
{
|
||||
const int count=input_params.GetCount();
|
||||
param::InputParam **ip=input_params.GetData();
|
||||
|
||||
for(int i=0;i<count;i++)
|
||||
if(!(*ip)->Check())
|
||||
return(false);
|
||||
else
|
||||
++ip;
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool Node::GetInputParamName(UTF8String &result,const param::InputParam *ip)
|
||||
{
|
||||
if(!ip)return(false);
|
||||
|
||||
result=node_name+U8_TEXT("_")+ip->GetName();
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool Node::GetOutputParamName(UTF8String &result,const param::OutputParam *op)
|
||||
{
|
||||
if(!op)return(false);
|
||||
|
||||
result=node_name+U8_TEXT("_")+op->GetName();
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool Node::GenInputParamCode(UTF8StringList &sl)
|
||||
{
|
||||
const int count=input_params.GetCount();
|
||||
param::InputParam **ip=input_params.GetData();
|
||||
|
||||
UTF8String in_name,out_name;
|
||||
Node *jin;
|
||||
param::OutputParam *jop;
|
||||
|
||||
for(int i=0;i<count;i++)
|
||||
{
|
||||
if(!this->GetInputParamName(in_name,*ip))
|
||||
return(false);
|
||||
|
||||
jin=(*ip)->GetJoinNode();
|
||||
if(jin)
|
||||
{
|
||||
jop=(*ip)->GetJoinParam();
|
||||
|
||||
if(!jin->GetOutputParamName(out_name,jop))
|
||||
return(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
out_name=(*ip)->GetDefaultValue();
|
||||
}
|
||||
|
||||
sl.Add(in_name+"="+out_name+";");
|
||||
|
||||
++ip;
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
#define SHADER_NODE_TEMP_VALUE_COMMENT ";\t\t\t// temp value of ["+node_name+"]"
|
||||
|
||||
bool Node::GenTempValueDefine(UTF8StringList &sl)
|
||||
{
|
||||
const int count=input_params.GetCount();
|
||||
param::InputParam **ip=input_params.GetData();
|
||||
param::ParamType pt;
|
||||
UTF8String value_name;
|
||||
|
||||
for(int i=0;i<count;i++)
|
||||
{
|
||||
if(!GetInputParamName(value_name,*ip))
|
||||
return(false);
|
||||
|
||||
pt=(*ip)->GetType();
|
||||
|
||||
if((*ip)->GetJoinNode())
|
||||
sl.Add("\t"+UTF8String(param::GetTypename(pt))+" "+value_name+SHADER_NODE_TEMP_VALUE_COMMENT);
|
||||
else
|
||||
sl.Add("\t"+UTF8String(param::GetTypename(pt))+" "+value_name+"="+(*ip)->GetDefaultValue()+SHADER_NODE_TEMP_VALUE_COMMENT);
|
||||
|
||||
++ip;
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool Node::GenCode(UTF8StringList &sl)
|
||||
{
|
||||
if(!GenInputParamCode(sl))
|
||||
return(false);
|
||||
|
||||
if(!GenOutputParamCode(sl))
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
SHADER_NODE_NAMESPACE_END
|
@ -1,12 +0,0 @@
|
||||
#include<hgl/graph/shader/node/vertex_input.h>
|
||||
|
||||
SHADER_NODE_NAMESPACE_BEGIN
|
||||
bool VertexInput::GetOutputParamName(UTF8String &result,const param::OutputParam *op)
|
||||
{
|
||||
if(!op||!IsOutput(op))
|
||||
return(false);
|
||||
|
||||
result=op->GetName();
|
||||
return(true);
|
||||
}
|
||||
SHADER_NODE_NAMESPACE_END
|
@ -1,20 +0,0 @@
|
||||
#include<hgl/graph/shader/param/in.h>
|
||||
#include<hgl/graph/shader/node/node.h>
|
||||
|
||||
SHADER_PARAM_NAMESPACE_BEGIN
|
||||
bool InputParam::Join(node::Node *n,param::OutputParam *op)
|
||||
{
|
||||
if(!n||!op)return(false);
|
||||
|
||||
if(!n->IsOutput(op))
|
||||
return(false);
|
||||
|
||||
if(!JoinCheck(n,op))
|
||||
return(false);
|
||||
|
||||
join_node=n;
|
||||
join_param=op;
|
||||
|
||||
return(true);
|
||||
}
|
||||
SHADER_PARAM_NAMESPACE_END
|
@ -1,86 +0,0 @@
|
||||
#include<hgl/graph/shader/param/type.h>
|
||||
|
||||
SHADER_PARAM_NAMESPACE_BEGIN
|
||||
const char *GetTypename(const ParamType pt)
|
||||
{
|
||||
const char *name[]=
|
||||
{
|
||||
"?boolean?",
|
||||
"?float?",
|
||||
"?double?",
|
||||
"?int?",
|
||||
"?uint?",
|
||||
"?matrix?",
|
||||
|
||||
"boolean",
|
||||
"bvec2",
|
||||
"bvec3",
|
||||
"bvec4",
|
||||
|
||||
"float",
|
||||
"vec2",
|
||||
"vec3",
|
||||
"vec4",
|
||||
|
||||
"int",
|
||||
"ivec2",
|
||||
"ivec3",
|
||||
"ivec4",
|
||||
|
||||
"uint",
|
||||
"uvec2",
|
||||
"uvec3",
|
||||
"uvec4",
|
||||
|
||||
"double",
|
||||
"dvec2",
|
||||
"dvec3",
|
||||
"dvec4",
|
||||
|
||||
"mat2",
|
||||
"mat3",
|
||||
"mat4",
|
||||
"mat3x2",
|
||||
"mat2x3",
|
||||
"mat4x2",
|
||||
"mat2x4",
|
||||
"mat4x3",
|
||||
"mat3x4",
|
||||
|
||||
"sampler1D",
|
||||
"sampler2D",
|
||||
"sampler3D",
|
||||
"samplerCube",
|
||||
"sampler2DRect",
|
||||
|
||||
"sampler1DArray",
|
||||
"sampler2DArray",
|
||||
"samplerCubeArray",
|
||||
|
||||
"sampler1DShadow",
|
||||
"sampler2DShadow",
|
||||
"samplerCubeShadow",
|
||||
"sampler2DRectShadow",
|
||||
|
||||
"sampler1DArrayShadow",
|
||||
"sampler2DArrayShadow",
|
||||
"samplerCubeArrayShadow",
|
||||
|
||||
"sampler2DMS",
|
||||
"sampler2DMSArray",
|
||||
|
||||
"samplerBuffer",
|
||||
|
||||
"?ARRAY_1D?",
|
||||
"?ARRAY_2D?",
|
||||
|
||||
"?UBO?",
|
||||
"?NODE?"
|
||||
};
|
||||
|
||||
if(pt<ParamType::BEGIN_RANGE
|
||||
||pt>ParamType::END_RANGE)return(nullptr);
|
||||
|
||||
return name[size_t(pt)-size_t(ParamType::BEGIN_RANGE)];
|
||||
}
|
||||
SHADER_PARAM_NAMESPACE_END
|
@ -1,64 +0,0 @@
|
||||
#include<hgl/graph/material/Material.h>
|
||||
#include<hgl/io/FileInputStream.h>
|
||||
#include<hgl/io/DataInputStream.h>
|
||||
#include<hgl/log/LogInfo.h>
|
||||
|
||||
MATERIAL_NAMESPACE_BEGIN
|
||||
//bool LoadMaterialFile(MaterialData &md,const OSString &filename)//,Texture **tex_list)
|
||||
//{
|
||||
// io::FileInputStream fis;
|
||||
// io::LEDataInputStream dis(&fis);
|
||||
|
||||
// if(!fis.Open(filename))
|
||||
// RETURN_FALSE;
|
||||
|
||||
// uint8 flag[9];
|
||||
|
||||
// if(dis.ReadFully(flag,9)!=9)
|
||||
// RETURN_FALSE;
|
||||
|
||||
// if(memcmp(flag,"Material\x1A",9))
|
||||
// RETURN_FALSE;
|
||||
|
||||
// uint8 ver;
|
||||
|
||||
// if(!dis.ReadUint8(ver))RETURN_FALSE;
|
||||
|
||||
// if(ver!=1)RETURN_FALSE;
|
||||
|
||||
// if(dis.ReadFloat(md.diffuse,3)!=3)RETURN_FALSE;
|
||||
// if(dis.ReadFloat(md.specular,3)!=3)RETURN_FALSE;
|
||||
// if(dis.ReadFloat(md.ambient,3)!=3)RETURN_FALSE;
|
||||
// if(dis.ReadFloat(md.emission,3)!=3)RETURN_FALSE;
|
||||
|
||||
// if(!dis.ReadFloat(md.shininess))RETURN_FALSE;
|
||||
// if(!dis.ReadBool(md.wireframe))RETURN_FALSE;
|
||||
// if(!dis.ReadBool(md.two_sided))RETURN_FALSE;
|
||||
|
||||
// if(!dis.ReadUint8(md.tex_count))RETURN_FALSE;
|
||||
|
||||
// md.Init(md.tex_count);
|
||||
|
||||
// for(uint8 i=0;i<md.tex_count;i++)
|
||||
// {
|
||||
// MaterialTextureData *mtd=&(md.tex_list[i]);
|
||||
|
||||
// uint8 tt;
|
||||
// if(!dis.ReadUint8(tt))RETURN_FALSE;
|
||||
// mtd->type=(TextureType)tt;
|
||||
|
||||
// if(!dis.ReadInt32(mtd->tex_id))RETURN_FALSE;
|
||||
// if(!dis.ReadUint8(mtd->uvindex))RETURN_FALSE;
|
||||
// if(!dis.ReadFloat(mtd->blend))RETURN_FALSE;
|
||||
// if(!dis.ReadUint8(mtd->op))RETURN_FALSE;
|
||||
|
||||
// uint8 wm[2];
|
||||
// if(!dis.ReadUint8(wm,2))RETURN_FALSE;
|
||||
// hgl_typecpy(mtd->wrap_mode,wm,2);
|
||||
|
||||
// //mtl.SetTexture(mtd->type,tex_list[mtd->tex_id]);
|
||||
// }
|
||||
|
||||
// return(true);
|
||||
//}
|
||||
MATERIAL_NAMESPACE_END
|
@ -1,42 +0,0 @@
|
||||
#include<hgl/graph/material/Component.h>
|
||||
|
||||
MATERIAL_NAMESPACE_BEGIN
|
||||
namespace
|
||||
{
|
||||
constexpr ComponentConfig material_component_config_list[]=
|
||||
{
|
||||
#define MCC_DEFINE(name,dt,c,lc) {Component::name,ComponentDataType::dt,c,lc}
|
||||
|
||||
MCC_DEFINE(ShadingModel, Uint, 1, false ),
|
||||
|
||||
MCC_DEFINE(BaseColor, Float, 3, true ),
|
||||
|
||||
MCC_DEFINE(Opacity, Float, 1, false ),
|
||||
MCC_DEFINE(Normal, Float, 3, false ),
|
||||
|
||||
MCC_DEFINE(Metallic, Float, 1, false ),
|
||||
MCC_DEFINE(Roughness, Float, 1, false ),
|
||||
|
||||
MCC_DEFINE(Emissive, Float, 3, true ),
|
||||
MCC_DEFINE(Refraction, Float, 1, false ),
|
||||
|
||||
MCC_DEFINE(AO, Float, 1, false ),
|
||||
MCC_DEFINE(SSS, Float, 1, false ),
|
||||
MCC_DEFINE(Height, Float, 1, false ),
|
||||
|
||||
MCC_DEFINE(RIM, Float, 1, false ),
|
||||
MCC_DEFINE(ClearCoat, Float, 1, false ),
|
||||
MCC_DEFINE(Anisotropy, Float, 1, false )
|
||||
|
||||
#undef MCC_DEFINE
|
||||
};
|
||||
};//namespace
|
||||
|
||||
const ComponentConfig *GetConfig(const Component c)
|
||||
{
|
||||
if(c<=Component::BEGIN_RANGE
|
||||
||c>=Component::END_RANGE)return(nullptr);
|
||||
|
||||
return material_component_config_list+(uint)c;
|
||||
}
|
||||
MATERIAL_NAMESPACE_END
|
Loading…
x
Reference in New Issue
Block a user