mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-09-10 14:07:25 +00:00
ed566919f4
Very self-explanatory; implementation of the feature for post-processing shaders for Android (at least for now); will allow users to enhance the graphic quality of video games based on the use of multiple shaders adjustable, presets and more, inspired on the PPSSPP implementation, this feature adds 22 customizable shaders (1 pass) that lives on the overlay of the screen, which means that aside of the capability to chain multiple shaders on the screen, this doesn't have depths (pixel/ depth z-buffer) so it ensures the performance with it's use. Few shaders were a faithful port from PPSSPP with their respective attribution on the shader headers for their respective owners; and there are adaptations from public references/ cinematographic (Anime4K) and the rest are my own addition. _Special Credits:_ 1.- PPSSPP Team for their contribution on the public references for shaders: Henrik Rydgard, ShadX, SimoneT, KillaMaaki and guest(r). 2.- Niklas Haas. 3.- bloc97. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4348 Reviewed-by: lizzie <lizzie@eden-emu.dev> Reviewed-by: Maufeat <sahyno1996@gmail.com>
80 lines
2.8 KiB
HLSL
80 lines
2.8 KiB
HLSL
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
// SPDX-FileCopyrightText: Copyright 2012 PPSSPP Project
|
|
// SPDX-FileCopyrightText: guest(r)
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
// Ported from cartoon.fsh in PPSSPP, Advanced Cartoon shader I by guest(r).
|
|
|
|
texture BackBufferTex : COLOR;
|
|
sampler BackBuffer { Texture = BackBufferTex; };
|
|
|
|
uniform float EdgeStrength <
|
|
ui_type = "slider";
|
|
ui_label = "Edge Strength";
|
|
ui_tooltip = "Darkness of the ink outline drawn around detected edges.";
|
|
ui_min = 0.0; ui_max = 2.0; ui_step = 0.05;
|
|
> = 0.5;
|
|
|
|
uniform float Levels <
|
|
ui_type = "slider";
|
|
ui_label = "Colour Levels";
|
|
ui_tooltip = "How many bands the colours are quantised into.";
|
|
ui_min = 2.0; ui_max = 16.0; ui_step = 1.0;
|
|
> = 4.0;
|
|
|
|
void VS_PostProcess(in uint id : SV_VertexID, out float4 pos : SV_Position, out float2 uv : TEXCOORD)
|
|
{
|
|
uv = float2(float(id & 2), float((id & 1) << 1));
|
|
pos = float4(uv * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
|
|
}
|
|
|
|
float4 PS_Cartoon(float4 pos : SV_Position, float2 uv : TEXCOORD) : SV_Target
|
|
{
|
|
float2 texel = float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT);
|
|
|
|
float3 c00 = tex2D(BackBuffer, uv + texel * float2(-1.0, -1.0)).rgb;
|
|
float3 c10 = tex2D(BackBuffer, uv + texel * float2( 0.0, -1.0)).rgb;
|
|
float3 c20 = tex2D(BackBuffer, uv + texel * float2( 1.0, -1.0)).rgb;
|
|
float3 c01 = tex2D(BackBuffer, uv + texel * float2(-1.0, 0.0)).rgb;
|
|
float3 c11 = tex2D(BackBuffer, uv).rgb;
|
|
float3 c21 = tex2D(BackBuffer, uv + texel * float2( 1.0, 0.0)).rgb;
|
|
float3 c02 = tex2D(BackBuffer, uv + texel * float2(-1.0, 1.0)).rgb;
|
|
float3 c12 = tex2D(BackBuffer, uv + texel * float2( 0.0, 1.0)).rgb;
|
|
float3 c22 = tex2D(BackBuffer, uv + texel * float2( 1.0, 1.0)).rgb;
|
|
|
|
const float3 dt = float3(1.0, 1.0, 1.0);
|
|
|
|
float d1 = dot(abs(c00 - c22), dt);
|
|
float d2 = dot(abs(c20 - c02), dt);
|
|
float hl = dot(abs(c01 - c21), dt);
|
|
float vl = dot(abs(c10 - c12), dt);
|
|
float edge = EdgeStrength * (d1 + d2 + hl + vl) / (dot(c11, dt) + 0.15);
|
|
|
|
float lc = Levels * length(c11);
|
|
float f = frac(lc);
|
|
f *= f;
|
|
lc = (floor(lc) + f * f) / Levels + 0.05;
|
|
|
|
float3 unit = normalize(max(c11, 0.0001));
|
|
float3 quant = Levels * unit;
|
|
float3 frct = frac(quant);
|
|
frct *= frct;
|
|
quant = floor(quant) + 0.05 * dt + frct * frct;
|
|
|
|
float3 color = lc * (1.1 - edge * sqrt(edge)) * quant / Levels;
|
|
return float4(saturate(color), 1.0);
|
|
}
|
|
|
|
technique Cartoon <
|
|
ui_label = "Cartoon";
|
|
ui_tooltip = "Ink outlines and flat colour bands. Faithful port of the PPSSPP shader; the outline gets heavy in dark scenes, so try Cartoon Soft or Cel Shading if the blacks smear.";
|
|
>
|
|
{
|
|
pass
|
|
{
|
|
VertexShader = VS_PostProcess;
|
|
PixelShader = PS_Cartoon;
|
|
}
|
|
}
|