diff --git a/shaders/simpletex_lcd/simpletex_lcd+gba-color.slang b/shaders/simpletex_lcd/simpletex_lcd+gba-color.slang index a1fd843..60c6791 100644 --- a/shaders/simpletex_lcd/simpletex_lcd+gba-color.slang +++ b/shaders/simpletex_lcd/simpletex_lcd+gba-color.slang @@ -60,6 +60,7 @@ #pragma parameter BRIGHTNESS "Brightness" 0.0 -0.5 0.5 0.05 #pragma parameter PAPER_TINT "Paper Tint (Warmth)" 0.0 0.0 1.0 0.05 #pragma parameter BLACK_LEVEL "Black Level" 0.0 0.0 0.3 0.01 +#pragma parameter TEXTURE_STRENGTH "Paper Texture Strength" 0.5 0.0 1.0 0.05 layout(push_constant) uniform Push { @@ -69,6 +70,7 @@ layout(push_constant) uniform Push float BRIGHTNESS; float PAPER_TINT; float BLACK_LEVEL; + float TEXTURE_STRENGTH; vec4 OutputSize; vec4 OriginalSize; vec4 SourceSize; @@ -173,16 +175,19 @@ void main() // here than they are in GLSL shaders... vec2 bgPixelCoord = floor(vTexCoord.xy * registers.OutputSize.xy) + vec2(0.5, 0.5); - // Sample background texture and 'colourise' according to current pixel colour - // (NB: the 'colourisation' here is lame, but the proper method is slow...) - vec3 bgTexture = texture(BACKGROUND, bgPixelCoord.xy * INV_BG_TEXTURE_SIZE).rgb * colour.rgb; - - // Blend current pixel with background according to luminosity - // (lighter colour == more transparent, more visible background) - // Note: Have to calculate luminosity a second time... tiresome, but - // it's not a particulary expensive operation... - float luma = (LUMA_R * colour.r) + (LUMA_G * colour.g) + (LUMA_B * colour.b); - colour.rgb = mix(colour.rgb, bgTexture.rgb, luma); + // 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 + 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; FragColor = vec4(colour.rgb, 1.0); } diff --git a/simpletex_lcd+gba-color.slangp b/simpletex_lcd+gba-color.slangp index 2063f83..bca6ce6 100644 --- a/simpletex_lcd+gba-color.slangp +++ b/simpletex_lcd+gba-color.slangp @@ -13,10 +13,11 @@ textures = "BACKGROUND" BACKGROUND = "shaders/simpletex_lcd/png/2k/textured_paper.png" BACKGROUND_linear = false -parameters = "DARKEN_COLOUR;GREYSCALE;CONTRAST;BRIGHTNESS;PAPER_TINT;BLACK_LEVEL" -DARKEN_COLOUR = "0.4" +parameters = "DARKEN_COLOUR;GREYSCALE;CONTRAST;BRIGHTNESS;PAPER_TINT;BLACK_LEVEL;TEXTURE_STRENGTH" +DARKEN_COLOUR = "0.0" GREYSCALE = "1.0" CONTRAST = "1.0" BRIGHTNESS = "0.0" PAPER_TINT = "0.0" BLACK_LEVEL = "0.05" +TEXTURE_STRENGTH = "1.0"