Last active
March 10, 2024 16:02
-
-
Save mariodivece/dab278f82ef3725b06001adec28ef92b to your computer and use it in GitHub Desktop.
A simple, configurable GLSL scanline effect shader for Dolphin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
[configuration] | |
[OptionRangeFloat] | |
GUIName = Blur Area | |
OptionName = BLUR_SIZE | |
MinValue = 0.0 | |
MaxValue = 10.0 | |
StepAmount = 0.1 | |
DefaultValue = 1.6 | |
[OptionRangeFloat] | |
GUIName = Scanline Alpha | |
OptionName = SEPARATOR_ALPHA | |
MinValue = 0.0 | |
MaxValue = 1.0 | |
StepAmount = 0.05 | |
DefaultValue = 0.15 | |
[OptionRangeFloat] | |
GUIName = Scanline Width | |
OptionName = SCANLINE_SIZE | |
MinValue = 0.0 | |
MaxValue = 64 | |
StepAmount = 0.1 | |
DefaultValue = 6.3 | |
[OptionRangeFloat] | |
GUIName = Brightness Boost | |
OptionName = BRIGHTNESS_BOOST | |
MinValue = 0.0 | |
MaxValue = 2.0 | |
StepAmount = 0.01 | |
DefaultValue = 1.25 | |
[/configuration] | |
*/ | |
void main() | |
{ | |
const float PI = 3.1415926535897932384626433832795; | |
float4 c0 = Sample(); | |
float blursize = GetOption(BLUR_SIZE); | |
float subtleLevel = GetOption(SEPARATOR_ALPHA); // 0 is very dark separator, 1 is no separator | |
float scanlineSize = GetOption(SCANLINE_SIZE); | |
float boost = GetOption(BRIGHTNESS_BOOST); | |
//blur | |
float4 blurtotal = float4(0.0, 0.0, 0.0, 0.0); | |
blurtotal += SampleLocation(GetCoordinates() + float2(-blursize, -blursize) * GetInvResolution()); | |
blurtotal += SampleLocation(GetCoordinates() + float2(-blursize, blursize) * GetInvResolution()); | |
blurtotal += SampleLocation(GetCoordinates() + float2( blursize, -blursize) * GetInvResolution()); | |
blurtotal += SampleLocation(GetCoordinates() + float2( blursize, blursize) * GetInvResolution()); | |
blurtotal += SampleLocation(GetCoordinates() + float2(-blursize, 0.0) * GetInvResolution()); | |
blurtotal += SampleLocation(GetCoordinates() + float2( blursize, 0.0) * GetInvResolution()); | |
blurtotal += SampleLocation(GetCoordinates() + float2( 0.0, -blursize) * GetInvResolution()); | |
blurtotal += SampleLocation(GetCoordinates() + float2( 0.0, blursize) * GetInvResolution()); | |
blurtotal *= 0.125; | |
c0 = blurtotal; | |
// get color factor intensity based on vertical pixel position | |
// coordinates are 0 to 1 while resolution is a pixel resolution | |
float vPos = GetCoordinates().y * GetWindowResolution().y; | |
float lineIntensity = subtleLevel + abs(cos(PI / scanlineSize * vPos)); | |
// output | |
SetOutput(c0 * clamp(lineIntensity, 0.0, 1.125) * boost); | |
} |
This is amazing! Thank you for making it! It's really improved my immersion playing Resident Evil 2 :)
Works great! 👍
Thank you!
Hi @mariodivece , I also would prefer no flicker so came to get this one. However, while the other one shows the scanlines nice and thin like I expected, this one with default settings shows them way too big:
What values should I configure the second one to match the first?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey guy, nice shader, i'm using duckstation emulator and this shade works normally, through the other scanline you made not. Can you make another shader, or its impossible? Using these same codes... I want some shaders which work with Duckstation like this above. If you need sugestion, the bad bloom is one which works too with duckstation.
RTX ON, Ultra Realistic is 2 shaders which i liked but half of the code not work...