From 9c39a7275fbe59beea41f7ef1efb7ddaa1a24e52 Mon Sep 17 00:00:00 2001 From: Bibu <44452075+B1BU@users.noreply.github.com> Date: Mon, 18 Nov 2024 02:55:32 -0300 Subject: [PATCH] Added customization options - Pixel size - Pixel edge width - Pixel edge opacity --- Bibu_LCD_3x.hlsl | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/Bibu_LCD_3x.hlsl b/Bibu_LCD_3x.hlsl index 524553f..edf7b51 100644 --- a/Bibu_LCD_3x.hlsl +++ b/Bibu_LCD_3x.hlsl @@ -1,6 +1,30 @@ //!MAGPIE EFFECT //!VERSION 4 +//!PARAMETER +//!LABEL Pixel Size +//!DEFAULT 3 +//!MIN 3 +//!MAX 60 +//!STEP 3 +int pixelSize; + +//!PARAMETER +//!LABEL Pixel Edge Width +//!DEFAULT 1 +//!MIN 1 +//!MAX 60 +//!STEP 1 +int pixelEdgeWidth; + +//!PARAMETER +//!LABEL Pixel Edge Opacity +//!DEFAULT 0 +//!MIN 0 +//!MAX 1 +//!STEP 0.025 +float pixelEdgeOpacity; + //!TEXTURE Texture2D INPUT; @@ -19,22 +43,30 @@ float4 Pass1(float2 pos) { // Get output size const uint2 outputSize = GetOutputSize(); - // Sample the texture color at the current position + // Sample color at current position float4 color = INPUT.SampleLevel(sam, pos, 0); - // Initialize the output color + // Initialize output color float4 outputColor = float4(0, 0, 0, color.a); // Convert normalized position to pixel coordinates int2 pixelPos = int2(pos * float2(outputSize) + 1); - // Use the pixel position to determine the color channel - if (pixelPos.x % 3 == 1) { - outputColor.r = color.r; // First third: Red only - } else if (pixelPos.x % 3 == 2) { - outputColor.g = color.g; // Second third: Green only + // Define pixel section + int2 pixelSection = (pixelPos / (pixelSize / 3)) % 3; + + // Determine the color channel from pixel section + if (pixelSection.x == 1) { + outputColor.r = color.r; // First third: Red channel + } else if (pixelSection.x == 2) { + outputColor.g = color.g; // Second third: Green channel } else { - outputColor.b = color.b; // Last third: Blue only + outputColor.b = color.b; // Last third: Blue channel + } + + // Darken the bottom of every pixel + if (pixelEdgeOpacity && pixelPos.y % pixelSize < pixelEdgeWidth) { + outputColor -= pixelEdgeOpacity; } return outputColor;