2026-09-04 22:45:02 -04:00
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2012 PPSSPP Project
// SPDX-License-Identifier: GPL-2.0-or-later
// Ported from scanlines.fsh in PPSSPP.
texture BackBufferTex : COLOR ;
sampler BackBuffer { Texture = BackBufferTex ; } ;
uniform float Density <
ui_type = " slider " ;
ui_label = " Line Density " ;
ui_tooltip = " Number of scanline pairs across the screen. " ;
ui_min = 60.0 ; ui_max = 720.0 ; ui_step = 10.0 ;
> = 340.0 ;
uniform float Intensity <
ui_type = " slider " ;
ui_label = " Intensity " ;
ui_tooltip = " How dark the gaps between lines become. " ;
ui_min = 0.0 ; ui_max = 1.0 ; ui_step = 0.05 ;
> = 0.5 ;
uniform float Tint <
ui_type = " slider " ;
ui_label = " Phosphor Tint " ;
ui_tooltip = " Strength of the green-warm phosphor cast. " ;
ui_min = 0.0 ; ui_max = 1.0 ; ui_step = 0.05 ;
> = 1.0 ;
void VS_PostProcess ( in uint id : SV_VertexID , out float4 pos : SV_Position , out float2 uv : TEXCOORD )
{
2026-09-08 04:18:37 -04:00
uv = float2 ( float ( id & 2 ) , float ( ( id & 1 ) << 1 ) ) ;
2026-09-04 22:45:02 -04:00
pos = float4 ( uv * float2 ( 2.0 , - 2.0 ) + float2 ( - 1.0 , 1.0 ) , 0.0 , 1.0 ) ;
}
float4 PS_Scanlines ( float4 pos : SV_Position , float2 uv : TEXCOORD ) : SV_Target
{
float line_pos = uv . y * Density * 0.5 ;
float gate = cos ( ( frac ( line_pos ) - 0.5 ) * 3.1415926 * Intensity ) * 1.5 ;
float3 rgb = tex2D ( BackBuffer , uv ) . rgb ;
float3 color = rgb * 0.5 + 0.5 * rgb * rgb * 1.2 ;
float3 phosphor = lerp ( float3 ( 1.0 , 1.0 , 1.0 ) , float3 ( 0.9 , 1.0 , 0.7 ) , Tint ) ;
color * = phosphor ;
float2 diff = uv - 0.5 ;
color * = 1.1 - 0.6 * ( dot ( diff , diff ) * 2.0 ) ;
return float4 ( saturate ( color * saturate ( gate ) ) , 1.0 ) ;
}
2026-09-07 17:58:46 -04:00
technique Scanlines <
ui_label = " Scanlines " ;
2026-09-08 22:03:50 -04:00
ui_tooltip = " Darkens alternating rows of pixels to imitate the horizontal scanlines of a CRT. Cheaper than the full CRT effect when you only want the lines. " ;
2026-09-07 17:58:46 -04:00
>
2026-09-04 22:45:02 -04:00
{
pass
{
VertexShader = VS_PostProcess ;
PixelShader = PS_Scanlines ;
}
}