Skip to content

Commit

Permalink
Use RG16F for normalized texture
Browse files Browse the repository at this point in the history
  • Loading branch information
brimson committed Jul 24, 2022
1 parent ab652e7 commit d4b06aa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
7 changes: 5 additions & 2 deletions shaders/cMotionBlur.fx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ namespace MotionBlur
#endif
};

CREATE_TEXTURE(Render_Common_0, int2(BUFFER_WIDTH >> 1, BUFFER_HEIGHT >> 1), RG8, 4)
CREATE_TEXTURE(Render_Common_0, int2(BUFFER_WIDTH >> 1, BUFFER_HEIGHT >> 1), RG16F, 6)
CREATE_SAMPLER(Sample_Common_0, Render_Common_0)

CREATE_TEXTURE(Render_Common_1_A, BUFFER_SIZE_1, RGBA16F, 9)
Expand Down Expand Up @@ -372,7 +372,7 @@ namespace MotionBlur
*/

// Create matrix A and solve its window sum
float3 A = float3(FP16_SMALLEST_SUBNORMAL, FP16_SMALLEST_SUBNORMAL, 0.0);
float3 A = 0.0;

// Create vector B and solve its window sum
float2 B = 0.0;
Expand All @@ -389,6 +389,9 @@ namespace MotionBlur
B.y += dot(S[i].zw, T[i].xy);
}

// Make determinant non-zero
A.xy = max(A.xy, FP16_SMALLEST_SUBNORMAL);

// Create -IxIy (A12) for A^-1 and its determinant
A.z = A.z * (-1.0);

Expand Down
7 changes: 5 additions & 2 deletions shaders/cOpticalFlowLK.fx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ namespace OpticalFlowLK
#endif
};

CREATE_TEXTURE(Render_Common_0, int2(BUFFER_WIDTH >> 1, BUFFER_HEIGHT >> 1), RG8, 4)
CREATE_TEXTURE(Render_Common_0, int2(BUFFER_WIDTH >> 1, BUFFER_HEIGHT >> 1), RG16F, 6)
CREATE_SAMPLER(Sample_Common_0, Render_Common_0)

CREATE_TEXTURE(Render_Common_1_A, BUFFER_SIZE_1, RGBA16F, 9)
Expand Down Expand Up @@ -365,7 +365,7 @@ namespace OpticalFlowLK
*/

// Create matrix A and solve its window sum
float3 A = float3(FP16_SMALLEST_SUBNORMAL, FP16_SMALLEST_SUBNORMAL, 0.0);
float3 A = 0.0;

// Create vector B and solve its window sum
float2 B = 0.0;
Expand All @@ -382,6 +382,9 @@ namespace OpticalFlowLK
B.y += dot(S[i].zw, T[i].xy);
}

// Make determinant non-zero
A.xy = max(A.xy, FP16_SMALLEST_SUBNORMAL);

// Create -IxIy (A12) for A^-1 and its determinant
A.z = A.z * (-1.0);

Expand Down
7 changes: 5 additions & 2 deletions shaders/kDatamosh.fx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ namespace Datamosh
MipFilter = LINEAR; \
};

CREATE_TEXTURE(Render_Common_0, int2(BUFFER_WIDTH >> 1, BUFFER_HEIGHT >> 1), RG8, 4)
CREATE_TEXTURE(Render_Common_0, int2(BUFFER_WIDTH >> 1, BUFFER_HEIGHT >> 1), RG16F, 6)
CREATE_SAMPLER(Sample_Common_0, Render_Common_0)

CREATE_TEXTURE(Render_Common_1_A, BUFFER_SIZE_1, RGBA16F, 9)
Expand Down Expand Up @@ -437,7 +437,7 @@ namespace Datamosh
*/

// Create matrix A and solve its window sum
float3 A = float3(FP16_SMALLEST_SUBNORMAL, FP16_SMALLEST_SUBNORMAL, 0.0);
float3 A = 0.0;

// Create vector B and solve its window sum
float2 B = 0.0;
Expand All @@ -454,6 +454,9 @@ namespace Datamosh
B.y += dot(S[i].zw, T[i].xy);
}

// Make determinant non-zero
A.xy = max(A.xy, FP16_SMALLEST_SUBNORMAL);

// Create -IxIy (A12) for A^-1 and its determinant
A.z = A.z * (-1.0);

Expand Down

0 comments on commit d4b06aa

Please sign in to comment.