Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
papadanku committed Jul 5, 2023
2 parents 6241276 + 2ae073b commit a5c4093
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 19 deletions.
2 changes: 1 addition & 1 deletion shaders/cBlockMatching.fx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace cBlockMatching
float2 PS_Normalize(VS2PS_Quad Input) : SV_TARGET0
{
float3 Color = tex2D(CShade_SampleColorTex, Input.Tex0).rgb;
return GetSphericalRG(Color);
return GetSphericalRG(Color, Input.HPos.xy);
}

float4 PS_Copy_0(VS2PS_Quad Input) : SV_TARGET0
Expand Down
16 changes: 8 additions & 8 deletions shaders/cChromaticity.fx
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,32 @@ uniform int _Select <

float4 PS_Chromaticity(VS2PS_Quad Input) : SV_TARGET0
{
float3 Color = tex2D(CShade_SampleColorTex, Input.Tex0).rgb;
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 (XY)
Chromaticity.rg = GetChromaticity(Color, 0).rg;
Chromaticity.rg = GetChromaticity(Color, Input.HPos.xy, 0).rg;
break;
case 1: // Length (XYZ)
Chromaticity.rgb = GetChromaticity(Color, 0).rgb;
Chromaticity.rgb = GetChromaticity(Color, Input.HPos.xy, 0).rgb;
break;
case 2: // Average (XY)
Chromaticity.rg = GetChromaticity(Color, 1).rg;
Chromaticity.rg = GetChromaticity(Color, Input.HPos.xy, 1).rg;
break;
case 3: // Average (XYZ)
Chromaticity.rgb = GetChromaticity(Color, 1).rgb;
Chromaticity.rgb = GetChromaticity(Color, Input.HPos.xy, 1).rgb;
break;
case 4: // Sum (XY)
Chromaticity.rg = GetChromaticity(Color, 2).rg;
Chromaticity.rg = GetChromaticity(Color, Input.HPos.xy, 2).rg;
break;
case 5: // Sum (XYZ)
Chromaticity.rgb = GetChromaticity(Color, 2).rgb;
Chromaticity.rgb = GetChromaticity(Color, Input.HPos.xy, 2).rgb;
break;
case 6: // Polar (XY)
Chromaticity.rg = GetSphericalRG(Color);
Chromaticity.rg = GetSphericalRG(Color, Input.HPos.xy);
break;
case 7: // CoCg (XY)
Chromaticity.rg = GetCoCg(Gamma);
Expand Down
4 changes: 2 additions & 2 deletions shaders/cMotionBlur.fx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace cMotionBlur
float2 PS_Normalize(VS2PS_Quad Input) : SV_TARGET0
{
float3 Color = tex2D(CShade_SampleColorTex, Input.Tex0).rgb;
return GetSphericalRG(Color);
return GetSphericalRG(Color, Input.HPos.xy);
}

float2 PS_HBlur_Prefilter(VS2PS_Quad Input) : SV_TARGET0
Expand Down Expand Up @@ -128,7 +128,7 @@ namespace cMotionBlur

float Noise(float2 Pos)
{
return frac(52.9829189 * frac(dot(Pos, float2(0.06711056, 0.00583715))));
return frac(52.9829189 * frac(dot(Pos, float2(0.06711056, 0.00583715)))) / 255.0;
}

float4 PS_MotionBlur(VS2PS_Quad Input) : SV_TARGET0
Expand Down
2 changes: 1 addition & 1 deletion shaders/cOpticalFlow.fx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace cOpticalFlow
float2 PS_Normalize(VS2PS_Quad Input) : SV_TARGET0
{
float3 Color = tex2D(CShade_SampleColorTex, Input.Tex0).rgb;
return GetSphericalRG(Color);
return GetSphericalRG(Color, Input.HPos.xy);
}

float2 PS_HBlur_Prefilter(VS2PS_Quad Input) : SV_TARGET0
Expand Down
2 changes: 1 addition & 1 deletion shaders/kDatamosh.fx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ namespace kDatamosh
float2 PS_Normalize(VS2PS_Quad Input) : SV_TARGET0
{
float3 Color = tex2D(CShade_SampleColorTex, Input.Tex0).rgb;
return GetSphericalRG(Color);
return GetSphericalRG(Color, Input.HPos.xy);
}

float2 PS_HBlur_Prefilter(VS2PS_Quad Input) : SV_TARGET0
Expand Down
40 changes: 34 additions & 6 deletions shaders/shared/cImageProcessing.fxh
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
const float3 Weights = float3(1.0, 2.0, 4.0) / 16.0;
float2 PixelSize = float2(ddx(Tex.x), ddy(Tex.y));
PixelSize = (DownSample) ? PixelSize * 0.5 : PixelSize;

float4 STex[3] =
{
Tex.xyyy + (float4(-2.0, 2.0, 0.0, -2.0) * abs(PixelSize.xyyy)),
Expand Down Expand Up @@ -152,14 +152,29 @@
return OutputColor0;
}

/*
[Noise Generation]
*/

/*
Interleaved Gradient Noise Dithering
---
http://www.iryoku.com/downloads/Next-Generation-Post-Processing-in-Call-of-Duty-Advanced-Warfare-v18.pptx
*/
float3 GetDither(float2 Position)
{
return frac(52.9829189 * frac(dot(Position, float2(0.06711056, 0.00583715)))) / 255.0;
}

/*
[Color Processing]
*/

float3 GetChromaticity(float3 Color, int Method)
float3 GetChromaticity(float3 Color, float2 Tex, int Method)
{
float Sum = 0.0;
float White = 0.0;
Color += GetDither(Tex);

switch(Method)
{
Expand Down Expand Up @@ -248,20 +263,33 @@
https://www.mia.uni-saarland.de/Publications/mileva-dagm07.pdf
*/

float2 GetSphericalRG(float3 Color)
float2 GetSphericalRG(float3 Color, float2 Tex)
{
const float Pi = acos(-1.0);
const float IHalfPi = 1.0 / (Pi / 2.0);
const float IHalfPi = 1.0 / acos(0.0);
const float2 White = float2(atan2(1.0, 1.0), asin(sqrt(2.0) / sqrt(3.0)));

Color += GetDither(Tex);
float DotRG = dot(Color.rg, 1.0);
float SumRG = length(Color.rg);
float SumRGB = length(Color.rgb);

float2 P = 0.0;
P.x = (DotRG == 0.0) ? White.x : atan2(abs(Color.g), abs(Color.r));
P.y = (SumRGB == 0.0) ? White.y : asin(abs(SumRG / SumRGB));

return saturate(P * IHalfPi);
}

float2 GetSphericalXY(float3 Color, float2 Tex)
{
const float IHalfPi = 1.0 / acos(0.0);
const float2 White = float2(atan2(sqrt(2.0), 1.0), atan2(1.0, 1.0));

Color += GetDither(Tex);
float2 N = float2(length(Color.rg), Color.g);
float2 D = Color.br;

float2 XY = ((N == 0.0) && (D == 0.0)) ? White : atan2(abs(N), abs(D));
return saturate(XY * IHalfPi);
}
#endif

0 comments on commit a5c4093

Please sign in to comment.