/*------------------. | :: Description :: | '-------------------/ Watermark (version 0.1) Authors: Kisa Kenshi (ElyFura) */ #include "ReShade.fxh" #include "Blending.fxh" #if GSHADE_DITHER #include "TriDither.fxh" #endif #ifndef WaterTex #define WaterTex "Watermark.png" #endif #ifndef Water_SIZE_X #define Water_SIZE_X BUFFER_WIDTH #endif #ifndef Water_SIZE_Y #define Water_SIZE_Y BUFFER_HEIGHT #endif #if Water_SINGLECHANNEL #define TEXFORMAT R8 #else #define TEXFORMAT RGBA8 #endif uniform int Water_Select < ui_label = "Watermark Selection"; ui_tooltip = "The image/texture you'd like to use."; ui_type = "combo"; ui_items= "Watermark \0Watermark2 \0Watermark3 \0Watermark4 \0Watermark5 \0Watermark6 \0"; ui_bind = "WaterTexture_Source"; > = 0; // Set default value(see above) by source code if the preset has not modified yet this variable/definition #ifndef WaterTexture_Source #define WaterTexture_Source 0 #endif BLENDING_COMBO(Water_BlendMode, "Blending Mode", "Select the blending mode applied to the Watermark.", "", false, 0, 0) uniform float Water_Blend < ui_label = "Blending Amount"; ui_tooltip = "The amount of blending applied to the layer."; ui_type = "slider"; ui_min = 0.0; ui_max = 1.0; ui_step = 0.001; > = 0.415; uniform float Water_Scale < ui_type = "slider"; ui_label = "Scale X & Y"; ui_min = 0.001; ui_max = 5.0; ui_step = 0.001; > = 0.350; uniform float Water_ScaleX < ui_type = "slider"; ui_label = "Scale X"; ui_min = 0.001; ui_max = 5.0; ui_step = 0.001; > = 0.562; uniform float Water_ScaleY < ui_type = "slider"; ui_label = "Scale Y"; ui_min = 0.001; ui_max = 5.0; ui_step = 0.001; > = 1.002; uniform float Water_PosX < ui_type = "slider"; ui_label = "Position X"; ui_min = -2.0; ui_max = 2.0; ui_step = 0.001; > = 0.942; uniform float Water_PosY < ui_type = "slider"; ui_label = "Position Y"; ui_min = -2.0; ui_max = 2.0; ui_step = 0.001; > = 0.824; uniform int Water_SnapRotate < ui_type = "combo"; ui_label = "Snap Rotation"; ui_items = "None\0" "90 Degrees\0" "-90 Degrees\0" "180 Degrees\0" "-180 Degrees\0"; ui_tooltip = "Snap rotation to a specific angle."; > = false; uniform float Water_Rotate < ui_label = "Rotate"; ui_type = "slider"; ui_min = -180.0; ui_max = 180.0; ui_step = 0.01; > = 0; #if WaterTexture_Source == 0 // Watermark.png #define _SOURCE_Water_FILE WaterTex #elif WaterTexture_Source == 1 // Watermark2.png #define _SOURCE_Water_FILE "Watermark2.png" #elif WaterTexture_Source == 2 // Watermark3.png #define _SOURCE_Water_FILE "Watermark3.png" #elif WaterTexture_Source == 3 // Watermark4.png #define _SOURCE_Water_FILE "Watermark4.png" #elif WaterTexture_Source == 4 // Watermark5.png #define _SOURCE_Water_FILE "Watermark5.png" #elif WaterTexture_Source == 5 // Watermark6.png #define _SOURCE_Water_FILE "Watermark6.png" #endif texture Water_Tex { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format=RGBA8; }; sampler Water_Sampler { Texture = Water_Tex; AddressU = CLAMP; AddressV = CLAMP; }; // ------------------------------------- // Entrypoints // ------------------------------------- void PS_Water(in float4 pos : SV_Position, float2 texCoord : TEXCOORD, out float4 passColor : SV_Target) { const float3 pivot = float3(0.5, 0.5, 0.0); const float AspectX = (1.0 - BUFFER_WIDTH * (1.0 / BUFFER_HEIGHT)); const float AspectY = (1.0 - BUFFER_HEIGHT * (1.0 / BUFFER_WIDTH)); const float3 mulUV = float3(texCoord.x, texCoord.y, 1); const float2 ScaleSize = (float2(Water_SIZE_X, Water_SIZE_Y) * Water_Scale / BUFFER_SCREEN_SIZE); const float ScaleX = ScaleSize.x * AspectX * Water_ScaleX; const float ScaleY = ScaleSize.y * AspectY * Water_ScaleY; float Rotate = Water_Rotate * (3.1415926 / 180.0); switch(Water_SnapRotate) { default: break; case 1: Rotate = -90.0 * (3.1415926 / 180.0); break; case 2: Rotate = 90.0 * (3.1415926 / 180.0); break; case 3: Rotate = 0.0; break; case 4: Rotate = 180.0 * (3.1415926 / 180.0); break; } const float3x3 positionMatrix = float3x3 ( 1, 0, 0, 0, 1, 0, -Water_PosX, -Water_PosY, 1 ); const float3x3 scaleMatrix = float3x3 ( 1/ScaleX, 0, 0, 0, 1/ScaleY, 0, 0, 0, 1 ); const float3x3 rotateMatrix = float3x3 ( (cos (Rotate) * AspectX), (sin(Rotate) * AspectX), 0, (-sin(Rotate) * AspectY), (cos(Rotate) * AspectY), 0, 0, 0, 1 ); const float3 SumUV = mul (mul (mul (mulUV, positionMatrix), rotateMatrix), scaleMatrix); const float4 backColor = tex2D(ReShade::BackBuffer, texCoord); passColor = tex2D(Water_Sampler, SumUV.rg + pivot.rg) * all(SumUV + pivot == saturate(SumUV + pivot)); passColor = float4(ComHeaders::Blending::Blend(Water_BlendMode, backColor.rgb, passColor.rgb, passColor.a * Water_Blend), backColor.a); #if GSHADE_DITHER passColor.rgb += TriDither(passColor.rgb, texCoord, BUFFER_COLOR_BIT_DEPTH); #endif } // ------------------------------------- // Techniques // ------------------------------------- technique Watermark { pass { VertexShader = PostProcessVS; PixelShader = PS_Water; } }