to update DataSource/Component of Material

This commit is contained in:
hyzboy 2020-01-09 22:01:27 +08:00
parent ac64f28e2f
commit 2df1b26a09
2 changed files with 67 additions and 69 deletions

View File

@ -15,6 +15,7 @@ BEGIN_MATERIAL_NAMESPACE
ShadingModel=0, ShadingModel=0,
Color, Color,
Mask,
Opacity, Opacity,
Normal, Normal,
@ -35,7 +36,7 @@ BEGIN_MATERIAL_NAMESPACE
BEGIN_RANGE =ShadingModel, BEGIN_RANGE =ShadingModel,
END_RANGE =Anisotropy, END_RANGE =Anisotropy,
RANGE_SIZE =END_RANGE-BEGIN_RANGE+1, RANGE_SIZE =END_RANGE-BEGIN_RANGE+1,
};// };//enum class Component
enum class ComponentBit enum class ComponentBit
{ {
@ -43,6 +44,7 @@ BEGIN_MATERIAL_NAMESPACE
MC_BIT_DEFINE(ShadingModel ), MC_BIT_DEFINE(ShadingModel ),
MC_BIT_DEFINE(Color ), MC_BIT_DEFINE(Color ),
MC_BIT_DEFINE(Mask ),
MC_BIT_DEFINE(Opacity ), MC_BIT_DEFINE(Opacity ),
MC_BIT_DEFINE(Normal ), MC_BIT_DEFINE(Normal ),
@ -66,31 +68,37 @@ BEGIN_MATERIAL_NAMESPACE
{ {
Bool=0, Bool=0,
Float, Float,
Double,
Int, Int,
Uint, Uint,
};// };//enum class ComponentDataType
enum class DataFormat enum class DataFormat
{ {
NONE=0, NONE=0,
#define MATERIAL_DATA_FORMAT_DEFINE(long_name,short_name,type) long_name =((uint(ComponentDataType)<<4)|1), \ #define MATERIAL_DATA_FORMAT_DEFINE(short_name,type) type =((uint(ComponentDataType::type)<<4)|1), \
vec##short_name##1 =((uint(ComponentDataType)<<4)|2), \ Vector##2##short_name =((uint(ComponentDataType::type)<<4)|2), \
vec##short_name##2 =((uint(ComponentDataType)<<4)|3), \ Vector##3##short_name =((uint(ComponentDataType::type)<<4)|3), \
vec##short_name##3 =((uint(ComponentDataType)<<4)|4), Vector##4##short_name =((uint(ComponentDataType::type)<<4)|4)
MATERIAL_DATA_FORMAT_DEFINE(boolean,b,Bool ), MATERIAL_DATA_FORMAT_DEFINE(b,Bool ),
MATERIAL_DATA_FORMAT_DEFINE(float, f,Float ), MATERIAL_DATA_FORMAT_DEFINE(f,Float ),
MATERIAL_DATA_FORMAT_DEFINE(int, i,Int ), MATERIAL_DATA_FORMAT_DEFINE(d,Double),
MATERIAL_DATA_FORMAT_DEFINE(uint, u,Uint ), MATERIAL_DATA_FORMAT_DEFINE(i,Int ),
MATERIAL_DATA_FORMAT_DEFINE(u,Uint ),
#undef MATERIAL_DATA_FORMAT_DEFINE #undef MATERIAL_DATA_FORMAT_DEFINE
}; };//enum class DataFormat
inline const ComponentDataType GetFormatBaseType (const enum class DataFormat &df){return ComponentDataType(uint(df)>>4);}
inline const uint GetFormatChannels (const enum class DataFormat &df){return uint(df)&7;}
using ComponentBitsConfig=uint32; using ComponentBitsConfig=uint32;
constexpr ComponentBitsConfig MCC_PureColor =uint32(ComponentBit::Color); constexpr ComponentBitsConfig MCC_PureColor =uint32(ComponentBit::Color);
constexpr ComponentBitsConfig MCC_PureNormal =uint32(ComponentBit::Normal); 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_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_CNMR =uint32(ComponentBit::Color)|uint32(ComponentBit::Normal)|uint32(ComponentBit::Metallic)|uint32(ComponentBit::Roughness);
@ -100,7 +108,7 @@ BEGIN_MATERIAL_NAMESPACE
ComponentDataType type; ///<数据类型 ComponentDataType type; ///<数据类型
uint channels; ///<通道数 uint channels; ///<通道数
bool LinearColorspace; ///<是要求线性颜色空间 bool LinearColorspace; ///<是要求线性颜色空间
}; };//struct ComponentConfig
const ComponentConfig *GetConfig(const enum class Component c); const ComponentConfig *GetConfig(const enum class Component c);
END_MATERIAL_NAMESPACE END_MATERIAL_NAMESPACE

View File

@ -15,65 +15,14 @@ class DataSource
public: public:
DataSource() const ComponentDataType GetDataType()const{return GetFormatBaseType(format);} ///<获取数据基本类型
{ const uint GetChannels()const{return GetFormatChannels(format);} ///<获取数据通道数量
format=DataFormat::NONE;
}
DataSource(const DataFormat &df) public:
{
format=df;
}
DataSource() {format=DataFormat::NONE;}
DataSource(const DataFormat &df){format=df;}
virtual ~DataSource()=default; virtual ~DataSource()=default;
virtual bool SetX(UTF8String &,const UTF8String &)const{return false;}
virtual bool SetY(UTF8String &,const UTF8String &)const{return false;}
virtual bool SetZ(UTF8String &,const UTF8String &)const{return false;}
virtual bool SetW(UTF8String &,const UTF8String &)const{return false;}
virtual bool SetXY(UTF8String &,const UTF8String &)const{return false;}
virtual bool SetYZ(UTF8String &,const UTF8String &)const{return false;}
virtual bool SetZW(UTF8String &,const UTF8String &)const{return false;}
virtual bool SetXYZ(UTF8String &,const UTF8String &)const{return false;}
virtual bool SetXYZW(UTF8String &,const UTF8String &)const{return false;}
bool SetR(UTF8String &result,const UTF8String &str)const{return this->SetX(result,str);}
bool SetG(UTF8String &result,const UTF8String &str)const{return this->SetY(result,str);}
bool SetB(UTF8String &result,const UTF8String &str)const{return this->SetZ(result,str);}
bool SetA(UTF8String &result,const UTF8String &str)const{return this->SetW(result,str);}
bool SetRG(UTF8String &result,const UTF8String &str)const{return this->SetXY(result,str);}
bool SetGB(UTF8String &result,const UTF8String &str)const{return this->SetYZ(result,str);}
bool SetBA(UTF8String &result,const UTF8String &str)const{return this->SetZW(result,str);}
bool SetRGB(UTF8String &result,const UTF8String &str)const{return this->SetXYZ(result,str);}
bool SetRGBA(UTF8String &result,const UTF8String &str)const{return this->SetXYZW(result,str);}
virtual bool GetX(UTF8String &)const{return false;}
virtual bool GetY(UTF8String &)const{return false;}
virtual bool GetZ(UTF8String &)const{return false;}
virtual bool GetW(UTF8String &)const{return false;}
virtual bool GetXY(UTF8String &)const{return false;}
virtual bool GetYZ(UTF8String &)const{return false;}
virtual bool GetZW(UTF8String &)const{return false;}
virtual bool GetXYZ(UTF8String &)const{return false;}
virtual bool GetXYZW(UTF8String &)const{return false;}
bool GetR(UTF8String &result)const{return this->GetX(result);}
bool GetG(UTF8String &result)const{return this->GetY(result);}
bool GetB(UTF8String &result)const{return this->GetZ(result);}
bool GetA(UTF8String &result)const{return this->GetW(result);}
bool GetRG(UTF8String &result)const{return this->GetXY(result);}
bool GetGB(UTF8String &result)const{return this->GetYZ(result);}
bool GetBA(UTF8String &result)const{return this->GetZW(result);}
bool GetRGB(UTF8String &result)const{return this->GetXYZ(result);}
bool GetRGBA(UTF8String &result)const{return this->GetXYZW(result);}
};//class DataSource };//class DataSource
/** /**
@ -81,40 +30,81 @@ public:
*/ */
class DataSourceConst:public DataSource class DataSourceConst:public DataSource
{ {
public:
using DataSource::DataSource;
};//class DataSourceConst:public DataSource };//class DataSourceConst:public DataSource
/** /**
* Uniform数据源 * Uniform
*/ */
class DataSourceUniform:public DataSource class DataSourceUniform:public DataSource
{ {
public:
using DataSource::DataSource;
};//class DataSourceUniform:public DataSource };//class DataSourceUniform:public DataSource
/**
*
*/
class DataSourceFunction:public DataSource
{
public:
using DataSource::DataSource;
};//class DataSourceFunction:public DataSource
/** /**
* *
*/ */
class DataSourceTexture:public DataSource class DataSourceTexture:public DataSource
{ {
public:
using DataSource::DataSource;
};//class DataSourceTexture:public DataSource };//class DataSourceTexture:public DataSource
class DataSourceTexture1D:public DataSourceTexture class DataSourceTexture1D:public DataSourceTexture
{ {
public:
using DataSourceTexture::DataSourceTexture;
};//class DataSourceTexture1D:public DataSourceTexture };//class DataSourceTexture1D:public DataSourceTexture
class DataSourceTexture1DArrays:public DataSourceTexture
{
public:
using DataSourceTexture::DataSourceTexture;
};//class DataSourceTexture1DArrays:public DataSourceTexture
class DataSourceTexture2D:public DataSourceTexture class DataSourceTexture2D:public DataSourceTexture
{ {
public:
using DataSourceTexture::DataSourceTexture;
};//class DataSourceTexture2D:public DataSourceTexture };//class DataSourceTexture2D:public DataSourceTexture
class DataSourceTexture2DArrays:public DataSourceTexture class DataSourceTexture2DArrays:public DataSourceTexture
{ {
public:
using DataSourceTexture::DataSourceTexture;
};//class DataSourceTexture2DArrays:public DataSourceTexture };//class DataSourceTexture2DArrays:public DataSourceTexture
class DataSourceTextureCubemap:public DataSourceTexture class DataSourceTextureCubemap:public DataSourceTexture
{ {
public:
using DataSourceTexture::DataSourceTexture;
};//class DataSourceTextureCubemap:public DataSourceTexture };//class DataSourceTextureCubemap:public DataSourceTexture
class DataSourceTextureCubemapArrays:public DataSourceTexture class DataSourceTextureCubemapArrays:public DataSourceTexture
{ {
public:
using DataSourceTexture::DataSourceTexture;
};//class DataSourceTextureCubemapArrays:public DataSourceTexture };//class DataSourceTextureCubemapArrays:public DataSourceTexture
END_MATERIAL_NAMESPACE END_MATERIAL_NAMESPACE
#endif//HGL_GRAPH_MATERIAL_DATA_SOURCE_INCLUDE #endif//HGL_GRAPH_MATERIAL_DATA_SOURCE_INCLUDE