Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed color space conversion in HLSL #157

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions color/space/YPbPr2rgb.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ license:
#ifndef MAT_YPBPR2RGB
#define MAT_YPBPR2RGB
#ifdef YPBPR_SDTV
const float3x3 YPBPR2RGB = float3x3(
static const float3x3 YPBPR2RGB = float3x3(
1.0, 1.0, 1.0,
0.0, -0.344, 1.772,
1.402, -0.714, 0.0
);
#else
const float3x3 YPBPR2RGB = float3x3(
static const float3x3 YPBPR2RGB = float3x3(
1.0, 1.0, 1.0,
0.0, -0.187, 1.856,
1.575, -0.468, 0.0
Expand Down
4 changes: 2 additions & 2 deletions color/space/lms2rgb.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ license:

#ifndef MAT_LMS2RGB
#define MAT_LMS2RGB
// const float3x3 LMS2RGB = float3x3(
// static const float3x3 LMS2RGB = float3x3(
// 2.85847e+0, -1.62879e+0, -2.48910e-2,
// -2.10182e-1, 1.15820e+0, 3.24281e-4,
// -4.18120e-2, -1.18169e-1, 1.06867e+0
// );
const float3x3 LMS2RGB = float3x3(
static const float3x3 LMS2RGB = float3x3(
0.0809444479, -0.0102485335, -0.000365296938,
-0.13050440, 0.0540193266, -0.00412161469,
0.116721066, -0.113614708, 0.693511405
Expand Down
4 changes: 2 additions & 2 deletions color/space/oklab2rgb.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ license:

#ifndef MAT_OKLAB2RGB
#define MAT_OKLAB2RGB
const float3x3 OKLAB2RGB_A = float3x3(
static const float3x3 OKLAB2RGB_A = float3x3(
1.0, 1.0, 1.0,
0.3963377774, -0.1055613458, -0.0894841775,
0.2158037573, -0.0638541728, -1.2914855480);

const float3x3 OKLAB2RGB_B = float3x3(
static const float3x3 OKLAB2RGB_B = float3x3(
4.0767416621, -1.2684380046, -0.0041960863,
-3.3077115913, 2.6097574011, -0.7034186147,
0.2309699292, -0.3413193965, 1.7076147010);
Expand Down
4 changes: 2 additions & 2 deletions color/space/rgb2YPbPr.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ license:
#ifndef MAT_RGB2PBPR
#define MAT_RGB2PBPR
#ifdef YPBPR_SDTV
const float3x3 RGB2PBPR = float3x3(
static const float3x3 RGB2PBPR = float3x3(
.299, -.169, .5,
.587, -.331, -.419,
.114, .5, -.081
);
#else
const float3x3 RGB2PBPR = float3x3(
static const float3x3 RGB2PBPR = float3x3(
0.2126, -0.1145721060573399, 0.5,
0.7152, -0.3854278939426601, -0.4541529083058166,
0.0722, 0.5, -0.0458470916941834
Expand Down
4 changes: 2 additions & 2 deletions color/space/rgb2lms.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ license:

#ifndef MAT_RGB2LMS
#define MAT_RGB2LMS
// const float3x3 RGB2LMS = float3x3(
// static const float3x3 RGB2LMS = float3x3(
// 3.90405e-1, 5.49941e-1, 8.92632e-3,
// 7.08416e-2, 9.63172e-1, 1.35775e-3,
// 2.31082e-2, 1.28021e-1, 9.36245e-1
// );

const float3x3 RGB2LMS = float3x3(
static const float3x3 RGB2LMS = float3x3(
17.8824, 3.45565, 0.0299566,
43.5161, 27.1554, 0.184309,
4.11935, 0.184309, 1.46709
Expand Down
4 changes: 2 additions & 2 deletions color/space/rgb2oklab.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ license:

#ifndef MAT_RGB2OKLAB
#define MAT_RGB2OKLAB
const float3x3 RGB2OKLAB_A = float3x3(
static const float3x3 RGB2OKLAB_A = float3x3(
0.2104542553, 1.9779984951, 0.0259040371,
0.7936177850, -2.4285922050, 0.7827717662,
-0.0040720468, 0.4505937099, -0.8086757660);

const float3x3 RGB2OKLAB_B = float3x3(
static const float3x3 RGB2OKLAB_B = float3x3(
0.4122214708, 0.2119034982, 0.0883024619,
0.5363325363, 0.6806995451, 0.2817188376,
0.0514459929, 0.1073969566, 0.6299787005);
Expand Down
2 changes: 1 addition & 1 deletion color/space/rgb2yiq.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license:

#ifndef MAT_RGB2YIQ
#define MAT_RGB2YIQ
const float3x3 RGB2YIQ = float3x3(
static const float3x3 RGB2YIQ = float3x3(
0.300, 0.5900, 0.1100,
0.599, -0.2773, -0.3217,
0.213, -0.5251, 0.3121);
Expand Down
4 changes: 2 additions & 2 deletions color/space/rgb2yuv.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ license:
#ifndef MAT_RGB2YUV
#define MAT_RGB2YUV
#ifdef YUV_SDTV
const float3x3 RGB2YUV = float3x3(
static const float3x3 RGB2YUV = float3x3(
0.299, -0.14713, 0.615,
0.587, -0.28886, -0.51499,
0.114, 0.436, -0.10001
);
#else
const float3x3 RGB2YUV = float3x3(
static const float3x3 RGB2YUV = float3x3(
0.2126, -0.09991, 0.615,
0.7152, -0.33609,-0.55861,
0.0722, 0.426, -0.05639
Expand Down
4 changes: 2 additions & 2 deletions color/space/xyz2rgb.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ license:
#ifndef MAT_XYZ2RGB
#define MAT_XYZ2RGB
#ifdef CIE_D50
const float3x3 XYZ2RGB = float3x3(
static const float3x3 XYZ2RGB = float3x3(
3.1338561,-0.9787684, 0.0719453,
-1.6168667, 1.9161415,-0.2289914,
-0.4906146, 0.0334540, 1.4052427
);
#else
// CIE D65
const float3x3 XYZ2RGB = float3x3(
static const float3x3 XYZ2RGB = float3x3(
3.2404542,-0.9692660, 0.0556434,
-1.5371385, 1.8760108,-0.2040259,
-0.4985314, 0.0415560, 1.0572252
Expand Down
2 changes: 1 addition & 1 deletion color/space/yiq2rgb.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license:

#ifndef MAT_YIQ2RGB
#define MAT_YIQ2RGB
const float3x3 YIQ2RGB = float3x3( 1.0, 0.9469, 0.6235,
static const float3x3 YIQ2RGB = float3x3( 1.0, 0.9469, 0.6235,
1.0, -0.2747, -0.6357,
1.0, -1.1085, 1.7020 );
#endif
Expand Down
4 changes: 2 additions & 2 deletions color/space/yuv2rgb.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ license:
#ifndef MAT_YUV2RGB
#define MAT_YUV2RGB
#ifdef YUV_SDTV
const float3x3 YUV2RGB = float3x3(
static const float3x3 YUV2RGB = float3x3(
1.0, 1.0, 1.0,
0.0, -0.39465, 2.03211,
1.13983, -0.58060, 0.0
);
#else
const float3x3 YUV2RGB = float3x3(
static const float3x3 YUV2RGB = float3x3(
1.0, 1.0, 1.0,
0.0, -0.21482, 2.12798,
1.28033, -0.38059, 0.0
Expand Down
8 changes: 4 additions & 4 deletions generative/psrdnoise.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,11 @@ float psrdnoise(float3 x, float3 period, float alpha, out float3 gradient) {

#ifndef PSRDNOISE_PERLIN_GRID
// Transformation matrices for the axis-aligned simplex grid
const float3x3 M = float3x3(0.0, 1.0, 1.0,
static const float3x3 M = float3x3(0.0, 1.0, 1.0,
1.0, 0.0, 1.0,
1.0, 1.0, 0.0);

const float3x3 Mi = float3x3(-0.5, 0.5, 0.5,
static const float3x3 Mi = float3x3(-0.5, 0.5, 0.5,
0.5,-0.5, 0.5,
0.5, 0.5,-0.5);
#endif
Expand Down Expand Up @@ -431,11 +431,11 @@ float psrdnoise(float3 x, float3 period, float alpha, out float3 gradient, out f

#ifndef PSRDNOISE_PERLIN_GRID
// Transformation matrices for the axis-aligned simplex grid
const float3x3 M = float3x3(0.0, 1.0, 1.0,
static const float3x3 M = float3x3(0.0, 1.0, 1.0,
1.0, 0.0, 1.0,
1.0, 1.0, 0.0);

const float3x3 Mi = float3x3(-0.5, 0.5, 0.5,
static const float3x3 Mi = float3x3(-0.5, 0.5, 0.5,
0.5,-0.5, 0.5,
0.5, 0.5,-0.5);
#endif
Expand Down