Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
papadanku committed Jun 27, 2023
2 parents dda27ae + 5f01867 commit 87f856e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 8 deletions.
23 changes: 15 additions & 8 deletions shaders/cChromaticity.fx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ uniform int _Select <
ui_label = "Method";
ui_tooltip = "Select Chromaticity";
ui_type = "combo";
ui_items = " Length (RG)\0 Length (RGB)\0 Average (RG)\0 Average (RGB)\0 Sum (RG)\0 Sum (RGB)\0 Polar (RG)\0";
ui_items = " Length (XY)\0 Length (XYZ)\0 Average (XY)\0 Average (XYZ)\0 Sum (XY)\0 Sum (XYZ)\0 Polar (XY)\0 CoCg (XY)\0 CrCb (XY)\0";
> = 0;

/*
Expand All @@ -19,31 +19,38 @@ uniform int _Select <
float4 PS_Chromaticity(VS2PS_Quad Input) : SV_TARGET0
{
float3 Color = tex2D(CShade_SampleColorTex, Input.Tex0).rgb;
float3 Gamma = tex2D(CShade_SampleGammaTex, Input.Tex0).rgb;
float3 Chromaticity = 0.0;

switch(_Select)
{
case 0: // Length (RG)
case 0: // Length (XY)
Chromaticity.rg = GetChromaticity(Color, 0).rg;
break;
case 1: // Length (RGB)
case 1: // Length (XYZ)
Chromaticity.rgb = GetChromaticity(Color, 0).rgb;
break;
case 2: // Average (RG)
case 2: // Average (XY)
Chromaticity.rg = GetChromaticity(Color, 1).rg;
break;
case 3: // Average (RGB)
case 3: // Average (XYZ)
Chromaticity.rgb = GetChromaticity(Color, 1).rgb;
break;
case 4: // Sum (RG)
case 4: // Sum (XY)
Chromaticity.rg = GetChromaticity(Color, 2).rg;
break;
case 5: // Sum (RGB)
case 5: // Sum (XYZ)
Chromaticity.rgb = GetChromaticity(Color, 2).rgb;
break;
case 6: // Polar (RG)
case 6: // Polar (XY)
Chromaticity.rg = GetPolar(Color);
break;
case 7: // CoCg (XY)
Chromaticity.rg = GetCoCg(Gamma);
break;
case 8: // CrCb (XY)
Chromaticity.rg = GetCrCb(Gamma);
break;
default: // No Chromaticity
Chromaticity.rgb = 0.0;
break;
Expand Down
19 changes: 19 additions & 0 deletions shaders/shared/cGraphics.fxh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
SRGBTexture = READ_SRGB;
};

sampler2D CShade_SampleGammaTex
{
Texture = CShade_ColorTex;
MagFilter = LINEAR;
MinFilter = LINEAR;
MipFilter = LINEAR;
SRGBTexture = FALSE;
};

/*
[Simple Vertex Shader]
*/
Expand Down Expand Up @@ -46,6 +55,16 @@
[Math Functions]
*/

int GetFactorial(int N)
{
int O = N;
for (int i = 1 ; i < N; i++)
{
O *= i;
}
return O;
}

float4 GetBlit(VS2PS_Quad Input, sampler2D SampleSource)
{
return tex2D(SampleSource, Input.Tex0);
Expand Down
12 changes: 12 additions & 0 deletions shaders/shared/cImageProcessing.fxh
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,18 @@
return (CoCg * 0.5) + 0.5;
}

/*
RGB to CrCb
---
https://docs.opencv.org/4.7.0/de/d25/imgproc_color_conversions.html
*/

float2 GetCrCb(float3 Color)
{
float Y = dot(Color, float3(0.299, 0.587, 0.114));
return ((Color.rb - Y) * float2(0.713, 0.564)) + 0.5;
}

/*
RGB to saturation value.
---
Expand Down

0 comments on commit 87f856e

Please sign in to comment.