tweaking into a detail adding super shader

This is for people involved in the developement of Snes9x, or SNES emulators in general.
Post Reply
Snes9x White Belt
Posts: 2
Joined: Wed Apr 20, 2016 2:16 pm

tweaking into a detail adding super shader

Post by pahakokki » Mon Jun 12, 2017 12:52 am

I modified some of the values in the retroarch shader mainly to have a more normal color scheme. Turns out this genius shader narrows the outlines and adds detail within pixels, making everything look more as if it was drawn in HD. It looks especially jaw dropping in Zelda with 6xBRZ setting on a 4k TV.

The only problem is the image is too dark so I need help from someone who can code to fix it. In fact someone should probably rewrite it for this purpose since I don't even know if editing even just the values is OK or not...?

Here is a picture of the problem/current status (left) and how it should look ideally (right). The right side has been manually shopped just to show you the possibilities. If you want to use this shader as it is then I suggest compensating the darkness with TV settings.


Is this perhaps a sensational discovery? Because I like it a lot.

Code: Select all

struct input
   float2 video_size;
   float2 texture_size;
   float2 output_size;
   float frame_count;
   float frame_direction;
   float frame_rotation;

struct vert_out
   float2 tex_direct;
   float2 tex_0;
   float2 tex_60;
   float2 tex_120;
   float2 tex_180;
   float2 tex_240;
   float2 tex_300;

void main_vertex
   float4 position : POSITION,
   out float4 oPosition : POSITION,
   uniform float4x4 modelViewProj,
   float2 tex : TEXCOORD0,
   uniform input IN,
   out vert_out verts: TEXCOORD1
   oPosition = mul(modelViewProj, position);
   float2 one = 1.1 / IN.texture_size;
   float angle = IN.frame_count = IN.frame_count / 60.0;
   float scale = 0.9 + 0.3 * sin(1.0 * angle);
   float2x2 rotate = scale * float2x2(
         cos(angle),   sin(angle),
         sin(angle),   cos(angle)

   verts.tex_direct = tex;
   verts.tex_0 = tex + one * mul(rotate, float2(1.0, 0.0));
   verts.tex_60 = tex + one * mul(rotate, float2(0.5, 0.7));
   verts.tex_120 = tex + one * mul(rotate, float2(-0.5, 0.7));
   verts.tex_180 = tex + one * mul(rotate, float2(-1.0, 0.0));
   verts.tex_240 = tex + one * mul(rotate, float2(-0.5, -0.7));
   verts.tex_300 = tex + one * mul(rotate, float2(0.5, -0.7));

float4 main_fragment (in vert_out verts : TEXCOORD1, uniform sampler2D s0 : TEXUNIT0) : COLOR
   float4 tex_mid = tex2D(s0, verts.tex_direct);
   float4 tex0 = tex2D(s0, verts.tex_0);
   float4 tex60 = tex2D(s0, verts.tex_60);
   float4 tex120 = tex2D(s0, verts.tex_120);
   float4 tex180 = tex2D(s0, verts.tex_180);
   float4 tex240 = tex2D(s0, verts.tex_240);
   float4 tex300 = tex2D(s0, verts.tex_300);

   float4 minimum = min(min(min(tex0, tex60), min(tex120, tex180)), min(tex240, tex300));
   float4 maximum = max(max(max(tex0, tex60), max(tex120, tex180)), max(tex240, tex300));
   float4 diff = 1.0 - exp(-(maximum - minimum));
   return lerp(tex_mid, diff, 0.6);

Post Reply