Shader for use with DeSmuME hybrid layout

I just used the DeSmuME core for the first time and fell instantly in love with the hybrid screen layout mode. I couldn’t find any shaders that worked with it, however, so I made a quick edit to the standard ‘zfast_lcd’ shader for compatibility (this is my absolute favourite shader for all handheld systems!). It works fairly well, so I thought I’d share:

The zip file contains two presets:

1 - zfast_lcd_nds_hybrid.glslp

This applies the nearest neighbour scaling + grid effect of zfast_lcd to the main NDS screen, and simple linear filtering to the dual screen hybrid section. It also improves the visibility of the mouse cursor when shown on the main NDS screen.

2 - zfast_lcd_nds_hybrid+nds-color.glslp

This does the same as 1, but includes a first pass of the standard ‘nds-color’ shader.

To use these shaders, you’ll need to set the following DeSmuME core options:

  • Internal resolution must be native (256x192)

  • Screen layout must be ‘hybrid/top’ or ‘hybrid/bottom’

  • ‘Hybrid Layout: Scale’ must be ‘3’

And here are a few random screenshots of ‘zfast_lcd_nds_hybrid+nds-color’ in action:

I hope someone finds this useful… :smiley:


I have the same issue, that shaders do not work with desmume. I would like to apply scalefx to improve the visuals of 2D games. But it is not working

Btw great images

A tiny update…

I made a new version of the zfast_lcd_nds_hybrid/zfast_lcd_nds_hybrid+nds-color shaders that work with any internal resolution setting. You can get a copy here:

As with the old shaders, they look best with purely 2D games running at native resolution, but they work quite well with mixed 2D/3D content in ‘high definition’ - for example:

(These were taken using the zfast_lcd_nds_hybrid_hd+nds-color.glslp shader)

1 Like

I did something crazy. It’s a shader that uses a bilinear blur on the big image when using hybrid x3 that makes it look like it was scaled from the original size. This way you can have the full resolution small screen while not having an ultra-sharp big screen.



Yep, I’m a psychopath.


Cool shader jdgleaver is there a way to easily switch between top and bottom for those games that switch all the time?

Edit: Derp, never mind :smiley:

Hi @jdgleaver,

Great work with your zfast_lcd modiffication. I wonder if you would be able to make a similar modification for crt-royale. I love crt-royale and I’m unable to apply it for NDS hybrid screen.

Besides that, would you do a similar modification for slang shaders? I use vulkjan and it uses slang instead of glgl.


Thanks very much for the shader @jdgleaver.

I’m having some trouble getting the grid to look uniform on my iPhone screen, see screenshot.

I have integer scaling on, running at 2046x1152 px. Any advice?

It looks awesome in those screenshots! Thanks for sharing.

I just tested your hybrid shader and this is my result, unfortunately :frowning_face:

Somehow the screen gets scaled down. I use the native DS resolution and my display resolution is 1366x768. The standard zfast_lcd works as intended:

Is there possibly an easy fix I can do to the glsl file? I glanced over it, but with very little coding experience I can’t figure it out.

Edit: I found the solution. You have to turn on the option “Hybrid: Scale So Small Screen is 1:1px” for the shader to work properly:

1 Like

I don’t know what I’m doing wrong. I set the aspect ratio to custom 1366x768 but the grid still looks uneven. If I set aspect ratio to core provided, or config, or PAR 341x192, integer scaling on or off, best I can get is the screenshot in my above post. Would anyone mind sharing some advice?

Hm my guess is that it might be caused by the on-screen overlay or the aspect ratio of your phone (which is 19.5:9). jdgleaver’s shader might be optimized for 16:9 displays.

Try to turn off the OSD to check if it does anything to improve the grid: Quick Menu > On Screen Overlay > Display Overlay

Maybe also try to turn on this option: “Hybrid: Scale So Small Screen is 1:1px” It helped in my case (1366x768 display).

What about if you turn off integer scaling and just leave the aspect ratio at “core provided”?

1 Like

Thanks for the suggestions @Ortega, but still no luck after testing with those changes.

I’ve been doing some research on why I’m having issues with my device. It looks like the shader is affected by both the aspect ratio and the resolution, just from random tests I’ve been doing on my iPhone. So I tried to figure out the maximum custom resolution I could set in Retroarch on my iPhone without losing the weird aspect ratio that results from Desmume’s hybrid layout.

An iPhone X has a resolution of 2436 x 1125 pixels and renders images at a scale of 3x (iOS Device Compatibility Reference). It looks like Retroarch uses a ‘safe area’ that avoids the screen’s curves, notch, and iOS UI etc. According to this, that safe area resolution (landscape) should be 2172 x 1062 pixels:

2436 − 3*(44 + 44) = 2172px width
1125 − 3*(21) = 1062px height

Values I found by opening the Retroarch xcode project in xcode verifies that as well.

So, if 2172 x 1062 px is the max res I can work with, what custom resolution should I set to keep Desmume’s hybrid layout aspect ratio? Desmume has an internal resolution of 256 x 192 pixels, according to the core options and to jdgleaver’s shader. So if I set the core options to hybrid layout 3:1, like the shader says I’m supposed to do, then that’d be a resolution/aspect ratio of 341.33 x 192 pixels:

256*(4/3) = 341.333333333333px width
192px height (Im pretty sure height stays the same)

If I scale that aspect ratio up, by multiples of 3 to get rid of the decimals, which I assume do not play nicely with the shader, the largest I can get before going outside the safe area is 1024 x 576 px (i.e. 341.33:192*3). Scaling it up 6 times (341.33:192*6) gives 2048 x 1152 px, which is taller than the safe area but it looks ok even though it overlaps with the ‘swipe-up-bar’ at the bottom of the screen. But with both, the shader doesn’t look even or uniform:

1024 x 576 px

2048 x 1152 px

I noticed that in Retroarch settings video > scaling > aspect ratio, Desmume’s DAR (default aspect ratio) is shown as 341:192, so I tried dropping the 0.333333 decimals completely. Largest res I can get in the safe area is 1705 x 960 px (or 2046 x 1152 px, like in the screenshot in my first post above, if I let the image overlap with the iOS UI at the bottom). Still, neither has a uniform grid:

1705 x 960 px

2046 x 1152 px

So, I’m not really sure what to do. I’ve looked at tweaking the shader settings in the .glslp preset file, but nothing seems to work really. I’ve been playing with adding settings like scale_type, but I still can’t get it right:

shaders = "1"
shader0 = "shaders/zfast_lcd_nds_hybrid_hd.glsl"
filter_linear0 = "true"
wrap_mode0 = "clamp_to_border"
mipmap_input0 = "false"
alias0 = ""
float_framebuffer0 = "false"
srgb_framebuffer0 = "false"
parameters = "BORDERMULT"

scale_type_y0 = "source"
scale_y0 = "3"
scale_type_x0 = "source"
scale_x0 = "3"

Any further insights or advice welcome.

Sorry for bumping up an old thread. Great work on making the zfast shader work with hybrid layout!

Could you teach me how to do this with scalefx shader? I’m using scalefx-aa shader in the preset folder. It works if I use top/bottom (bottom/top) or left/right (right/left) or top (bottom) hybrid layout. But if I use any hybrid layout and set the scale so small 1:1, the shader no longer works.

Here is what I mean: a) Use top/bottom with scalefx-aa shader:

b) Use hybrid top with scalefx-aa shader:

As you can see in this layout, the shader stopped working.

c) Continue on (b). If I set the scale so small 1:1 to be off, the main screen view works, but the small screen is no longer viewable: