Data: Add reshade-shaders (mainly headers)

This commit is contained in:
Stenzek 2023-08-28 00:23:05 +10:00
parent 8a40c7bf94
commit 720b5c1e9d
14 changed files with 2901 additions and 0 deletions

View file

@ -0,0 +1,19 @@
ReShade FX shaders
==================
This repository aims to collect post-processing shaders written in the ReShade FX shader language.
Installation
------------
1. [Download](https://github.com/crosire/reshade-shaders/archive/master.zip) this repository
2. Extract the downloaded archive file somewhere
3. Start your game, open the ReShade in-game menu and switch to the "Settings" tab
4. Add the path to the extracted [Shaders](/Shaders) folder to "Effect Search Paths"
5. Add the path to the extracted [Textures](/Textures) folder to "Texture Search Paths"
6. Switch back to the "Home" tab and click on "Reload" to load the shaders
Contributing
------------
Check out [the language reference document](REFERENCE.md) to get started on how to write your own!

View file

@ -0,0 +1,632 @@
ReShade FX shading language
===========================
# Contents
* [Macros](#macros)
* [Texture object](#texture-object)
* [Sampler object](#sampler-object)
* [Storage object](#storage-object)
* [Uniform variables](#uniform-variables)
* [Structs](#structs)
* [Namespaces](#namespaces)
* [User functions](#user-functions)
* [Intrinsic functions](#intrinsic-functions)
* [Techniques](#techniques)
# Concepts
The ReShade FX shading language is heavily based on the DX9-style HLSL syntax, with a few extensions. For more details on HLSL, check out the Programming Guide: https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-writing-shaders-9 .\
This document will instead primarily focus on syntax and features that are unique to ReShade FX.
### Macros
The ReShade FX compiler predefines certain preprocessor macros, as listed below:
* ``__FILE__`` Current file path
* ``__FILE_NAME__`` Current file name without path
* ``__FILE_STEM__`` Current file name without extension and path
* ``__LINE__`` Current line number
* ``__RESHADE__`` Version of the injector (in the format `MAJOR * 10000 + MINOR * 100 + REVISION`)
* ``__APPLICATION__`` 32-bit truncated Fnv1a hash of the application executable name
* ``__VENDOR__`` Vendor id (e.g. 0x10de for NVIDIA, 0x1002 for AMD)
* ``__DEVICE__`` Device id
* ``__RENDERER__`` Graphics API used to render effects
* D3D9: 0x9000
* D3D10: 0xa000 or higher
* D3D11: 0xb000 or higher (e.g. 0xb100 for D3D11.1)
* D3D12: 0xc000 or higher
* OpenGL: 0x10000 or higher (e.g. 0x14300 for OpenGL 4.3)
* Vulkan: 0x20000 or higher (e.g. 0x21100 for Vulkan 1.1)
* ``BUFFER_WIDTH`` Backbuffer width (essentially the width of the image the application renders to the screen)
* ``BUFFER_HEIGHT`` Backbuffer height
* ``BUFFER_RCP_WIDTH`` Reciprocal of the backbuffer width (equals `1.0 / BUFFER_WIDTH`)
* ``BUFFER_RCP_HEIGHT`` Reciprocal of the backbuffer height (equals `1.0 / BUFFER_HEIGHT`)
* ``BUFFER_COLOR_BIT_DEPTH`` Color bit depth of the backbuffer (8 or 10)
* ``BUFFER_COLOR_SPACE`` Color space type for presentation; 0 = unknown, 1 = sRGB, 2 = scRGB, 3 = HDR10 ST2084, 4 = HDR10 HLG.
Constructs like the following may be interpreted as a configurable UI option. To prevent this, the preprocessor define name can be prefixed with an underscore or made shorter than 8 characters, in which case ReShade will not display it in the UI.
```hlsl
#ifndef MY_PREPROCESSOR_DEFINE
#define MY_PREPROCESSOR_DEFINE 0
#endif
```
You can disable optimization during shader compilation by adding this line to an effect file:
```c
#pragma reshade skipoptimization
```
### Texture Object
> Textures are multidimensional data containers usually used to store images.
Annotations:
* ``texture2D imageTex < source = "path/to/image.bmp"; > { ... };``
Opens image from the patch specified, resizes it to the texture size and loads it into the texture.\
ReShade supports Bitmap (\*.bmp), Portable Network Graphics (\*.png), JPEG (\*.jpg), Targa Image (\*.tga) and DirectDraw Surface (\*.dds) files.
* ``texture2D myTex1 < pooled = true; > { Width = 100; Height = 100; Format = RGBA8; };``
``texture2D myTex2 < pooled = true; > { Width = 100; Height = 100; Format = RGBA8; };``
ReShade will attempt to re-use the same memory for textures with the same dimensions and format across effect files if the pooled annotation is set.
ReShade FX allows semantics to be used on texture declarations. This is used to request special textures:
* ``texture2D texColor : COLOR;``
Receives the backbuffer contents (read-only).
* ``texture2D texDepth : DEPTH;``
Receives the game's depth information (read-only).
Declared textures are created at runtime with the parameters specified in their definition body.
```hlsl
texture2D texColorBuffer : COLOR;
texture2D texDepthBuffer : DEPTH;
texture2D texTarget
{
// The texture dimensions (default: 1x1).
Width = BUFFER_WIDTH / 2; // Used with texture1D
Height = BUFFER_HEIGHT / 2; // Used with texture1D and texture2D
Depth = 1; // Used with texture1D, texture2D and texture3D
// The number of mipmaps including the base level (default: 1).
MipLevels = 1;
// The internal texture format (default: RGBA8).
// Available formats:
// R8, R16, R16F, R32F, R32I, R32U
// RG8, RG16, RG16F, RG32F
// RGBA8, RGBA16, RGBA16F, RGBA32F
// RGB10A2
Format = RGBA8;
// Unspecified properties are set to the defaults shown here.
};
texture3D texIntegerVolume
{
Width = 10;
Height = 10;
Depth = 10;
Format = R32I; // Single-component integer format, which means sampler and storage have to be of that integer type (sampler3D<int> or storage3D<int>)
};
```
### Sampler Object
> Samplers are the bridge between textures and shaders. They define how a texture is read from and how data outside texel coordinates is sampled. Multiple samplers can refer to the same texture using different options.
```hlsl
sampler2D samplerColor
{
// The texture to be used for sampling.
Texture = texColorBuffer;
// The method used for resolving texture coordinates which are out of bounds.
// Available values: CLAMP, MIRROR, WRAP or REPEAT, BORDER
AddressU = CLAMP;
AddressV = CLAMP;
AddressW = CLAMP;
// The magnification, minification and mipmap filtering types.
// Available values: POINT, LINEAR
MagFilter = LINEAR;
MinFilter = LINEAR;
MipFilter = LINEAR;
// The maximum mipmap levels accessible.
MinLOD = 0.0f;
MaxLOD = 1000.0f;
// An offset applied to the calculated mipmap level (default: 0).
MipLODBias = 0.0f;
// Enable or disable converting to linear colors when sampling from the
// texture.
SRGBTexture = false;
// Unspecified properties are set to the defaults shown here.
};
sampler2D samplerDepth
{
Texture = texDepthBuffer;
};
sampler2D samplerTarget
{
Texture = texTarget;
};
```
### Storage Object
> Storage objects define how a texture should be written to from compute shaders.
```hlsl
storage2D storageTarget
{
// The texture to be used as storage.
Texture = texTarget;
// The mipmap level of the texture to fetch/store.
MipLevel = 0;
};
storage3D<int> storageIntegerVolume
{
Texture = texIntegerVolume;
};
```
### Uniform Variables
> Global variables with the `uniform` qualifier are constant across each iteration of a shader per pass and may be controlled via the UI.
Annotations to customize UI appearance:
* ui_type: Can be `input`, `drag`, `slider`, `combo`, `radio` or `color`
* ui_min: The smallest value allowed in this variable (required when `ui_type = "drag"` or `ui_type = "slider"`)
* ui_max: The largest value allowed in this variable (required when `ui_type = "drag"` or `ui_type = "slider"`)
* ui_step: The value added/subtracted when clicking the button next to the slider
* ui_items: A list of items for the combo box or radio buttons, each item is terminated with a `\0` character (required when `ui_type = "combo"` or `ui_type = "radio"`)
* ui_label: Display name of the variable in the UI. If this is missing, the variable name is used instead.
* ui_tooltip: Text that is displayed when the user hovers over the variable in the UI. Use this for a description.
* ui_category: Groups values together under a common headline. Note that all variables in the same category also have to be declared next to each other for this to be displayed correctly.
* ui_category_closed: Set to true to show a category closed by default.
* ui_spacing: Adds space before the UI widget (multiplied by the value of the annotation).
* ui_units: Adds units description on the slider/drag bar (only used when `ui_type = "drag"` or `ui_type = "slider"`)
* hidden: Set to true to hide this technique in the UI.
Annotations are also used to request special runtime values (via the `source` annotation):
* ``uniform float frametime < source = "frametime"; >;``
Time in milliseconds it took for the last frame to complete.
* ``uniform int framecount < source = "framecount"; >;``
Total amount of frames since the game started.
* ``uniform float4 date < source = "date"; >;``
float4(year, month (1 - 12), day of month (1 - 31), time in seconds)
* ``uniform float timer < source = "timer"; >;``
Timer counting time in milliseconds since game start.
* ``uniform float2 pingpong < source = "pingpong"; min = 0; max = 10; step = 2; smoothing = 0.0; >;``
Value that smoothly interpolates between `min` and `max` using `step` as the increase/decrease value every second (so a step value of 1 means the value is increased/decreased by 1 per second).\
In this case it would go from 0 to 10 in 5 seconds and then back to 0 in another 5 seconds (interpolated every frame).
The `smoothing` value affects the interpolation curve (0 is linear interpolation and anything else changes the speed depending on how close the current value is to `min` or `max`).
The second component is either +1 or -1 depending on the direction it currently goes.
* ``uniform int random_value < source = "random"; min = 0; max = 10; >;``
Gets a new random value between min and max every pass.
* ``uniform bool space_bar_down < source = "key"; keycode = 0x20; mode = ""; >;``
True if specified keycode (in this case the spacebar) is pressed and false otherwise.
If mode is set to "press" the value is true only in the frame the key was initially held down.
If mode is set to "toggle" the value stays true until the key is pressed a second time.
* ``uniform bool left_mouse_button_down < source = "mousebutton"; keycode = 0; mode = ""; >;``
True if specified mouse button (0 - 4) is pressed and false otherwise.
If mode is set to "press" the value is true only in the frame the key was initially held down.
If mode is set to "toggle" the value stays true until the key is pressed a second time.
* ``uniform float2 mouse_point < source = "mousepoint"; >;``
Gets the position of the mouse cursor in screen coordinates.
* ``uniform float2 mouse_delta < source = "mousedelta"; >;``
Gets the movement of the mouse cursor in screen coordinates.
* ``uniform float2 mouse_value < source = "mousewheel"; min = 0.0; max = 10.0; > = 1.0;``
The first component value is modified via the mouse wheel. Starts at 1.0, goes up (but not past 10.0) when mouse wheel is moved forward and down (but not past 0.0) when it is moved backward.
The second component holds the current wheel state (how much the mouse wheel was moved this frame). It's positive for forward movement, negative for backward movement or zero for no movement.
* ``uniform bool has_depth < source = "bufready_depth"; >;``
True if the application's depth buffer is available in textures declared with `DEPTH`, false if not.
* ``uniform bool overlay_open < source = "overlay_open"; >;``
True if the ReShade in-game overlay is currently open, false if not.
* ``uniform int active_variable < source = "overlay_active"; >;``
Contains the one-based index of the uniform variable currently being modified in the overlay, zero if none.
* ``uniform int hovered_variable < source = "overlay_hovered"; >;``
Contains the one-based index of the uniform variable currently hovered with the cursor in the overlay, zero if none.
* ``uniform bool screenshot < source = "screenshot"; >;``
True if a screenshot is being taken, false if not.
```hlsl
// Initializers are used to specify the default value (zero is used if not specified).
uniform float4 UniformSingleValue = float4(0.0f, 0.0f, 0.0f, 0.0f);
// It is recommended to use constants instead of uniforms if the value is not changing or user-configurable.
static const float4 ConstantSingleValue = float4(0.0f, 0.0f, 0.0f, 0.0f);
```
### Structs
> Structs are user defined data types that can be used as types for variables. These behave the same as in HLSL.
```hlsl
struct MyStruct
{
int MyField1, MyField2;
float MyField3;
};
```
### Namespaces
> Namespaces are used to group functions and variables together, which is especially useful to prevent name clashing.
> The "::" operator is used to resolve variables or functions inside other namespaces.
```hlsl
namespace MyNamespace
{
namespace MyNestedNamespace
{
void DoNothing()
{
}
}
void DoNothing()
{
MyNestedNamespace::DoNothing();
}
}
```
### User functions
Parameter qualifiers:
* ``in`` Declares an input parameter. Default and implicit if none is used. Functions expect these to be filled with a value.
* ``out`` Declares an output parameter. The value is filled in the function and can be used in the caller again.
* ``inout`` Declares a parameter that provides input and also expects output.
Supported flow-control statements:
* ``if ([condition]) { [statement...] } [else { [statement...] }]``
Statements after if are only executed if condition is true, otherwise the ones after else are executed (if it exists).
* ``switch ([expression]) { [case [constant]/default]: [statement...] }``
Selects the case matching the switch expression or default if non does and it exists.
* ``for ([declaration]; [condition]; [iteration]) { [statement...] }``
Runs the statements in the body as long as the condition is true. The iteration expression is executed after each run.
* ``while ([condition]) { [statement...] }``
Runs the statements in the body as long as the condition is true.
* ``do { [statement...] } while ([condition]);``
Similar to a normal while loop with the difference that the statements are executed at least once.
* ``break;``
Breaks out of the current loop or switch statement and jumps to the statement after.
* ``continue;``
Jumps directly to the next loop iteration ignoring any left code in the current one.
* ``return [expression];``
Jumps out of the current function, optionally providing a value to the caller.
* ``discard;``
Abort rendering of the current pixel and step out of the shader. Can be used in pixel shaders only.
```hlsl
// Semantics are used to tell the runtime which arguments to connect between shader stages.
// They are ignored on non-entry-point functions (those not used in any pass below).
// Semantics starting with "SV_" are system value semantics and serve a special meaning.
// The following vertex shader demonstrates how to generate a simple fullscreen triangle with the three vertices provided by ReShade (http://redd.it/2j17wk):
void ExampleVS(uint id : SV_VertexID, out float4 position : SV_Position, out float2 texcoord : TEXCOORD0)
{
texcoord.x = (id == 2) ? 2.0 : 0.0;
texcoord.y = (id == 1) ? 2.0 : 0.0;
position = float4(texcoord * float2(2, -2) + float2(-1, 1), 0, 1);
}
// The following pixel shader simply returns the color of the games output again without modifying it (via the "color" output parameter):
void ExamplePS0(float4 pos : SV_Position, float2 texcoord : TEXCOORD0, out float4 color : SV_Target)
{
color = tex2D(samplerColor, texcoord);
}
// The following pixel shader takes the output of the previous pass and adds the depth buffer content to the right screen side.
float4 ExamplePS1(float4 pos : SV_Position, float2 texcoord : TEXCOORD0) : SV_Target
{
// Here color information is sampled with "samplerTarget" and thus from "texTarget" (see sampler declaration above),
// which was set as render target in the previous pass (see the technique definition below) and now contains its output.
// In this case it is the game output, but downsampled to half because the texture is only half of the screen size.
float4 color = tex2D(samplerTarget, texcoord);
// Only execute the following code block when on the right half of the screen.
if (texcoord.x > 0.5f)
{
// Sample from the game depth buffer using the "samplerDepth" sampler declared above.
float depth = tex2D(samplerDepth, texcoord).r;
// Linearize the depth values to better visualize them.
depth = 2.0 / (-99.0 * depth + 101.0);
color.rgb = depth.rrr;
}
return color;
}
// The following compute shader uses shared memory within a thread group:
groupshared int sharedMem[64];
void ExampleCS0(uint3 tid : SV_GroupThreadID)
{
if (tid.y == 0)
sharedMem[tid.x] = tid.x;
barrier();
if (tid.y == 0 && (tid.x % 2) != 0)
sharedMem[tid.x] += sharedMem[tid.x + 1];
}
// The following compute shader writes a color gradient to the "texTarget" texture:
void ExampleCS1(uint3 id : SV_DispatchThreadID, uint3 tid : SV_GroupThreadID)
{
tex2Dstore(storageTarget, id.xy, float4(tid.xy / float2(20 * 64, 2 * 8), 0, 1));
}
```
### Intrinsic functions
ReShade FX supports most of the standard HLSL intrinsics.\
Check out https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-intrinsic-functions for reference on them:
> abs, acos, all, any, asfloat, asin, asint, asuint, atan, atan2, ceil, clamp, cos, cosh, cross, ddx, ddy, degrees, determinant, distance, dot, exp, exp2, faceforward, floor, frac, frexp, fwidth, isinf, isnan, ldexp, length, lerp, log, log10, log2, mad, max, min, modf, mul, normalize, pow, radians, rcp, reflect, refract, round, rsqrt, saturate, sign, sin, sincos, sinh, smoothstep, sqrt, step, tan, tanh, transpose, trunc
In addition to these, ReShade FX provides a few additional ones:
* ``T tex1D(sampler1D<T> s, float coords)``
* ``T tex1D(sampler1D<T> s, float coords, int offset)``
* ``T tex2D(sampler2D<T> s, float2 coords)``
* ``T tex2D(sampler2D<T> s, float2 coords, int2 offset)``
* ``T tex3D(sampler3D<T> s, float3 coords)``
* ``T tex3D(sampler3D<T> s, float3 coords, int3 offset)``
Samples a texture.\
See also https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-to-sample.
* ``T tex1Dlod(sampler1D<T> s, float4 coords)``
* ``T tex1Dlod(sampler1D<T> s, float4 coords, int offset)``
* ``T tex2Dlod(sampler2D<T> s, float4 coords)``
* ``T tex2Dlod(sampler2D<T> s, float4 coords, int2 offset)``
* ``T tex3Dlod(sampler3D<T> s, float4 coords)``
* ``T tex3Dlod(sampler3D<T> s, float4 coords, int3 offset)``
Samples a texture on a specific mipmap level.\
The accepted coordinates are in the form `float4(x, y, 0, lod)`.\
See also https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-to-samplelevel.
* ``T tex1Dfetch(sampler1D<T> s, int coords)``
* ``T tex1Dfetch(sampler1D<T> s, int coords, int lod)``
* ``T tex1Dfetch(storage1D<T> s, int coords)``
* ``T tex2Dfetch(sampler2D<T> s, int2 coords)``
* ``T tex2Dfetch(sampler2D<T> s, int2 coords, int lod)``
* ``T tex2Dfetch(storage2D<T> s, int2 coords)``
* ``T tex3Dfetch(sampler3D<T> s, int3 coords)``
* ``T tex3Dfetch(sampler3D<T> s, int3 coords, int lod)``
* ``T tex3Dfetch(storage3D<T> s, int3 coords)``
Fetches a value from the texture directly without any sampling.\
See also https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-to-load.
* ``float4 tex2DgatherR(sampler2D s, float2 coords)``
* ``float4 tex2DgatherR(sampler2D s, float2 coords, int2 offset)``
* ``float4 tex2DgatherG(sampler2D s, float2 coords)``
* ``float4 tex2DgatherG(sampler2D s, float2 coords, int2 offset)``
* ``float4 tex2DgatherB(sampler2D s, float2 coords)``
* ``float4 tex2DgatherB(sampler2D s, float2 coords, int2 offset)``
* ``float4 tex2DgatherA(sampler2D s, float2 coords)``
* ``float4 tex2DgatherA(sampler2D s, float2 coords, int2 offset)``
Gathers the specified component of the four neighboring pixels and returns the result.\
`tex2DgatherR` for example is equivalent to https://docs.microsoft.com/windows/win32/direct3dhlsl/texture2d-gatherred.
The return value is effectively:
```
float4(tex2Dfetch(s, coords * tex2Dsize(s) + int2(0, 1)).comp,
tex2Dfetch(s, coords * tex2Dsize(s) + int2(1, 1)).comp,
tex2Dfetch(s, coords * tex2Dsize(s) + int2(0, 1)).comp,
tex2Dfetch(s, coords * tex2Dsize(s) + int2(0, 0)).comp)
```
* ``int tex1Dsize(sampler1D<T> s)``
* ``int tex1Dsize(sampler1D<T> s, int lod)``
* ``int tex1Dsize(storage1D<T> s)``
* ``int2 tex2Dsize(sampler2D<T> s)``
* ``int2 tex2Dsize(sampler2D<T> s, int lod)``
* ``int2 tex2Dsize(storage2D<T> s)``
* ``int3 tex3Dsize(sampler3D<T> s)``
* ``int3 tex3Dsize(sampler3D<T> s, int lod)``
* ``int3 tex3Dsize(storage3D<T> s)``
Gets the texture dimensions of the specified mipmap level.\
See also https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-to-getdimensions
* ``void tex1Dstore(storage1D<T> s, int coords, T value)``
* ``void tex2Dstore(storage2D<T> s, int2 coords, T value)``
* ``void tex3Dstore(storage2D<T> s, int3 coords, T value)``
Writes the specified value to the texture referenced by the storage. Only valid from within compute shaders.\
See also https://docs.microsoft.com/windows/win32/direct3dhlsl/sm5-object-rwtexture2d-operatorindex
* ``void barrier()``
Synchronizes threads in a thread group.\
Is equivalent to https://docs.microsoft.com/windows/win32/direct3dhlsl/groupmemorybarrierwithgroupsync
* ``void memoryBarrier()``
Waits on the completion of all memory accesses resulting from the use of texture or storage operations.\
Is equivalent to https://docs.microsoft.com/windows/win32/direct3dhlsl/allmemorybarrier
* ``void groupMemoryBarrier()``
Waits on the completion of all memory accesses within the thread group resulting from the use of texture or storage operations.\
Is equivalent to https://docs.microsoft.com/windows/win32/direct3dhlsl/groupmemorybarrier
* ``int atomicAdd(inout int dest, int value)``
* ``int atomicAdd(storage1D<int> s, int coords, int value)``
* ``int atomicAdd(storage2D<int> s, int2 coords, int value)``
* ``int atomicAdd(storage3D<int> s, int3 coords, int value)``
https://docs.microsoft.com/windows/win32/direct3dhlsl/interlockedadd
* ``int atomicAnd(inout int dest, int value)``
* ``int atomicAnd(storage1D<int> s, int coords, int value)``
* ``int atomicAnd(storage2D<int> s, int2 coords, int value)``
* ``int atomicAnd(storage3D<int> s, int3 coords, int value)``
https://docs.microsoft.com/windows/win32/direct3dhlsl/interlockedand
* ``int atomicOr(inout int dest, int value)``
* ``int atomicOr(storage1D<int> s, int coords, int value)``
* ``int atomicOr(storage2D<int> s, int2 coords, int value)``
* ``int atomicOr(storage3D<int> s, int3 coords, int value)``
https://docs.microsoft.com/windows/win32/direct3dhlsl/interlockedor
* ``int atomicXor(inout int dest, int value)``
* ``int atomicXor(storage1D<int> s, int coords, int value)``
* ``int atomicXor(storage2D<int> s, int2 coords, int value)``
* ``int atomicXor(storage3D<int> s, int3 coords, int value)``
https://docs.microsoft.com/windows/win32/direct3dhlsl/interlockedxor
* ``int atomicMin(inout int dest, int value)``
* ``int atomicMin(storage1D<int> s, int coords, int value)``
* ``int atomicMin(storage2D<int> s, int2 coords, int value)``
* ``int atomicMin(storage3D<int> s, int3 coords, int value)``
https://docs.microsoft.com/windows/win32/direct3dhlsl/interlockedmin
* ``int atomicMax(inout int dest, int value)``
* ``int atomicMax(storage<int> s, int coords, int value)``
* ``int atomicMax(storage<int> s, int2 coords, int value)``
* ``int atomicMax(storage<int> s, int3 coords, int value)``
https://docs.microsoft.com/windows/win32/direct3dhlsl/interlockedmax
* ``int atomicExchange(inout int dest, int value)``
* ``int atomicExchange(storage1D<int> s, int coords, int value)``
* ``int atomicExchange(storage2D<int> s, int2 coords, int value)``
* ``int atomicExchange(storage3D<int> s, int3 coords, int value)``
https://docs.microsoft.com/windows/win32/direct3dhlsl/interlockedexchange
* ``int atomicCompareExchange(inout int dest, int compare, int value)``
* ``int atomicCompareExchange(storage1D<int> s, int coords, int compare, int value)``
* ``int atomicCompareExchange(storage2D<int> s, int2 coords, int compare, int value)``
* ``int atomicCompareExchange(storage3D<int> s, int3 coords, int compare, int value)``
https://docs.microsoft.com/windows/win32/direct3dhlsl/interlockedcompareexchange
### Techniques
> An effect file can have multiple techniques, each representing a full render pipeline, which is executed to apply post-processing effects. ReShade executes all enabled techniques in the order they were defined in the effect file.
> A technique is made up of one or more passes which contain info about which render states to set and what shaders to execute. They are run sequentially starting with the top most declared. A name is optional.
> Each pass can set render states. The default value is used if one is not specified in the pass body.
Annotations:
* ``technique Name < enabled = true; >``
Enable (or disable if false) this technique by default.
* ``technique Name < enabled_in_screenshot = true; >``
Set this to false to disabled this technique while a screenshot is taken.
* ``technique Name < timeout = 1000; >``
Auto-toggle this technique off 1000 milliseconds after it was enabled.\
This can for example be used to have a technique run a single time only to do some initialization work, via ``technique Name < enabled = true; timeout = 1; >``
* ``technique Name < toggle = 0x20; togglectrl = false; toggleshift = false; togglealt = false; >``
Toggle this technique when the specified key is pressed.
* ``technique Name < hidden = true; >``
Hide this technique in the UI.
* ``technique Name < ui_label = "My Effect Name"; >``
Uses a custom name for the technique in the UI.
* ``technique Name < ui_tooltip = "My Effect description"; >``
Shows the specified text when the user hovers the technique in the UI.
```hlsl
technique Example < ui_tooltip = "This is an example!"; >
{
pass p0
{
// The primitive topology rendered in the draw call.
// Available values:
// POINTLIST, LINELIST, LINESTRIP, TRIANGLELIST, TRIANGLESTRIP
PrimitiveTopology = TRIANGLELIST; // or PrimitiveType
// The number of vertices ReShade generates for the draw call.
// This has different effects on the rendered primitives based on the primitive topology.
// A triangle list needs 3 separate vertices for every triangle for example, a strip on the other hand reuses the last 2, so only 1 is needed for every additional triangle.
VertexCount = 3;
// The following two accept function names declared above which are used as entry points for the shader.
// Please note that all parameters must have an associated semantic so the runtime can match them between shader stages.
VertexShader = ExampleVS;
PixelShader = ExamplePS0;
// The number of thread groups to dispatch when a compute shader is used.
DispatchSizeX = 1;
DispatchSizeY = 1;
DispatchSizeZ = 1;
// Compute shaders are specified with the number of threads per thread group in brackets.
// The following for example will create groups of 64x1x1 threads:
ComputeShader = ExampleCS0<64,1,1>;
// RenderTarget0 to RenderTarget7 allow to set one or more render targets for rendering to textures.
// Set them to a texture name declared above in order to write the color output (SV_Target0 to RenderTarget0, SV_Target1 to RenderTarget1, ...) to this texture in this pass.
// If multiple render targets are used, the dimensions of them has to match each other.
// If no render targets are set here, RenderTarget0 points to the backbuffer.
// Be aware that you can only read **OR** write a texture at the same time, so do not sample from it while it is still bound as render target here.
// RenderTarget and RenderTarget0 are aliases.
RenderTarget = texTarget;
// Set to true to clear all bound render targets to zero before rendering.
ClearRenderTargets = false;
// Set to false to disable automatic rebuilding of the mipmap chain of all render targets and/or storage objects.
// This is useful when using a compute shader that writes to specific mipmap levels, rather than relying on the automatic generation.
GenerateMipMaps = true;
// A mask applied to the color output before it is written to the render target.
RenderTargetWriteMask = 0xF; // or ColorWriteEnable
// Enable or disable gamma correction applied to the output.
SRGBWriteEnable = false;
// BlendEnable0 to BlendEnable7 allow to enable or disable color and alpha blending for the respective render target.
// Don't forget to also set "ClearRenderTargets" to "false" if you want to blend with existing data in a render target.
// BlendEnable and BlendEnable0 are aliases,
BlendEnable = false;
// The operator used for color and alpha blending.
// To set these individually for each render target, append the render target index to the pass state name, e.g. BlendOp3 for the fourth render target (zero-based index 3).
// Available values:
// ADD, SUBTRACT, REVSUBTRACT, MIN, MAX
BlendOp = ADD;
BlendOpAlpha = ADD;
// The data source and optional pre-blend operation used for blending.
// To set these individually for each render target, append the render target index to the pass state name, e.g. SrcBlend3 for the fourth render target (zero-based index 3).
// Available values:
// ZERO, ONE,
// SRCCOLOR, SRCALPHA, INVSRCCOLOR, INVSRCALPHA
// DESTCOLOR, DESTALPHA, INVDESTCOLOR, INVDESTALPHA
SrcBlend = ONE;
SrcBlendAlpha = ONE;
DestBlend = ZERO;
DestBlendAlpha = ZERO;
// Enable or disable the stencil test.
// The depth and stencil buffers are cleared before rendering each pass in a technique.
StencilEnable = false;
// The masks applied before reading from/writing to the stencil.
// Available values:
// 0-255
StencilReadMask = 0xFF; // or StencilMask
StencilWriteMask = 0xFF;
// The function used for stencil testing.
// Available values:
// NEVER, ALWAYS
// EQUAL, NEQUAL or NOTEQUAL
// LESS, GREATER, LEQUAL or LESSEQUAL, GEQUAL or GREATEREQUAL
StencilFunc = ALWAYS;
// The reference value used with the stencil function.
StencilRef = 0;
// The operation to perform on the stencil buffer when the
// stencil test passed/failed or stencil passed but depth test
// failed.
// Available values:
// KEEP, ZERO, REPLACE, INCR, INCRSAT, DECR, DECRSAT, INVERT
StencilPassOp = KEEP; // or StencilPass
StencilFailOp = KEEP; // or StencilFail
StencilDepthFailOp = KEEP; // or StencilZFail
}
pass p1
{
ComputeShader = ExampleCS1<64,8>;
DispatchSizeX = 20; // 20 * 64 threads total in X dimension
DispatchSizeY = 2; // 2 * 8 threads total in Y dimension
}
pass p2
{
VertexShader = ExampleVS;
PixelShader = ExamplePS1;
}
}
```

View 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);
}
}
}
}

View 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;
}
}

View 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;
}
}

View 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

View 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;
}
}

View 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; \
}

View file

@ -0,0 +1,113 @@
#pragma once
#if !defined(__RESHADE__) || __RESHADE__ < 30000
#error "ReShade 3.0+ is required to use this header file"
#endif
#ifndef RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN
#define RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN 0
#endif
#ifndef RESHADE_DEPTH_INPUT_IS_REVERSED
#define RESHADE_DEPTH_INPUT_IS_REVERSED 1
#endif
#ifndef RESHADE_DEPTH_INPUT_IS_LOGARITHMIC
#define RESHADE_DEPTH_INPUT_IS_LOGARITHMIC 0
#endif
#ifndef RESHADE_DEPTH_MULTIPLIER
#define RESHADE_DEPTH_MULTIPLIER 1
#endif
#ifndef RESHADE_DEPTH_LINEARIZATION_FAR_PLANE
#define RESHADE_DEPTH_LINEARIZATION_FAR_PLANE 1000.0
#endif
// Above 1 expands coordinates, below 1 contracts and 1 is equal to no scaling on any axis
#ifndef RESHADE_DEPTH_INPUT_Y_SCALE
#define RESHADE_DEPTH_INPUT_Y_SCALE 1
#endif
#ifndef RESHADE_DEPTH_INPUT_X_SCALE
#define RESHADE_DEPTH_INPUT_X_SCALE 1
#endif
// An offset to add to the Y coordinate, (+) = move up, (-) = move down
#ifndef RESHADE_DEPTH_INPUT_Y_OFFSET
#define RESHADE_DEPTH_INPUT_Y_OFFSET 0
#endif
#ifndef RESHADE_DEPTH_INPUT_Y_PIXEL_OFFSET
#define RESHADE_DEPTH_INPUT_Y_PIXEL_OFFSET 0
#endif
// An offset to add to the X coordinate, (+) = move right, (-) = move left
#ifndef RESHADE_DEPTH_INPUT_X_OFFSET
#define RESHADE_DEPTH_INPUT_X_OFFSET 0
#endif
#ifndef RESHADE_DEPTH_INPUT_X_PIXEL_OFFSET
#define RESHADE_DEPTH_INPUT_X_PIXEL_OFFSET 0
#endif
#define BUFFER_PIXEL_SIZE float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT)
#define BUFFER_SCREEN_SIZE float2(BUFFER_WIDTH, BUFFER_HEIGHT)
#define BUFFER_ASPECT_RATIO (BUFFER_WIDTH * BUFFER_RCP_HEIGHT)
namespace ReShade
{
#if defined(__RESHADE_FXC__)
float GetAspectRatio() { return BUFFER_WIDTH * BUFFER_RCP_HEIGHT; }
float2 GetPixelSize() { return float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT); }
float2 GetScreenSize() { return float2(BUFFER_WIDTH, BUFFER_HEIGHT); }
#define AspectRatio GetAspectRatio()
#define PixelSize GetPixelSize()
#define ScreenSize GetScreenSize()
#else
// These are deprecated and will be removed eventually.
static const float AspectRatio = BUFFER_WIDTH * BUFFER_RCP_HEIGHT;
static const float2 PixelSize = float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT);
static const float2 ScreenSize = float2(BUFFER_WIDTH, BUFFER_HEIGHT);
#endif
// Global textures and samplers
texture BackBufferTex : COLOR;
texture DepthBufferTex : DEPTH;
sampler BackBuffer { Texture = BackBufferTex; };
sampler DepthBuffer { Texture = DepthBufferTex; };
// Helper functions
float GetLinearizedDepth(float2 texcoord)
{
#if RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN
texcoord.y = 1.0 - texcoord.y;
#endif
texcoord.x /= RESHADE_DEPTH_INPUT_X_SCALE;
texcoord.y /= RESHADE_DEPTH_INPUT_Y_SCALE;
#if RESHADE_DEPTH_INPUT_X_PIXEL_OFFSET
texcoord.x -= RESHADE_DEPTH_INPUT_X_PIXEL_OFFSET * BUFFER_RCP_WIDTH;
#else // Do not check RESHADE_DEPTH_INPUT_X_OFFSET, since it may be a decimal number, which the preprocessor cannot handle
texcoord.x -= RESHADE_DEPTH_INPUT_X_OFFSET / 2.000000001;
#endif
#if RESHADE_DEPTH_INPUT_Y_PIXEL_OFFSET
texcoord.y += RESHADE_DEPTH_INPUT_Y_PIXEL_OFFSET * BUFFER_RCP_HEIGHT;
#else
texcoord.y += RESHADE_DEPTH_INPUT_Y_OFFSET / 2.000000001;
#endif
float depth = tex2Dlod(DepthBuffer, float4(texcoord, 0, 0)).x * RESHADE_DEPTH_MULTIPLIER;
#if RESHADE_DEPTH_INPUT_IS_LOGARITHMIC
const float C = 0.01;
depth = (exp(depth * log(C + 1.0)) - 1.0) / C;
#endif
#if RESHADE_DEPTH_INPUT_IS_REVERSED
depth = 1.0 - depth;
#endif
const float N = 1.0;
depth /= RESHADE_DEPTH_LINEARIZATION_FAR_PLANE - depth * (RESHADE_DEPTH_LINEARIZATION_FAR_PLANE - N);
return depth;
}
}
// Vertex shader generating a triangle covering the entire screen
void PostProcessVS(in uint id : SV_VertexID, out float4 position : SV_Position, out float2 texcoord : TEXCOORD)
{
texcoord.x = (id == 2) ? 2.0 : 0.0;
texcoord.y = (id == 1) ? 2.0 : 0.0;
position = float4(texcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
}

View file

@ -0,0 +1,216 @@
#pragma once
#if !defined(__RESHADE__) || __RESHADE__ < 30000
#error "ReShade 3.0+ is required to use this header file"
#endif
#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
// 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
// Since 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"; >
// https://reshade.me/forum/releases/4772-4-0
#if SUPPORTED_VERSION(4,0,1)
#define __UNIFORM_DRAG_ANY ui_type = "drag";
// Since 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"; >)
// https://reshade.me/forum/releases/4772-4-0
#elif SUPPORTED_VERSION(4,0,0)
#define __UNIFORM_DRAG_ANY ui_type = "drag2";
// Since 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
// https://reshade.me/forum/releases/2341-3-0
#else
#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
// Since 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"; >
// https://reshade.me/forum/releases/4772-4-0
#if SUPPORTED_VERSION(4,0,1)
#define __UNIFORM_SLIDER_ANY ui_type = "slider";
// Since 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"; >)
// https://reshade.me/forum/releases/4772-4-0
#elif SUPPORTED_VERSION(4,0,0)
#define __UNIFORM_SLIDER_ANY ui_type = "drag";
#else
#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
// Since 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
// https://reshade.me/forum/releases/2341-3-0
#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
// Since 4.0.0 (but the ui_items force set "Off\0On\0"), and if less than it force converted to checkbox
// 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
// Added option to display boolean values as combo box instead of checkbox (via < ui_type = "combo"; >)
// https://reshade.me/forum/releases/4772-4-0
#define __UNIFORM_COMBO_BOOL1 __UNIFORM_COMBO_ANY
// Since 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"; >)
// https://reshade.me/forum/releases/4772-4-0
#if SUPPORTED_VERSION(4,0,0)
#define __UNIFORM_RADIO_ANY ui_type = "radio";
#else
#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
// Since 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
// 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
// __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
// Since 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
// https://reshade.me/forum/releases/5150-4-2
#if SUPPORTED_VERSION(4,2,0)
#define __UNIFORM_COLOR_FLOAT1 __UNIFORM_COLOR_ANY
#else
#define __UNIFORM_COLOR_FLOAT1 __UNIFORM_SLIDER_ANY
#endif
// Since 4.3.0
// Add new "list" GUI widget (#103)
// https://github.com/crosire/reshade/commit/515287d20ce615c19cf3d4c21b49f83896f04ddc#diff-59405a313bd8cbfb0ca6dd633230e504R1894
// Added new "list" GUI widget
// https://reshade.me/forum/releases/5417-4-3
#if SUPPORTED_VERSION(4,3,0)
#define __UNIFORM_LIST_ANY ui_type = "list";
#else
#define __UNIFORM_LIST_ANY __UNIFORM_COMBO_ANY
#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
// For compatible with ComboBox
#define __UNIFORM_LIST_BOOL1 __UNIFORM_COMBO_ANY

View 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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 B

View file

@ -0,0 +1 @@
https://github.com/crosire/reshade-shaders