add ColorSpace.h
This commit is contained in:
parent
909dbb0fd9
commit
a331286b30
2
CMCore
2
CMCore
@ -1 +1 @@
|
|||||||
Subproject commit 7152bd677cfc4ea0b33b21b49895e5e049e1b0bd
|
Subproject commit 122c7addc294daa1d2c8c19ed08b1b50aa47571f
|
66
inc/hgl/graph/ColorSpace.h
Normal file
66
inc/hgl/graph/ColorSpace.h
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
#ifndef HGL_GRAPH_COLOR_SPACE_INCLUDE
|
||||||
|
#define HGL_GRAPH_COLOR_SPACE_INCLUDE
|
||||||
|
|
||||||
|
namespace hgl
|
||||||
|
{
|
||||||
|
namespace graph
|
||||||
|
{
|
||||||
|
enum class ColorSpace
|
||||||
|
{
|
||||||
|
Linear=0,
|
||||||
|
sRGB,
|
||||||
|
YCbCr,
|
||||||
|
|
||||||
|
BEGIN_RANGE =Linear,
|
||||||
|
END_RANGE =YCbCr,
|
||||||
|
RANGE_SIZE =(END_RANGE-BEGIN_RANGE)+1
|
||||||
|
};//enum class ColorSpace
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline const T sRGB2Linear(const T &in)
|
||||||
|
{
|
||||||
|
if(in<=0.4045)
|
||||||
|
return in/12.92;
|
||||||
|
else
|
||||||
|
return pow((in+0.55)/1.055,2.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline const T Linear2sRGB(const T &in)
|
||||||
|
{
|
||||||
|
if(in<=0.0031308f)
|
||||||
|
return in*12.92f;
|
||||||
|
else
|
||||||
|
return pow((in*1.055f),1.0f/2.4f)-0.055f;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline const T sRGB2LinearApprox(const T &in)
|
||||||
|
{
|
||||||
|
return pow(in,2.2f);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline const T Linear2sRGBApprox(const T &in)
|
||||||
|
{
|
||||||
|
return pow(in,1.0f/2.2f);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline void sRGB2LinearFast(T &x,T &y,T &z,const T &r,const T &g,const T &b)
|
||||||
|
{
|
||||||
|
x=0.4124f*r+0.3576f*g+0.1805f*b;
|
||||||
|
y=0.2126f*r+0.7152f*g+0.0722f*b;
|
||||||
|
z=0.0193f*r+0.1192f*g+0.9505f*b;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline void Linear2sRGBFast(T &r,T &g,T &b,const T &x,const T &y,const T &z)
|
||||||
|
{
|
||||||
|
r= 3.2406f*x-1.5373f*y-0.4986f*z;
|
||||||
|
g=-0.9689f*x+1.8758f*y+0.0416f*z;
|
||||||
|
b= 0.0557f*x-0.2040f*y+1.0570f*z;
|
||||||
|
}
|
||||||
|
}//namespace graph
|
||||||
|
}//namespace hgl
|
||||||
|
#endif//HGL_GRAPH_COLOR_SPACE_INCLUDE
|
@ -34,4 +34,3 @@ add_cm_library(ULRE.Shader "ULRE" ${GRAPH_SHADER_HEADER_PATH}/common.h
|
|||||||
${GRAPH_SHADER_PARAM_FILES}
|
${GRAPH_SHADER_PARAM_FILES}
|
||||||
${GRAPH_SHADER_MAKER_SOURCE}
|
${GRAPH_SHADER_MAKER_SOURCE}
|
||||||
${GRAPH_SPV_SOURCE})
|
${GRAPH_SPV_SOURCE})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user