u/suka-blyat

▲ 3 r/VITURE

Fix for Chromatic Aberration and Edge Blur on Windows

I've been using my Viture Beast XR glasses for months now. They are great for media consumption when connected to a Samsung phone using DeX, but reading text around the edges is almost impossible especially on Windows due to the chromatic aberration.

I saw how the browser based test tool by u/nroro could correct this in software, so I started experimenting with Magpie, it's a window upscaling utility. After a lot of trial and error, I found a solution that works well, at least for me.

​If you want to give it a try, download Blinue/Magpie upscaler from GitHub and extract the files. Open the effects folder inside the extracted Magpie directory and create a new text file. Paste the code provided below into the file and save it as VitureCA.hlsl, make sure you change the file extension to .hlsl and not .txt.

​Next, open Magpie and navigate to Scaling Modes from the left side of the Magpie window. Scroll to the bottom, click New Scaling Mode, and name it Viture Fix. Leave the "Copy from" option set to none and click create. Select this newly created mode from the list, click the dropdown arrow to its right, click Add Effect, and select VitureCA. Now click Defaults under the Profiles menu on the left side of the Magpie window and select your Viture Fix scaling mode.

​When using your glasses, you can press Alt+Shift+A to toggle the fix on the active window. Alternatively, you can create a dedicated profile for your browser or any open application and select "Apply profile automatically in fullscreen mode." The profile will activate automatically when you click the window. To exit, you need to click the exit button at the top of the screen.

To fine-tune the correction for your specific glasses, go back to Scaling Modes, click the dropdown menu, and select Edit. This will allow you to adjust the correction and sharpness for all edges.

​Disclaimer: I did not develop this software or write the core application code. I've used AI to help with the math of the HLSL shader.

Here's the shader:

//!MAGPIE EFFECT

//!VERSION 4

//!SORT_NAME Viture 6-Point

//!PARAMETER

//!LABEL Sharpness

//!DEFAULT 0.0

//!MIN 0.0

//!MAX 2.0

//!STEP 0.1

float cfg_sharp;

//!PARAMETER

//!LABEL Curve

//!DEFAULT 2.0

//!MIN 0.5

//!MAX 4.0

//!STEP 0.1

float cfg_curve;

//!PARAMETER

//!LABEL TL Red X

//!DEFAULT 0.0000

//!MIN -0.0100

//!MAX 0.0100

//!STEP 0.0001

float cfg_tl_rx;

//!PARAMETER

//!LABEL TL Red Y

//!DEFAULT 0.0000

//!MIN -0.0100

//!MAX 0.0100

//!STEP 0.0001

float cfg_tl_ry;

//!PARAMETER

//!LABEL TL Blue X

//!DEFAULT 0.0000

//!MIN -0.0100

//!MAX 0.0100

//!STEP 0.0001

float cfg_tl_bx;

//!PARAMETER

//!LABEL TL Blue Y

//!DEFAULT 0.0000

//!MIN -0.0100

//!MAX 0.0100

//!STEP 0.0001

float cfg_tl_by;

//!PARAMETER

//!LABEL MT Red X

//!DEFAULT 0.0000

//!MIN -0.0100

//!MAX 0.0100

//!STEP 0.0001

float cfg_mt_rx;

//!PARAMETER

//!LABEL MT Red Y

//!DEFAULT 0.0000

//!MIN -0.0100

//!MAX 0.0100

//!STEP 0.0001

float cfg_mt_ry;

//!PARAMETER

//!LABEL MT Blue X

//!DEFAULT 0.0000

//!MIN -0.0100

//!MAX 0.0100

//!STEP 0.0001

float cfg_mt_bx;

//!PARAMETER

//!LABEL MT Blue Y

//!DEFAULT 0.0000

//!MIN -0.0100

//!MAX 0.0100

//!STEP 0.0001

float cfg_mt_by;

//!PARAMETER

//!LABEL TR Red X

//!DEFAULT 0.0000

//!MIN -0.0100

//!MAX 0.0100

//!STEP 0.0001

float cfg_tr_rx;

//!PARAMETER

//!LABEL TR Red Y

//!DEFAULT 0.0000

//!MIN -0.0100

//!MAX 0.0100

//!STEP 0.0001

float cfg_tr_ry;

//!PARAMETER

//!LABEL TR Blue X

//!DEFAULT 0.0000

//!MIN -0.0100

//!MAX 0.0100

//!STEP 0.0001

float cfg_tr_bx;

//!PARAMETER

//!LABEL TR Blue Y

//!DEFAULT 0.0000

//!MIN -0.0100

//!MAX 0.0100

//!STEP 0.0001

float cfg_tr_by;

//!PARAMETER

//!LABEL BL Red X

//!DEFAULT 0.0000

//!MIN -0.0100

//!MAX 0.0100

//!STEP 0.0001

float cfg_bl_rx;

//!PARAMETER

//!LABEL BL Red Y

//!DEFAULT 0.0000

//!MIN -0.0100

//!MAX 0.0100

//!STEP 0.0001

float cfg_bl_ry;

//!PARAMETER

//!LABEL BL Blue X

//!DEFAULT 0.0000

//!MIN -0.0100

//!MAX 0.0100

//!STEP 0.0001

float cfg_bl_bx;

//!PARAMETER

//!LABEL BL Blue Y

//!DEFAULT 0.0000

//!MIN -0.0100

//!MAX 0.0100

//!STEP 0.0001

float cfg_bl_by;

//!PARAMETER

//!LABEL MB Red X

//!DEFAULT 0.0000

//!MIN -0.0100

//!MAX 0.0100

//!STEP 0.0001

float cfg_mb_rx;

//!PARAMETER

//!LABEL MB Red Y

//!DEFAULT 0.0000

//!MIN -0.0100

//!MAX 0.0100

//!STEP 0.0001

float cfg_mb_ry;

//!PARAMETER

//!LABEL MB Blue X

//!DEFAULT 0.0000

//!MIN -0.0100

//!MAX 0.0100

//!STEP 0.0001

float cfg_mb_bx;

//!PARAMETER

//!LABEL MB Blue Y

//!DEFAULT 0.0000

//!MIN -0.0100

//!MAX 0.0100

//!STEP 0.0001

float cfg_mb_by;

//!PARAMETER

//!LABEL BR Red X

//!DEFAULT 0.0000

//!MIN -0.0100

//!MAX 0.0100

//!STEP 0.0001

float cfg_br_rx;

//!PARAMETER

//!LABEL BR Red Y

//!DEFAULT 0.0000

//!MIN -0.0100

//!MAX 0.0100

//!STEP 0.0001

float cfg_br_ry;

//!PARAMETER

//!LABEL BR Blue X

//!DEFAULT 0.0000

//!MIN -0.0100

//!MAX 0.0100

//!STEP 0.0001

float cfg_br_bx;

//!PARAMETER

//!LABEL BR Blue Y

//!DEFAULT 0.0000

//!MIN -0.0100

//!MAX 0.0100

//!STEP 0.0001

float cfg_br_by;

//!TEXTURE

Texture2D INPUT;

//!TEXTURE

//!WIDTH INPUT_WIDTH

//!HEIGHT INPUT_HEIGHT

Texture2D OUTPUT;

//!SAMPLER

//!FILTER LINEAR

SamplerState SampleLinear;

//!PASS 1

//!STYLE PS

//!IN INPUT

//!OUT OUTPUT

float4 Pass1(float2 pos) {

float2 uvNorm = pos * 2.0 - 1.0;

float2 tlRed = float2(cfg_tl_rx, cfg_tl_ry);

float2 mtRed = float2(cfg_mt_rx, cfg_mt_ry);

float2 trRed = float2(cfg_tr_rx, cfg_tr_ry);

float2 tlBlue = float2(cfg_tl_bx, cfg_tl_by);

float2 mtBlue = float2(cfg_mt_bx, cfg_mt_by);

float2 trBlue = float2(cfg_tr_bx, cfg_tr_by);

float2 blRed = float2(cfg_bl_rx, cfg_bl_ry);

float2 mbRed = float2(cfg_mb_rx, cfg_mb_ry);

float2 brRed = float2(cfg_br_rx, cfg_br_ry);

float2 blBlue = float2(cfg_bl_bx, cfg_bl_by);

float2 mbBlue = float2(cfg_mb_bx, cfg_mb_by);

float2 brBlue = float2(cfg_br_bx, cfg_br_by);

float2 topRed = lerp(lerp(tlRed, mtRed, saturate(pos.x * 2.0)), trRed, saturate(pos.x * 2.0 - 1.0));

float2 bottomRed = lerp(lerp(blRed, mbRed, saturate(pos.x * 2.0)), brRed, saturate(pos.x * 2.0 - 1.0));

float2 rShift = lerp(topRed, bottomRed, pos.y);

float2 topBlue = lerp(lerp(tlBlue, mtBlue, saturate(pos.x * 2.0)), trBlue, saturate(pos.x * 2.0 - 1.0));

float2 bottomBlue = lerp(lerp(blBlue, mbBlue, saturate(pos.x * 2.0)), brBlue, saturate(pos.x * 2.0 - 1.0));

float2 bShift = lerp(topBlue, bottomBlue, pos.y);

float r = length(uvNorm);

float curve = pow(r, cfg_curve);

float2 r_offset = rShift * curve;

float2 b_offset = bShift * curve;

float2 r_uv = saturate(pos - r_offset);

float2 g_uv = pos;

float2 b_uv = saturate(pos - b_offset);

float r_col = INPUT.SampleLevel(SampleLinear, r_uv, 0).r;

float g_col = INPUT.SampleLevel(SampleLinear, g_uv, 0).g;

float b_col = INPUT.SampleLevel(SampleLinear, b_uv, 0).b;

float3 baseColor = float3(r_col, g_col, b_col);

float2 px = float2(0.0007, 0.0007);

float edgeMask = saturate(curve);

float activeSharp = cfg_sharp * edgeMask;

float r_n = INPUT.SampleLevel(SampleLinear, float2(r_uv.x, r_uv.y - px.y), 0).r;

float r_s = INPUT.SampleLevel(SampleLinear, float2(r_uv.x, r_uv.y + px.y), 0).r;

float r_e = INPUT.SampleLevel(SampleLinear, float2(r_uv.x + px.x, r_uv.y), 0).r;

float r_w = INPUT.SampleLevel(SampleLinear, float2(r_uv.x - px.x, r_uv.y), 0).r;

float r_contrast = (r_col * 4.0) - (r_n + r_s + r_e + r_w);

float g_n = INPUT.SampleLevel(SampleLinear, float2(g_uv.x, g_uv.y - px.y), 0).g;

float g_s = INPUT.SampleLevel(SampleLinear, float2(g_uv.x, g_uv.y + px.y), 0).g;

float g_e = INPUT.SampleLevel(SampleLinear, float2(g_uv.x + px.x, g_uv.y), 0).g;

float g_w = INPUT.SampleLevel(SampleLinear, float2(g_uv.x - px.x, g_uv.y), 0).g;

float g_contrast = (g_col * 4.0) - (g_n + g_s + g_e + g_w);

float b_n = INPUT.SampleLevel(SampleLinear, float2(b_uv.x, b_uv.y - px.y), 0).b;

float b_s = INPUT.SampleLevel(SampleLinear, float2(b_uv.x, b_uv.y + px.y), 0).b;

float b_e = INPUT.SampleLevel(SampleLinear, float2(b_uv.x + px.x, b_uv.y), 0).b;

float b_w = INPUT.SampleLevel(SampleLinear, float2(b_uv.x - px.x, b_uv.y), 0).b;

float b_contrast = (b_col * 4.0) - (b_n + b_s + b_e + b_w);

baseColor.r += (r_contrast * activeSharp);

baseColor.g += (g_contrast * activeSharp);

baseColor.b += (b_contrast * activeSharp);

return float4(baseColor, 1.0);

}

reddit.com
u/suka-blyat — 4 hours ago