Handheld Border Shaders

I managed to make the dmg-2x preset work up the the 5th pass by removing the code responsible for the motion blur in the first pass, but of course it is very slow. Can you describe what each pass does ? A Pi version, if feasible, would require to remove lots of options.

first pass sets up the integer scaling, does the motion blur and sets up the pixel grid. The second pass does some blurring of the pixels, passes 3 and 4 do gaussian blurring of the image for making the shadow effect and pass 5 puts them all together. You could probably hack out passes 2, 3 and 4.

How exactly do I add motion blur to the GBA shaders? I managed to actually add it, but for some reason, no matter where I position it within the GBA border .cgp config (GBA-standard-4x.cgp, in this case), it cancels out the color correction. The motion blur .cg I’m using is as follows:

struct previous
{
   uniform sampler2D texture;
   float2 tex_coord;
};


struct input
{
    float2 video_size;
    float2 texture_size;
    float2 output_size;
    float frame_count;
    float frame_direction;
    float frame_rotation;
    sampler2D texture : TEXUNIT0;
};


struct tex_coords
{
   float2 tex;
   float2 prev;
   float2 prev1;
   float2 prev2;
   float2 prev3;
   float2 prev4;
   float2 prev5;
   float2 prev6;
};


void main_vertex
(
   float4 position : POSITION,
   out float4 oPosition : POSITION,
   uniform float4x4 modelViewProj,
   float2 tex : TEXCOORD,


   previous PREV,
   previous PREV1,
   previous PREV2,
   previous PREV3,
   previous PREV4,
   previous PREV5,
   previous PREV6,
   out tex_coords coords
)
{
   oPosition = mul(modelViewProj, position);
   coords = tex_coords(tex, PREV.tex_coord,
      PREV1.tex_coord,
      PREV2.tex_coord,
      PREV3.tex_coord,
      PREV4.tex_coord,
      PREV5.tex_coord,
      PREV6.tex_coord);
}


struct output 
{
  float4 col    : COLOR;
};


output main_fragment(tex_coords coords,
uniform input IN,
      previous PREV,
      previous PREV1,
      previous PREV2,
      previous PREV3,
      previous PREV4,
      previous PREV5,
      previous PREV6
)
{
   float4 color = tex2D(PREV6.texture, coords.prev6);
   color = (color + tex2D(PREV5.texture, coords.prev5)) / 2.0;
   color = (color + tex2D(PREV4.texture, coords.prev4)) / 2.0;
   color = (color + tex2D(PREV3.texture, coords.prev3)) / 2.0;
   color = (color + tex2D(PREV2.texture, coords.prev2)) / 2.0;
   color = (color + tex2D(PREV1.texture, coords.prev1)) / 2.0;
   color = (color + tex2D(PREV.texture, coords.prev)) / 2.0;
   color = (color + tex2D(IN.texture, coords.tex)) / 2.0;




   output OUT;
   OUT.col = color;
   return OUT;
}


By the way, any chance of a white GBA version for the overlay?

[QUOTE=DuoDynamo;47027]By the way, any chance of a white GBA version for the overlay? [/QUOTE] I can’t find a white one at the moment but there is a whitish, transparent purple one here.

You’ve got the “Platinum” version SixWingedFreak made from BlueAmnesiac picture here that would be the closest to a white model.

No clue about motion-blur, I’m not using it.

You can try using the feedback shader, like I just added to the slang version:

[QUOTE=hunterk;47032]You can try using the feedback shader, like I just added to the slang version: https://github.com/libretro/slang-shaders/blob/master/handheld/console-border/gba-4x.slangp[/QUOTE] Tried it, but the same thing happens. Either I have motion blur, or I have color correction.

I’m not an expert on this, but there’s something about color on the float4 value in the motion blur .cg file (in my previous post). Can it be that it’s canceling out the color correction from the other passes?

I think the problem is that the non-feedback motion blur shaders sample previous unfiltered frames (i.e., no color correction). The feedback shader samples a previous filtered frame (i.e., with the color correction applied). However, I forgot that the Cg feedback needs something added to the preset that slang does not. Here’s what it should look like:

shaders = "4"

shader0 = "../../motionblur/shaders/feedback.cg"
scale_type0 = source
scale0 = 1.0
filter_linear0 = false
feedback_pass = 0

shader1 = "../shaders/color/gba-color.cg
filter_linear1 = false

shader2 = "../shaders/lcd_cgwg/lcd-grid.cg"
filter_linear2 = "false"
wrap_mode2 = "clamp_to_border"
scale_type_x2 = "source"
scale_x2 = "4.000000"
scale_type_y2 = "source"
scale_y2 = "4.000000"

shader3 = "shader-files/gb-pass-5.cg"
filter_linear3 = "true"
wrap_mode3 = "clamp_to_border"

parameters = "SCALE;OUT_X;OUT_Y;GRID_STRENGTH;mixfactor"
GRID_STRENGTH = "0.150000"
SCALE = "1.0"
OUT_X = "3200.0"
OUT_Y = "1600.0"
mixfactor = "0.50"

textures = "BORDER"
BORDER = "resources/gba-border-square-4x.png"
BORDER_linear = "true"
BORDER_wrap_mode = "clamp_to_border"
BORDER_mipmap = "false"

EDIT: well, maybe not because this one–using motionblur-simple–seems to work fine for me, too:

shaders = "4"

shader0 = "../../motionblur/shaders/motionblur-simple.cg"
scale_type0 = source
scale0 = 1.0
filter_linear0 = false

shader1 = "../shaders/color/gba-color.cg
filter_linear1 = false

shader2 = "../shaders/lcd_cgwg/lcd-grid.cg"
filter_linear2 = "false"
wrap_mode2 = "clamp_to_border"
scale_type_x2 = "source"
scale_x2 = "4.000000"
scale_type_y2 = "source"
scale_y2 = "4.000000"

shader3 = "shader-files/gb-pass-5.cg"
filter_linear3 = "true"
wrap_mode3 = "clamp_to_border"

parameters = "SCALE;OUT_X;OUT_Y;GRID_STRENGTH;mixfactor"
GRID_STRENGTH = "0.150000"
SCALE = "1.0"
OUT_X = "3200.0"
OUT_Y = "1600.0"
mixfactor = "0.50"

textures = "BORDER"
BORDER = "resources/gba-border-square-4x.png"
BORDER_linear = "true"
BORDER_wrap_mode = "clamp_to_border"
BORDER_mipmap = "false"

I don’t know what I did, but when I tried to use this code, well… this happened.


In any case, I managed to make it work. I used this preset and inserted the GBA border in it.

I’ll try to figure out what I did wrong with your code though.

Thanks for the assistance :slight_smile:


EDIT: I figured it out. Apparently, there was something wrong with the gba-color.cg file I was using. I swapped it for the one contained in “shaders_cg\handheld\shaders\color” and it worked like a charm.

Again, thank you!


[B]–FINAL EDIT–: I figured out the source of the whole problem. Turns out it all goes back to my utter lack of knowledge on how to edit .cgp files.

I didn’t change the numbers on the parameters when I added a new pass so that they would actually correlate to the shaders.

In other words, I changed shader0 to shader1, but didn’t change alias0 to alias1, scale_x0 to scale_x1, and so on. After fixing this, I was able to successfully add a motion blur pass to OP’s .cgp files.[/B]

Borders with background pictures made by damageinc86: The mega link is down.

Thanks!! All of you did a great job with these shaders.

Glad you like them.

I’ll remove the link as I don’t have a copy for those.

Would it be possible to convert GBA-LUT to slang? I love the way it looks but sadly it doesn’t seem to work with Vulkan.

You would have to ask the author of this shader in his thread:

I’m not able to convert those shaders myself. I tried making a glsl/vulkan version but ran into issues with several of the converted ones.

Hi!

Thank you for these great Handheld Shaders. Is there a way to disable the screen glare? I find this effect very distracting while playing.

You’ll have to erase it on the png picture.

I don´t see that effect on the GBA PNG.

edit: Just found it

I’ve just installed and set these shaders and I’ve gotta say that they look pretty nice! There are a few problems that I’d like to point out, though:

  • The somewhat muted colors on the LCD grid shaders are a bit of a problem for games whose palettes were built around the backlit GBA SP or the DS, such as Kirby and the Amazing Mirror.

  • The DS shaders seem to be scaled pretty oddly on my monitor compared to the other shaders (I have a 15.6’’ Dell Inspiron 15 laptop). To be more specific, using the 4x variants cause the image to clip past what my monitor is capable of displaying, meaning I can only see half of each screen, while the 2x and 3x variants position the screens in such a way that the middle of the DS border cuts through them (the two video feeds appear to be oriented in such a way that they are directly adjacent with each other, similarly to how they are oriented with the standard LCD shader).

  • For some reason the Game Gear shaders make RetroArch slow down significantly, both in the RGUI and when playing a game (I assume this is due to the graphics for the Game Gear border being uncompressed); I haven’t seen this issue with the WonderSwan shaders or the Neo Geo Pocket Color ones because I haven’t installed any games to use them with yet.

Aside from these issues, I’m mostly satisfied with how these shaders look on my computer. Keep up the good work!

For the DS shader, there should be a core option to increase the separation between the two images to fit the border better.

Dunno about the game gear slowdown. I haven’t noticed any issues with it but I also haven’t used it much.

You’re probably using a particular resolution (768p for that Dell?). I could only test with my 1080p screen here.

The only particular thing the Game Gear shader does is stretching the horizontal resolution by 1.2 as the pixels aren’t square. Not sure if that’s enough to make a difference and if you need to force performance in your Video drivers or energy profiles.

Alright, I’ve finally gotten around to following your suggestion and it’s worked like a charm! There is some apparent overscan with New Super Mario Bros. and Mario Kart DS, but they’re just minor problems that don’t bug me too much.

I still haven’t figured out why the Game Bear borders slow down RetroArch so badly for me or how to fix the problem; for now, I’ll just have to make do with other shaders.