Skip to content

Commit

Permalink
Use fwidth instead
Browse files Browse the repository at this point in the history
  • Loading branch information
papadanku committed Nov 20, 2023
1 parent c71947c commit 00d5da0
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion shaders/cBlockMatching.fx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace cBlockMatching

float4 PS_Display(VS2PS_Quad Input) : SV_TARGET0
{
float2 InvTexSize = float2(ddx(Input.Tex0.x), ddy(Input.Tex0.y));
float2 InvTexSize = fwidth(Input.Tex0);

float2 Vectors = tex2Dlod(SampleOFlowTex, float4(Input.Tex0.xy, 0.0, _MipBias)).xy;
Vectors = DecodeVectors(Vectors, InvTexSize);
Expand Down
2 changes: 1 addition & 1 deletion shaders/cOpticalFlow.fx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ namespace cOpticalFlow

float4 PS_Display(VS2PS_Quad Input) : SV_TARGET0
{
float2 InvTexSize = float2(ddx(Input.Tex0.x), ddy(Input.Tex0.y));
float2 InvTexSize = fwidth(Input.Tex0);

float2 Vectors = tex2Dlod(SampleTempTex2b, float4(Input.Tex0.xy, 0.0, _MipBias)).xy;
Vectors = DecodeVectors(Vectors, InvTexSize);
Expand Down
4 changes: 2 additions & 2 deletions shaders/kDatamosh.fx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ namespace kDatamosh

float2 GetMVBlocks(float2 MV, float2 Tex, out float3 Random)
{
float2 TexSize = float2(ddx(Tex.x), ddy(Tex.y));
float2 TexSize = fwidth(Tex);
float2 Time = float2(_Time, 0.0);

// Random numbers
Expand Down Expand Up @@ -251,7 +251,7 @@ namespace kDatamosh

float4 PS_Datamosh(VS2PS_Quad Input) : SV_TARGET0
{
float2 TexSize = float2(ddx(Input.Tex0.x), ddy(Input.Tex0.y));
float2 TexSize = fwidth(Input.Tex0);
const float2 DisplacementTexel = BUFFER_SIZE_0;
const float Quality = 1.0 - _Entropy;
float3 Random = 0.0;
Expand Down
4 changes: 2 additions & 2 deletions shaders/shared/cImageProcessing.fxh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
const float4 VShift = float4(0.0, -1.0, 0.0, 1.0);

float4 OutputColor = 0.0;
float4 PSize = float2(ddx(Input.Tex0.x), ddy(Input.Tex0.y)).xyxy;
float4 PSize = fwidth(Input.Tex0).xyxy;

const float Offsets[KernelSize] =
{
Expand Down Expand Up @@ -93,7 +93,7 @@
float4 Filter3x3(sampler2D SampleSource, float2 Tex, bool DownSample)
{
const float3 Weights = float3(1.0, 2.0, 4.0) / 16.0;
float2 PixelSize = float2(ddx(Tex.x), ddy(Tex.y));
float2 PixelSize = fwidth(Tex);
PixelSize = (DownSample) ? PixelSize * 0.5 : PixelSize;

float4 STex[3] =
Expand Down
4 changes: 2 additions & 2 deletions shaders/shared/cVideoProcessing.fxh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
// Get required data to calculate main texel data
const float Pi2 = acos(-1.0) * 2.0;
const float2 ImageSize = tex2Dsize(SampleI0, 0.0);
float2 PixelSize = float2(ddx(MainTex.x), ddy(MainTex.y));
float2 PixelSize = fwidth(MainTex);

// Calculate main texel data (TexelSize, TexelLOD)
T.Mask = float4(1.0, 1.0, 0.0, 0.0) * abs(PixelSize.xyyy);
Expand Down Expand Up @@ -222,7 +222,7 @@

// Get required data to calculate main texel data
const float2 ImageSize = tex2Dsize(SampleTemplate, 0.0);
float2 PixelSize = float2(ddx(MainTex.x), ddy(MainTex.y));
float2 PixelSize = fwidth(MainTex);

// Calculate main texel data (TexelSize, TexelLOD)
B.Mask = float4(1.0, 1.0, 0.0, 0.0) * abs(PixelSize.xyyy);
Expand Down

0 comments on commit 00d5da0

Please sign in to comment.