From d4b06aad8cb95771cb296258a7d84135e48124ca Mon Sep 17 00:00:00 2001 From: brimson Date: Sat, 23 Jul 2022 23:24:18 -0700 Subject: [PATCH] Use RG16F for normalized texture --- shaders/cMotionBlur.fx | 7 +++++-- shaders/cOpticalFlowLK.fx | 7 +++++-- shaders/kDatamosh.fx | 7 +++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/shaders/cMotionBlur.fx b/shaders/cMotionBlur.fx index d1722ba..c03fd90 100644 --- a/shaders/cMotionBlur.fx +++ b/shaders/cMotionBlur.fx @@ -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) @@ -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; @@ -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); diff --git a/shaders/cOpticalFlowLK.fx b/shaders/cOpticalFlowLK.fx index 9fb2fbf..5a6e24b 100644 --- a/shaders/cOpticalFlowLK.fx +++ b/shaders/cOpticalFlowLK.fx @@ -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) @@ -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; @@ -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); diff --git a/shaders/kDatamosh.fx b/shaders/kDatamosh.fx index b8fcc59..a4e47d8 100644 --- a/shaders/kDatamosh.fx +++ b/shaders/kDatamosh.fx @@ -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) @@ -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; @@ -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);