From 6ff7ee96a07b749b5b53bcab8986ca2f5d2efab5 Mon Sep 17 00:00:00 2001 From: Corbin Crutchley Date: Fri, 12 Dec 2025 22:52:15 -0800 Subject: [PATCH] feat: dark and light now both work --- .../simpletex_lcd/simpletex_lcd+gba-color.slang | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/shaders/simpletex_lcd/simpletex_lcd+gba-color.slang b/shaders/simpletex_lcd/simpletex_lcd+gba-color.slang index 60c6791..1f7b93b 100644 --- a/shaders/simpletex_lcd/simpletex_lcd+gba-color.slang +++ b/shaders/simpletex_lcd/simpletex_lcd+gba-color.slang @@ -178,16 +178,23 @@ void main() // Sample background texture vec3 bgTexture = texture(BACKGROUND, bgPixelCoord.xy * INV_BG_TEXTURE_SIZE).rgb; - // Apply paper texture uniformly using overlay blend - // This ensures texture is visible on both light and dark pixels + // Calculate pixel luminosity for blend weighting + float luma = (LUMA_R * colour.r) + (LUMA_G * colour.g) + (LUMA_B * colour.b); + + // Method 1: Luminosity-based blend (works well for light pixels) + vec3 lumaBlend = mix(colour.rgb, bgTexture * colour.rgb, luma * registers.TEXTURE_STRENGTH); + + // Method 2: Overlay blend (works well for dark pixels) vec3 textureEffect = mix(vec3(0.5), bgTexture, registers.TEXTURE_STRENGTH); - // Overlay blend: combines multiply and screen for balanced effect vec3 overlayBlend = vec3( colour.r < 0.5 ? (2.0 * colour.r * textureEffect.r) : (1.0 - 2.0 * (1.0 - colour.r) * (1.0 - textureEffect.r)), colour.g < 0.5 ? (2.0 * colour.g * textureEffect.g) : (1.0 - 2.0 * (1.0 - colour.g) * (1.0 - textureEffect.g)), colour.b < 0.5 ? (2.0 * colour.b * textureEffect.b) : (1.0 - 2.0 * (1.0 - colour.b) * (1.0 - textureEffect.b)) ); - colour.rgb = overlayBlend; + + // Blend between methods based on luminosity + // Dark pixels use overlay, light pixels use luminosity blend + colour.rgb = mix(overlayBlend, lumaBlend, luma); FragColor = vec4(colour.rgb, 1.0); } -- 2.51.2