Overscan compensation?

Greetings.

I’m not really sure if this should be about shaders, so please let me know if it’s not.

I want a way to correct how integer-scaled images fit into the screen of a different aspect ration. For example, a 240x160 image is 3x2 and I want it to fit into a 640x480 screen in a following way. Here is my thought train:

  • Basic starting rule: integer scale by x3 to fit the screen.
  • Since it would be 720x480, vertical stripes of 40 pixels worth on each side would not fit the screen.
  • That sounds bad. But actually, it would mean that only ~14 real pixel stripes (because 40/3) are hidden from view on each side.
  • I’d still like them to be visible though. And I still don’t want to distort the whole picture.
  • So what if I’m willing to sacrifice a few more pixels to the left and to the right, in order to have those 14 pixels displayed, even if they will be distorted?
  • For example it would work like this: those 14 real pixels from both sides are squashed into 1x3 screen area on both sides, and since that would take 14 screen pixels by itself, we’d need to squash additional ~5 (14/3) real pixels.
  • Some adjustments can be made to sacrifice additional pixels to be squashed into 2x3 pixels as a small transition between the perfect picture at the center and squashed 1x3 pixels on the sides. But in the end, we might have a screen image that consists of the integer-scaled 3x picture by more than 90%, while still keeping all the visual information. This might be a much better option than an integer-scaled 2x picture with huge black bars.

And it doesn’t seem like anyone ever created this type of shader. If it is to be implemented as a shader, of course. I’d appreciate if someone can give an advice on where to look if I want to implement something like this.

Thanks.

I think a better solution would be to bend cylindrically the side borders (same size as the overscanned portions) so that all framebuffer fills up the screen.

2 Likes

the “anamorphic” shader does cylindrical stretching: https://github.com/libretro/slang-shaders/blob/master/anamorphic/shaders/anamorphic.slang

It was designed to go the other way (i.e., stretching 4:3 to 16:9) but it may already work to shrink, and if not, it should be easily adaptable.

1 Like

My device doesn’t support Vulkan. So far I failed at converting it into GLSL.

Yes, “bending cylindrically the side borders” sound very similar to what I’d like.