• Login
  • Register
  • Dolphin Forums
  • Home
  • FAQ
  • Download
  • Wiki
  • Code


Dolphin, the GameCube and Wii emulator - Forums › Dolphin Emulator Discussion and Support › General Discussion v
« Previous 1 2 3 4 5 ... 368 Next »

Zoom widescreen shader for letterboxed GC games (like Resident Evil 4)
View New Posts | View Today's Posts

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Thread Modes
Zoom widescreen shader for letterboxed GC games (like Resident Evil 4)
01-17-2019, 05:21 PM (This post was last modified: 01-17-2019, 05:23 PM by Derek.)
#1
Derek Offline
Junior Member
**
Posts: 18
Threads: 8
Joined: Feb 2015
There are a few gamecube games like, Resident Evil 4, that play in 16:9 with letter boxing to fill out the 4:3 screen. I was playing Resident Evil 4 again today and was disappointed that Dolphin doesn't have an option to zoom the image to fill my monitor, and I couldn't find any solution online. So I wrote a post-processing shader to help with this. Maybe some day Dolphin will support this effect natively, but until then this is a quick and easy solution!

Just copy and paste the code below into a .gsl file in your "Dolphin Emulator/Shaders" folder, then enable the shader under Graphics > Enhancements > Post-Processing Effects (it will be called whatever you named the file).

Code:
// For games that are 16:9 and letterboxed to fit a 4:3 screen, this shader will
// help by zooming the image in to fill a widescreen monitor.
//
// To use, set the aspect ratio to force 16:9 in the graphics option, then
// enable this shader in Post-Processing Effects.

void main() {
    float2 coords = GetCoordinates() - float2(0.5, 0.5);
    float2 new_coords = float2(coords.x, coords.y*3/4);
    float2 sample_coords = new_coords + float2(0.5, 0.5);
    SetOutput(SampleLocation(sample_coords));
}

The way this works is by simply stretching the image along the vertical axis. Forcing 16:9 aspect ratio in the Dolphin settings will stretch the image horizontally, so as long as the vertical stretch matches the horizontal stretch the original aspect ratio will be preserved, and the image will fill the screen horizontally.

I'm sure there's room for improvement, but this was simple and worked.

Comparison screenshots.
Find
Reply
01-17-2019, 11:12 PM
#2
DrHouse64 Offline
A woman yet a man, a man yet a woman
****
Posts: 343
Threads: 18
Joined: Jun 2013
Really nice sir, thank you.
I would rather have a game hack that fix this issue internally to use it on real hardware and avoid scaling artefacts but this is a good universal workaround.

btw I was wondering if RE4 was taking advantage of the letterbox by running the game on a lower vertical resolution, saving performance, or if it's running on the standard resolution and then letterboxed by post-processing.
From France with love.
Laptop ROG : W10 / Ryzen 7 4800HS @2.9 GHz (4.2 GHz Turbo disabled unless necessary for better thermals) / 16 Go DDR4 / RTX 2060 MaxQ (6 Go GDDR6)
Find
Reply
01-09-2022, 01:32 AM
#3
Iron2004 Offline
Junior Member
**
Posts: 1
Threads: 0
Joined: Jan 2022
(01-17-2019, 05:21 PM)Derek Wrote: There are a few gamecube games like, Resident Evil 4, that play in 16:9 with letter boxing to fill out the 4:3 screen. I was playing Resident Evil 4 again today and was disappointed that Dolphin doesn't have an option to zoom the image to fill my monitor, and I couldn't find any solution online. So I wrote a post-processing shader to help with this. Maybe some day Dolphin will support this effect natively, but until then this is a quick and easy solution!

Just copy and paste the code below into a .gsl file in your "Dolphin Emulator/Shaders" folder, then enable the shader under Graphics > Enhancements > Post-Processing Effects (it will be called whatever you named the file).


Code:
// For games that are 16:9 and letterboxed to fit a 4:3 screen, this shader will
// help by zooming the image in to fill a widescreen monitor.
//
// To use, set the aspect ratio to force 16:9 in the graphics option, then
// enable this shader in Post-Processing Effects.

void main() {
float2 coords = GetCoordinates() - float2(0.5, 0.5);
float2 new_coords = float2(coords.x, coords.y*3/4);
float2 sample_coords = new_coords + float2(0.5, 0.5);
SetOutput(SampleLocation(sample_coords));
}

The way this works is by simply stretching the image along the vertical axis. Forcing 16:9 aspect ratio in the Dolphin settings will stretch the image horizontally, so as long as the vertical stretch matches the horizontal stretch the original aspect ratio will be preserved, and the image will fill the screen horizontally.

I'm sure there's room for improvement, but this was simple and worked.

Comparison screenshots.

Well I suppose this is just because I'm using the android version of the dolphin. There is black borders in resident evil 4. I have tried what u wrote down there but it didn't work out.


Attached Files Thumbnail(s)
   
Find
Reply
05-12-2022, 06:41 AM
#4
tysard Offline
Junior Member
**
Posts: 1
Threads: 0
Joined: May 2022
(01-09-2022, 01:32 AM)Iron2004 Wrote: Well I suppose this is just because I'm using the android version of the dolphin. There is black borders in resident evil 4. I have tried what u wrote down there but it didn't work out.

Hello! This thread was the first result on Google when I was trying to find a solution to the letterboxing problem.
I'm also on android and got the same error as you but I fixed it by changing all the values in the code to floats and it seems to work now so I've made an account just to share this information. 

First of all, if anyone stumbles upon this looking for a solution and happens to be on mobile, the file goes in the following location:


\Android\data\org.dolphinemu.dolphinemu\files\Shaders

It should also be noted that it need to be a glsl file and not a gsl file as previously mentioned.

Here's the updated code:


Code:
void main()
{
   float2 coords = GetCoordinates() - float2(0.5f, 0.5f);
   float2 new_coords = float2(coords.x, coords.y*3.0f/4.0f);
   float2 sample_coords = new_coords + float2(0.5f, 0.5f);
   SetOutput(SampleLocation(sample_coords));
}

Best of luck!
Find
Reply
01-13-2023, 02:00 PM
#5
sh5dc Offline
Junior Member
**
Posts: 6
Threads: 1
Joined: Jan 2023
(05-12-2022, 06:41 AM)tysard Wrote: Hello! This thread was the first result on Google when I was trying to find a solution to the letterboxing problem.
I'm also on android and got the same error as you but I fixed it by changing all the values in the code to floats and it seems to work now so I've made an account just to share this information. 

First of all, if anyone stumbles upon this looking for a solution and happens to be on mobile, the file goes in the following location:


\Android\data\org.dolphinemu.dolphinemu\files\Shaders

It should also be noted that it need to be a glsl file and not a gsl file as previously mentioned.

Here's the updated code:





Code:
void main()
{
   float2 coords = GetCoordinates() - float2(0.5f, 0.5f);
   float2 new_coords = float2(coords.x, coords.y*3.0f/4.0f);
   float2 sample_coords = new_coords + float2(0.5f, 0.5f);
   SetOutput(SampleLocation(sample_coords));
}

Best of luck!
hi sorry for bump

but any chance you could help rewrite this aethersx2 shader cas.glsl file to dolphin 's glsl format?

this is best crt shader
Contrast Adaptive Sharpening  (cas shapeness shader) any chance add it  to dolphin android? aethersx did it on 1/1/2023 before shutdown it make game at 1x res look like on real crt tv from year 2000.....
swear to god no other crt shader can beat this Contrast Adaptive Sharpening

https://abload.de/img/residentevil4-crtllit9.jpg
[Image: residentevil4-crtllit9.jpg]
Find
Reply
01-13-2023, 02:01 PM
#6
sh5dc Offline
Junior Member
**
Posts: 6
Threads: 1
Joined: Jan 2023
// Based on CAS_Shader.glsl
// Copyright© 2019 Advanced Micro Devices, Inc.All rights reserved.
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files(the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions :
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

uniform uvec4 const0;
uniform uvec4 const1;
uniform ivec2 srcOffset;

layout(binding=0) uniform sampler2D imgSrc;
layout(binding=0, rgba8) uniform writeonly image2D imgDst;

#define A_GPU 1
#define A_GLSL 1

#include "ffx_a.h"

AF3 CasLoad(ASU2 p)
{
return texelFetch(imgSrc, srcOffset + ivec2(p), 0).rgb;
}

// Lets you transform input from the load into a linear color space between 0 and 1. See ffx_cas.h
// In this case, our input is already linear and between 0 and 1
void CasInput(inout AF1 r, inout AF1 g, inout AF1 b) {}

#include "ffx_cas.h"

layout(local_size_x=64) in;
void main()
{
// Do remapping of local xy in workgroup for a more PS-like swizzle pattern.
AU2 gxy = ARmp8x8(gl_LocalInvocationID.x)+AU2(gl_WorkGroupID.x<<4u,gl_WorkGroupID.y<<4u);

// Filter.
AF4 c;
CasFilter(c.r, c.g, c.b, gxy, const0, const1, CAS_SHARPEN_ONLY);
imageStore(imgDst, ASU2(gxy), c);
gxy.x += 8u;

CasFilter(c.r, c.g, c.b, gxy, const0, const1, CAS_SHARPEN_ONLY);
imageStore(imgDst, ASU2(gxy), c);
gxy.y += 8u;

CasFilter(c.r, c.g, c.b, gxy, const0, const1, CAS_SHARPEN_ONLY);
imageStore(imgDst, ASU2(gxy), c);
gxy.x -= 8u;

CasFilter(c.r, c.g, c.b, gxy, const0, const1, CAS_SHARPEN_ONLY);
imageStore(imgDst, ASU2(gxy), c);
}
Find
Reply
01-13-2023, 07:46 PM
#7
sh5dc Offline
Junior Member
**
Posts: 6
Threads: 1
Joined: Jan 2023
here is aethersx2 shader glsl file from apk package


Attached Files
.zip   shaders.zip (Size: 413.73 KB / Downloads: 17)
Find
Reply
« Next Oldest | Next Newest »


  • View a Printable Version
  • Subscribe to this thread
Forum Jump:


Users browsing this thread: 1 Guest(s)



Powered By MyBB | Theme by Fragma

Linear Mode
Threaded Mode