Migrated DEV-Build 0.3.0
This commit is contained in:
589
EXE/reshade-shaders/Shaders/Blending.fxh
Normal file
589
EXE/reshade-shaders/Shaders/Blending.fxh
Normal file
@@ -0,0 +1,589 @@
|
||||
/*------------------.
|
||||
| :: Description :: |
|
||||
'-------------------/
|
||||
|
||||
Blending Header (version 0.8)
|
||||
|
||||
Blending Algorithm Sources:
|
||||
https://www.khronos.org/registry/OpenGL/extensions/NV/NV_blend_equation_advanced.txt
|
||||
|
||||
http://www.nathanm.com/photoshop-blending-math/
|
||||
(Alt) https://github.com/cplotts/WPFSLBlendModeFx/blob/master/PhotoshopMathFP.hlsl
|
||||
|
||||
Header Authors: originalnicodr, prod80, uchu suzume, Marot Satil
|
||||
|
||||
About:
|
||||
Provides a variety of blending methods for you to use as you wish. Just include this header.
|
||||
|
||||
History:
|
||||
(*) Feature (+) Improvement (x) Bugfix (-) Information (!) Compatibility
|
||||
|
||||
Version 0.1 by Marot Satil & uchu suzume
|
||||
* Added and improved upon multiple blending modes thanks to the work of uchu suzume, prod80, and originalnicodr.
|
||||
|
||||
Version 0.2 by uchu suzume & Marot Satil
|
||||
* Added Addition, Subtract, Divide blending modes and improved code readability.
|
||||
|
||||
Version 0.3 by uchu suzume & Marot Satil
|
||||
* Sorted blending modes in a more logical fashion, grouping by type.
|
||||
|
||||
Version 0.4 by uchu suzume
|
||||
x Corrected Color Dodge blending behavior.
|
||||
|
||||
Version 0.5 by Marot Satil & uchu suzume
|
||||
* Added preprocessor macros for uniform variable combo UI element & lerp.
|
||||
|
||||
Version 0.6 by Marot Satil & uchu suzume
|
||||
* Added Divide (Alternative) and Divide (Photoshop) blending modes.
|
||||
|
||||
Version 0.7 by prod80
|
||||
- Added original sources for blending algorithms.
|
||||
x Corrected average luminosity values.
|
||||
|
||||
Version 0.8 by Marot Satil
|
||||
* Added a new funciton to output blended data.
|
||||
+ Moved all code into the BlendingH namespace, which is part of the ComHeaders common namespace meant to be used by other headers.
|
||||
! Removed old preprocessor macro blending output.
|
||||
|
||||
.------------------.
|
||||
| :: How To Use :: |
|
||||
'------------------/
|
||||
|
||||
Blending two variables using this header in your own shaders is very straightforward.
|
||||
Very basic example code using the "Darken" blending mode follows:
|
||||
|
||||
// First, include the header.
|
||||
#include "Blending.fxh"
|
||||
|
||||
// You can use this preprocessor macro to generate an attractive and functional uniform int UI combo element containing the list of blending techniques:
|
||||
// BLENDING_COMBO(variable_name, label, tooltip, category, category_closed, spacing, default_value)
|
||||
BLENDING_COMBO(_BlendMode, "Blending Mode", "Select the blending mode applied to the layer.", "Blending Options", false, 0, 0)
|
||||
|
||||
// Inside of your function you can call this function to apply the blending option specified by an int (variable) to your float3 (input) via
|
||||
// a lerp between your float3 (input), float3 (output), and a float (blending) for the alpha channel.
|
||||
// ComHeaders::Blending::Blend(int variable, float3 input, float3 output, float blending)
|
||||
outColor.rgb = ComHeaders::Blending::Blend(_BlendMode, inColor, outColor, outColor.a);
|
||||
*/
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
// Preprocessor Macros
|
||||
// -------------------------------------
|
||||
|
||||
#undef BLENDING_COMBO
|
||||
#define BLENDING_COMBO(variable, name_label, description, group, grp_closed, space, default_value) \
|
||||
uniform int variable \
|
||||
< \
|
||||
ui_category = group; \
|
||||
ui_category_closed = grp_closed; \
|
||||
ui_items = \
|
||||
"Normal\0" \
|
||||
/* "Darken" */ \
|
||||
"Darken\0" \
|
||||
" Multiply\0" \
|
||||
" Color Burn\0" \
|
||||
" Linear Burn\0" \
|
||||
/* "Lighten" */ \
|
||||
"Lighten\0" \
|
||||
" Screen\0" \
|
||||
" Color Dodge\0" \
|
||||
" Linear Dodge\0" \
|
||||
" Addition\0" \
|
||||
" Glow\0" \
|
||||
/* "Contrast" */ \
|
||||
"Overlay\0" \
|
||||
" Soft Light\0" \
|
||||
" Hard Light\0" \
|
||||
" Vivid Light\0" \
|
||||
" Linear Light\0" \
|
||||
" Pin Light\0" \
|
||||
" Hard Mix\0" \
|
||||
/* "Inversion" */ \
|
||||
"Difference\0" \
|
||||
" Exclusion\0" \
|
||||
/* "Cancelation" */ \
|
||||
"Subtract\0" \
|
||||
" Divide\0" \
|
||||
" Divide (Alternative)\0" \
|
||||
" Divide (Photoshop)\0" \
|
||||
" Reflect\0" \
|
||||
" Grain Extract\0" \
|
||||
" Grain Merge\0" \
|
||||
/* "Component" */ \
|
||||
"Hue\0" \
|
||||
" Saturation\0" \
|
||||
" Color\0" \
|
||||
" Luminosity\0"; \
|
||||
ui_label = name_label; \
|
||||
ui_tooltip = description; \
|
||||
ui_type = "combo"; \
|
||||
ui_spacing = space; \
|
||||
> = default_value;
|
||||
|
||||
namespace ComHeaders
|
||||
{
|
||||
namespace Blending
|
||||
{
|
||||
|
||||
// -------------------------------------
|
||||
// Helper Functions
|
||||
// -------------------------------------
|
||||
|
||||
float3 Aux(float3 a)
|
||||
{
|
||||
if (a.r <= 0.25 && a.g <= 0.25 && a.b <= 0.25)
|
||||
return ((16.0 * a - 12.0) * a + 4) * a;
|
||||
else
|
||||
return sqrt(a);
|
||||
}
|
||||
|
||||
float Lum(float3 a)
|
||||
{
|
||||
return (0.33333 * a.r + 0.33334 * a.g + 0.33333 * a.b);
|
||||
}
|
||||
|
||||
float3 SetLum (float3 a, float b){
|
||||
const float c = b - Lum(a);
|
||||
return float3(a.r + c, a.g + c, a.b + c);
|
||||
}
|
||||
|
||||
float min3 (float a, float b, float c)
|
||||
{
|
||||
return min(a, (min(b, c)));
|
||||
}
|
||||
|
||||
float max3 (float a, float b, float c)
|
||||
{
|
||||
return max(a, max(b, c));
|
||||
}
|
||||
|
||||
float3 SetSat(float3 a, float b){
|
||||
float ar = a.r;
|
||||
float ag = a.g;
|
||||
float ab = a.b;
|
||||
if (ar == max3(ar, ag, ab) && ab == min3(ar, ag, ab))
|
||||
{
|
||||
//caso r->max g->mid b->min
|
||||
if (ar > ab)
|
||||
{
|
||||
ag = (((ag - ab) * b) / (ar - ab));
|
||||
ar = b;
|
||||
}
|
||||
else
|
||||
{
|
||||
ag = 0.0;
|
||||
ar = 0.0;
|
||||
}
|
||||
ab = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ar == max3(ar, ag, ab) && ag == min3(ar, ag, ab))
|
||||
{
|
||||
//caso r->max b->mid g->min
|
||||
if (ar > ag)
|
||||
{
|
||||
ab = (((ab - ag) * b) / (ar - ag));
|
||||
ar = b;
|
||||
}
|
||||
else
|
||||
{
|
||||
ab = 0.0;
|
||||
ar = 0.0;
|
||||
}
|
||||
ag = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ag == max3(ar, ag, ab) && ab == min3(ar, ag, ab))
|
||||
{
|
||||
//caso g->max r->mid b->min
|
||||
if (ag > ab)
|
||||
{
|
||||
ar = (((ar - ab) * b) / (ag - ab));
|
||||
ag = b;
|
||||
}
|
||||
else
|
||||
{
|
||||
ar = 0.0;
|
||||
ag = 0.0;
|
||||
}
|
||||
ab = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ag == max3(ar, ag, ab) && ar == min3(ar, ag, ab))
|
||||
{
|
||||
//caso g->max b->mid r->min
|
||||
if (ag > ar)
|
||||
{
|
||||
ab = (((ab - ar) * b) / (ag - ar));
|
||||
ag = b;
|
||||
}
|
||||
else
|
||||
{
|
||||
ab = 0.0;
|
||||
ag = 0.0;
|
||||
}
|
||||
ar = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ab == max3(ar, ag, ab) && ag == min3(ar, ag, ab))
|
||||
{
|
||||
//caso b->max r->mid g->min
|
||||
if (ab > ag)
|
||||
{
|
||||
ar = (((ar - ag) * b) / (ab - ag));
|
||||
ab = b;
|
||||
}
|
||||
else
|
||||
{
|
||||
ar = 0.0;
|
||||
ab = 0.0;
|
||||
}
|
||||
ag = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ab == max3(ar, ag, ab) && ar == min3(ar, ag, ab))
|
||||
{
|
||||
//caso b->max g->mid r->min
|
||||
if (ab > ar)
|
||||
{
|
||||
ag = (((ag - ar) * b) / (ab - ar));
|
||||
ab = b;
|
||||
}
|
||||
else
|
||||
{
|
||||
ag = 0.0;
|
||||
ab = 0.0;
|
||||
}
|
||||
ar = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return float3(ar, ag, ab);
|
||||
}
|
||||
|
||||
float Sat(float3 a)
|
||||
{
|
||||
return max3(a.r, a.g, a.b) - min3(a.r, a.g, a.b);
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
// Blending Modes
|
||||
// -------------------------------------
|
||||
|
||||
// Darken
|
||||
float3 Darken(float3 a, float3 b)
|
||||
{
|
||||
return min(a, b);
|
||||
}
|
||||
|
||||
// Multiply
|
||||
float3 Multiply(float3 a, float3 b)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
|
||||
// Color Burn
|
||||
float3 ColorBurn(float3 a, float3 b)
|
||||
{
|
||||
if (b.r > 0 && b.g > 0 && b.b > 0)
|
||||
return 1.0 - min(1.0, (0.5 - a) / b);
|
||||
else
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
// Linear Burn
|
||||
float3 LinearBurn(float3 a, float3 b)
|
||||
{
|
||||
return max(a + b - 1.0f, 0.0f);
|
||||
}
|
||||
|
||||
// Lighten
|
||||
float3 Lighten(float3 a, float3 b)
|
||||
{
|
||||
return max(a, b);
|
||||
}
|
||||
|
||||
// Screen
|
||||
float3 Screen(float3 a, float3 b)
|
||||
{
|
||||
return 1.0 - (1.0 - a) * (1.0 - b);
|
||||
}
|
||||
|
||||
// Color Dodge
|
||||
float3 ColorDodge(float3 a, float3 b)
|
||||
{
|
||||
if (b.r < 1 && b.g < 1 && b.b < 1)
|
||||
return min(1.0, a / (1.0 - b));
|
||||
else
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
// Linear Dodge
|
||||
float3 LinearDodge(float3 a, float3 b)
|
||||
{
|
||||
return min(a + b, 1.0f);
|
||||
}
|
||||
|
||||
// Addition
|
||||
float3 Addition(float3 a, float3 b)
|
||||
{
|
||||
return min((a + b), 1);
|
||||
}
|
||||
|
||||
// Reflect
|
||||
float3 Reflect(float3 a, float3 b)
|
||||
{
|
||||
if (b.r >= 0.999999 || b.g >= 0.999999 || b.b >= 0.999999)
|
||||
return b;
|
||||
else
|
||||
return saturate(a * a / (1.0f - b));
|
||||
}
|
||||
|
||||
// Glow
|
||||
float3 Glow(float3 a, float3 b)
|
||||
{
|
||||
return Reflect(b, a);
|
||||
}
|
||||
|
||||
// Overlay
|
||||
float3 Overlay(float3 a, float3 b)
|
||||
{
|
||||
return lerp(2 * a * b, 1.0 - 2 * (1.0 - a) * (1.0 - b), step(0.5, a));
|
||||
}
|
||||
|
||||
// Soft Light
|
||||
float3 SoftLight(float3 a, float3 b)
|
||||
{
|
||||
if (b.r <= 0.5 && b.g <= 0.5 && b.b <= 0.5)
|
||||
return clamp(a - (1.0 - 2 * b) * a * (1 - a), 0,1);
|
||||
else
|
||||
return clamp(a + (2 * b - 1.0) * (Aux(a) - a), 0, 1);
|
||||
}
|
||||
|
||||
// Hard Light
|
||||
float3 HardLight(float3 a, float3 b)
|
||||
{
|
||||
return lerp(2 * a * b, 1.0 - 2 * (1.0 - b) * (1.0 - a), step(0.5, b));
|
||||
}
|
||||
|
||||
// Vivid Light
|
||||
float3 VividLight(float3 a, float3 b)
|
||||
{
|
||||
return lerp(2 * a * b, b / (2 * (1.01 - a)), step(0.50, a));
|
||||
}
|
||||
|
||||
// Linear Light
|
||||
float3 LinearLight(float3 a, float3 b)
|
||||
{
|
||||
if (b.r < 0.5 || b.g < 0.5 || b.b < 0.5)
|
||||
return LinearBurn(a, (2.0 * b));
|
||||
else
|
||||
return LinearDodge(a, (2.0 * (b - 0.5)));
|
||||
}
|
||||
|
||||
// Pin Light
|
||||
float3 PinLight(float3 a, float3 b)
|
||||
{
|
||||
if (b.r < 0.5 || b.g < 0.5 || b.b < 0.5)
|
||||
return Darken(a, (2.0 * b));
|
||||
else
|
||||
return Lighten(a, (2.0 * (b - 0.5)));
|
||||
}
|
||||
|
||||
// Hard Mix
|
||||
float3 HardMix(float3 a, float3 b)
|
||||
{
|
||||
const float3 vl = VividLight(a, b);
|
||||
if (vl.r < 0.5 || vl.g < 0.5 || vl.b < 0.5)
|
||||
return 0.0;
|
||||
else
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
// Difference
|
||||
float3 Difference(float3 a, float3 b)
|
||||
{
|
||||
return max(a - b, b - a);
|
||||
}
|
||||
|
||||
// Exclusion
|
||||
float3 Exclusion(float3 a, float3 b)
|
||||
{
|
||||
return a + b - 2 * a * b;
|
||||
}
|
||||
|
||||
// Subtract
|
||||
float3 Subtract(float3 a, float3 b)
|
||||
{
|
||||
return max((a - b), 0);
|
||||
}
|
||||
|
||||
// Divide
|
||||
float3 Divide(float3 a, float3 b)
|
||||
{
|
||||
return (saturate(a / (b + 0.01)));
|
||||
}
|
||||
|
||||
// Divide (Alternative)
|
||||
float3 DivideAlt(float3 a, float3 b)
|
||||
{
|
||||
return (saturate(1.0 / (a / b)));
|
||||
}
|
||||
|
||||
// Divide (Photoshop)
|
||||
float3 DividePS(float3 a, float3 b)
|
||||
{
|
||||
return (saturate(a / b));
|
||||
}
|
||||
|
||||
// Grain Merge
|
||||
float3 GrainMerge(float3 a, float3 b)
|
||||
{
|
||||
return saturate(b + a - 0.5);
|
||||
}
|
||||
|
||||
// Grain Extract
|
||||
float3 GrainExtract(float3 a, float3 b)
|
||||
{
|
||||
return saturate(a - b + 0.5);
|
||||
}
|
||||
|
||||
// Hue
|
||||
float3 Hue(float3 a, float3 b)
|
||||
{
|
||||
return SetLum(SetSat(b, Sat(a)), Lum(a));
|
||||
}
|
||||
|
||||
// Saturation
|
||||
float3 Saturation(float3 a, float3 b)
|
||||
{
|
||||
return SetLum(SetSat(a, Sat(b)), Lum(a));
|
||||
}
|
||||
|
||||
// Color
|
||||
float3 ColorB(float3 a, float3 b)
|
||||
{
|
||||
return SetLum(b, Lum(a));
|
||||
}
|
||||
|
||||
// Luminousity
|
||||
float3 Luminosity(float3 a, float3 b)
|
||||
{
|
||||
return SetLum(a, Lum(b));
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
// Output Functions
|
||||
// -------------------------------------
|
||||
|
||||
float3 Blend(int mode, float3 input, float3 output, float blending)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
// Normal
|
||||
default:
|
||||
return lerp(input.rgb, output.rgb, blending);
|
||||
// Darken
|
||||
case 1:
|
||||
return lerp(input.rgb, Darken(input.rgb, output.rgb), blending);
|
||||
// Multiply
|
||||
case 2:
|
||||
return lerp(input.rgb, Multiply(input.rgb, output.rgb), blending);
|
||||
// Color Burn
|
||||
case 3:
|
||||
return lerp(input.rgb, ColorBurn(input.rgb, output.rgb), blending);
|
||||
// Linear Burn
|
||||
case 4:
|
||||
return lerp(input.rgb, LinearBurn(input.rgb, output.rgb), blending);
|
||||
// Lighten
|
||||
case 5:
|
||||
return lerp(input.rgb, Lighten(input.rgb, output.rgb), blending);
|
||||
// Screen
|
||||
case 6:
|
||||
return lerp(input.rgb, Screen(input.rgb, output.rgb), blending);
|
||||
// Color Dodge
|
||||
case 7:
|
||||
return lerp(input.rgb, ColorDodge(input.rgb, output.rgb), blending);
|
||||
// Linear Dodge
|
||||
case 8:
|
||||
return lerp(input.rgb, LinearDodge(input.rgb, output.rgb), blending);
|
||||
// Addition
|
||||
case 9:
|
||||
return lerp(input.rgb, Addition(input.rgb, output.rgb), blending);
|
||||
// Glow
|
||||
case 10:
|
||||
return lerp(input.rgb, Glow(input.rgb, output.rgb), blending);
|
||||
// Overlay
|
||||
case 11:
|
||||
return lerp(input.rgb, Overlay(input.rgb, output.rgb), blending);
|
||||
// Soft Light
|
||||
case 12:
|
||||
return lerp(input.rgb, SoftLight(input.rgb, output.rgb), blending);
|
||||
// Hard Light
|
||||
case 13:
|
||||
return lerp(input.rgb, HardLight(input.rgb, output.rgb), blending);
|
||||
// Vivid Light
|
||||
case 14:
|
||||
return lerp(input.rgb, VividLight(input.rgb, output.rgb), blending);
|
||||
// Linear Light
|
||||
case 15:
|
||||
return lerp(input.rgb, LinearLight(input.rgb, output.rgb), blending);
|
||||
// Pin Light
|
||||
case 16:
|
||||
return lerp(input.rgb, PinLight(input.rgb, output.rgb), blending);
|
||||
// Hard Mix
|
||||
case 17:
|
||||
return lerp(input.rgb, HardMix(input.rgb, output.rgb), blending);
|
||||
// Difference
|
||||
case 18:
|
||||
return lerp(input.rgb, Difference(input.rgb, output.rgb), blending);
|
||||
// Exclusion
|
||||
case 19:
|
||||
return lerp(input.rgb, Exclusion(input.rgb, output.rgb), blending);
|
||||
// Subtract
|
||||
case 20:
|
||||
return lerp(input.rgb, Subtract(input.rgb, output.rgb), blending);
|
||||
// Divide
|
||||
case 21:
|
||||
return lerp(input.rgb, Divide(input.rgb, output.rgb), blending);
|
||||
// Divide (Alternative)
|
||||
case 22:
|
||||
return lerp(input.rgb, DivideAlt(input.rgb, output.rgb), blending);
|
||||
// Divide (Photoshop)
|
||||
case 23:
|
||||
return lerp(input.rgb, DividePS(input.rgb, output.rgb), blending);
|
||||
// Reflect
|
||||
case 24:
|
||||
return lerp(input.rgb, Reflect(input.rgb, output.rgb), blending);
|
||||
// Grain Merge
|
||||
case 25:
|
||||
return lerp(input.rgb, GrainMerge(input.rgb, output.rgb), blending);
|
||||
// Grain Extract
|
||||
case 26:
|
||||
return lerp(input.rgb, GrainExtract(input.rgb, output.rgb), blending);
|
||||
// Hue
|
||||
case 27:
|
||||
return lerp(input.rgb, Hue(input.rgb, output.rgb), blending);
|
||||
// Saturation
|
||||
case 28:
|
||||
return lerp(input.rgb, Saturation(input.rgb, output.rgb), blending);
|
||||
// Color
|
||||
case 29:
|
||||
return lerp(input.rgb, ColorB(input.rgb, output.rgb), blending);
|
||||
// Luminosity
|
||||
case 30:
|
||||
return lerp(input.rgb, Luminosity(input.rgb, output.rgb), blending);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,182 +0,0 @@
|
||||
// LICENSE
|
||||
// =======
|
||||
// Copyright (c) 2017-2019 Advanced Micro Devices, Inc. All rights reserved.
|
||||
// -------
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
||||
// files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
||||
// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
// -------
|
||||
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
||||
// Software.
|
||||
// -------
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
|
||||
|
||||
//Initial port to ReShade: SLSNe https://gist.github.com/SLSNe/bbaf2d77db0b2a2a0755df581b3cf00c
|
||||
|
||||
//Optimizations by Marty McFly:
|
||||
// vectorized math, even with scalar gcn hardware this should work
|
||||
// out the same, order of operations has not changed
|
||||
// For some reason, it went from 64 to 48 instructions, a lot of MOV gone
|
||||
// Also modified the way the final window is calculated
|
||||
//
|
||||
// reordered min() and max() operations, from 11 down to 9 registers
|
||||
//
|
||||
// restructured final weighting, 49 -> 48 instructions
|
||||
//
|
||||
// delayed RCP to replace SQRT with RSQRT
|
||||
//
|
||||
// removed the saturate() from the control var as it is clamped
|
||||
// by UI manager already, 48 -> 47 instructions
|
||||
//
|
||||
// replaced tex2D with tex2Doffset intrinsic (address offset by immediate integer)
|
||||
// 47 -> 43 instructions
|
||||
// 9 -> 8 registers
|
||||
|
||||
//Further modified by OopyDoopy and Lord of Lunacy:
|
||||
// Changed wording in the UI for the existing variable and added a new variable and relevant code to adjust sharpening strength.
|
||||
|
||||
//Fix by Lord of Lunacy:
|
||||
// Made the shader use a linear colorspace rather than sRGB, as recommended by the original AMD documentation from FidelityFX.
|
||||
|
||||
//Modified by CeeJay.dk:
|
||||
// Included a label and tooltip description. I followed AMDs official naming guidelines for FidelityFX.
|
||||
//
|
||||
// Used gather trick to reduce the number of texture operations by one (9 -> 8). It's now 42 -> 51 instructions but still faster
|
||||
// because of the texture operation that was optimized away.
|
||||
|
||||
//Fix by CeeJay.dk
|
||||
// Fixed precision issues with the gather at super high resolutions
|
||||
// Also tried to refactor the samples so more work can be done while they are being sampled, but it's not so easy and the gains
|
||||
// I'm seeing are so small they might be statistical noise. So it MIGHT be faster - no promises.
|
||||
|
||||
//Fix by BC46
|
||||
// Removed the "0.5 * pixel" expressions in the DX10 or higher check.
|
||||
// With the use of dgVoodoo at least, the previous code caused the entire image to be blurry and slightly mispositioned.
|
||||
|
||||
uniform float Contrast <
|
||||
ui_type = "drag";
|
||||
ui_label = "Contrast Adaptation";
|
||||
ui_tooltip = "Adjusts the range the shader adapts to high contrast (0 is not all the way off). Higher values = more high contrast sharpening.";
|
||||
ui_min = 0.0; ui_max = 1.0;
|
||||
> = 0.0;
|
||||
|
||||
uniform float Sharpening <
|
||||
ui_type = "drag";
|
||||
ui_label = "Sharpening intensity";
|
||||
ui_tooltip = "Adjusts sharpening intensity by averaging the original pixels to the sharpened result. 1.0 is the unmodified default.";
|
||||
ui_min = 0.0; ui_max = 1.0;
|
||||
> = 1.0;
|
||||
|
||||
#include "ReShade.fxh"
|
||||
#define pixel float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT)
|
||||
|
||||
texture TexColor : COLOR;
|
||||
sampler sTexColor {Texture = TexColor; SRGBTexture = true;};
|
||||
|
||||
float3 CASPass(float4 vpos : SV_Position, float2 texcoord : TexCoord) : SV_Target
|
||||
{
|
||||
// fetch a 3x3 neighborhood around the pixel 'e',
|
||||
// a b c
|
||||
// d(e)f
|
||||
// g h i
|
||||
|
||||
|
||||
float3 b = tex2Doffset(sTexColor, texcoord, int2(0, -1)).rgb;
|
||||
float3 d = tex2Doffset(sTexColor, texcoord, int2(-1, 0)).rgb;
|
||||
|
||||
|
||||
#if __RENDERER__ >= 0xa000 // If DX10 or higher
|
||||
float4 red_efhi = tex2DgatherR(sTexColor, texcoord);
|
||||
|
||||
float3 e = float3( red_efhi.w, red_efhi.w, red_efhi.w);
|
||||
float3 f = float3( red_efhi.z, red_efhi.z, red_efhi.z);
|
||||
float3 h = float3( red_efhi.x, red_efhi.x, red_efhi.x);
|
||||
float3 i = float3( red_efhi.y, red_efhi.y, red_efhi.y);
|
||||
|
||||
float4 green_efhi = tex2DgatherG(sTexColor, texcoord);
|
||||
|
||||
e.g = green_efhi.w;
|
||||
f.g = green_efhi.z;
|
||||
h.g = green_efhi.x;
|
||||
i.g = green_efhi.y;
|
||||
|
||||
float4 blue_efhi = tex2DgatherB(sTexColor, texcoord);
|
||||
|
||||
e.b = blue_efhi.w;
|
||||
f.b = blue_efhi.z;
|
||||
h.b = blue_efhi.x;
|
||||
i.b = blue_efhi.y;
|
||||
|
||||
|
||||
#else // If DX9
|
||||
float3 e = tex2D(sTexColor, texcoord).rgb;
|
||||
float3 f = tex2Doffset(sTexColor, texcoord, int2(1, 0)).rgb;
|
||||
|
||||
float3 h = tex2Doffset(sTexColor, texcoord, int2(0, 1)).rgb;
|
||||
float3 i = tex2Doffset(sTexColor, texcoord, int2(1, 1)).rgb;
|
||||
|
||||
#endif
|
||||
|
||||
float3 g = tex2Doffset(sTexColor, texcoord, int2(-1, 1)).rgb;
|
||||
float3 a = tex2Doffset(sTexColor, texcoord, int2(-1, -1)).rgb;
|
||||
float3 c = tex2Doffset(sTexColor, texcoord, int2(1, -1)).rgb;
|
||||
|
||||
|
||||
// Soft min and max.
|
||||
// a b c b
|
||||
// d e f * 0.5 + d e f * 0.5
|
||||
// g h i h
|
||||
// These are 2.0x bigger (factored out the extra multiply).
|
||||
float3 mnRGB = min(min(min(d, e), min(f, b)), h);
|
||||
float3 mnRGB2 = min(mnRGB, min(min(a, c), min(g, i)));
|
||||
mnRGB += mnRGB2;
|
||||
|
||||
float3 mxRGB = max(max(max(d, e), max(f, b)), h);
|
||||
float3 mxRGB2 = max(mxRGB, max(max(a, c), max(g, i)));
|
||||
mxRGB += mxRGB2;
|
||||
|
||||
// Smooth minimum distance to signal limit divided by smooth max.
|
||||
float3 rcpMRGB = rcp(mxRGB);
|
||||
float3 ampRGB = saturate(min(mnRGB, 2.0 - mxRGB) * rcpMRGB);
|
||||
|
||||
// Shaping amount of sharpening.
|
||||
ampRGB = rsqrt(ampRGB);
|
||||
|
||||
float peak = -3.0 * Contrast + 8.0;
|
||||
float3 wRGB = -rcp(ampRGB * peak);
|
||||
|
||||
float3 rcpWeightRGB = rcp(4.0 * wRGB + 1.0);
|
||||
|
||||
// 0 w 0
|
||||
// Filter shape: w 1 w
|
||||
// 0 w 0
|
||||
float3 window = (b + d) + (f + h);
|
||||
float3 outColor = saturate((window * wRGB + e) * rcpWeightRGB);
|
||||
|
||||
return lerp(e, outColor, Sharpening);
|
||||
}
|
||||
|
||||
technique ContrastAdaptiveSharpen
|
||||
<
|
||||
ui_label = "AMD FidelityFX Contrast Adaptive Sharpening";
|
||||
ui_tooltip =
|
||||
"CAS is a low overhead adaptive sharpening algorithm that AMD includes with their drivers.\n"
|
||||
"This port to ReShade works with all cards from all vendors,\n"
|
||||
"but cannot do the optional scaling that CAS is normally also capable of when activated in the AMD drivers.\n"
|
||||
"\n"
|
||||
"The algorithm adjusts the amount of sharpening per pixel to target an even level of sharpness across the image.\n"
|
||||
"Areas of the input image that are already sharp are sharpened less, while areas that lack detail are sharpened more.\n"
|
||||
"This allows for higher overall natural visual sharpness with fewer artifacts.";
|
||||
>
|
||||
{
|
||||
pass
|
||||
{
|
||||
VertexShader = PostProcessVS;
|
||||
PixelShader = CASPass;
|
||||
SRGBWriteEnable = true;
|
||||
}
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
// Copyright (c) 2016-2018, bacondither
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// 1. Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer
|
||||
// in this position and unchanged.
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
|
||||
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Colourfulness - version 2018-11-12
|
||||
// EXPECTS FULL RANGE GAMMA LIGHT
|
||||
|
||||
#include "ReShadeUI.fxh"
|
||||
|
||||
uniform float colourfulness < __UNIFORM_SLIDER_FLOAT1
|
||||
ui_min = -1.0; ui_max = 2.0;
|
||||
ui_tooltip = "Degree of colourfulness, 0 = neutral";
|
||||
ui_step = 0.01;
|
||||
> = 0.4;
|
||||
|
||||
uniform float lim_luma < __UNIFORM_SLIDER_FLOAT1
|
||||
ui_min = 0.1; ui_max = 1.0;
|
||||
ui_tooltip = "Lower values allows for more change near clipping";
|
||||
ui_step = 0.01;
|
||||
> = 0.7;
|
||||
|
||||
uniform bool enable_dither <
|
||||
ui_tooltip = "Enables dithering, avoids introducing banding in gradients";
|
||||
ui_category = "Dither";
|
||||
> = false;
|
||||
|
||||
uniform bool col_noise <
|
||||
ui_tooltip = "Coloured dither noise, lower subjective noise level";
|
||||
ui_category = "Dither";
|
||||
> = true;
|
||||
|
||||
uniform float backbuffer_bits <
|
||||
ui_min = 1.0; ui_max = 32.0;
|
||||
ui_tooltip = "Backbuffer bith depth, most likely 8 or 10 bits";
|
||||
ui_category = "Dither";
|
||||
> = 8.0;
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
#ifndef fast_luma
|
||||
#define fast_luma 1 // Rapid approx of sRGB gamma, small difference in quality
|
||||
#endif
|
||||
|
||||
#ifndef temporal_dither
|
||||
#define temporal_dither 0 // Dither changes with every frame
|
||||
#endif
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
||||
#include "ReShade.fxh"
|
||||
|
||||
#if (temporal_dither == 1)
|
||||
uniform int rnd < source = "random"; min = 0; max = 1000; >;
|
||||
#endif
|
||||
|
||||
// Sigmoid function, sign(v)*pow(pow(abs(v), -2) + pow(s, -2), 1.0/-2)
|
||||
#define soft_lim(v,s) ( (v*s)*rcp(sqrt(s*s + v*v)) )
|
||||
|
||||
// Weighted power mean, p = 0.5
|
||||
#define wpmean(a,b,w) ( pow(abs(w)*sqrt(abs(a)) + abs(1-w)*sqrt(abs(b)), 2) )
|
||||
|
||||
// Max/Min RGB components
|
||||
#define maxRGB(c) ( max((c).r, max((c).g, (c).b)) )
|
||||
#define minRGB(c) ( min((c).r, min((c).g, (c).b)) )
|
||||
|
||||
// Mean of Rec. 709 & 601 luma coefficients
|
||||
#define lumacoeff float3(0.2558, 0.6511, 0.0931)
|
||||
|
||||
float3 Colourfulness(float4 vpos : SV_Position, float2 tex : TEXCOORD) : SV_Target
|
||||
{
|
||||
#if (fast_luma == 1)
|
||||
float3 c0 = tex2D(ReShade::BackBuffer, tex).rgb;
|
||||
float luma = sqrt(dot(saturate(c0*abs(c0)), lumacoeff));
|
||||
c0 = saturate(c0);
|
||||
#else // Better approx of sRGB gamma
|
||||
float3 c0 = saturate(tex2D(ReShade::BackBuffer, tex).rgb);
|
||||
float luma = pow(dot(pow(c0 + 0.06, 2.4), lumacoeff), 1.0/2.4) - 0.06;
|
||||
#endif
|
||||
|
||||
// Calc colour saturation change
|
||||
float3 diff_luma = c0 - luma;
|
||||
float3 c_diff = diff_luma*(colourfulness + 1) - diff_luma;
|
||||
|
||||
if (colourfulness > 0.0)
|
||||
{
|
||||
// 120% of c_diff clamped to max visible range + overshoot
|
||||
float3 rlc_diff = clamp((c_diff*1.2) + c0, -0.0001, 1.0001) - c0;
|
||||
|
||||
// Calc max saturation-increase without altering RGB ratios
|
||||
float poslim = (1.0002 - luma)/(abs(maxRGB(diff_luma)) + 0.0001);
|
||||
float neglim = (luma + 0.0002)/(abs(minRGB(diff_luma)) + 0.0001);
|
||||
|
||||
float3 diffmax = diff_luma*min(min(poslim, neglim), 32) - diff_luma;
|
||||
|
||||
// Soft limit diff
|
||||
c_diff = soft_lim( c_diff, max(wpmean(diffmax, rlc_diff, lim_luma), 1e-7) );
|
||||
}
|
||||
|
||||
if (enable_dither == true)
|
||||
{
|
||||
// Interleaved gradient noise by Jorge Jimenez
|
||||
const float3 magic = float3(0.06711056, 0.00583715, 52.9829189);
|
||||
#if (temporal_dither == 1)
|
||||
float xy_magic = (vpos.x + rnd)*magic.x + (vpos.y + rnd)*magic.y;
|
||||
#else
|
||||
float xy_magic = vpos.x*magic.x + vpos.y*magic.y;
|
||||
#endif
|
||||
float noise = (frac(magic.z*frac(xy_magic)) - 0.5)/(exp2(backbuffer_bits) - 1);
|
||||
c_diff += col_noise == true ? float3(-noise, noise, -noise) : noise;
|
||||
}
|
||||
|
||||
return saturate(c0 + c_diff);
|
||||
}
|
||||
|
||||
technique Colourfulness
|
||||
{
|
||||
pass
|
||||
{
|
||||
VertexShader = PostProcessVS;
|
||||
PixelShader = Colourfulness;
|
||||
}
|
||||
}
|
||||
73
EXE/reshade-shaders/Shaders/Daltonize.fx
Normal file
73
EXE/reshade-shaders/Shaders/Daltonize.fx
Normal file
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* Daltonization algorithm by daltonize.org
|
||||
* http://www.daltonize.org/2010/05/lms-daltonization-algorithm.html
|
||||
* Originally ported to ReShade by IDDQD, modified for ReShade 3.0 by crosire
|
||||
*/
|
||||
|
||||
uniform int Type <
|
||||
ui_type = "combo";
|
||||
ui_items = "Protanopia\0Deuteranopia\0Tritanopia\0";
|
||||
> = 0;
|
||||
|
||||
#include "ReShade.fxh"
|
||||
|
||||
float3 PS_DaltonizeFXmain(float4 vpos : SV_Position, float2 texcoord : TexCoord) : SV_Target
|
||||
{
|
||||
float3 input = tex2D(ReShade::BackBuffer, texcoord).rgb;
|
||||
|
||||
// RGB to LMS matrix conversion
|
||||
float OnizeL = (17.8824f * input.r) + (43.5161f * input.g) + (4.11935f * input.b);
|
||||
float OnizeM = (3.45565f * input.r) + (27.1554f * input.g) + (3.86714f * input.b);
|
||||
float OnizeS = (0.0299566f * input.r) + (0.184309f * input.g) + (1.46709f * input.b);
|
||||
|
||||
// Simulate color blindness
|
||||
float Daltl, Daltm, Dalts;
|
||||
|
||||
if (Type == 0) // Protanopia - reds are greatly reduced (1% men)
|
||||
{
|
||||
Daltl = 0.0f * OnizeL + 2.02344f * OnizeM + -2.52581f * OnizeS;
|
||||
Daltm = 0.0f * OnizeL + 1.0f * OnizeM + 0.0f * OnizeS;
|
||||
Dalts = 0.0f * OnizeL + 0.0f * OnizeM + 1.0f * OnizeS;
|
||||
}
|
||||
else if (Type == 1) // Deuteranopia - greens are greatly reduced (1% men)
|
||||
{
|
||||
Daltl = 1.0f * OnizeL + 0.0f * OnizeM + 0.0f * OnizeS;
|
||||
Daltm = 0.494207f * OnizeL + 0.0f * OnizeM + 1.24827f * OnizeS;
|
||||
Dalts = 0.0f * OnizeL + 0.0f * OnizeM + 1.0f * OnizeS;
|
||||
}
|
||||
else if (Type == 2) // Tritanopia - blues are greatly reduced (0.003% population)
|
||||
{
|
||||
Daltl = 1.0f * OnizeL + 0.0f * OnizeM + 0.0f * OnizeS;
|
||||
Daltm = 0.0f * OnizeL + 1.0f * OnizeM + 0.0f * OnizeS;
|
||||
Dalts = -0.395913f * OnizeL + 0.801109f * OnizeM + 0.0f * OnizeS;
|
||||
}
|
||||
|
||||
// LMS to RGB matrix conversion
|
||||
float3 error;
|
||||
error.r = (0.0809444479f * Daltl) + (-0.130504409f * Daltm) + (0.116721066f * Dalts);
|
||||
error.g = (-0.0102485335f * Daltl) + (0.0540193266f * Daltm) + (-0.113614708f * Dalts);
|
||||
error.b = (-0.000365296938f * Daltl) + (-0.00412161469f * Daltm) + (0.693511405f * Dalts);
|
||||
|
||||
// Isolate invisible colors to color vision deficiency (calculate error matrix)
|
||||
error = (input - error);
|
||||
|
||||
// Shift colors towards visible spectrum (apply error modifications)
|
||||
float3 correction;
|
||||
correction.r = 0; // (error.r * 0.0) + (error.g * 0.0) + (error.b * 0.0);
|
||||
correction.g = (error.r * 0.7) + (error.g * 1.0); // + (error.b * 0.0);
|
||||
correction.b = (error.r * 0.7) + (error.b * 1.0); // + (error.g * 0.0);
|
||||
|
||||
// Add compensation to original values
|
||||
correction = input + correction;
|
||||
|
||||
return correction;
|
||||
}
|
||||
|
||||
technique Daltonize
|
||||
{
|
||||
pass
|
||||
{
|
||||
VertexShader = PostProcessVS;
|
||||
PixelShader = PS_DaltonizeFXmain;
|
||||
}
|
||||
}
|
||||
252
EXE/reshade-shaders/Shaders/Deband.fx
Normal file
252
EXE/reshade-shaders/Shaders/Deband.fx
Normal file
@@ -0,0 +1,252 @@
|
||||
/**
|
||||
* Deband shader by haasn
|
||||
* https://github.com/haasn/gentoo-conf/blob/xor/home/nand/.mpv/shaders/deband-pre.glsl
|
||||
*
|
||||
* Copyright (c) 2015 Niklas Haas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* Modified and optimized for ReShade by JPulowski
|
||||
* https://reshade.me/forum/shader-presentation/768-deband
|
||||
*
|
||||
* Do not distribute without giving credit to the original author(s).
|
||||
*
|
||||
* 1.0 - Initial release
|
||||
* 1.1 - Replaced the algorithm with the one from MPV
|
||||
* 1.1a - Minor optimizations
|
||||
* - Removed unnecessary lines and replaced them with ReShadeFX intrinsic counterparts
|
||||
* 2.0 - Replaced "grain" with CeeJay.dk's ordered dithering algorithm and enabled it by default
|
||||
* - The configuration is now more simpler and straightforward
|
||||
* - Some minor code changes and optimizations
|
||||
* - Improved the algorithm and made it more robust by adding some of the madshi's
|
||||
* improvements to flash3kyuu_deband which should cause an increase in quality. Higher
|
||||
* iterations/ranges should now yield higher quality debanding without too much decrease
|
||||
* in quality.
|
||||
* - Changed licensing text and original source code URL
|
||||
* 3.0 - Replaced the entire banding detection algorithm with modified standard deviation and
|
||||
* Weber ratio analyses which give more accurate and error-free results compared to the
|
||||
* previous algorithm
|
||||
* - Added banding map debug view
|
||||
* - Added and redefined UI categories
|
||||
* - Added depth detection (credits to spiro) which should be useful when banding only
|
||||
* occurs in the sky texture for example
|
||||
* - Fixed a bug in random number generation which was causing artifacts on the upper left
|
||||
* side of the screen
|
||||
* - Dithering is now applied only when debanding a pixel as it should be which should
|
||||
* reduce the overall noise in the final texture
|
||||
* - Minor code optimizations
|
||||
* 3.1 - Switched to chroma-based analysis from luma-based analysis which was causing artifacts
|
||||
* under some scenarios
|
||||
* - Changed parts of the code which was causing compatibility issues on some renderers
|
||||
*/
|
||||
|
||||
#include "ReShadeUI.fxh"
|
||||
#include "ReShade.fxh"
|
||||
|
||||
uniform bool enable_weber <
|
||||
ui_category = "Banding analysis";
|
||||
ui_label = "Weber ratio";
|
||||
ui_tooltip = "Weber ratio analysis that calculates the ratio of the each local pixel's intensity to average background intensity of all the local pixels.";
|
||||
ui_type = "radio";
|
||||
> = true;
|
||||
|
||||
uniform bool enable_sdeviation <
|
||||
ui_category = "Banding analysis";
|
||||
ui_label = "Standard deviation";
|
||||
ui_tooltip = "Modified standard deviation analysis that calculates nearby pixels' intensity deviation from the current pixel instead of the mean.";
|
||||
ui_type = "radio";
|
||||
> = true;
|
||||
|
||||
uniform bool enable_depthbuffer <
|
||||
ui_category = "Banding analysis";
|
||||
ui_label = "Depth detection";
|
||||
ui_tooltip = "Allows depth information to be used when analysing banding, pixels will only be analysed if they are in a certain depth. (e.g. debanding only the sky)";
|
||||
ui_type = "radio";
|
||||
> = false;
|
||||
|
||||
uniform float t1 <
|
||||
ui_category = "Banding analysis";
|
||||
ui_label = "Standard deviation threshold";
|
||||
ui_max = 0.5;
|
||||
ui_min = 0.0;
|
||||
ui_step = 0.001;
|
||||
ui_tooltip = "Standard deviations lower than this threshold will be flagged as flat regions with potential banding.";
|
||||
ui_type = "slider";
|
||||
> = 0.007;
|
||||
|
||||
uniform float t2 <
|
||||
ui_category = "Banding analysis";
|
||||
ui_label = "Weber ratio threshold";
|
||||
ui_max = 2.0;
|
||||
ui_min = 0.0;
|
||||
ui_step = 0.01;
|
||||
ui_tooltip = "Weber ratios lower than this threshold will be flagged as flat regions with potential banding.";
|
||||
ui_type = "slider";
|
||||
> = 0.04;
|
||||
|
||||
uniform float banding_depth <
|
||||
ui_category = "Banding analysis";
|
||||
ui_label = "Banding depth";
|
||||
ui_max = 1.0;
|
||||
ui_min = 0.0;
|
||||
ui_step = 0.001;
|
||||
ui_tooltip = "Pixels under this depth threshold will not be processed and returned as they are.";
|
||||
ui_type = "slider";
|
||||
> = 1.0;
|
||||
|
||||
uniform float range <
|
||||
ui_category = "Banding detection & removal";
|
||||
ui_label = "Radius";
|
||||
ui_max = 32.0;
|
||||
ui_min = 1.0;
|
||||
ui_step = 1.0;
|
||||
ui_tooltip = "The radius increases linearly for each iteration. A higher radius will find more gradients, but a lower radius will smooth more aggressively.";
|
||||
ui_type = "slider";
|
||||
> = 24.0;
|
||||
|
||||
uniform int iterations <
|
||||
ui_category = "Banding detection & removal";
|
||||
ui_label = "Iterations";
|
||||
ui_max = 4;
|
||||
ui_min = 1;
|
||||
ui_tooltip = "The number of debanding steps to perform per sample. Each step reduces a bit more banding, but takes time to compute.";
|
||||
ui_type = "slider";
|
||||
> = 1;
|
||||
|
||||
uniform int debug_output <
|
||||
ui_category = "Debug";
|
||||
ui_items = "None\0Blurred (LPF) image\0Banding map\0";
|
||||
ui_label = "Debug view";
|
||||
ui_tooltip = "Blurred (LPF) image: Useful when tweaking radius and iterations to make sure all banding regions are blurred enough.\nBanding map: Useful when tweaking analysis parameters, continuous green regions indicate flat (i.e. banding) regions.";
|
||||
ui_type = "combo";
|
||||
> = 0;
|
||||
|
||||
// Reshade uses C rand for random, max cannot be larger than 2^15-1
|
||||
uniform int drandom < source = "random"; min = 0; max = 32767; >;
|
||||
|
||||
float rand(float x)
|
||||
{
|
||||
return frac(x / 41.0);
|
||||
}
|
||||
|
||||
float permute(float x)
|
||||
{
|
||||
return ((34.0 * x + 1.0) * x) % 289.0;
|
||||
}
|
||||
|
||||
float3 PS_Deband(float4 vpos : SV_Position, float2 texcoord : TexCoord) : SV_Target
|
||||
{
|
||||
float3 ori = tex2Dlod(ReShade::BackBuffer, float4(texcoord, 0.0, 0.0)).rgb;
|
||||
|
||||
if (enable_depthbuffer && (ReShade::GetLinearizedDepth(texcoord) < banding_depth))
|
||||
return ori;
|
||||
|
||||
// Initialize the PRNG by hashing the position + a random uniform
|
||||
float3 m = float3(texcoord + 1.0, (drandom / 32767.0) + 1.0);
|
||||
float h = permute(permute(permute(m.x) + m.y) + m.z);
|
||||
|
||||
// Compute a random angle
|
||||
float dir = rand(permute(h)) * 6.2831853;
|
||||
float2 o;
|
||||
sincos(dir, o.y, o.x);
|
||||
|
||||
// Distance calculations
|
||||
float2 pt;
|
||||
float dist;
|
||||
|
||||
for (int i = 1; i <= iterations; ++i) {
|
||||
dist = rand(h) * range * i;
|
||||
pt = dist * BUFFER_PIXEL_SIZE;
|
||||
|
||||
h = permute(h);
|
||||
}
|
||||
|
||||
// Sample at quarter-turn intervals around the source pixel
|
||||
float3 ref[4] = {
|
||||
tex2Dlod(ReShade::BackBuffer, float4(mad(pt, o, texcoord), 0.0, 0.0)).rgb, // SE
|
||||
tex2Dlod(ReShade::BackBuffer, float4(mad(pt, -o, texcoord), 0.0, 0.0)).rgb, // NW
|
||||
tex2Dlod(ReShade::BackBuffer, float4(mad(pt, float2(-o.y, o.x), texcoord), 0.0, 0.0)).rgb, // NE
|
||||
tex2Dlod(ReShade::BackBuffer, float4(mad(pt, float2( o.y, -o.x), texcoord), 0.0, 0.0)).rgb // SW
|
||||
};
|
||||
|
||||
// Calculate weber ratio
|
||||
float3 mean = (ori + ref[0] + ref[1] + ref[2] + ref[3]) * 0.2;
|
||||
float3 k = abs(ori - mean);
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
k += abs(ref[j] - mean);
|
||||
}
|
||||
|
||||
k = k * 0.2 / mean;
|
||||
|
||||
// Calculate std. deviation
|
||||
float3 sd = 0.0;
|
||||
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
sd += pow(ref[j] - ori, 2);
|
||||
}
|
||||
|
||||
sd = sqrt(sd * 0.25);
|
||||
|
||||
// Generate final output
|
||||
float3 output;
|
||||
|
||||
if (debug_output == 2)
|
||||
output = float3(0.0, 1.0, 0.0);
|
||||
else
|
||||
output = (ref[0] + ref[1] + ref[2] + ref[3]) * 0.25;
|
||||
|
||||
// Generate a binary banding map
|
||||
bool3 banding_map = true;
|
||||
|
||||
if (debug_output != 1) {
|
||||
if (enable_weber)
|
||||
banding_map = banding_map && k <= t2 * iterations;
|
||||
|
||||
if (enable_sdeviation)
|
||||
banding_map = banding_map && sd <= t1 * iterations;
|
||||
}
|
||||
|
||||
/*------------------------.
|
||||
| :: Ordered Dithering :: |
|
||||
'------------------------*/
|
||||
//Calculate grid position
|
||||
float grid_position = frac(dot(texcoord, (BUFFER_SCREEN_SIZE * float2(1.0 / 16.0, 10.0 / 36.0)) + 0.25));
|
||||
|
||||
//Calculate how big the shift should be
|
||||
float dither_shift = 0.25 * (1.0 / (pow(2, BUFFER_COLOR_BIT_DEPTH) - 1.0));
|
||||
|
||||
//Shift the individual colors differently, thus making it even harder to see the dithering pattern
|
||||
float3 dither_shift_RGB = float3(dither_shift, -dither_shift, dither_shift); //subpixel dithering
|
||||
|
||||
//modify shift acording to grid position.
|
||||
dither_shift_RGB = lerp(2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position); //shift acording to grid position.
|
||||
|
||||
return banding_map ? output + dither_shift_RGB : ori;
|
||||
}
|
||||
|
||||
technique Deband <
|
||||
ui_tooltip = "Alleviates color banding by trying to approximate original color values.";
|
||||
>
|
||||
{
|
||||
pass
|
||||
{
|
||||
VertexShader = PostProcessVS;
|
||||
PixelShader = PS_Deband;
|
||||
}
|
||||
}
|
||||
427
EXE/reshade-shaders/Shaders/DisplayDepth.fx
Normal file
427
EXE/reshade-shaders/Shaders/DisplayDepth.fx
Normal file
@@ -0,0 +1,427 @@
|
||||
/*
|
||||
DisplayDepth by CeeJay.dk (with many updates and additions by the Reshade community)
|
||||
|
||||
Visualizes the depth buffer. The distance of pixels determine their brightness.
|
||||
Close objects are dark. Far away objects are bright.
|
||||
Use this to configure the depth input preprocessor definitions (RESHADE_DEPTH_INPUT_*).
|
||||
*/
|
||||
|
||||
#include "ReShade.fxh"
|
||||
|
||||
// -- Basic options --
|
||||
#if RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN
|
||||
#define TEXT_UPSIDE_DOWN "1"
|
||||
#define TEXT_UPSIDE_DOWN_ALTER "0"
|
||||
#else
|
||||
#define TEXT_UPSIDE_DOWN "0"
|
||||
#define TEXT_UPSIDE_DOWN_ALTER "1"
|
||||
#endif
|
||||
#if RESHADE_DEPTH_INPUT_IS_REVERSED
|
||||
#define TEXT_REVERSED "1"
|
||||
#define TEXT_REVERSED_ALTER "0"
|
||||
#else
|
||||
#define TEXT_REVERSED "0"
|
||||
#define TEXT_REVERSED_ALTER "1"
|
||||
#endif
|
||||
#if RESHADE_DEPTH_INPUT_IS_LOGARITHMIC
|
||||
#define TEXT_LOGARITHMIC "1"
|
||||
#define TEXT_LOGARITHMIC_ALTER "0"
|
||||
#else
|
||||
#define TEXT_LOGARITHMIC "0"
|
||||
#define TEXT_LOGARITHMIC_ALTER "1"
|
||||
#endif
|
||||
|
||||
// "ui_text" was introduced in ReShade 4.5, so cannot show instructions in older versions
|
||||
|
||||
uniform int iUIPresentType <
|
||||
ui_label = "Present type";
|
||||
ui_label_ja_jp = "画面効果";
|
||||
ui_type = "combo";
|
||||
ui_items = "Depth map\0Normal map\0Show both (Vertical 50/50)\0";
|
||||
ui_items_ja_jp = "深度マップ\0法線マップ\0両方を表示 (左右分割)\0";
|
||||
#if __RESHADE__ < 40500
|
||||
ui_tooltip =
|
||||
#else
|
||||
ui_text =
|
||||
#endif
|
||||
"The right settings need to be set in the dialog that opens after clicking the \"Edit global preprocessor definitions\" button above.\n"
|
||||
"\n"
|
||||
"RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN is currently set to " TEXT_UPSIDE_DOWN ".\n"
|
||||
"If the Depth map is shown upside down set it to " TEXT_UPSIDE_DOWN_ALTER ".\n"
|
||||
"\n"
|
||||
"RESHADE_DEPTH_INPUT_IS_REVERSED is currently set to " TEXT_REVERSED ".\n"
|
||||
"If close objects in the Depth map are bright and far ones are dark set it to " TEXT_REVERSED_ALTER ".\n"
|
||||
"Also try this if you can see the normals, but the depth view is all black.\n"
|
||||
"\n"
|
||||
"RESHADE_DEPTH_INPUT_IS_LOGARITHMIC is currently set to " TEXT_LOGARITHMIC ".\n"
|
||||
"If the Normal map has banding artifacts (extra stripes) set it to " TEXT_LOGARITHMIC_ALTER ".";
|
||||
ui_text_ja_jp =
|
||||
#if ADDON_ADJUST_DEPTH
|
||||
"Adjust Depthアドオンのインストールを検出しました。\n"
|
||||
"'設定に保存して反映する'ボタンをクリックすると、このエフェクトで調節した全ての変数が共通設定に反映されます。\n"
|
||||
"または、上の'プリプロセッサの定義を編集'ボタンをクリックした後に開くダイアログで直接編集する事もできます。";
|
||||
#else
|
||||
"調節が終わったら、上の'プリプロセッサの定義を編集'ボタンをクリックした後に開くダイアログに入力する必要があります。\n"
|
||||
"\n"
|
||||
"RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWNは現在" TEXT_UPSIDE_DOWN "に設定されています。\n"
|
||||
"深度マップが上下逆さまに表示されている場合は" TEXT_UPSIDE_DOWN_ALTER "に変更して下さい。\n"
|
||||
"\n"
|
||||
"RESHADE_DEPTH_INPUT_IS_REVERSEDは現在" TEXT_REVERSED "に設定されています。\n"
|
||||
"画面効果が深度マップのとき、近くの形状がより白く、遠くの形状がより黒い場合は" TEXT_REVERSED_ALTER "に変更して下さい。\n"
|
||||
"また、法線マップで形が判別出来るが、深度マップが真っ暗に見えるという場合も、この設定の変更を試して下さい。\n"
|
||||
"\n"
|
||||
"RESHADE_DEPTH_INPUT_IS_LOGARITHMICは現在" TEXT_LOGARITHMIC "に設定されています。\n"
|
||||
"画面効果に実際のレンダリングと合致しない縞模様がある場合は" TEXT_LOGARITHMIC_ALTER "に変更して下さい。";
|
||||
#endif
|
||||
ui_tooltip_ja_jp =
|
||||
"'深度マップ'は、形状の遠近を白黒で表現します。正しい見え方では、近くの形状ほど黒く、遠くの形状ほど白くなります。\n"
|
||||
"'法線マップ'は、形状を滑らかに表現します。正しい見え方では、全体的に青緑風で、地平線を見たときに地面が緑掛かった色合いになります。\n"
|
||||
"'両方を表示 (左右分割)'が選択された場合は、左に法線マップ、右に深度マップを表示します。";
|
||||
> = 2;
|
||||
|
||||
uniform bool bUIShowOffset <
|
||||
ui_label = "Blend Depth map into the image (to help with finding the right offset)";
|
||||
ui_label_ja_jp = "透かし比較";
|
||||
ui_tooltip_ja_jp = "補正作業を支援するために、画面効果を半透過で適用します。";
|
||||
> = false;
|
||||
|
||||
uniform bool bUIUseLivePreview <
|
||||
ui_category = "Preview settings";
|
||||
ui_category_ja_jp = "基本的な補正";
|
||||
#if __RESHADE__ <= 50902
|
||||
ui_category_closed = true;
|
||||
#elif !ADDON_ADJUST_DEPTH
|
||||
ui_category_toggle = true;
|
||||
#endif
|
||||
ui_label = "Show live preview and ignore preprocessor definitions";
|
||||
ui_label_ja_jp = "プリプロセッサの定義を無視 (補正プレビューをオン)";
|
||||
ui_tooltip = "Enable this to preview with the current preset settings instead of the global preprocessor settings.";
|
||||
ui_tooltip_ja_jp =
|
||||
"共通設定に保存されたプリプロセッサの定義ではなく、これより下のプレビュー設定を使用するには、これを有効にします。\n"
|
||||
#if ADDON_ADJUST_DEPTH
|
||||
"設定の準備が出来たら、'設定に保存して反映する'ボタンをクリックしてから、このチェックボックスをオフにして下さい。"
|
||||
#else
|
||||
"設定の準備が出来たら、上の'プリプロセッサの定義を編集'ボタンをクリックした後に開くダイアログに入力して下さい。"
|
||||
#endif
|
||||
"\n\n"
|
||||
"プレビューをオンにした場合と比較して画面効果がまったく同じになれば、正しく設定が反映されています。";
|
||||
> = false;
|
||||
|
||||
#if __RESHADE__ <= 50902
|
||||
uniform int iUIUpsideDown <
|
||||
#else
|
||||
uniform bool iUIUpsideDown <
|
||||
#endif
|
||||
ui_category = "Preview settings";
|
||||
ui_label = "Upside Down";
|
||||
ui_label_ja_jp = "深度バッファの上下反転を修正";
|
||||
#if __RESHADE__ <= 50902
|
||||
ui_type = "combo";
|
||||
ui_items = "Off\0On\0";
|
||||
#endif
|
||||
ui_text_ja_jp =
|
||||
"\n"
|
||||
#if ADDON_ADJUST_DEPTH
|
||||
"項目にカーソルを合わせると、設定が必要な状況の説明が表示されます。"
|
||||
#else
|
||||
"項目にカーソルを合わせると、設定が必要な状況の説明と、プリプロセッサの定義が表示されます。"
|
||||
#endif
|
||||
;
|
||||
ui_tooltip_ja_jp =
|
||||
"深度マップが上下逆さまに表示されている場合は変更して下さい。"
|
||||
#if !ADDON_ADJUST_DEPTH
|
||||
"\n\n"
|
||||
"定義名は次の通りです。文字は完全に一致する必要があり、半角大文字の英字とアンダーバーを用いなければなりません。\n"
|
||||
"RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN=値\n"
|
||||
"定義値は次の通りです。オンの場合は1、オフの場合は0を指定して下さい。\n"
|
||||
"RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN=1\n"
|
||||
"RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN=0"
|
||||
#endif
|
||||
;
|
||||
> = RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN;
|
||||
|
||||
#if __RESHADE__ <= 50902
|
||||
uniform int iUIReversed <
|
||||
#else
|
||||
uniform bool iUIReversed <
|
||||
#endif
|
||||
ui_category = "Preview settings";
|
||||
ui_label = "Reversed";
|
||||
ui_label_ja_jp = "深度バッファの奥行反転を修正";
|
||||
#if __RESHADE__ <= 50902
|
||||
ui_type = "combo";
|
||||
ui_items = "Off\0On\0";
|
||||
#endif
|
||||
ui_tooltip_ja_jp =
|
||||
"画面効果が深度マップのとき、近くの形状が明るく、遠くの形状が暗い場合は変更して下さい。\n"
|
||||
"また、法線マップで形が判別出来るが、深度マップが真っ暗に見えるという場合も、この設定の変更を試して下さい。"
|
||||
#if !ADDON_ADJUST_DEPTH
|
||||
"\n\n"
|
||||
"定義名は次の通りです。文字は完全に一致する必要があり、半角大文字の英字とアンダーバーを用いなければなりません。\n"
|
||||
"RESHADE_DEPTH_INPUT_IS_REVERSED=値\n"
|
||||
"定義値は次の通りです。オンの場合は1、オフの場合は0を指定して下さい。\n"
|
||||
"RESHADE_DEPTH_INPUT_IS_REVERSED=1\n"
|
||||
"RESHADE_DEPTH_INPUT_IS_REVERSED=0"
|
||||
#endif
|
||||
;
|
||||
> = RESHADE_DEPTH_INPUT_IS_REVERSED;
|
||||
|
||||
#if __RESHADE__ <= 50902
|
||||
uniform int iUILogarithmic <
|
||||
#else
|
||||
uniform bool iUILogarithmic <
|
||||
#endif
|
||||
ui_category = "Preview settings";
|
||||
ui_label = "Logarithmic";
|
||||
ui_label_ja_jp = "深度バッファを対数分布として扱うように修正";
|
||||
#if __RESHADE__ <= 50902
|
||||
ui_type = "combo";
|
||||
ui_items = "Off\0On\0";
|
||||
#endif
|
||||
ui_tooltip = "Change this setting if the displayed surface normals have stripes in them.";
|
||||
ui_tooltip_ja_jp =
|
||||
"画面効果に実際のゲーム画面と合致しない縞模様がある場合は変更して下さい。"
|
||||
#if !ADDON_ADJUST_DEPTH
|
||||
"\n\n"
|
||||
"定義名は次の通りです。文字は完全に一致する必要があり、半角大文字の英字とアンダーバーを用いなければなりません。\n"
|
||||
"RESHADE_DEPTH_INPUT_IS_LOGARITHMIC=値\n"
|
||||
"定義値は次の通りです。オンの場合は1、オフの場合は0を指定して下さい。\n"
|
||||
"RESHADE_DEPTH_INPUT_IS_LOGARITHMIC=1\n"
|
||||
"RESHADE_DEPTH_INPUT_IS_LOGARITHMIC=0"
|
||||
#endif
|
||||
;
|
||||
> = RESHADE_DEPTH_INPUT_IS_LOGARITHMIC;
|
||||
|
||||
// -- Advanced options --
|
||||
|
||||
uniform float2 fUIScale <
|
||||
ui_category = "Preview settings";
|
||||
ui_label = "Scale";
|
||||
ui_label_ja_jp = "拡大率";
|
||||
ui_type = "drag";
|
||||
ui_text =
|
||||
"\n"
|
||||
" * Advanced options\n"
|
||||
"\n"
|
||||
"The following settings also need to be set using \"Edit global preprocessor definitions\" above in order to take effect.\n"
|
||||
"You can preview how they will affect the Depth map using the controls below.\n"
|
||||
"\n"
|
||||
"It is rarely necessary to change these though, as their defaults fit almost all games.\n\n";
|
||||
ui_text_ja_jp =
|
||||
"\n"
|
||||
" * その他の補正 (不定形またはその他)\n"
|
||||
"\n"
|
||||
"これより下は、深度バッファが不定形など、特別なケース向けの設定です。\n"
|
||||
"通常はこれより上の'基本的な補正'のみでほとんどのゲームに適合します。\n"
|
||||
"また、これらの設定は画質の向上にはまったく役に立ちません。\n\n";
|
||||
ui_tooltip =
|
||||
"Best use 'Present type'->'Depth map' and enable 'Offset' in the options below to set the scale.\n"
|
||||
"Use these values for:\nRESHADE_DEPTH_INPUT_X_SCALE=<left value>\nRESHADE_DEPTH_INPUT_Y_SCALE=<right value>\n"
|
||||
"\n"
|
||||
"If you know the right resolution of the games depth buffer then this scale value is simply the ratio\n"
|
||||
"between the correct resolution and the resolution Reshade thinks it is.\n"
|
||||
"For example:\n"
|
||||
"If it thinks the resolution is 1920 x 1080, but it's really 1280 x 720 then the right scale is (1.5 , 1.5)\n"
|
||||
"because 1920 / 1280 is 1.5 and 1080 / 720 is also 1.5, so 1.5 is the right scale for both the x and the y";
|
||||
ui_tooltip_ja_jp =
|
||||
"深度バッファの解像度がクライアント解像度と異なる場合に変更して下さい。\n"
|
||||
"このスケール値は、深度バッファの解像度とクライアント解像度との単純な比率になります。\n"
|
||||
"深度バッファの解像度が1280×720でクライアント解像度が1920×1080の場合、横の比率が1920÷1280、縦の比率が1080÷720となります。\n"
|
||||
"計算した結果を設定すると、値はそれぞれX_SCALE=1.5、Y_SCALE=1.5となります。"
|
||||
#if !ADDON_ADJUST_DEPTH
|
||||
"\n\n"
|
||||
"定義名は次の通りです。文字は完全に一致する必要があり、半角大文字の英字とアンダーバーを用いなければなりません。\n"
|
||||
"RESHADE_DEPTH_INPUT_X_SCALE=横の値\n"
|
||||
"RESHADE_DEPTH_INPUT_Y_SCALE=縦の値\n"
|
||||
"定義値は次の通りです。横の値はX_SCALE、縦の値はY_SCALEに指定して下さい。\n"
|
||||
"RESHADE_DEPTH_INPUT_X_SCALE=1.0\n"
|
||||
"RESHADE_DEPTH_INPUT_Y_SCALE=1.0"
|
||||
#endif
|
||||
;
|
||||
ui_min = 0.0; ui_max = 2.0;
|
||||
ui_step = 0.001;
|
||||
> = float2(RESHADE_DEPTH_INPUT_X_SCALE, RESHADE_DEPTH_INPUT_Y_SCALE);
|
||||
|
||||
uniform int2 iUIOffset <
|
||||
ui_category = "Preview settings";
|
||||
ui_label = "Offset";
|
||||
ui_label_ja_jp = "位置オフセット";
|
||||
ui_type = "slider";
|
||||
ui_tooltip =
|
||||
"Best use 'Present type'->'Depth map' and enable 'Offset' in the options below to set the offset in pixels.\n"
|
||||
"Use these values for:\nRESHADE_DEPTH_INPUT_X_PIXEL_OFFSET=<left value>\nRESHADE_DEPTH_INPUT_Y_PIXEL_OFFSET=<right value>";
|
||||
ui_tooltip_ja_jp =
|
||||
"深度バッファにレンダリングされた物体の形状が画面効果と重なり合っていない場合に変更して下さい。\n"
|
||||
"この値は、ピクセル単位で指定します。"
|
||||
#if !ADDON_ADJUST_DEPTH
|
||||
"\n\n"
|
||||
"定義名は次の通りです。文字は完全に一致する必要があり、半角大文字の英字とアンダーバーを用いなければなりません。\n"
|
||||
"RESHADE_DEPTH_INPUT_X_PIXEL_OFFSET=横の値\n"
|
||||
"RESHADE_DEPTH_INPUT_Y_PIXEL_OFFSET=縦の値\n"
|
||||
"定義値は次の通りです。横の値はX_PIXEL_OFFSET、縦の値はY_PIXEL_OFFSETに指定して下さい。\n"
|
||||
"RESHADE_DEPTH_INPUT_X_PIXEL_OFFSET=0.0\n"
|
||||
"RESHADE_DEPTH_INPUT_Y_PIXEL_OFFSET=0.0"
|
||||
#endif
|
||||
;
|
||||
ui_min = -BUFFER_SCREEN_SIZE;
|
||||
ui_max = BUFFER_SCREEN_SIZE;
|
||||
ui_step = 1;
|
||||
> = int2(RESHADE_DEPTH_INPUT_X_PIXEL_OFFSET, RESHADE_DEPTH_INPUT_Y_PIXEL_OFFSET);
|
||||
|
||||
uniform float fUIFarPlane <
|
||||
ui_category = "Preview settings";
|
||||
ui_label = "Far Plane";
|
||||
ui_label_ja_jp = "遠点距離";
|
||||
ui_type = "drag";
|
||||
ui_tooltip =
|
||||
"RESHADE_DEPTH_LINEARIZATION_FAR_PLANE=<value>\n"
|
||||
"Changing this value is not necessary in most cases.";
|
||||
ui_tooltip_ja_jp =
|
||||
"深度マップの色合いが距離感と合致しない、法線マップの表面が平面に見える、などの場合に変更して下さい。\n"
|
||||
"遠点距離を1000に設定すると、ゲームの描画距離が1000メートルであると見なします。\n\n"
|
||||
"このプレビュー画面はあくまでプレビューであり、ほとんどの場合、深度バッファは深度マップの色数より遥かに高い精度で表現されています。\n"
|
||||
"例えば、10m前後の距離の形状が純粋な黒に見えるからという理由で値を変更しないで下さい。"
|
||||
#if !ADDON_ADJUST_DEPTH
|
||||
"\n\n"
|
||||
"定義名は次の通りです。文字は完全に一致する必要があり、半角大文字の英字とアンダーバーを用いなければなりません。\n"
|
||||
"RESHADE_DEPTH_LINEARIZATION_FAR_PLANE=値\n"
|
||||
"定義値は次の通りです。\n"
|
||||
"RESHADE_DEPTH_LINEARIZATION_FAR_PLANE=1000.0"
|
||||
#endif
|
||||
;
|
||||
ui_min = 0.0; ui_max = 1000.0;
|
||||
ui_step = 0.1;
|
||||
> = RESHADE_DEPTH_LINEARIZATION_FAR_PLANE;
|
||||
|
||||
uniform float fUIDepthMultiplier <
|
||||
ui_category = "Preview settings";
|
||||
ui_label = "Multiplier";
|
||||
ui_label_ja_jp = "深度乗数";
|
||||
ui_type = "drag";
|
||||
ui_tooltip = "RESHADE_DEPTH_MULTIPLIER=<value>";
|
||||
ui_tooltip_ja_jp =
|
||||
"特定のエミュレータソフトウェアにおける深度バッファを修正するため、特別に追加された変数です。\n"
|
||||
"この値は僅かな変更でも計算式を破壊するため、設定すべき値を知らない場合は変更しないで下さい。"
|
||||
#if !ADDON_ADJUST_DEPTH
|
||||
"\n\n"
|
||||
"定義名は次の通りです。文字は完全に一致する必要があり、半角大文字の英字とアンダーバーを用いなければなりません。\n"
|
||||
"RESHADE_DEPTH_MULTIPLIER=値\n"
|
||||
"定義値は次の通りです。\n"
|
||||
"RESHADE_DEPTH_MULTIPLIER=1.0"
|
||||
#endif
|
||||
;
|
||||
ui_min = 0.0; ui_max = 1000.0;
|
||||
ui_step = 0.001;
|
||||
> = RESHADE_DEPTH_MULTIPLIER;
|
||||
|
||||
float GetLinearizedDepth(float2 texcoord)
|
||||
{
|
||||
if (!bUIUseLivePreview)
|
||||
{
|
||||
return ReShade::GetLinearizedDepth(texcoord);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (iUIUpsideDown) // RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN
|
||||
texcoord.y = 1.0 - texcoord.y;
|
||||
|
||||
texcoord.x /= fUIScale.x; // RESHADE_DEPTH_INPUT_X_SCALE
|
||||
texcoord.y /= fUIScale.y; // RESHADE_DEPTH_INPUT_Y_SCALE
|
||||
texcoord.x -= iUIOffset.x * BUFFER_RCP_WIDTH; // RESHADE_DEPTH_INPUT_X_PIXEL_OFFSET
|
||||
texcoord.y += iUIOffset.y * BUFFER_RCP_HEIGHT; // RESHADE_DEPTH_INPUT_Y_PIXEL_OFFSET
|
||||
|
||||
float depth = tex2Dlod(ReShade::DepthBuffer, float4(texcoord, 0, 0)).x * fUIDepthMultiplier;
|
||||
|
||||
const float C = 0.01;
|
||||
if (iUILogarithmic) // RESHADE_DEPTH_INPUT_IS_LOGARITHMIC
|
||||
depth = (exp(depth * log(C + 1.0)) - 1.0) / C;
|
||||
|
||||
if (iUIReversed) // RESHADE_DEPTH_INPUT_IS_REVERSED
|
||||
depth = 1.0 - depth;
|
||||
|
||||
const float N = 1.0;
|
||||
depth /= fUIFarPlane - depth * (fUIFarPlane - N);
|
||||
|
||||
return depth;
|
||||
}
|
||||
}
|
||||
|
||||
float3 GetScreenSpaceNormal(float2 texcoord)
|
||||
{
|
||||
float3 offset = float3(BUFFER_PIXEL_SIZE, 0.0);
|
||||
float2 posCenter = texcoord.xy;
|
||||
float2 posNorth = posCenter - offset.zy;
|
||||
float2 posEast = posCenter + offset.xz;
|
||||
|
||||
float3 vertCenter = float3(posCenter - 0.5, 1) * GetLinearizedDepth(posCenter);
|
||||
float3 vertNorth = float3(posNorth - 0.5, 1) * GetLinearizedDepth(posNorth);
|
||||
float3 vertEast = float3(posEast - 0.5, 1) * GetLinearizedDepth(posEast);
|
||||
|
||||
return normalize(cross(vertCenter - vertNorth, vertCenter - vertEast)) * 0.5 + 0.5;
|
||||
}
|
||||
|
||||
void PS_DisplayDepth(in float4 position : SV_Position, in float2 texcoord : TEXCOORD, out float3 color : SV_Target)
|
||||
{
|
||||
float3 depth = GetLinearizedDepth(texcoord).xxx;
|
||||
float3 normal = GetScreenSpaceNormal(texcoord);
|
||||
|
||||
// Ordered dithering
|
||||
#if 1
|
||||
const float dither_bit = 8.0; // Number of bits per channel. Should be 8 for most monitors.
|
||||
// Calculate grid position
|
||||
float grid_position = frac(dot(texcoord, (BUFFER_SCREEN_SIZE * float2(1.0 / 16.0, 10.0 / 36.0)) + 0.25));
|
||||
// Calculate how big the shift should be
|
||||
float dither_shift = 0.25 * (1.0 / (pow(2, dither_bit) - 1.0));
|
||||
// Shift the individual colors differently, thus making it even harder to see the dithering pattern
|
||||
float3 dither_shift_RGB = float3(dither_shift, -dither_shift, dither_shift); // Subpixel dithering
|
||||
// Modify shift acording to grid position.
|
||||
dither_shift_RGB = lerp(2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position);
|
||||
depth += dither_shift_RGB;
|
||||
#endif
|
||||
|
||||
color = depth;
|
||||
if (iUIPresentType == 1)
|
||||
color = normal;
|
||||
if (iUIPresentType == 2)
|
||||
color = lerp(normal, depth, step(BUFFER_WIDTH * 0.5, position.x));
|
||||
|
||||
if (bUIShowOffset)
|
||||
{
|
||||
float3 color_orig = tex2D(ReShade::BackBuffer, texcoord).rgb;
|
||||
|
||||
// Blend depth and back buffer color with 'overlay' so the offset is more noticeable
|
||||
color = lerp(2 * color * color_orig, 1.0 - 2.0 * (1.0 - color) * (1.0 - color_orig), max(color.r, max(color.g, color.b)) < 0.5 ? 0.0 : 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
technique DisplayDepth <
|
||||
ui_tooltip =
|
||||
"This shader helps you set the right preprocessor settings for depth input.\n"
|
||||
"To set the settings click on 'Edit global preprocessor definitions' and set them there - not in this shader.\n"
|
||||
"The settings will then take effect for all shaders, including this one.\n"
|
||||
"\n"
|
||||
"By default calculated normals and depth are shown side by side.\n"
|
||||
"Normals (on the left) should look smooth and the ground should be greenish when looking at the horizon.\n"
|
||||
"Depth (on the right) should show close objects as dark and use gradually brighter shades the further away objects are.\n";
|
||||
ui_tooltip_ja_jp =
|
||||
"これは、深度バッファの入力をReShade側の計算式に合わせる調節をするための、設定作業の支援に特化した特殊な扱いのエフェクトです。\n"
|
||||
"初期状態では「両方を表示」が選択されており、左に法線マップ、右に深度マップが表示されます。\n"
|
||||
"\n"
|
||||
"法線マップ(左側)は、形状を滑らかに表現します。正しい設定では、全体的に青緑風で、地平線を見たときに地面が緑を帯びた色になります。\n"
|
||||
"深度マップ(右側)は、形状の遠近を白黒で表現します。正しい設定では、近くの形状ほど黒く、遠くの形状ほど白くなります。\n"
|
||||
"\n"
|
||||
#if ADDON_ADJUST_DEPTH
|
||||
"設定を完了するには、DisplayDepth.fxエフェクトの変数の一覧にある'設定に保存して反映する'ボタンをクリックして下さい。\n"
|
||||
#else
|
||||
"設定を完了するには、エフェクト変数の編集画面にある'プリプロセッサの定義を編集'ボタンをクリックした後に開くダイアログに入力して下さい。\n"
|
||||
#endif
|
||||
"すると、インストール先のゲームに対して共通の設定として保存され、他のプリセットでも正しく表示されるようになります。";
|
||||
>
|
||||
|
||||
{
|
||||
pass
|
||||
{
|
||||
VertexShader = PostProcessVS;
|
||||
PixelShader = PS_DisplayDepth;
|
||||
}
|
||||
}
|
||||
228
EXE/reshade-shaders/Shaders/DrawText.fxh
Normal file
228
EXE/reshade-shaders/Shaders/DrawText.fxh
Normal file
@@ -0,0 +1,228 @@
|
||||
#ifndef _DRAWTEXT_H_
|
||||
#define _DRAWTEXT_H_
|
||||
|
||||
#define _DRAWTEXT_GRID_X 14.0
|
||||
#define _DRAWTEXT_GRID_Y 7.0
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// DrawText.fxh by kingreic1992 ( update: Sep.28.2019 ) //
|
||||
// //
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
|
||||
// //
|
||||
// Available functions: //
|
||||
// DrawText_String( offset, text size, xy ratio, input coord, string array, array size, output) //
|
||||
// float2 offset = top left corner of string, screen hight pixel unit. //
|
||||
// float text size = text size, screen hight pixel unit. //
|
||||
// float xy ratio = xy ratio of text. //
|
||||
// float2 input coord = current texture coord. //
|
||||
// int string array = string data in float2 array format, ex: "Demo Text" //
|
||||
// int String0[9] = { __D, __e, __m, __o, __Space, __T, __e, __x, __t}; //
|
||||
// int string size = size of the string array. //
|
||||
// float output = output. //
|
||||
// //
|
||||
// DrawText_Digit( offset, text size, xy ratio, input coord, precision after dot, data, output) //
|
||||
// float2 offset = same as DrawText_String. //
|
||||
// float text size = same as DrawText_String. //
|
||||
// float xy ratio = same as DrawText_String. //
|
||||
// float2 input coord = same as DrawText_String. //
|
||||
// int precision = digits after dot. //
|
||||
// float data = input float. //
|
||||
// float output = output. //
|
||||
// //
|
||||
// float2 DrawText_Shift(offset, shift, text size, xy ratio) //
|
||||
// float2 offset = same as DrawText_String. //
|
||||
// float2 shift = shift line(y) and column. //
|
||||
// float text size = same as DrawText_String. //
|
||||
// float xy ratio = same as DrawText_String. //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//Sample Usage
|
||||
|
||||
/*
|
||||
|
||||
#include "DrawText.fxh"
|
||||
|
||||
float4 main_fragment( float4 position : POSITION,
|
||||
float2 txcoord : TEXCOORD) : COLOR {
|
||||
float res = 0.0;
|
||||
|
||||
int line0[9] = { __D, __e, __m, __o, __Space, __T, __e, __x, __t }; //Demo Text
|
||||
int line1[15] = { __b, __y, __Space, __k, __i, __n, __g, __e, __r, __i, __c, __1, __9, __9, __2 }; //by kingeric1992
|
||||
int line2[6] = { __S, __i, __z, __e, __Colon, __Space }; // Size: %d.
|
||||
|
||||
DrawText_String(float2(100.0 , 100.0), 32, 1, txcoord, line0, 9, res);
|
||||
DrawText_String(float2(100.0 , 134.0), textSize, 1, txcoord, line1, 15, res);
|
||||
DrawText_String(DrawText_Shift(float2(100.0 , 134.0), int2(0, 1), textSize, 1), 18, 1, txcoord, line2, 6, res);
|
||||
DrawText_Digit(DrawText_Shift(DrawText_Shift(float2(100.0 , 134.0), int2(0, 1), textSize, 1), int2(8, 0), 18, 1),
|
||||
18, 1, txcoord, 0, textSize, res);
|
||||
return res;
|
||||
}
|
||||
*/
|
||||
|
||||
//Text display
|
||||
//Character indexing
|
||||
#define __Space 0 // (space)
|
||||
#define __Exclam 1 // !
|
||||
#define __Quote 2 // "
|
||||
#define __Pound 3 // #
|
||||
#define __Dollar 4 // $
|
||||
#define __Percent 5 // %
|
||||
#define __And 6 // &
|
||||
#define __sQuote 7 // '
|
||||
#define __rBrac_O 8 // (
|
||||
#define __rBrac_C 9 // )
|
||||
#define __Asterisk 10 // *
|
||||
#define __Plus 11 // +
|
||||
#define __Comma 12 // ,
|
||||
#define __Minus 13 // -
|
||||
|
||||
#define __Dot 14 // .
|
||||
#define __Slash 15 // /
|
||||
#define __0 16 // 0
|
||||
#define __1 17 // 1
|
||||
#define __2 18 // 2
|
||||
#define __3 19 // 3
|
||||
#define __4 20 // 4
|
||||
#define __5 21 // 5
|
||||
#define __6 22 // 6
|
||||
#define __7 23 // 7
|
||||
#define __8 24 // 8
|
||||
#define __9 25 // 9
|
||||
#define __Colon 26 // :
|
||||
#define __sColon 27 // ;
|
||||
|
||||
#define __Less 28 // <
|
||||
#define __Equals 29 // =
|
||||
#define __Greater 30 // >
|
||||
#define __Question 31 // ?
|
||||
#define __at 32 // @
|
||||
#define __A 33 // A
|
||||
#define __B 34 // B
|
||||
#define __C 35 // C
|
||||
#define __D 36 // D
|
||||
#define __E 37 // E
|
||||
#define __F 38 // F
|
||||
#define __G 39 // G
|
||||
#define __H 40 // H
|
||||
#define __I 41 // I
|
||||
|
||||
#define __J 42 // J
|
||||
#define __K 43 // K
|
||||
#define __L 44 // L
|
||||
#define __M 45 // M
|
||||
#define __N 46 // N
|
||||
#define __O 47 // O
|
||||
#define __P 48 // P
|
||||
#define __Q 49 // Q
|
||||
#define __R 50 // R
|
||||
#define __S 51 // S
|
||||
#define __T 52 // T
|
||||
#define __U 53 // U
|
||||
#define __V 54 // V
|
||||
#define __W 55 // W
|
||||
|
||||
#define __X 56 // X
|
||||
#define __Y 57 // Y
|
||||
#define __Z 58 // Z
|
||||
#define __sBrac_O 59 // [
|
||||
#define __Backslash 60 // \..
|
||||
#define __sBrac_C 61 // ]
|
||||
#define __Caret 62 // ^
|
||||
#define __Underscore 63 // _
|
||||
#define __Punc 64 // `
|
||||
#define __a 65 // a
|
||||
#define __b 66 // b
|
||||
#define __c 67 // c
|
||||
#define __d 68 // d
|
||||
#define __e 69 // e
|
||||
|
||||
#define __f 70 // f
|
||||
#define __g 71 // g
|
||||
#define __h 72 // h
|
||||
#define __i 73 // i
|
||||
#define __j 74 // j
|
||||
#define __k 75 // k
|
||||
#define __l 76 // l
|
||||
#define __m 77 // m
|
||||
#define __n 78 // n
|
||||
#define __o 79 // o
|
||||
#define __p 80 // p
|
||||
#define __q 81 // q
|
||||
#define __r 82 // r
|
||||
#define __s 83 // s
|
||||
|
||||
#define __t 84 // t
|
||||
#define __u 85 // u
|
||||
#define __v 86 // v
|
||||
#define __w 87 // w
|
||||
#define __x 88 // x
|
||||
#define __y 89 // y
|
||||
#define __z 90 // z
|
||||
#define __cBrac_O 91 // {
|
||||
#define __vBar 92 // |
|
||||
#define __cBrac_C 93 // }
|
||||
#define __Tilde 94 // ~
|
||||
#define __tridot 95 // (...)
|
||||
#define __empty0 96 // (null)
|
||||
#define __empty1 97 // (null)
|
||||
//Character indexing ends
|
||||
|
||||
texture Texttex < source = "FontAtlas.png"; > {
|
||||
Width = 512;
|
||||
Height = 512;
|
||||
};
|
||||
|
||||
sampler samplerText {
|
||||
Texture = Texttex;
|
||||
};
|
||||
|
||||
//accomodate for undef array size.
|
||||
#define DrawText_String( pos, size, ratio, tex, array, arrSize, output ) \
|
||||
{ float text = 0.0; \
|
||||
float2 uv = (tex * float2(BUFFER_WIDTH, BUFFER_HEIGHT) - pos) / size; \
|
||||
uv.y = saturate(uv.y); \
|
||||
uv.x *= ratio * 2.0; \
|
||||
float id = array[int(trunc(uv.x))]; \
|
||||
if(uv.x <= arrSize && uv.x >= 0.0) \
|
||||
text = tex2D(samplerText, (frac(uv) + float2( id % 14.0, trunc(id / 14.0))) \
|
||||
/ float2( _DRAWTEXT_GRID_X, _DRAWTEXT_GRID_Y) ).x; \
|
||||
output += text; }
|
||||
|
||||
float2 DrawText_Shift( float2 pos, int2 shift, float size, float ratio ) {
|
||||
return pos + size * shift * float2(0.5, 1.0) / ratio;
|
||||
}
|
||||
|
||||
void DrawText_Digit( float2 pos, float size, float ratio, float2 tex, int digit, float data, inout float res) {
|
||||
int digits[13] = {
|
||||
__0, __1, __2, __3, __4, __5, __6, __7, __8, __9, __Minus, __Space, __Dot
|
||||
};
|
||||
|
||||
float2 uv = (tex * float2(BUFFER_WIDTH, BUFFER_HEIGHT) - pos) / size;
|
||||
uv.y = saturate(uv.y);
|
||||
uv.x *= ratio * 2.0;
|
||||
|
||||
float t = abs(data);
|
||||
int radix = floor(t)? ceil(log2(t)/3.32192809):0;
|
||||
|
||||
//early exit:
|
||||
if(uv.x > digit+1 || -uv.x > radix+1) return;
|
||||
|
||||
float index = t;
|
||||
if(floor(uv.x) > 0)
|
||||
for(int i = ceil(-uv.x); i<0; i++) index *= 10.;
|
||||
else
|
||||
for(int i = ceil(uv.x); i<0; i++) index /= 10.;
|
||||
|
||||
index = (uv.x >= -radix-!radix)? index%10 : (10+step(0, data)); //adding sign
|
||||
index = (uv.x > 0 && uv.x < 1)? 12:index; //adding dot
|
||||
index = digits[(uint)index];
|
||||
|
||||
res += tex2D(samplerText, (frac(uv) + float2( index % 14.0, trunc(index / 14.0))) /
|
||||
float2( _DRAWTEXT_GRID_X, _DRAWTEXT_GRID_Y)).x;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,67 +0,0 @@
|
||||
/**
|
||||
* HDR
|
||||
* by Christian Cann Schuldt Jensen ~ CeeJay.dk
|
||||
*
|
||||
* Not actual HDR - It just tries to mimic an HDR look (relatively high performance cost)
|
||||
*/
|
||||
|
||||
#include "ReShadeUI.fxh"
|
||||
|
||||
uniform float HDRPower < __UNIFORM_SLIDER_FLOAT1
|
||||
ui_min = 0.0; ui_max = 8.0;
|
||||
ui_label = "Power";
|
||||
> = 1.30;
|
||||
uniform float radius1 < __UNIFORM_SLIDER_FLOAT1
|
||||
ui_min = 0.0; ui_max = 8.0;
|
||||
ui_label = "Radius 1";
|
||||
> = 0.793;
|
||||
uniform float radius2 < __UNIFORM_SLIDER_FLOAT1
|
||||
ui_min = 0.0; ui_max = 8.0;
|
||||
ui_label = "Radius 2";
|
||||
ui_tooltip = "Raising this seems to make the effect stronger and also brighter.";
|
||||
> = 0.87;
|
||||
|
||||
#include "ReShade.fxh"
|
||||
|
||||
float3 HDRPass(float4 vpos : SV_Position, float2 texcoord : TexCoord) : SV_Target
|
||||
{
|
||||
float3 color = tex2D(ReShade::BackBuffer, texcoord).rgb;
|
||||
|
||||
float3 bloom_sum1 = tex2D(ReShade::BackBuffer, texcoord + float2(1.5, -1.5) * radius1 * BUFFER_PIXEL_SIZE).rgb;
|
||||
bloom_sum1 += tex2D(ReShade::BackBuffer, texcoord + float2(-1.5, -1.5) * radius1 * BUFFER_PIXEL_SIZE).rgb;
|
||||
bloom_sum1 += tex2D(ReShade::BackBuffer, texcoord + float2( 1.5, 1.5) * radius1 * BUFFER_PIXEL_SIZE).rgb;
|
||||
bloom_sum1 += tex2D(ReShade::BackBuffer, texcoord + float2(-1.5, 1.5) * radius1 * BUFFER_PIXEL_SIZE).rgb;
|
||||
bloom_sum1 += tex2D(ReShade::BackBuffer, texcoord + float2( 0.0, -2.5) * radius1 * BUFFER_PIXEL_SIZE).rgb;
|
||||
bloom_sum1 += tex2D(ReShade::BackBuffer, texcoord + float2( 0.0, 2.5) * radius1 * BUFFER_PIXEL_SIZE).rgb;
|
||||
bloom_sum1 += tex2D(ReShade::BackBuffer, texcoord + float2(-2.5, 0.0) * radius1 * BUFFER_PIXEL_SIZE).rgb;
|
||||
bloom_sum1 += tex2D(ReShade::BackBuffer, texcoord + float2( 2.5, 0.0) * radius1 * BUFFER_PIXEL_SIZE).rgb;
|
||||
|
||||
bloom_sum1 *= 0.005;
|
||||
|
||||
float3 bloom_sum2 = tex2D(ReShade::BackBuffer, texcoord + float2(1.5, -1.5) * radius2 * BUFFER_PIXEL_SIZE).rgb;
|
||||
bloom_sum2 += tex2D(ReShade::BackBuffer, texcoord + float2(-1.5, -1.5) * radius2 * BUFFER_PIXEL_SIZE).rgb;
|
||||
bloom_sum2 += tex2D(ReShade::BackBuffer, texcoord + float2( 1.5, 1.5) * radius2 * BUFFER_PIXEL_SIZE).rgb;
|
||||
bloom_sum2 += tex2D(ReShade::BackBuffer, texcoord + float2(-1.5, 1.5) * radius2 * BUFFER_PIXEL_SIZE).rgb;
|
||||
bloom_sum2 += tex2D(ReShade::BackBuffer, texcoord + float2( 0.0, -2.5) * radius2 * BUFFER_PIXEL_SIZE).rgb;
|
||||
bloom_sum2 += tex2D(ReShade::BackBuffer, texcoord + float2( 0.0, 2.5) * radius2 * BUFFER_PIXEL_SIZE).rgb;
|
||||
bloom_sum2 += tex2D(ReShade::BackBuffer, texcoord + float2(-2.5, 0.0) * radius2 * BUFFER_PIXEL_SIZE).rgb;
|
||||
bloom_sum2 += tex2D(ReShade::BackBuffer, texcoord + float2( 2.5, 0.0) * radius2 * BUFFER_PIXEL_SIZE).rgb;
|
||||
|
||||
bloom_sum2 *= 0.010;
|
||||
|
||||
float dist = radius2 - radius1;
|
||||
float3 HDR = (color + (bloom_sum2 - bloom_sum1)) * dist;
|
||||
float3 blend = HDR + color;
|
||||
color = pow(abs(blend), abs(HDRPower)) + HDR; // pow - don't use fractions for HDRpower
|
||||
|
||||
return saturate(color);
|
||||
}
|
||||
|
||||
technique HDR
|
||||
{
|
||||
pass
|
||||
{
|
||||
VertexShader = PostProcessVS;
|
||||
PixelShader = HDRPass;
|
||||
}
|
||||
}
|
||||
80
EXE/reshade-shaders/Shaders/LUT.fx
Normal file
80
EXE/reshade-shaders/Shaders/LUT.fx
Normal file
@@ -0,0 +1,80 @@
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ReShade effect file
|
||||
// visit facebook.com/MartyMcModding for news/updates
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// Marty's LUT shader 1.0 for ReShade 3.0
|
||||
// Copyright © 2008-2016 Marty McFly
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
#ifndef fLUT_TextureName
|
||||
#define fLUT_TextureName "lut.png"
|
||||
#endif
|
||||
#ifndef fLUT_TileSizeXY
|
||||
#define fLUT_TileSizeXY 32
|
||||
#endif
|
||||
#ifndef fLUT_TileAmount
|
||||
#define fLUT_TileAmount 32
|
||||
#endif
|
||||
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
//
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
#include "ReShadeUI.fxh"
|
||||
|
||||
uniform float fLUT_AmountChroma < __UNIFORM_SLIDER_FLOAT1
|
||||
ui_min = 0.00; ui_max = 1.00;
|
||||
ui_label = "LUT chroma amount";
|
||||
ui_tooltip = "Intensity of color/chroma change of the LUT.";
|
||||
> = 1.00;
|
||||
|
||||
uniform float fLUT_AmountLuma < __UNIFORM_SLIDER_FLOAT1
|
||||
ui_min = 0.00; ui_max = 1.00;
|
||||
ui_label = "LUT luma amount";
|
||||
ui_tooltip = "Intensity of luma change of the LUT.";
|
||||
> = 1.00;
|
||||
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
//
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
#include "ReShade.fxh"
|
||||
texture texLUT < source = fLUT_TextureName; > { Width = fLUT_TileSizeXY*fLUT_TileAmount; Height = fLUT_TileSizeXY; Format = RGBA8; };
|
||||
sampler SamplerLUT { Texture = texLUT; };
|
||||
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
//
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
void PS_LUT_Apply(float4 vpos : SV_Position, float2 texcoord : TEXCOORD, out float4 res : SV_Target0)
|
||||
{
|
||||
float4 color = tex2D(ReShade::BackBuffer, texcoord.xy);
|
||||
float2 texelsize = 1.0 / fLUT_TileSizeXY;
|
||||
texelsize.x /= fLUT_TileAmount;
|
||||
|
||||
float3 lutcoord = float3((color.xy*fLUT_TileSizeXY-color.xy+0.5)*texelsize.xy,color.z*fLUT_TileSizeXY-color.z);
|
||||
float lerpfact = frac(lutcoord.z);
|
||||
lutcoord.x += (lutcoord.z-lerpfact)*texelsize.y;
|
||||
|
||||
float3 lutcolor = lerp(tex2D(SamplerLUT, lutcoord.xy).xyz, tex2D(SamplerLUT, float2(lutcoord.x+texelsize.y,lutcoord.y)).xyz,lerpfact);
|
||||
|
||||
color.xyz = lerp(normalize(color.xyz), normalize(lutcolor.xyz), fLUT_AmountChroma) *
|
||||
lerp(length(color.xyz), length(lutcolor.xyz), fLUT_AmountLuma);
|
||||
|
||||
res.xyz = color.xyz;
|
||||
res.w = 1.0;
|
||||
}
|
||||
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
//
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
|
||||
technique LUT
|
||||
{
|
||||
pass LUT_Apply
|
||||
{
|
||||
VertexShader = PostProcessVS;
|
||||
PixelShader = PS_LUT_Apply;
|
||||
}
|
||||
}
|
||||
625
EXE/reshade-shaders/Shaders/Macros.fxh
Normal file
625
EXE/reshade-shaders/Shaders/Macros.fxh
Normal file
@@ -0,0 +1,625 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
// BASIC MACROS FOR RESHADE 4 //
|
||||
// AUTHOR: TREYM //
|
||||
////////////////////////////////////////////////////////////
|
||||
// Modified by dddfault //
|
||||
// //
|
||||
// Changelogs : //
|
||||
// Added Sampler texture boundary resolver option //
|
||||
// Added float2 parameters option //
|
||||
////////////////////////////////////////////////////////////
|
||||
// Macros Guide: //
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
/* //////////////////////////////////////////////////// *
|
||||
* //////////////////////////////////////////////////// *
|
||||
|
||||
Usage of these macros is very simple once you understand
|
||||
the syntax and variable names. Let's start with a Simple
|
||||
integer slider. To begin, type:
|
||||
|
||||
UI_INT
|
||||
|
||||
Next we need to add _S to indicate that this is a
|
||||
"slider" widget. Follow the syntax below:
|
||||
|
||||
UI_INT_S(INT_NAME, "Label", "Tooltip", 0, 100, 50)
|
||||
|
||||
Using just a single line of code, we have created a UI
|
||||
tweakable integer named INT_NAME with a minimum value of
|
||||
0, a maximum value of 100, and a default value of 50.
|
||||
|
||||
Next, let's create that same widget, but within a UI
|
||||
category. This time, we'll type:
|
||||
|
||||
CAT_INT_S(INT_NAME, "Category", "Label", "Tooltip", 0, 100, 50)
|
||||
|
||||
As you can see, the syntax follows the same pattern but
|
||||
with a new input for "Category"
|
||||
|
||||
Below you will find a useful list of examples to get you
|
||||
started. I hope you find these useful and they help your
|
||||
workflow. Happy coding!
|
||||
|
||||
- TreyM
|
||||
|
||||
* //////////////////////////////////////////////////// *
|
||||
* //////////////////////////////////////////////////// *
|
||||
|
||||
Widget Types
|
||||
Input = _I
|
||||
Slider = _S
|
||||
Drag = _D
|
||||
|
||||
* //////////////////////////////////////////////////// *
|
||||
|
||||
BOOLEAN Macro
|
||||
UI_BOOL(BOOL_NAME, "Label", "Tooltip", true)
|
||||
|
||||
BOOLEAN Categorized Macro
|
||||
CAT_BOOL(BOOL_NAME, "Category", "Label", "Tooltip", true)
|
||||
|
||||
* //////////////////////////////////////////////////// *
|
||||
|
||||
INTEGER Combo Widget
|
||||
UI_COMBO(INT_NAME, "Label", "Tooltip", 0, 2, 0, "Item 1\0Item 2\0Item 3\0")
|
||||
|
||||
INTEGER Drag Widget
|
||||
UI_INT_D(INT_NAME, "Label", "Tooltip", 0, 100, 50)
|
||||
|
||||
INTEGER Input Widget
|
||||
UI_INT_I(INT_NAME, "Label", "Tooltip", 0, 100, 50)
|
||||
|
||||
INTEGER Radio Widget
|
||||
UI_RADIO(INT_NAME, "Label", "Tooltip", 0, 2, 0, " Item 1 \0 Item 2 \0 Item 3\0")
|
||||
|
||||
INTEGER Slider Widget
|
||||
UI_INT_S(INT_NAME, "Label", "Tooltip", 0, 100, 50)
|
||||
|
||||
INTEGER Categorized Combo Widget
|
||||
CAT_COMBO(INT_NAME, "Category", "Label", "Tooltip", 0, 2, 0, " Item 1 \0 Item 2 \0 Item 3\0")
|
||||
|
||||
INTEGER Categorized Drag Widget
|
||||
CAT_INT_D(INT_NAME, "Category", "Label", "Tooltip", 0, 100, 50)
|
||||
|
||||
INTEGER Categorized Input Widget
|
||||
CAT_INT_I(INT_NAME, "Category", "Label", "Tooltip", 0, 100, 50)
|
||||
|
||||
INTEGER Categorized Radio Widget
|
||||
CAT_RADIO(INT_NAME, "Category", "Label", "Tooltip", 0, 2, 0, " Item 1 \0 Item 2 \0 Item 3\0")
|
||||
|
||||
INTEGER Categorized Slider Widget
|
||||
CAT_INT_S(INT_NAME, "Category", "Label", "Tooltip", 0, 100, 50)
|
||||
|
||||
* //////////////////////////////////////////////////// *
|
||||
|
||||
FLOAT Drag Widget
|
||||
UI_FLOAT_D(FLOAT_NAME, "Label", "Tooltip", 0.0, 1.0, 0.5)
|
||||
|
||||
FLOAT Input Widget
|
||||
UI_FLOAT_I(FLOAT_NAME, "Label", "Tooltip", 0.0, 1.0, 0.5)
|
||||
|
||||
FLOAT Slider Widget
|
||||
UI_FLOAT_S(FLOAT_NAME, "Label", "Tooltip", 0.0, 1.0, 0.5)
|
||||
|
||||
FLOAT Categorized Drag Widget
|
||||
CAT_FLOAT_D(FLOAT_NAME, "Category", "Label", "Tooltip", 0.0, 1.0, 0.5)
|
||||
|
||||
FLOAT Categorized Input Widget
|
||||
CAT_FLOAT_I(FLOAT_NAME, "Category", "Label", "Tooltip", 0.0, 1.0, 0.5)
|
||||
|
||||
FLOAT Categorized Slider Widget
|
||||
CAT_FLOAT_S(FLOAT_NAME, "Category", "Label", "Tooltip", 0.0, 1.0, 0.5)
|
||||
|
||||
FLOAT macro with full control (value after "Tooltip" is ui_step)
|
||||
UI_FLOAT_FULL(FLOAT_NAME, "ui_type", "Label", "Tooltip", 0.1, 0.0, 1.0, 0.5)
|
||||
|
||||
FLOAT Categorized macro with full control (value after "Tooltip" is ui_step)
|
||||
CAT_FLOAT_FULL(FLOAT_NAME, "ui_type", "Category", "Label", "Tooltip", 0.1, 0.0, 1.0, 0.5)
|
||||
|
||||
* //////////////////////////////////////////////////// *
|
||||
|
||||
FLOAT2 Drag Widget
|
||||
UI_FLOAT2_D(FLOAT_NAME, "Label", "Tooltip", 0.0, 1.0, 0.5, 0.5)
|
||||
|
||||
FLOAT2 Input Widget
|
||||
UI_FLOAT2_I(FLOAT_NAME, "Label", "Tooltip", 0.0, 1.0, 0.5, 0.5)
|
||||
|
||||
FLOAT2 Slider Widget
|
||||
UI_FLOAT2_S(FLOAT_NAME, "Label", "Tooltip", 0.0, 1.0, 0.5, 0.5)
|
||||
|
||||
FLOAT2 Categorized Drag Widget
|
||||
CAT_FLOAT2_D(FLOAT_NAME, "Category", "Label", "Tooltip", 0.0, 1.0, 0.5, 0.5)
|
||||
|
||||
FLOAT2 Categorized Input Widget
|
||||
CAT_FLOAT2_I(FLOAT_NAME, "Category", "Label", "Tooltip", 0.0, 1.0, 0.5, 0.5)
|
||||
|
||||
FLOAT2 Categorized Slider Widget
|
||||
CAT_FLOAT2_S(FLOAT_NAME, "Category", "Label", "Tooltip", 0.0, 1.0, 0.5, 0.5)
|
||||
|
||||
FLOAT2 macro with full control (value after "Tooltip" is ui_step)
|
||||
UI_FLOAT2_FULL(FLOAT_NAME, "ui_type", "Label", "Tooltip", 0.1, 0.0, 1.0, 0.5, 0.5)
|
||||
|
||||
FLOAT2 Categorized macro with full control (value after "Tooltip" is ui_step)
|
||||
CAT_FLOAT2_FULL(FLOAT_NAME, "ui_type", "Category", "Label", "Tooltip", 0.1, 0.0, 1.0, 0.5, 0.5)
|
||||
|
||||
* //////////////////////////////////////////////////// *
|
||||
|
||||
FLOAT3 Drag Widget
|
||||
UI_FLOAT3_D(FLOAT_NAME, "Label", "Tooltip", 0.5, 0.5, 0.5)
|
||||
|
||||
FLOAT3 Input Widget
|
||||
UI_FLOAT3_I(FLOAT_NAME, "Label", "Tooltip", 0.5, 0.5, 0.5)
|
||||
|
||||
FLOAT3 Slider Widget
|
||||
UI_FLOAT3_S(FLOAT_NAME, "Label", "Tooltip", 0.5, 0.5, 0.5)
|
||||
|
||||
FLOAT3 Categorized Drag Widget
|
||||
CAT_FLOAT3_D(FLOAT_NAME, "Category", "Label", "Tooltip", 0.5, 0.5, 0.5)
|
||||
|
||||
FLOAT3 Categorized Input Widget
|
||||
CAT_FLOAT3_I(FLOAT_NAME, "Category", "Label", "Tooltip", 0.5, 0.5, 0.5)
|
||||
|
||||
FLOAT3 Categorized Slider Widget
|
||||
CAT_FLOAT3_S(FLOAT_NAME, "Category", "Label", "Tooltip", 0.5, 0.5, 0.5)
|
||||
|
||||
* //////////////////////////////////////////////////// *
|
||||
|
||||
FLOAT3 Color Widget
|
||||
UI_COLOR(FLOAT_NAME, "Label", "Tooltip", 0.5, 0.5, 0.5)
|
||||
|
||||
FLOAT3 Categorized Color Widget
|
||||
CAT_COLOR(FLOAT_NAME, "Category", "Label", "Tooltip", 0.5, 0.5, 0.5)
|
||||
|
||||
* //////////////////////////////////////////////////// *
|
||||
|
||||
SAMPLER Macro
|
||||
SAMPLER(SamplerName, TextureName)
|
||||
|
||||
SAMPLER Macro with texture boundary resolver option
|
||||
SAMPLER_UV(SamplerName, TextureName, ResolverType)
|
||||
|
||||
TEXTURE Macro
|
||||
TEXTURE(TextureName, "TexturePath")
|
||||
|
||||
TEXTURE Full Macro
|
||||
TEXTURE_FULL(TextureName, "TexturePath", Width, Height, Format)
|
||||
|
||||
* //////////////////////////////////////////////////// *
|
||||
|
||||
TECHNIQUE Macro
|
||||
TECHNIQUE(TechniqueName, PassMacro)
|
||||
|
||||
PASS Macro
|
||||
PASS(PassID, VertexShader, PixelShader)
|
||||
|
||||
PASS Macro with RenderTarget
|
||||
PASS_RT(PassID, VertexShader, PixelShader, RenderTarget)
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
* //////////////////////////////////////////////////// */
|
||||
|
||||
// INTEGER MACROS ////////////////////////////////
|
||||
#define UI_COMBO(var, label, tooltip, minval, maxval, defval, items) \
|
||||
uniform int var \
|
||||
< \
|
||||
ui_type = "combo"; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
ui_items = items; \
|
||||
ui_min = minval; \
|
||||
ui_max = maxval; \
|
||||
> = defval;
|
||||
|
||||
#define CAT_COMBO(var, category, label, tooltip, minval, maxval, defval, items) \
|
||||
uniform int var \
|
||||
< \
|
||||
ui_type = "combo"; \
|
||||
ui_category = category; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
ui_items = items; \
|
||||
ui_min = minval; \
|
||||
ui_max = maxval; \
|
||||
> = defval;
|
||||
|
||||
#define UI_INT_I(var, label, tooltip, minval, maxval, defval) \
|
||||
uniform int var \
|
||||
< \
|
||||
ui_type = "input"; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
ui_min = minval; \
|
||||
ui_max = maxval; \
|
||||
> = defval;
|
||||
|
||||
#define CAT_INT_I(var, category, label, tooltip, minval, maxval, defval) \
|
||||
uniform int var \
|
||||
< \
|
||||
ui_type = "input"; \
|
||||
ui_category = category; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
ui_min = minval; \
|
||||
ui_max = maxval; \
|
||||
> = defval;
|
||||
|
||||
#define UI_INT_S(var, label, tooltip, minval, maxval, defval) \
|
||||
uniform int var \
|
||||
< \
|
||||
ui_type = "slider"; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
ui_min = minval; \
|
||||
ui_max = maxval; \
|
||||
> = defval;
|
||||
|
||||
#define CAT_INT_S(var, category, label, tooltip, minval, maxval, defval) \
|
||||
uniform int var \
|
||||
< \
|
||||
ui_type = "slider"; \
|
||||
ui_category = category; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
ui_min = minval; \
|
||||
ui_max = maxval; \
|
||||
> = defval;
|
||||
|
||||
#define UI_INT_D(var, label, tooltip, minval, maxval, defval) \
|
||||
uniform int var \
|
||||
< \
|
||||
ui_type = "drag"; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
ui_min = minval; \
|
||||
ui_max = maxval; \
|
||||
> = defval;
|
||||
|
||||
#define CAT_INT_D(var, category, label, tooltip, minval, maxval, defval) \
|
||||
uniform int var \
|
||||
< \
|
||||
ui_type = "drag"; \
|
||||
ui_category = category; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
ui_min = minval; \
|
||||
ui_max = maxval; \
|
||||
> = defval;
|
||||
|
||||
#define UI_RADIO(var, label, tooltip, minval, maxval, defval, items) \
|
||||
uniform int var \
|
||||
< \
|
||||
ui_type = "radio"; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
ui_items = items; \
|
||||
ui_min = minval; \
|
||||
ui_max = maxval; \
|
||||
> = defval;
|
||||
|
||||
#define CAT_RADIO(var, category, label, tooltip, minval, maxval, defval, items) \
|
||||
uniform int var \
|
||||
< \
|
||||
ui_type = "radio"; \
|
||||
ui_category = category; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
ui_items = items; \
|
||||
ui_min = minval; \
|
||||
ui_max = maxval; \
|
||||
> = defval;
|
||||
|
||||
// BOOL MACROS ///////////////////////////////////
|
||||
#define UI_BOOL(var, label, tooltip, def) \
|
||||
uniform bool var \
|
||||
< \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
> = def;
|
||||
|
||||
#define CAT_BOOL(var, category, label, tooltip, def) \
|
||||
uniform bool var \
|
||||
< \
|
||||
ui_category = category; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
> = def;
|
||||
|
||||
// FLOAT MACROS //////////////////////////////////
|
||||
#define UI_FLOAT_D(var, label, tooltip, minval, maxval, defval) \
|
||||
uniform float var \
|
||||
< \
|
||||
ui_type = "drag"; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
ui_min = minval; \
|
||||
ui_max = maxval; \
|
||||
> = defval;
|
||||
|
||||
#define CAT_FLOAT_D(var, category, label, tooltip, minval, maxval, defval) \
|
||||
uniform float var \
|
||||
< \
|
||||
ui_type = "drag"; \
|
||||
ui_category = category; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
ui_min = minval; \
|
||||
ui_max = maxval; \
|
||||
> = defval;
|
||||
|
||||
#define UI_FLOAT_FULL(var, uitype, label, tooltip, uistep, minval, maxval, defval) \
|
||||
uniform float var \
|
||||
< \
|
||||
ui_type = uitype; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
ui_step = uistep; \
|
||||
ui_min = minval; \
|
||||
ui_max = maxval; \
|
||||
> = defval;
|
||||
|
||||
#define CAT_FLOAT_FULL(var, uitype, category, label, tooltip, uistep, minval, maxval, defval) \
|
||||
uniform float var \
|
||||
< \
|
||||
ui_type = uitype; \
|
||||
ui_category = category; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
ui_step = uistep; \
|
||||
ui_min = minval; \
|
||||
ui_max = maxval; \
|
||||
> = defval;
|
||||
|
||||
#define UI_FLOAT_I(var, label, tooltip, minval, maxval, defval) \
|
||||
uniform float var \
|
||||
< \
|
||||
ui_type = "input"; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
ui_min = minval; \
|
||||
ui_max = maxval; \
|
||||
> = defval;
|
||||
|
||||
#define CAT_FLOAT_I(var, category, label, tooltip, minval, maxval, defval) \
|
||||
uniform float var \
|
||||
< \
|
||||
ui_type = "input"; \
|
||||
ui_category = category; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
ui_min = minval; \
|
||||
ui_max = maxval; \
|
||||
> = defval;
|
||||
|
||||
#define UI_FLOAT_S(var, label, tooltip, minval, maxval, defval) \
|
||||
uniform float var \
|
||||
< \
|
||||
ui_type = "slider"; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
ui_min = minval; \
|
||||
ui_max = maxval; \
|
||||
> = defval;
|
||||
|
||||
#define CAT_FLOAT_S(var, category, label, tooltip, minval, maxval, defval) \
|
||||
uniform float var \
|
||||
< \
|
||||
ui_type = "slider"; \
|
||||
ui_category = category; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
ui_min = minval; \
|
||||
ui_max = maxval; \
|
||||
> = defval;
|
||||
|
||||
#define UI_FLOAT2_D(var, label, tooltip, minval, maxval, defval1, defval2) \
|
||||
uniform float2 var \
|
||||
< \
|
||||
ui_type = "drag"; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
ui_min = minval; \
|
||||
ui_max = maxval; \
|
||||
> = float2(defval1, defval2);
|
||||
|
||||
#define CAT_FLOAT2_D(var, category, label, tooltip, minval, maxval, defval1, defval2) \
|
||||
uniform float2 var \
|
||||
< \
|
||||
ui_type = "drag"; \
|
||||
ui_category = category; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
ui_min = minval; \
|
||||
ui_max = maxval; \
|
||||
> = float2(defval1, defval2);
|
||||
|
||||
#define UI_FLOAT2_FULL(var, uitype, label, tooltip, uistep, minval, maxval, defval1, defval2) \
|
||||
uniform float2 var \
|
||||
< \
|
||||
ui_type = uitype; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
ui_step = uistep; \
|
||||
ui_min = minval; \
|
||||
ui_max = maxval; \
|
||||
> = float2(defval1, defval2);
|
||||
|
||||
#define CAT_FLOAT2_FULL(var, uitype, category, label, tooltip, uistep, minval, defval1, defval2) \
|
||||
uniform float2 var \
|
||||
< \
|
||||
ui_type = uitype; \
|
||||
ui_category = category; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
ui_step = uistep; \
|
||||
ui_min = minval; \
|
||||
ui_max = maxval; \
|
||||
> = float2(defval1, defval2);
|
||||
|
||||
#define UI_FLOAT2_I(var, label, tooltip, minval, maxval, defval1, defval2) \
|
||||
uniform float2 var \
|
||||
< \
|
||||
ui_type = "input"; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
ui_min = minval; \
|
||||
ui_max = maxval; \
|
||||
> = float2(defval1, defval2);
|
||||
|
||||
#define CAT_FLOAT2_I(var, category, label, tooltip, minval, maxval, defval1, defval2) \
|
||||
uniform float2 var \
|
||||
< \
|
||||
ui_type = "input"; \
|
||||
ui_category = category; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
ui_min = minval; \
|
||||
ui_max = maxval; \
|
||||
> = float2(defval1, defval2);
|
||||
|
||||
#define UI_FLOAT2_S(var, label, tooltip, minval, maxval, defval1, defval2) \
|
||||
uniform float2 var \
|
||||
< \
|
||||
ui_type = "slider"; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
ui_min = minval; \
|
||||
ui_max = maxval; \
|
||||
> = float2(defval1, defval2);
|
||||
|
||||
#define CAT_FLOAT2_S(var, category, label, tooltip, minval, maxval, defval1, defval2) \
|
||||
uniform float2 var \
|
||||
< \
|
||||
ui_type = "slider"; \
|
||||
ui_category = category; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
ui_min = minval; \
|
||||
ui_max = maxval; \
|
||||
> = float2(defval1, defval2);
|
||||
|
||||
#define UI_FLOAT3_D(var, label, tooltip, defval1, defval2, defval3) \
|
||||
uniform float3 var \
|
||||
< \
|
||||
ui_type = "drag"; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
> = float3(defval1, defval2, defval3);
|
||||
|
||||
#define CAT_FLOAT3_D(var, category, label, tooltip, defval1, defval2, defval3) \
|
||||
uniform float3 var \
|
||||
< \
|
||||
ui_type = "drag"; \
|
||||
ui_category = category; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
> = float3(defval1, defval2, defval3);
|
||||
|
||||
#define UI_FLOAT3_I(var, label, tooltip, defval1, defval2, defval3) \
|
||||
uniform float3 var \
|
||||
< \
|
||||
ui_type = "input"; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
> = float3(defval1, defval2, defval3);
|
||||
|
||||
#define CAT_FLOAT3_I(var, category, label, tooltip, defval1, defval2, defval3) \
|
||||
uniform float3 var \
|
||||
< \
|
||||
ui_type = "input"; \
|
||||
ui_category = category; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
> = float3(defval1, defval2, defval3);
|
||||
|
||||
#define UI_FLOAT3_S(var, label, tooltip, defval1, defval2, defval3) \
|
||||
uniform float3 var \
|
||||
< \
|
||||
ui_type = "slider"; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
> = float3(defval1, defval2, defval3);
|
||||
|
||||
#define CAT_FLOAT3_S(var, category, label, tooltip, defval1, defval2, defval3) \
|
||||
uniform float3 var \
|
||||
< \
|
||||
ui_type = "slider"; \
|
||||
ui_category = category; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
> = float3(defval1, defval2, defval3);
|
||||
|
||||
|
||||
// COLOR WIDGET MACROS ///////////////////////////
|
||||
#define UI_COLOR(var, label, tooltip, defval1, defval2, defval3) \
|
||||
uniform float3 var \
|
||||
< \
|
||||
ui_type = "color"; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
> = float3(defval1, defval2, defval3);
|
||||
|
||||
#define CAT_COLOR(var, category, label, tooltip, defval1, defval2, defval3) \
|
||||
uniform float3 var \
|
||||
< \
|
||||
ui_type = "color"; \
|
||||
ui_category = category; \
|
||||
ui_label = label; \
|
||||
ui_tooltip = tooltip; \
|
||||
> = float3(defval1, defval2, defval3);
|
||||
|
||||
|
||||
// SAMPLER MACRO /////////////////////////////////
|
||||
#define SAMPLER(sname, tname) \
|
||||
sampler sname \
|
||||
{ \
|
||||
Texture = tname; \
|
||||
};
|
||||
|
||||
#define SAMPLER_UV(sname, tname, addUVW) \
|
||||
sampler sname \
|
||||
{ \
|
||||
Texture = tname; \
|
||||
AddressU = addUVW; \
|
||||
AddressV = addUVW; \
|
||||
AddressW = addUVW; \
|
||||
};
|
||||
|
||||
|
||||
// TEXTURE MACROs ////////////////////////////////
|
||||
#define TEXTURE(tname, src) \
|
||||
texture tname <source=src;> \
|
||||
{ \
|
||||
Width = BUFFER_WIDTH; \
|
||||
Height = BUFFER_HEIGHT; \
|
||||
Format = RGBA8; \
|
||||
};
|
||||
|
||||
#define TEXTURE_FULL(tname, src, width, height, fomat) \
|
||||
texture tname <source=src;> \
|
||||
{ \
|
||||
Width = width; \
|
||||
Height = height; \
|
||||
Format = fomat; \
|
||||
};
|
||||
|
||||
|
||||
// TECHNIQUE MACROS //////////////////////////////
|
||||
#define TECHNIQUE(tname, pass) \
|
||||
technique tname \
|
||||
{ \
|
||||
pass \
|
||||
}
|
||||
|
||||
#define PASS(ID, vs, ps) pass \
|
||||
{ \
|
||||
VertexShader = vs; \
|
||||
PixelShader = ps; \
|
||||
}
|
||||
|
||||
#define PASS_RT(ID, vs, ps, rt) pass \
|
||||
{ \
|
||||
VertexShader = vs; \
|
||||
PixelShader = ps; \
|
||||
RenderTarget = rt; \
|
||||
}
|
||||
@@ -1,492 +0,0 @@
|
||||
/*
|
||||
Magic Bloom by luluco250
|
||||
Attempts to simulate a natural-looking bloom.
|
||||
|
||||
Features:
|
||||
|
||||
--Wide bloom blurring, derived from the gaussian function
|
||||
defined here: https://en.wikipedia.org/wiki/Gaussian_blur#Mathematics
|
||||
|
||||
--Eye adaptation, decreases or increases the brightness
|
||||
of bloom according to the overall image luminance.
|
||||
|
||||
--Lens dirt, as standard I suppose. Really not much here.
|
||||
It uses an image named "MagicBloom_Dirt.png" so make
|
||||
sure you have one in your textures directory.
|
||||
|
||||
--Unwanted features can be disabled through
|
||||
preprocessor definitions, saving performance.
|
||||
|
||||
Preprocessor definitions:
|
||||
|
||||
--MAGICBLOOM_ADAPT_RESOLUTION:
|
||||
Determines the width/height of the texture used for adaptation.
|
||||
It is recommended to use 256, but you can use as far as 1024 without issues.
|
||||
Too low resolutions will make adaptation seem "unstable".
|
||||
Must be a power of two value: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024 etc.
|
||||
|
||||
--MAGICBLOOM_BLUR_PRECALCULATED:
|
||||
If set to 0 the gaussian blur will be calculated inside the shader.
|
||||
Otherwise, it uses a pre-calculated kernel (array).
|
||||
|
||||
--MAGICBLOOM_NODIRT:
|
||||
If set to 1 all lens dirt related features are disabled.
|
||||
Beneficial for performance if you don't wish to use lens dirt.
|
||||
|
||||
--MAGICBLOOM_NOADAPT:
|
||||
If set to 1 all adaptation related features are disabled.
|
||||
Beneficial for performance if you don't wish to use adaptation.
|
||||
|
||||
MIT Licensed:
|
||||
|
||||
Copyright (c) 2017 luluco250
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "ReShade.fxh"
|
||||
|
||||
//Statics
|
||||
|
||||
#ifndef MAGICBLOOM_ADAPT_RESOLUTION
|
||||
#define MAGICBLOOM_ADAPT_RESOLUTION 256
|
||||
#endif
|
||||
|
||||
#ifndef MAGICBLOOM_BLUR_PRECALCULATED
|
||||
#define MAGICBLOOM_BLUR_PRECALCULATED 1
|
||||
#endif
|
||||
|
||||
#ifndef MAGICBLOOM_NODIRT
|
||||
#define MAGICBLOOM_NODIRT 0
|
||||
#endif
|
||||
|
||||
#ifndef MAGICBLOOM_NOADAPT
|
||||
#define MAGICBLOOM_NOADAPT 0
|
||||
#endif
|
||||
|
||||
static const int iBlurSamples = 4;
|
||||
static const int iAdaptResolution = MAGICBLOOM_ADAPT_RESOLUTION;
|
||||
|
||||
#define CONST_LOG2(v) (((v) & 0xAAAAAAAA) != 0) | ((((v) & 0xFFFF0000) != 0) << 4) | ((((v) & 0xFF00FF00) != 0) << 3) | ((((v) & 0xF0F0F0F0) != 0) << 2) | ((((v) & 0xCCCCCCCC) != 0) << 1)
|
||||
|
||||
static const float sigma = float(iBlurSamples) / 2.0;
|
||||
static const float double_pi = 6.283185307179586476925286766559;
|
||||
static const int lowest_mip = CONST_LOG2(iAdaptResolution) + 1;
|
||||
static const float3 luma_value = float3(0.2126, 0.7152, 0.0722);
|
||||
|
||||
//Uniforms
|
||||
|
||||
#include "ReShadeUI.fxh"
|
||||
|
||||
uniform float fBloom_Intensity < __UNIFORM_SLIDER_FLOAT1
|
||||
ui_label = "Bloom Intensity";
|
||||
ui_tooltip = "Amount of bloom applied to the image.";
|
||||
ui_min = 0.0;
|
||||
ui_max = 10.0;
|
||||
ui_step = 0.001;
|
||||
> = 1.0;
|
||||
|
||||
uniform float fBloom_Threshold <
|
||||
ui_label = "Bloom Threshold";
|
||||
ui_tooltip =
|
||||
"Thresholds (limits) dark pixels from being accounted for bloom.\n"
|
||||
"Essentially, it increases the contrast in bloom and blackens darker pixels.\n"
|
||||
"At 1.0 all pixels are used in bloom.\n"
|
||||
"This value is not normalized, it is exponential, therefore changes in lower values are more noticeable than at higher values.";
|
||||
ui_type = "drag";
|
||||
ui_min = 1.0;
|
||||
ui_max = 10.0;
|
||||
ui_step = 0.1;
|
||||
> = 2.0;
|
||||
|
||||
#if !MAGICBLOOM_NODIRT
|
||||
uniform float fDirt_Intensity < __UNIFORM_SLIDER_FLOAT1
|
||||
ui_label = "Dirt Intensity";
|
||||
ui_tooltip =
|
||||
"Amount of lens dirt applied to bloom.\n"
|
||||
"Uses a texture called \"MagicBloom_Dirt.png\" from your textures directory(ies).";
|
||||
ui_min = 0.0;
|
||||
ui_max = 1.0;
|
||||
ui_step = 0.001;
|
||||
> = 0.0;
|
||||
#endif
|
||||
|
||||
#if !MAGICBLOOM_NOADAPT
|
||||
uniform float fExposure < __UNIFORM_SLIDER_FLOAT1
|
||||
ui_label = "Exposure";
|
||||
ui_tooltip =
|
||||
"The target exposure that bloom adapts to.\n"
|
||||
"It is recommended to just leave it at 0.5, unless you wish for a brighter (1.0) or darker (0.0) image.";
|
||||
ui_min = 0.0;
|
||||
ui_max = 1.0;
|
||||
ui_step = 0.001;
|
||||
> = 0.5;
|
||||
|
||||
uniform float fAdapt_Speed <
|
||||
ui_label = "Adaptation Speed";
|
||||
ui_tooltip =
|
||||
"How quick bloom adapts to changes in the image brightness.\n"
|
||||
"At 1.0, changes are instantaneous.\n"
|
||||
"It is recommended to use low values, between 0.01 and 0.1.\n"
|
||||
"0.1 will provide a quick but natural adaptation.\n"
|
||||
"0.01 will provide a slow form of adaptation.";
|
||||
ui_type = "drag";
|
||||
ui_min = 0.001;
|
||||
ui_max = 1.0;
|
||||
ui_step = 0.001;
|
||||
> = 0.1;
|
||||
|
||||
uniform float fAdapt_Sensitivity < __UNIFORM_SLIDER_FLOAT1
|
||||
ui_label = "Adapt Sensitivity";
|
||||
ui_tooltip =
|
||||
"How sensitive adaptation is towards brightness.\n"
|
||||
"At higher values bloom can get darkened at the slightest amount of brightness.\n"
|
||||
"At lower values bloom will require a lot of image brightness before it's fully darkened."
|
||||
"1.0 will not modify the amount of brightness that is accounted for adaptation.\n"
|
||||
"0.5 is a good value, but may miss certain bright spots.";
|
||||
ui_min = 0.0;
|
||||
ui_max = 3.0;
|
||||
ui_step = 0.001;
|
||||
> = 1.0;
|
||||
|
||||
uniform float2 f2Adapt_Clip < __UNIFORM_SLIDER_FLOAT2
|
||||
ui_label = "Adaptation Min/Max";
|
||||
ui_tooltip =
|
||||
"Determines the minimum and maximum values that adaptation can determine to ajust bloom.\n"
|
||||
"Reducing the maximum would cause bloom to be brighter (as it is less adapted).\n"
|
||||
"Increasing the minimum would cause bloom to be darker (as it is more adapted).\n"
|
||||
"Keep the maximum above or equal to the minium and vice-versa.";
|
||||
ui_min = 0.0;
|
||||
ui_max = 1.0;
|
||||
ui_step = 0.001;
|
||||
> = float2(0.0, 1.0);
|
||||
|
||||
uniform int iAdapt_Precision < __UNIFORM_SLIDER_INT1
|
||||
ui_label = "Adaptation Precision";
|
||||
ui_tooltip =
|
||||
"Determins how accurately bloom adapts to the center of image.\n"
|
||||
"At 0 the adaptation is calculated from the average of the whole image.\n"
|
||||
"At the highest value (which may vary) adaptation focuses solely on the center pixel(s) of the screen.\n"
|
||||
"Values closer to 0 are recommended.";
|
||||
ui_min = 0;
|
||||
ui_max = lowest_mip;
|
||||
ui_step = 0.1;
|
||||
> = lowest_mip * 0.3;
|
||||
#endif
|
||||
|
||||
uniform uint iDebug <
|
||||
ui_label = "Debug Options";
|
||||
ui_tooltip = "Contains debugging options like displaying the bloom texture.";
|
||||
ui_type = "combo";
|
||||
ui_items = "None\0Display Bloom Texture\0";
|
||||
> = 0;
|
||||
|
||||
//Textures
|
||||
|
||||
texture tMagicBloom_1 < pooled = true; > { Width = BUFFER_WIDTH / 2; Height = BUFFER_HEIGHT / 2; Format = RGBA16F; };
|
||||
texture tMagicBloom_2 < pooled = true; > { Width = BUFFER_WIDTH / 4; Height = BUFFER_HEIGHT / 4; Format = RGBA16F; };
|
||||
texture tMagicBloom_3 < pooled = true; > { Width = BUFFER_WIDTH / 8; Height = BUFFER_HEIGHT / 8; Format = RGBA16F; };
|
||||
texture tMagicBloom_4 < pooled = true; > { Width = BUFFER_WIDTH / 16; Height = BUFFER_HEIGHT / 16; Format = RGBA16F; };
|
||||
texture tMagicBloom_5 < pooled = true; > { Width = BUFFER_WIDTH / 32; Height = BUFFER_HEIGHT / 32; Format = RGBA16F; };
|
||||
texture tMagicBloom_6 < pooled = true; > { Width = BUFFER_WIDTH / 64; Height = BUFFER_HEIGHT / 64; Format = RGBA16F; };
|
||||
texture tMagicBloom_7 < pooled = true; > { Width = BUFFER_WIDTH / 128; Height = BUFFER_HEIGHT / 128; Format = RGBA16F; };
|
||||
texture tMagicBloom_8 < pooled = true; > { Width = BUFFER_WIDTH / 256; Height = BUFFER_HEIGHT / 256; Format = RGBA16F; };
|
||||
#if !MAGICBLOOM_NOADAPT
|
||||
texture tMagicBloom_Small { Width = iAdaptResolution; Height = iAdaptResolution; Format = R32F; MipLevels = lowest_mip; };
|
||||
texture tMagicBloom_Adapt { Format = R32F; };
|
||||
texture tMagicBloom_LastAdapt { Format = R32F; };
|
||||
#endif
|
||||
#if !MAGICBLOOM_NODIRT
|
||||
texture tMagicBloom_Dirt <source="MagicBloom_Dirt.png";> { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; };
|
||||
#endif
|
||||
|
||||
//Samplers
|
||||
|
||||
sampler sMagicBloom_1 { Texture = tMagicBloom_1; };
|
||||
sampler sMagicBloom_2 { Texture = tMagicBloom_2; };
|
||||
sampler sMagicBloom_3 { Texture = tMagicBloom_3; };
|
||||
sampler sMagicBloom_4 { Texture = tMagicBloom_4; };
|
||||
sampler sMagicBloom_5 { Texture = tMagicBloom_5; };
|
||||
sampler sMagicBloom_6 { Texture = tMagicBloom_6; };
|
||||
sampler sMagicBloom_7 { Texture = tMagicBloom_7; };
|
||||
sampler sMagicBloom_8 { Texture = tMagicBloom_8; };
|
||||
#if !MAGICBLOOM_NOADAPT
|
||||
sampler sMagicBloom_Small { Texture = tMagicBloom_Small; };
|
||||
sampler sMagicBloom_Adapt { Texture = tMagicBloom_Adapt; MinFilter = POINT; MagFilter = POINT; };
|
||||
sampler sMagicBloom_LastAdapt { Texture = tMagicBloom_LastAdapt; MinFilter = POINT; MagFilter = POINT; };
|
||||
#endif
|
||||
#if !MAGICBLOOM_NODIRT
|
||||
sampler sMagicBloom_Dirt { Texture = tMagicBloom_Dirt; };
|
||||
#endif
|
||||
|
||||
//Functions
|
||||
|
||||
#if !MAGICBLOOM_BLUR_PRECALCULATED
|
||||
float gaussian_function(float2 i) {
|
||||
static const float first_part = 1.0 / (double_pi * pow(sigma, 2.0));
|
||||
static const float second_part_a = 1.0 / (2.0 * pow(sigma, 2.0));
|
||||
float second_part_b = (pow(i.x, 2.0) + pow(i.y, 2.0)) * second_part_a;
|
||||
return first_part * exp(-second_part_b);
|
||||
}
|
||||
#endif
|
||||
|
||||
//Why use a single-pass blur? To reduce the amount of textures used in half.
|
||||
//Scale should be the original resolution divided by target resolution.
|
||||
float3 blur(sampler sp, float2 uv, float scale) {
|
||||
float2 ps = BUFFER_PIXEL_SIZE * scale;
|
||||
|
||||
#if MAGICBLOOM_BLUR_PRECALCULATED
|
||||
static const float kernel[9] = {
|
||||
0.0269955, 0.0647588, 0.120985, 0.176033, 0.199471, 0.176033, 0.120985, 0.0647588, 0.0269955
|
||||
};
|
||||
static const float accum = 1.02352;
|
||||
#else
|
||||
float accum = 0.0;
|
||||
#endif
|
||||
|
||||
float gaussian_weight = 0.0;
|
||||
float3 col = 0.0;
|
||||
|
||||
[loop]
|
||||
for (int x = -iBlurSamples; x <= iBlurSamples; ++x) {
|
||||
for (int y = -iBlurSamples; y <= iBlurSamples; ++y) {
|
||||
#if MAGICBLOOM_BLUR_PRECALCULATED
|
||||
gaussian_weight = kernel[x + iBlurSamples] * kernel[y + iBlurSamples];
|
||||
#else
|
||||
gaussian_weight = gaussian_function(float2(x, y));
|
||||
accum += gaussian_weight;
|
||||
#endif
|
||||
col += tex2D(sp, uv + ps * float2(x, y)).rgb * gaussian_weight;
|
||||
}
|
||||
}
|
||||
|
||||
#if MAGICBLOOM_BLUR_PRECALCULATED
|
||||
return col * accum;
|
||||
#else
|
||||
return col / accum;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
Uncharted 2 Tonemapper
|
||||
|
||||
Thanks John Hable and Naughty Dog.
|
||||
*/
|
||||
float3 tonemap(float3 col, float exposure) {
|
||||
static const float A = 0.15; //shoulder strength
|
||||
static const float B = 0.50; //linear strength
|
||||
static const float C = 0.10; //linear angle
|
||||
static const float D = 0.20; //toe strength
|
||||
static const float E = 0.02; //toe numerator
|
||||
static const float F = 0.30; //toe denominator
|
||||
static const float W = 11.2; //linear white point value
|
||||
|
||||
col *= exposure;
|
||||
|
||||
col = ((col * (A * col + C * B) + D * E) / (col * (A * col + B) + D * F)) - E / F;
|
||||
static const float white = 1.0 / (((W * (A * W + C * B) + D * E) / (W * (A * W + B) + D * F)) - E / F);
|
||||
col *= white;
|
||||
return col;
|
||||
}
|
||||
|
||||
float3 blend_screen(float3 a, float3 b) {
|
||||
return 1.0 - (1.0 - a) * (1.0 - b);
|
||||
}
|
||||
|
||||
/*
|
||||
The function below is a leftover from debugging.
|
||||
It just draws a line on the screen, it's horizontal position being
|
||||
the value you specify (from 0.0-1.0, becoming left-right).
|
||||
No use now but might be useful later on so I just left it here.
|
||||
*/
|
||||
/*void debug_value(inout float3 col, float2 uv, float value, float3 needle_color) {
|
||||
static const float2 ps = BUFFER_PIXEL_SIZE;
|
||||
col = (uv.x + ps.x > value && uv.x - ps.x < value) ? needle_color : col;
|
||||
}*/
|
||||
|
||||
//Shaders
|
||||
|
||||
/*
|
||||
Thresholding is performed on the first blur for two reasons:
|
||||
--Save an entire texture from being used to threshold.
|
||||
--Being the smallest blur it also results in the least amount of artifacts.
|
||||
*/
|
||||
float4 PS_Blur1(float4 pos : SV_Position, float2 uv : TEXCOORD) : SV_Target {
|
||||
float3 col = blur(ReShade::BackBuffer, uv, 2.0);
|
||||
col = pow(abs(col), fBloom_Threshold);
|
||||
col *= fBloom_Intensity;
|
||||
return float4(col, 1.0);
|
||||
}
|
||||
|
||||
float4 PS_Blur2(float4 pos : SV_Position, float2 uv : TEXCOORD) : SV_Target {
|
||||
return float4(blur(sMagicBloom_1, uv, 4.0), 1.0);
|
||||
}
|
||||
|
||||
float4 PS_Blur3(float4 pos : SV_Position, float2 uv : TEXCOORD) : SV_Target {
|
||||
return float4(blur(sMagicBloom_2, uv, 8.0), 1.0);
|
||||
}
|
||||
|
||||
float4 PS_Blur4(float4 pos : SV_Position, float2 uv : TEXCOORD) : SV_Target {
|
||||
return float4(blur(sMagicBloom_3, uv, 8.0), 1.0);
|
||||
}
|
||||
|
||||
float4 PS_Blur5(float4 pos : SV_Position, float2 uv : TEXCOORD) : SV_Target {
|
||||
return float4(blur(sMagicBloom_4, uv, 16.0), 1.0);
|
||||
}
|
||||
|
||||
float4 PS_Blur6(float4 pos : SV_Position, float2 uv : TEXCOORD) : SV_Target {
|
||||
return float4(blur(sMagicBloom_5, uv, 32.0), 1.0);
|
||||
}
|
||||
|
||||
float4 PS_Blur7(float4 pos : SV_Position, float2 uv : TEXCOORD) : SV_Target {
|
||||
return float4(blur(sMagicBloom_6, uv, 64.0), 1.0);
|
||||
}
|
||||
|
||||
float4 PS_Blur8(float4 pos : SV_Position, float2 uv : TEXCOORD) : SV_Target {
|
||||
return float4(blur(sMagicBloom_7, uv, 128.0), 1.0);
|
||||
}
|
||||
|
||||
//Final blend shader
|
||||
float4 PS_Blend(float4 pos : SV_Position, float2 uv : TEXCOORD) : SV_Target {
|
||||
float3 col = tex2D(ReShade::BackBuffer, uv).rgb;
|
||||
float3 bloom = tex2D(sMagicBloom_1, uv).rgb
|
||||
+ tex2D(sMagicBloom_2, uv).rgb
|
||||
+ tex2D(sMagicBloom_3, uv).rgb
|
||||
+ tex2D(sMagicBloom_4, uv).rgb
|
||||
+ tex2D(sMagicBloom_5, uv).rgb
|
||||
+ tex2D(sMagicBloom_6, uv).rgb
|
||||
+ tex2D(sMagicBloom_7, uv).rgb
|
||||
+ tex2D(sMagicBloom_8, uv).rgb;
|
||||
//Dunno if making the division by 8 a static multiplication helps, but whatever.
|
||||
static const float bloom_accum = 1.0 / 8.0;
|
||||
bloom *= bloom_accum;
|
||||
|
||||
#if !MAGICBLOOM_NOADAPT
|
||||
float exposure = fExposure / max(tex2D(sMagicBloom_Adapt, 0.0).x, 0.00001);
|
||||
bloom = tonemap(bloom, exposure);
|
||||
#else
|
||||
//Without adaptation it seems 100.0 exposure is needed for bloom to look bright enough.
|
||||
bloom = tonemap(bloom, 100.0);
|
||||
#endif
|
||||
|
||||
#if !MAGICBLOOM_NODIRT
|
||||
float3 dirt = tex2D(sMagicBloom_Dirt, uv).rgb;
|
||||
dirt *= fDirt_Intensity;
|
||||
bloom = blend_screen(bloom, dirt * bloom);
|
||||
#endif
|
||||
|
||||
col = blend_screen(col, bloom);
|
||||
|
||||
//If we're to display the bloom texture, we replace col with it.
|
||||
col = iDebug == 1 ? bloom : col;
|
||||
|
||||
return float4(col, 1.0);
|
||||
}
|
||||
|
||||
#if !MAGICBLOOM_NOADAPT
|
||||
/*
|
||||
How adaptation works:
|
||||
--Calculate image luminance.
|
||||
--Save it to a smaller, mipmapped texture.
|
||||
--Mipmaps require a power of 2 texture.
|
||||
--Fetch a mipmap level according to a specfied amount of precision.
|
||||
--The lowest mipmap is simply an average of the entire image.
|
||||
*/
|
||||
float PS_GetSmall(float4 pos : SV_Position, float2 uv : TEXCOORD) : SV_Target {
|
||||
return dot(tex2D(ReShade::BackBuffer, uv).rgb, luma_value);
|
||||
}
|
||||
|
||||
float PS_GetAdapt(float4 pos : SV_Position, float2 uv : TEXCOORD) : SV_Target {
|
||||
float curr = tex2Dlod(sMagicBloom_Small, float4(0.5, 0.5, 0, lowest_mip - iAdapt_Precision)).x;
|
||||
curr *= fAdapt_Sensitivity;
|
||||
curr = clamp(curr, f2Adapt_Clip.x, f2Adapt_Clip.y);
|
||||
float last = tex2D(sMagicBloom_LastAdapt, 0.0).x;
|
||||
//Using the frametime/delta here would actually scale adaptation with the framerate.
|
||||
//We don't want that, so we don't even bother with it.
|
||||
return lerp(last, curr, fAdapt_Speed);
|
||||
}
|
||||
|
||||
float PS_SaveAdapt(float4 pos : SV_Position, float2 uv : TEXCOORD) : SV_Target {
|
||||
return tex2D(sMagicBloom_Adapt, 0.0).x;
|
||||
}
|
||||
#endif
|
||||
|
||||
technique MagicBloom {
|
||||
pass Blur1 {
|
||||
VertexShader = PostProcessVS;
|
||||
PixelShader = PS_Blur1;
|
||||
RenderTarget = tMagicBloom_1;
|
||||
}
|
||||
pass Blur2 {
|
||||
VertexShader = PostProcessVS;
|
||||
PixelShader = PS_Blur2;
|
||||
RenderTarget = tMagicBloom_2;
|
||||
}
|
||||
pass Blur3 {
|
||||
VertexShader = PostProcessVS;
|
||||
PixelShader = PS_Blur3;
|
||||
RenderTarget = tMagicBloom_3;
|
||||
}
|
||||
pass Blur4 {
|
||||
VertexShader = PostProcessVS;
|
||||
PixelShader = PS_Blur4;
|
||||
RenderTarget = tMagicBloom_4;
|
||||
}
|
||||
pass Blur5 {
|
||||
VertexShader = PostProcessVS;
|
||||
PixelShader = PS_Blur5;
|
||||
RenderTarget = tMagicBloom_5;
|
||||
}
|
||||
pass Blur6 {
|
||||
VertexShader = PostProcessVS;
|
||||
PixelShader = PS_Blur6;
|
||||
RenderTarget = tMagicBloom_6;
|
||||
}
|
||||
pass Blur7 {
|
||||
VertexShader = PostProcessVS;
|
||||
PixelShader = PS_Blur7;
|
||||
RenderTarget = tMagicBloom_7;
|
||||
}
|
||||
pass Blur8 {
|
||||
VertexShader = PostProcessVS;
|
||||
PixelShader = PS_Blur8;
|
||||
RenderTarget = tMagicBloom_8;
|
||||
}
|
||||
pass Blend {
|
||||
VertexShader = PostProcessVS;
|
||||
PixelShader = PS_Blend;
|
||||
}
|
||||
#if !MAGICBLOOM_NOADAPT
|
||||
pass GetSmall {
|
||||
VertexShader = PostProcessVS;
|
||||
PixelShader = PS_GetSmall;
|
||||
RenderTarget = tMagicBloom_Small;
|
||||
}
|
||||
pass GetAdapt {
|
||||
VertexShader = PostProcessVS;
|
||||
PixelShader = PS_GetAdapt;
|
||||
RenderTarget = tMagicBloom_Adapt;
|
||||
}
|
||||
pass SaveAdapt {
|
||||
VertexShader = PostProcessVS;
|
||||
PixelShader = PS_SaveAdapt;
|
||||
RenderTarget = tMagicBloom_LastAdapt;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1,3 +1,7 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: CC0-1.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(__RESHADE__) || __RESHADE__ < 30000
|
||||
@@ -10,6 +14,9 @@
|
||||
#ifndef RESHADE_DEPTH_INPUT_IS_REVERSED
|
||||
#define RESHADE_DEPTH_INPUT_IS_REVERSED 1
|
||||
#endif
|
||||
#ifndef RESHADE_DEPTH_INPUT_IS_MIRRORED
|
||||
#define RESHADE_DEPTH_INPUT_IS_MIRRORED 0
|
||||
#endif
|
||||
#ifndef RESHADE_DEPTH_INPUT_IS_LOGARITHMIC
|
||||
#define RESHADE_DEPTH_INPUT_IS_LOGARITHMIC 0
|
||||
#endif
|
||||
@@ -75,6 +82,9 @@ namespace ReShade
|
||||
{
|
||||
#if RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN
|
||||
texcoord.y = 1.0 - texcoord.y;
|
||||
#endif
|
||||
#if RESHADE_DEPTH_INPUT_IS_MIRRORED
|
||||
texcoord.x = 1.0 - texcoord.x;
|
||||
#endif
|
||||
texcoord.x /= RESHADE_DEPTH_INPUT_X_SCALE;
|
||||
texcoord.y /= RESHADE_DEPTH_INPUT_Y_SCALE;
|
||||
@@ -105,6 +115,7 @@ namespace ReShade
|
||||
}
|
||||
|
||||
// Vertex shader generating a triangle covering the entire screen
|
||||
// See also https://www.reddit.com/r/gamedev/comments/2j17wk/a_slightly_faster_bufferless_vertex_shader_trick/
|
||||
void PostProcessVS(in uint id : SV_VertexID, out float4 position : SV_Position, out float2 texcoord : TEXCOORD)
|
||||
{
|
||||
texcoord.x = (id == 2) ? 2.0 : 0.0;
|
||||
|
||||
@@ -7,27 +7,27 @@
|
||||
#define RESHADE_VERSION(major,minor,build) (10000 * (major) + 100 * (minor) + (build))
|
||||
#define SUPPORTED_VERSION(major,minor,build) (__RESHADE__ >= RESHADE_VERSION(major,minor,build))
|
||||
|
||||
// Since 3.0.0
|
||||
// >= 3.0.0
|
||||
// Commit current in-game user interface status
|
||||
// https://github.com/crosire/reshade/commit/302bacc49ae394faedc2e29a296c1cebf6da6bb2#diff-82cf230afdb2a0d5174111e6f17548a5R1183
|
||||
// Added various GUI related uniform variable annotations
|
||||
// https://reshade.me/forum/releases/2341-3-0
|
||||
#define __UNIFORM_INPUT_ANY ui_type = "input";
|
||||
|
||||
#define __UNIFORM_INPUT_BOOL1 __UNIFORM_INPUT_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_INPUT_BOOL2 __UNIFORM_INPUT_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_INPUT_BOOL3 __UNIFORM_INPUT_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_INPUT_BOOL4 __UNIFORM_INPUT_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_INPUT_INT1 __UNIFORM_INPUT_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_INPUT_INT2 __UNIFORM_INPUT_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_INPUT_INT3 __UNIFORM_INPUT_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_INPUT_INT4 __UNIFORM_INPUT_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_INPUT_FLOAT1 __UNIFORM_INPUT_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_INPUT_FLOAT2 __UNIFORM_INPUT_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_INPUT_FLOAT3 __UNIFORM_INPUT_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_INPUT_FLOAT4 __UNIFORM_INPUT_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_INPUT_BOOL1 __UNIFORM_INPUT_ANY
|
||||
#define __UNIFORM_INPUT_BOOL2 __UNIFORM_INPUT_ANY
|
||||
#define __UNIFORM_INPUT_BOOL3 __UNIFORM_INPUT_ANY
|
||||
#define __UNIFORM_INPUT_BOOL4 __UNIFORM_INPUT_ANY
|
||||
#define __UNIFORM_INPUT_INT1 __UNIFORM_INPUT_ANY
|
||||
#define __UNIFORM_INPUT_INT2 __UNIFORM_INPUT_ANY
|
||||
#define __UNIFORM_INPUT_INT3 __UNIFORM_INPUT_ANY
|
||||
#define __UNIFORM_INPUT_INT4 __UNIFORM_INPUT_ANY
|
||||
#define __UNIFORM_INPUT_FLOAT1 __UNIFORM_INPUT_ANY
|
||||
#define __UNIFORM_INPUT_FLOAT2 __UNIFORM_INPUT_ANY
|
||||
#define __UNIFORM_INPUT_FLOAT3 __UNIFORM_INPUT_ANY
|
||||
#define __UNIFORM_INPUT_FLOAT4 __UNIFORM_INPUT_ANY
|
||||
|
||||
// Since 4.0.1
|
||||
// >= 4.0.1
|
||||
// Change slider widget to be used with new "slider" instead of a "drag" type annotation
|
||||
// https://github.com/crosire/reshade/commit/746229f31cd6f311a3e72a543e4f1f23faa23f11#diff-59405a313bd8cbfb0ca6dd633230e504R1701
|
||||
// Changed slider widget to be used with < ui_type = "slider"; > instead of < ui_type = "drag"; >
|
||||
@@ -35,7 +35,7 @@
|
||||
#if SUPPORTED_VERSION(4,0,1)
|
||||
#define __UNIFORM_DRAG_ANY ui_type = "drag";
|
||||
|
||||
// Since 4.0.0
|
||||
// >= 4.0.0
|
||||
// Rework statistics tab and add drag widgets back
|
||||
// https://github.com/crosire/reshade/commit/1b2c38795f00efd66c007da1f483f1441b230309
|
||||
// Changed drag widget to a slider widget (old one is still available via < ui_type = "drag2"; >)
|
||||
@@ -43,7 +43,7 @@
|
||||
#elif SUPPORTED_VERSION(4,0,0)
|
||||
#define __UNIFORM_DRAG_ANY ui_type = "drag2";
|
||||
|
||||
// Since 3.0.0
|
||||
// >= 3.0.0
|
||||
// Commit current in-game user interface status
|
||||
// https://github.com/crosire/reshade/commit/302bacc49ae394faedc2e29a296c1cebf6da6bb2#diff-82cf230afdb2a0d5174111e6f17548a5R1187
|
||||
// Added various GUI related uniform variable annotations
|
||||
@@ -52,20 +52,20 @@
|
||||
#define __UNIFORM_DRAG_ANY ui_type = "drag";
|
||||
#endif
|
||||
|
||||
#define __UNIFORM_DRAG_BOOL1 __UNIFORM_DRAG_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_DRAG_BOOL2 __UNIFORM_DRAG_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_DRAG_BOOL3 __UNIFORM_DRAG_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_DRAG_BOOL4 __UNIFORM_DRAG_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_DRAG_INT1 __UNIFORM_DRAG_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_DRAG_INT2 __UNIFORM_DRAG_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_DRAG_INT3 __UNIFORM_DRAG_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_DRAG_INT4 __UNIFORM_DRAG_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_DRAG_FLOAT1 __UNIFORM_DRAG_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_DRAG_FLOAT2 __UNIFORM_DRAG_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_DRAG_FLOAT3 __UNIFORM_DRAG_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_DRAG_FLOAT4 __UNIFORM_DRAG_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_DRAG_BOOL1 __UNIFORM_DRAG_ANY
|
||||
#define __UNIFORM_DRAG_BOOL2 __UNIFORM_DRAG_ANY
|
||||
#define __UNIFORM_DRAG_BOOL3 __UNIFORM_DRAG_ANY
|
||||
#define __UNIFORM_DRAG_BOOL4 __UNIFORM_DRAG_ANY
|
||||
#define __UNIFORM_DRAG_INT1 __UNIFORM_DRAG_ANY
|
||||
#define __UNIFORM_DRAG_INT2 __UNIFORM_DRAG_ANY
|
||||
#define __UNIFORM_DRAG_INT3 __UNIFORM_DRAG_ANY
|
||||
#define __UNIFORM_DRAG_INT4 __UNIFORM_DRAG_ANY
|
||||
#define __UNIFORM_DRAG_FLOAT1 __UNIFORM_DRAG_ANY
|
||||
#define __UNIFORM_DRAG_FLOAT2 __UNIFORM_DRAG_ANY
|
||||
#define __UNIFORM_DRAG_FLOAT3 __UNIFORM_DRAG_ANY
|
||||
#define __UNIFORM_DRAG_FLOAT4 __UNIFORM_DRAG_ANY
|
||||
|
||||
// Since 4.0.1
|
||||
// >= 4.0.1
|
||||
// Change slider widget to be used with new "slider" instead of a "drag" type annotation
|
||||
// https://github.com/crosire/reshade/commit/746229f31cd6f311a3e72a543e4f1f23faa23f11#diff-59405a313bd8cbfb0ca6dd633230e504R1699
|
||||
// Changed slider widget to be used with < ui_type = "slider"; > instead of < ui_type = "drag"; >
|
||||
@@ -73,7 +73,7 @@
|
||||
#if SUPPORTED_VERSION(4,0,1)
|
||||
#define __UNIFORM_SLIDER_ANY ui_type = "slider";
|
||||
|
||||
// Since 4.0.0
|
||||
// >= 4.0.0
|
||||
// Rework statistics tab and add drag widgets back
|
||||
// https://github.com/crosire/reshade/commit/1b2c38795f00efd66c007da1f483f1441b230309
|
||||
// Changed drag widget to a slider widget (old one is still available via < ui_type = "drag2"; >)
|
||||
@@ -84,20 +84,20 @@
|
||||
#define __UNIFORM_SLIDER_ANY __UNIFORM_DRAG_ANY
|
||||
#endif
|
||||
|
||||
#define __UNIFORM_SLIDER_BOOL1 __UNIFORM_SLIDER_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_SLIDER_BOOL2 __UNIFORM_SLIDER_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_SLIDER_BOOL3 __UNIFORM_SLIDER_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_SLIDER_BOOL4 __UNIFORM_SLIDER_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_SLIDER_INT1 __UNIFORM_SLIDER_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_SLIDER_INT2 __UNIFORM_SLIDER_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_SLIDER_INT3 __UNIFORM_SLIDER_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_SLIDER_INT4 __UNIFORM_SLIDER_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_SLIDER_FLOAT1 __UNIFORM_SLIDER_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_SLIDER_FLOAT2 __UNIFORM_SLIDER_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_SLIDER_FLOAT3 __UNIFORM_SLIDER_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_SLIDER_FLOAT4 __UNIFORM_SLIDER_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_SLIDER_BOOL1 __UNIFORM_SLIDER_ANY
|
||||
#define __UNIFORM_SLIDER_BOOL2 __UNIFORM_SLIDER_ANY
|
||||
#define __UNIFORM_SLIDER_BOOL3 __UNIFORM_SLIDER_ANY
|
||||
#define __UNIFORM_SLIDER_BOOL4 __UNIFORM_SLIDER_ANY
|
||||
#define __UNIFORM_SLIDER_INT1 __UNIFORM_SLIDER_ANY
|
||||
#define __UNIFORM_SLIDER_INT2 __UNIFORM_SLIDER_ANY
|
||||
#define __UNIFORM_SLIDER_INT3 __UNIFORM_SLIDER_ANY
|
||||
#define __UNIFORM_SLIDER_INT4 __UNIFORM_SLIDER_ANY
|
||||
#define __UNIFORM_SLIDER_FLOAT1 __UNIFORM_SLIDER_ANY
|
||||
#define __UNIFORM_SLIDER_FLOAT2 __UNIFORM_SLIDER_ANY
|
||||
#define __UNIFORM_SLIDER_FLOAT3 __UNIFORM_SLIDER_ANY
|
||||
#define __UNIFORM_SLIDER_FLOAT4 __UNIFORM_SLIDER_ANY
|
||||
|
||||
// Since 3.0.0
|
||||
// >= 3.0.0
|
||||
// Add combo box display type for uniform variables and fix displaying of integer variable under Direct3D 9
|
||||
// https://github.com/crosire/reshade/commit/b025bfae5f7343509ec0cacf6df0cff537c499f2#diff-82cf230afdb2a0d5174111e6f17548a5R1631
|
||||
// Added various GUI related uniform variable annotations
|
||||
@@ -105,19 +105,19 @@
|
||||
#define __UNIFORM_COMBO_ANY ui_type = "combo";
|
||||
|
||||
// __UNIFORM_COMBO_BOOL1
|
||||
#define __UNIFORM_COMBO_BOOL2 __UNIFORM_COMBO_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_COMBO_BOOL3 __UNIFORM_COMBO_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_COMBO_BOOL4 __UNIFORM_COMBO_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_COMBO_INT1 __UNIFORM_COMBO_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_COMBO_INT2 __UNIFORM_COMBO_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_COMBO_INT3 __UNIFORM_COMBO_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_COMBO_INT4 __UNIFORM_COMBO_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_COMBO_FLOAT1 __UNIFORM_COMBO_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_COMBO_FLOAT2 __UNIFORM_COMBO_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_COMBO_FLOAT3 __UNIFORM_COMBO_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_COMBO_FLOAT4 __UNIFORM_COMBO_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_COMBO_BOOL2 __UNIFORM_COMBO_ANY
|
||||
#define __UNIFORM_COMBO_BOOL3 __UNIFORM_COMBO_ANY
|
||||
#define __UNIFORM_COMBO_BOOL4 __UNIFORM_COMBO_ANY
|
||||
#define __UNIFORM_COMBO_INT1 __UNIFORM_COMBO_ANY
|
||||
#define __UNIFORM_COMBO_INT2 __UNIFORM_COMBO_ANY
|
||||
#define __UNIFORM_COMBO_INT3 __UNIFORM_COMBO_ANY
|
||||
#define __UNIFORM_COMBO_INT4 __UNIFORM_COMBO_ANY
|
||||
#define __UNIFORM_COMBO_FLOAT1 __UNIFORM_COMBO_ANY
|
||||
#define __UNIFORM_COMBO_FLOAT2 __UNIFORM_COMBO_ANY
|
||||
#define __UNIFORM_COMBO_FLOAT3 __UNIFORM_COMBO_ANY
|
||||
#define __UNIFORM_COMBO_FLOAT4 __UNIFORM_COMBO_ANY
|
||||
|
||||
// Since 4.0.0 (but the ui_items force set "Off\0On\0"), and if less than it force converted to checkbox
|
||||
// >= 4.0.0
|
||||
// Add option to display boolean values as combo box instead of checkbox
|
||||
// https://github.com/crosire/reshade/commit/aecb757c864c9679e77edd6f85a1521c49e489c1#diff-59405a313bd8cbfb0ca6dd633230e504R1147
|
||||
// https://github.com/crosire/reshade/blob/v4.0.0/source/gui.cpp
|
||||
@@ -125,7 +125,7 @@
|
||||
// https://reshade.me/forum/releases/4772-4-0
|
||||
#define __UNIFORM_COMBO_BOOL1 __UNIFORM_COMBO_ANY
|
||||
|
||||
// Since 4.0.0
|
||||
// >= 4.0.0
|
||||
// Cleanup GUI code and rearrange some widgets
|
||||
// https://github.com/crosire/reshade/commit/6751f7bd50ea7c0556cf0670f10a4b4ba912ee7d#diff-59405a313bd8cbfb0ca6dd633230e504R1711
|
||||
// Added radio button widget (via < ui_type = "radio"; ui_items = "Button 1\0Button 2\0...\0"; >)
|
||||
@@ -136,48 +136,46 @@
|
||||
#define __UNIFORM_RADIO_ANY __UNIFORM_COMBO_ANY
|
||||
#endif
|
||||
|
||||
#define __UNIFORM_RADIO_BOOL1 __UNIFORM_RADIO_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_RADIO_BOOL2 __UNIFORM_RADIO_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_RADIO_BOOL3 __UNIFORM_RADIO_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_RADIO_BOOL4 __UNIFORM_RADIO_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_RADIO_INT1 __UNIFORM_RADIO_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_RADIO_INT2 __UNIFORM_RADIO_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_RADIO_INT3 __UNIFORM_RADIO_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_RADIO_INT4 __UNIFORM_RADIO_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_RADIO_FLOAT1 __UNIFORM_RADIO_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_RADIO_FLOAT2 __UNIFORM_RADIO_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_RADIO_FLOAT3 __UNIFORM_RADIO_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_RADIO_FLOAT4 __UNIFORM_RADIO_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_RADIO_BOOL1 __UNIFORM_RADIO_ANY
|
||||
#define __UNIFORM_RADIO_BOOL2 __UNIFORM_RADIO_ANY
|
||||
#define __UNIFORM_RADIO_BOOL3 __UNIFORM_RADIO_ANY
|
||||
#define __UNIFORM_RADIO_BOOL4 __UNIFORM_RADIO_ANY
|
||||
#define __UNIFORM_RADIO_INT1 __UNIFORM_RADIO_ANY
|
||||
#define __UNIFORM_RADIO_INT2 __UNIFORM_RADIO_ANY
|
||||
#define __UNIFORM_RADIO_INT3 __UNIFORM_RADIO_ANY
|
||||
#define __UNIFORM_RADIO_INT4 __UNIFORM_RADIO_ANY
|
||||
#define __UNIFORM_RADIO_FLOAT1 __UNIFORM_RADIO_ANY
|
||||
#define __UNIFORM_RADIO_FLOAT2 __UNIFORM_RADIO_ANY
|
||||
#define __UNIFORM_RADIO_FLOAT3 __UNIFORM_RADIO_ANY
|
||||
#define __UNIFORM_RADIO_FLOAT4 __UNIFORM_RADIO_ANY
|
||||
|
||||
// Since 4.1.0
|
||||
// >= 4.1.0
|
||||
// Fix floating point uniforms with unknown "ui_type" not showing up in UI
|
||||
// https://github.com/crosire/reshade/commit/50e5bf44dfc84bc4220c2b9f19d5f50c7a0fda66#diff-59405a313bd8cbfb0ca6dd633230e504R1788
|
||||
// Fixed floating point uniforms with unknown "ui_type" not showing up in UI
|
||||
// https://reshade.me/forum/releases/5021-4-1
|
||||
#define __UNIFORM_COLOR_ANY ui_type = "color";
|
||||
|
||||
// Since 3.0.0
|
||||
// >= 3.0.0
|
||||
// Move technique list to preset configuration file
|
||||
// https://github.com/crosire/reshade/blob/84bba3aa934c1ebe4c6419b69dfe1690d9ab9d34/source/runtime.cpp#L1328
|
||||
// Added various GUI related uniform variable annotations
|
||||
// https://reshade.me/forum/releases/2341-3-0
|
||||
|
||||
// If empty, these versions before 4.1.0 are decide that the type is color from the number of components
|
||||
|
||||
#define __UNIFORM_COLOR_BOOL1 __UNIFORM_COLOR_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_COLOR_BOOL2 __UNIFORM_COLOR_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_COLOR_BOOL3 __UNIFORM_COLOR_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_COLOR_BOOL4 __UNIFORM_COLOR_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_COLOR_INT1 __UNIFORM_COLOR_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_COLOR_INT2 __UNIFORM_COLOR_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_COLOR_INT3 __UNIFORM_COLOR_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_COLOR_INT4 __UNIFORM_COLOR_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_COLOR_BOOL1 __UNIFORM_COLOR_ANY
|
||||
#define __UNIFORM_COLOR_BOOL2 __UNIFORM_COLOR_ANY
|
||||
#define __UNIFORM_COLOR_BOOL3 __UNIFORM_COLOR_ANY
|
||||
#define __UNIFORM_COLOR_BOOL4 __UNIFORM_COLOR_ANY
|
||||
#define __UNIFORM_COLOR_INT1 __UNIFORM_COLOR_ANY
|
||||
#define __UNIFORM_COLOR_INT2 __UNIFORM_COLOR_ANY
|
||||
#define __UNIFORM_COLOR_INT3 __UNIFORM_COLOR_ANY
|
||||
#define __UNIFORM_COLOR_INT4 __UNIFORM_COLOR_ANY
|
||||
// __UNIFORM_COLOR_FLOAT1
|
||||
#define __UNIFORM_COLOR_FLOAT2 __UNIFORM_COLOR_ANY // It is unsupported on all version
|
||||
#define __UNIFORM_COLOR_FLOAT3 __UNIFORM_COLOR_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_COLOR_FLOAT4 __UNIFORM_COLOR_ANY // If it was not supported in someday or now, please add information
|
||||
#define __UNIFORM_COLOR_FLOAT2 __UNIFORM_COLOR_ANY
|
||||
#define __UNIFORM_COLOR_FLOAT3 __UNIFORM_COLOR_ANY
|
||||
#define __UNIFORM_COLOR_FLOAT4 __UNIFORM_COLOR_ANY
|
||||
|
||||
// Since 4.2.0
|
||||
// >= 4.2.0
|
||||
// Add alpha slider widget for single component uniform variables (#86)
|
||||
// https://github.com/crosire/reshade/commit/87a740a8e3c4dcda1dd4eeec8d5cff7fa35fe829#diff-59405a313bd8cbfb0ca6dd633230e504R1820
|
||||
// Added alpha slider widget for single component uniform variables
|
||||
@@ -188,7 +186,7 @@
|
||||
#define __UNIFORM_COLOR_FLOAT1 __UNIFORM_SLIDER_ANY
|
||||
#endif
|
||||
|
||||
// Since 4.3.0
|
||||
// >= 4.3.0
|
||||
// Add new "list" GUI widget (#103)
|
||||
// https://github.com/crosire/reshade/commit/515287d20ce615c19cf3d4c21b49f83896f04ddc#diff-59405a313bd8cbfb0ca6dd633230e504R1894
|
||||
// Added new "list" GUI widget
|
||||
@@ -200,17 +198,17 @@
|
||||
#endif
|
||||
|
||||
// __UNIFORM_LIST_BOOL1
|
||||
#define __UNIFORM_LIST_BOOL2 __UNIFORM_LIST_ANY // Not supported in all versions
|
||||
#define __UNIFORM_LIST_BOOL3 __UNIFORM_LIST_ANY // Not supported in all versions
|
||||
#define __UNIFORM_LIST_BOOL4 __UNIFORM_LIST_ANY // Not supported in all versions
|
||||
#define __UNIFORM_LIST_INT1 __UNIFORM_LIST_ANY // Supported in 4.3.0
|
||||
#define __UNIFORM_LIST_INT2 __UNIFORM_LIST_ANY // Not supported in all versions
|
||||
#define __UNIFORM_LIST_INT3 __UNIFORM_LIST_ANY // Not supported in all versions
|
||||
#define __UNIFORM_LIST_INT4 __UNIFORM_LIST_ANY // Not supported in all versions
|
||||
#define __UNIFORM_LIST_FLOAT1 __UNIFORM_LIST_ANY // Not supported in all versions
|
||||
#define __UNIFORM_LIST_FLOAT2 __UNIFORM_LIST_ANY // Not supported in all versions
|
||||
#define __UNIFORM_LIST_FLOAT3 __UNIFORM_LIST_ANY // Not supported in all versions
|
||||
#define __UNIFORM_LIST_FLOAT4 __UNIFORM_LIST_ANY // Not supported in all versions
|
||||
#define __UNIFORM_LIST_BOOL2 __UNIFORM_LIST_ANY
|
||||
#define __UNIFORM_LIST_BOOL3 __UNIFORM_LIST_ANY
|
||||
#define __UNIFORM_LIST_BOOL4 __UNIFORM_LIST_ANY
|
||||
#define __UNIFORM_LIST_INT1 __UNIFORM_LIST_ANY // >= 4.3.0
|
||||
#define __UNIFORM_LIST_INT2 __UNIFORM_LIST_ANY
|
||||
#define __UNIFORM_LIST_INT3 __UNIFORM_LIST_ANY
|
||||
#define __UNIFORM_LIST_INT4 __UNIFORM_LIST_ANY
|
||||
#define __UNIFORM_LIST_FLOAT1 __UNIFORM_LIST_ANY
|
||||
#define __UNIFORM_LIST_FLOAT2 __UNIFORM_LIST_ANY
|
||||
#define __UNIFORM_LIST_FLOAT3 __UNIFORM_LIST_ANY
|
||||
#define __UNIFORM_LIST_FLOAT4 __UNIFORM_LIST_ANY
|
||||
|
||||
// For compatible with ComboBox
|
||||
// For compatible with 'combo'
|
||||
#define __UNIFORM_LIST_BOOL1 __UNIFORM_COMBO_ANY
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/**
|
||||
* Tonemap version 1.1
|
||||
* by Christian Cann Schuldt Jensen ~ CeeJay.dk
|
||||
*/
|
||||
|
||||
#include "ReShadeUI.fxh"
|
||||
|
||||
uniform float Gamma < __UNIFORM_SLIDER_FLOAT1
|
||||
ui_min = 0.0; ui_max = 2.0;
|
||||
ui_tooltip = "Adjust midtones. 1.0 is neutral. This setting does exactly the same as the one in Lift Gamma Gain, only with less control.";
|
||||
> = 1.0;
|
||||
uniform float Exposure < __UNIFORM_SLIDER_FLOAT1
|
||||
ui_min = -1.0; ui_max = 1.0;
|
||||
ui_tooltip = "Adjust exposure";
|
||||
> = 0.0;
|
||||
uniform float Saturation < __UNIFORM_SLIDER_FLOAT1
|
||||
ui_min = -1.0; ui_max = 1.0;
|
||||
ui_tooltip = "Adjust saturation";
|
||||
> = 0.0;
|
||||
|
||||
uniform float Bleach < __UNIFORM_SLIDER_FLOAT1
|
||||
ui_min = 0.0; ui_max = 1.0;
|
||||
ui_tooltip = "Brightens the shadows and fades the colors";
|
||||
> = 0.0;
|
||||
|
||||
uniform float Defog < __UNIFORM_SLIDER_FLOAT1
|
||||
ui_min = 0.0; ui_max = 1.0;
|
||||
ui_tooltip = "How much of the color tint to remove";
|
||||
> = 0.0;
|
||||
uniform float3 FogColor < __UNIFORM_COLOR_FLOAT3
|
||||
ui_label = "Defog Color";
|
||||
ui_tooltip = "Which color tint to remove";
|
||||
> = float3(0.0, 0.0, 1.0);
|
||||
|
||||
|
||||
#include "ReShade.fxh"
|
||||
|
||||
float3 TonemapPass(float4 position : SV_Position, float2 texcoord : TexCoord) : SV_Target
|
||||
{
|
||||
float3 color = tex2D(ReShade::BackBuffer, texcoord).rgb;
|
||||
color = saturate(color - Defog * FogColor * 2.55); // Defog
|
||||
color *= pow(2.0f, Exposure); // Exposure
|
||||
color = pow(color, Gamma); // Gamma
|
||||
|
||||
const float3 coefLuma = float3(0.2126, 0.7152, 0.0722);
|
||||
float lum = dot(coefLuma, color);
|
||||
|
||||
float L = saturate(10.0 * (lum - 0.45));
|
||||
float3 A2 = Bleach * color;
|
||||
|
||||
float3 result1 = 2.0f * color * lum;
|
||||
float3 result2 = 1.0f - 2.0f * (1.0f - lum) * (1.0f - color);
|
||||
|
||||
float3 newColor = lerp(result1, result2, L);
|
||||
float3 mixRGB = A2 * newColor;
|
||||
color += ((1.0f - A2) * mixRGB);
|
||||
|
||||
float3 middlegray = dot(color, (1.0 / 3.0));
|
||||
float3 diffcolor = color - middlegray;
|
||||
color = (color + diffcolor * Saturation) / (1 + (diffcolor * Saturation)); // Saturation
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
technique Tonemap
|
||||
{
|
||||
pass
|
||||
{
|
||||
VertexShader = PostProcessVS;
|
||||
PixelShader = TonemapPass;
|
||||
}
|
||||
}
|
||||
73
EXE/reshade-shaders/Shaders/TriDither.fxh
Normal file
73
EXE/reshade-shaders/Shaders/TriDither.fxh
Normal file
@@ -0,0 +1,73 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Triangular Dither //
|
||||
// By The Sandvich Maker //
|
||||
// Ported to ReShade by TreyM //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// Usage: //
|
||||
// Include this file in your shader like so: #include "TriDither.fx" //
|
||||
// //
|
||||
// For shader developers, use this syntax to do a function call in your //
|
||||
// code as the last thing before exiting a given shader. You should dither //
|
||||
// anytime data is going to be truncated to a lower bitdepth. Color input //
|
||||
// must be a float3 value. //
|
||||
// //
|
||||
// input.rgb += TriDither(input.rgb, uv, bits); //
|
||||
// //
|
||||
// "bits" is an integer number that determines the bit depth //
|
||||
// being dithered to. Usually 8, sometimes 10 //
|
||||
// You can automate this by letting Reshade decide like so: //
|
||||
// //
|
||||
// input += TriDither(input, uv, BUFFER_COLOR_BIT_DEPTH); //
|
||||
// //
|
||||
// Manual setup looks something like this for an 8-bit backbuffer: //
|
||||
// //
|
||||
// input.rgb += TriDither(input.rgb, uv, 8); //
|
||||
// //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
uniform float DitherTimer < source = "timer"; >;
|
||||
#define remap(v, a, b) (((v) - (a)) / ((b) - (a)))
|
||||
|
||||
float rand21(float2 uv)
|
||||
{
|
||||
float2 noise = frac(sin(dot(uv, float2(12.9898, 78.233) * 2.0)) * 43758.5453);
|
||||
return (noise.x + noise.y) * 0.5;
|
||||
}
|
||||
|
||||
float rand11(float x)
|
||||
{
|
||||
return frac(x * 0.024390243);
|
||||
}
|
||||
|
||||
float permute(float x)
|
||||
{
|
||||
return ((34.0 * x + 1.0) * x) % 289.0;
|
||||
}
|
||||
|
||||
float3 TriDither(float3 color, float2 uv, int bits)
|
||||
{
|
||||
float bitstep = exp2(bits) - 1.0;
|
||||
float lsb = 1.0 / bitstep;
|
||||
float lobit = 0.5 / bitstep;
|
||||
float hibit = (bitstep - 0.5) / bitstep;
|
||||
|
||||
float3 m = float3(uv, rand21(uv + (DitherTimer * 0.001))) + 1.0;
|
||||
float h = permute(permute(permute(m.x) + m.y) + m.z);
|
||||
|
||||
float3 noise1, noise2;
|
||||
noise1.x = rand11(h); h = permute(h);
|
||||
noise2.x = rand11(h); h = permute(h);
|
||||
noise1.y = rand11(h); h = permute(h);
|
||||
noise2.y = rand11(h); h = permute(h);
|
||||
noise1.z = rand11(h); h = permute(h);
|
||||
noise2.z = rand11(h);
|
||||
|
||||
float3 lo = saturate(remap(color.xyz, 0.0, lobit));
|
||||
float3 hi = saturate(remap(color.xyz, 1.0, hibit));
|
||||
float3 uni = noise1 - 0.5;
|
||||
float3 tri = noise1 - noise2;
|
||||
return lerp(uni, tri, min(lo, hi)) * lsb;
|
||||
}
|
||||
289
EXE/reshade-shaders/Shaders/UIMask.fx
Normal file
289
EXE/reshade-shaders/Shaders/UIMask.fx
Normal file
@@ -0,0 +1,289 @@
|
||||
/*
|
||||
Simple UIMask shader by luluco250
|
||||
|
||||
I have no idea why this was never ported back to ReShade 3.0 from 2.0,
|
||||
but if you missed it, here it is.
|
||||
|
||||
It doesn't feature the auto mask from the original shader.
|
||||
|
||||
It does feature a new multi-channnel masking feature. UI masks can now contain
|
||||
separate 'modes' within each of the three color channels.
|
||||
|
||||
For example, you can have the regular hud on the red channel (the default one),
|
||||
a mask for an inventory screen on the green channel and a mask for a quest menu
|
||||
on the blue channel. You can then use keyboard keys to toggle each channel on or off.
|
||||
|
||||
Multiple channels can be active at once, they'll just add up to mask the image.
|
||||
|
||||
Simple/legacy masks are not affected by this, they'll work just as you'd expect,
|
||||
so you can still make simple black and white masks that use all color channels, it'll
|
||||
be no different than just having it on a single channel.
|
||||
|
||||
Tips:
|
||||
|
||||
--You can adjust how much it will affect your HUD by changing "Mask Intensity".
|
||||
|
||||
--You don't actually need to place the UIMask_Bottom technique at the bottom of
|
||||
your shader pipeline, if you have any effects that don't necessarily affect
|
||||
the visibility of the HUD you can place it before that.
|
||||
For instance, if you use color correction shaders like LUT, you might want
|
||||
to place UIMask_Bottom just before that.
|
||||
|
||||
--Preprocessor flags:
|
||||
--UIMASK_MULTICHANNEL:
|
||||
Enables having up to three different masks on each color channel.
|
||||
|
||||
--Refer to this page for keycodes:
|
||||
https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
|
||||
|
||||
--To make a custom mask:
|
||||
|
||||
1-Take a screenshot of your game with the HUD enabled,
|
||||
preferrably with any effects disabled for maximum visibility.
|
||||
|
||||
2-Open the screenshot with your preferred image editor program, I use GIMP.
|
||||
|
||||
3-Make a background white layer if there isn't one already.
|
||||
Be sure to leave it behind your actual screenshot for the while.
|
||||
|
||||
4-Make an empty layer for the mask itself, you can call it "mask".
|
||||
|
||||
5-Having selected the mask layer, paint the places where HUD constantly is,
|
||||
such as health bars, important messages, minimaps etc.
|
||||
|
||||
6-Delete or make your screenshot layer invisible.
|
||||
|
||||
7-Before saving your mask, let's do some gaussian blurring to improve it's look and feel:
|
||||
For every step of blurring you want to do, make a new layer, such as:
|
||||
Mask - Blur16x16
|
||||
Mask - Blur8x8
|
||||
Mask - Blur4x4
|
||||
Mask - Blur2x2
|
||||
Mask - NoBlur
|
||||
You should use your image editor's default gaussian blurring filter, if there is one.
|
||||
This avoids possible artifacts and makes the mask blend more easily on the eyes.
|
||||
You may not need this if your mask is accurate enough and/or the HUD is simple enough.
|
||||
|
||||
8-Now save the final image with a unique name such as "MyUIMask.png" in your textures folder.
|
||||
|
||||
9-Set the preprocessor definition UIMASK_TEXTURE to the unique name of your image, with quotes.
|
||||
You're done!
|
||||
|
||||
|
||||
MIT Licensed:
|
||||
|
||||
Copyright (c) 2017 Lucas Melo
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
//#region Preprocessor
|
||||
|
||||
#include "ReShade.fxh"
|
||||
#include "ReShadeUI.fxh"
|
||||
|
||||
#ifndef UIMASK_MULTICHANNEL
|
||||
#define UIMASK_MULTICHANNEL 0
|
||||
#endif
|
||||
|
||||
#if !UIMASK_MULTICHANNEL
|
||||
#define TEXFORMAT R8
|
||||
#else
|
||||
#define TEXFORMAT RGBA8
|
||||
#endif
|
||||
|
||||
#ifndef UIMASK_TEXTURE
|
||||
#define UIMASK_TEXTURE "UIMask.png"
|
||||
#endif
|
||||
|
||||
//#endregion
|
||||
|
||||
namespace UIMask
|
||||
{
|
||||
|
||||
//#region Uniforms
|
||||
|
||||
uniform int _Help
|
||||
<
|
||||
ui_label = " ";
|
||||
ui_text =
|
||||
"For more detailed instructions, see the text at the top of this "
|
||||
"effect's shader file (UIMask.fx).\n"
|
||||
"\n"
|
||||
"Available preprocessor definitions:\n"
|
||||
" UIMASK_MULTICHANNEL:\n"
|
||||
" If set to 1, each of the RGB color channels in the texture is "
|
||||
"treated as a separate mask.\n"
|
||||
"\n"
|
||||
"How to create a mask:\n"
|
||||
"\n"
|
||||
"1. Take a screenshot with the game's UI appearing.\n"
|
||||
"2. Open the screenshot in an image editor, GIMP or Photoshop are "
|
||||
"recommended.\n"
|
||||
"3. Create a new layer over the screenshot layer, fill it with black.\n"
|
||||
"4. Reduce the layer opacity so you can see the screenshot layer "
|
||||
"below.\n"
|
||||
"5. Cover the UI with white to mask it from effects. The stronger the "
|
||||
"mask white color, the more opaque the mask will be.\n"
|
||||
"6. Set the mask layer opacity back to 100%.\n"
|
||||
"7. Save the image in one of your texture folders, making sure to "
|
||||
"use a unique name such as: \"MyUIMask.png\"\n"
|
||||
"8. Set the preprocessor definition UIMASK_TEXTURE to the name of "
|
||||
"your image, with quotes: \"MyUIMask.png\"\n"
|
||||
;
|
||||
ui_category = "Help";
|
||||
ui_category_closed = true;
|
||||
ui_type = "radio";
|
||||
>;
|
||||
|
||||
uniform float fMask_Intensity
|
||||
<
|
||||
__UNIFORM_SLIDER_FLOAT1
|
||||
|
||||
ui_label = "Mask Intensity";
|
||||
ui_tooltip =
|
||||
"How much to mask effects from affecting the original image.\n"
|
||||
"\nDefault: 1.0";
|
||||
ui_min = 0.0;
|
||||
ui_max = 1.0;
|
||||
ui_step = 0.001;
|
||||
> = 1.0;
|
||||
|
||||
uniform bool bDisplayMask <
|
||||
ui_label = "Display Mask";
|
||||
ui_tooltip =
|
||||
"Display the mask texture.\n"
|
||||
"Useful for testing multiple channels or simply the mask itself.\n"
|
||||
"\nDefault: Off";
|
||||
> = false;
|
||||
|
||||
#if UIMASK_MULTICHANNEL
|
||||
|
||||
uniform bool bToggleRed <
|
||||
ui_label = "Toggle Red Channel";
|
||||
ui_tooltip = "Toggle UI masking for the red channel.\n"
|
||||
"Right click to assign a hotkey.\n"
|
||||
"\nDefault: On";
|
||||
> = true;
|
||||
|
||||
uniform bool bToggleGreen <
|
||||
ui_label = "Toggle Green Channel";
|
||||
ui_tooltip = "Toggle UI masking for the green channel.\n"
|
||||
"Right click to assign a hotkey."
|
||||
"\nDefault: On";
|
||||
> = true;
|
||||
|
||||
uniform bool bToggleBlue <
|
||||
ui_label = "Toggle Blue Channel";
|
||||
ui_tooltip = "Toggle UI masking for the blue channel.\n"
|
||||
"Right click to assign a hotkey."
|
||||
"\nDefault: On";
|
||||
> = true;
|
||||
|
||||
#endif
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Textures
|
||||
|
||||
texture BackupTex
|
||||
{
|
||||
Width = BUFFER_WIDTH;
|
||||
Height = BUFFER_HEIGHT;
|
||||
};
|
||||
sampler Backup
|
||||
{
|
||||
Texture = BackupTex;
|
||||
};
|
||||
|
||||
texture MaskTex <source=UIMASK_TEXTURE;>
|
||||
{
|
||||
Width = BUFFER_WIDTH;
|
||||
Height = BUFFER_HEIGHT;
|
||||
Format = TEXFORMAT;
|
||||
};
|
||||
sampler Mask
|
||||
{
|
||||
Texture = MaskTex;
|
||||
};
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Shaders
|
||||
|
||||
float4 BackupPS(float4 pos : SV_Position, float2 uv : TEXCOORD) : SV_Target {
|
||||
return tex2D(ReShade::BackBuffer, uv);
|
||||
}
|
||||
|
||||
float4 MainPS(float4 pos : SV_Position, float2 uv : TEXCOORD) : SV_Target {
|
||||
float4 color = tex2D(ReShade::BackBuffer, uv);
|
||||
float4 backup = tex2D(Backup, uv);
|
||||
|
||||
#if !UIMASK_MULTICHANNEL
|
||||
float mask = tex2D(Mask, uv).r;
|
||||
#else
|
||||
float3 mask_rgb = tex2D(Mask, uv).rgb;
|
||||
|
||||
// This just works, it basically adds masking with each channel that has
|
||||
// been toggled.
|
||||
float mask = saturate(
|
||||
1.0 - dot(1.0 - mask_rgb,
|
||||
float3(bToggleRed, bToggleGreen, bToggleBlue)));
|
||||
#endif
|
||||
|
||||
color = lerp(color, backup, mask * fMask_Intensity);
|
||||
color = bDisplayMask ? mask : color;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Techniques
|
||||
|
||||
technique UIMask_Top
|
||||
<
|
||||
ui_tooltip = "Place this *above* the effects to be masked.";
|
||||
>
|
||||
{
|
||||
pass
|
||||
{
|
||||
VertexShader = PostProcessVS;
|
||||
PixelShader = BackupPS;
|
||||
RenderTarget = BackupTex;
|
||||
}
|
||||
}
|
||||
|
||||
technique UIMask_Bottom
|
||||
<
|
||||
ui_tooltip =
|
||||
"Place this *below* the effects to be masked.\n"
|
||||
"If you want to add a toggle key for the effect, set it to this one.";
|
||||
>
|
||||
{
|
||||
pass
|
||||
{
|
||||
VertexShader = PostProcessVS;
|
||||
PixelShader = MainPS;
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
} // Namespace.
|
||||
Reference in New Issue
Block a user