diff --git a/enbseries.ini b/enbseries.ini index 57d5616..d47d291 100644 --- a/enbseries.ini +++ b/enbseries.ini @@ -56,22 +56,22 @@ AmountInteriorNight=1.0 [SKY] IgnoreWeatherSystem=true Enable=true -GradientIntensityDawn=0.89 +GradientIntensityDawn=1.02 GradientIntensitySunrise=1.15 GradientIntensityDay=1.29 GradientIntensitySunset=1.130001 -GradientIntensityDusk=0.920001 -GradientIntensityNight=0.620001 +GradientIntensityDusk=1.080001 +GradientIntensityNight=0.410001 GradientIntensityInteriorDay=1.18 -GradientIntensityInteriorNight=0.35 -GradientDesaturationDawn=0.0 -GradientDesaturationSunrise=0.0 -GradientDesaturationDay=0.0 -GradientDesaturationSunset=0.0 -GradientDesaturationDusk=0.0 -GradientDesaturationNight=0.0 -GradientDesaturationInteriorDay=0.0 -GradientDesaturationInteriorNight=0.0 +GradientIntensityInteriorNight=0.37 +GradientDesaturationDawn=0.35 +GradientDesaturationSunrise=0.43 +GradientDesaturationDay=0.33 +GradientDesaturationSunset=0.45 +GradientDesaturationDusk=0.36 +GradientDesaturationNight=0.28 +GradientDesaturationInteriorDay=0.32 +GradientDesaturationInteriorNight=0.23 GradientTopIntensityDawn=0.62 GradientTopIntensitySunrise=0.79 GradientTopIntensityDay=0.990001 @@ -100,7 +100,7 @@ GradientMiddleIntensityDawn=0.84 GradientMiddleIntensitySunrise=1.02 GradientMiddleIntensityDay=1.27 GradientMiddleIntensitySunset=1.03 -GradientMiddleIntensityDusk=0.89 +GradientMiddleIntensityDusk=0.96 GradientMiddleIntensityNight=0.66 GradientMiddleIntensityInteriorDay=1.0 GradientMiddleIntensityInteriorNight=0.55 @@ -112,11 +112,11 @@ GradientMiddleCurveDusk=0.92 GradientMiddleCurveNight=0.88 GradientMiddleCurveInteriorDay=1.05 GradientMiddleCurveInteriorNight=0.87 -GradientMiddleColorFilterDawn=0.965, 0.463, 0.337 -GradientMiddleColorFilterSunrise=0.976, 0.702, 0.443 +GradientMiddleColorFilterDawn=0.976, 0.612, 0.529 +GradientMiddleColorFilterSunrise=0.984, 0.82, 0.663 GradientMiddleColorFilterDay=1, 1, 1 -GradientMiddleColorFilterSunset=0.976, 0.694, 0.412 -GradientMiddleColorFilterDusk=0.969, 0.463, 0.365 +GradientMiddleColorFilterSunset=0.984, 0.784, 0.584 +GradientMiddleColorFilterDusk=0.984, 0.651, 0.592 GradientMiddleColorFilterNight=0.518, 0.667, 0.988 GradientMiddleColorFilterInteriorDay=1, 1, 1 GradientMiddleColorFilterInteriorNight=0.561, 0.561, 0.976 @@ -124,7 +124,7 @@ GradientHorizonIntensityDawn=1.11 GradientHorizonIntensitySunrise=1.25 GradientHorizonIntensityDay=1.310001 GradientHorizonIntensitySunset=1.24 -GradientHorizonIntensityDusk=1.12 +GradientHorizonIntensityDusk=1.11 GradientHorizonIntensityNight=0.930001 GradientHorizonIntensityInteriorDay=1.32 GradientHorizonIntensityInteriorNight=0.94 @@ -132,24 +132,24 @@ GradientHorizonCurveDawn=0.82 GradientHorizonCurveSunrise=0.86 GradientHorizonCurveDay=0.92 GradientHorizonCurveSunset=0.87 -GradientHorizonCurveDusk=0.84 +GradientHorizonCurveDusk=0.87 GradientHorizonCurveNight=0.78 GradientHorizonCurveInteriorDay=0.9 GradientHorizonCurveInteriorNight=0.98 -GradientHorizonColorFilterDawn=0.961, 0.306, 0.161 -GradientHorizonColorFilterSunrise=0.976, 0.565, 0.388 +GradientHorizonColorFilterDawn=0.984, 0.667, 0.6 +GradientHorizonColorFilterSunrise=0.992, 0.839, 0.773 GradientHorizonColorFilterDay=1, 1, 1 -GradientHorizonColorFilterSunset=0.973, 0.557, 0.416 -GradientHorizonColorFilterDusk=0.973, 0.259, 0.133 -GradientHorizonColorFilterNight=0.655, 0.816, 0.976 +GradientHorizonColorFilterSunset=0.992, 0.827, 0.773 +GradientHorizonColorFilterDusk=0.992, 0.753, 0.718 +GradientHorizonColorFilterNight=0.706, 0.843, 0.98 GradientHorizonColorFilterInteriorDay=1, 1, 1 GradientHorizonColorFilterInteriorNight=0.851, 0.863, 0.89 -CloudsIntensityDawn=0.74 +CloudsIntensityDawn=0.87 CloudsIntensitySunrise=0.920001 CloudsIntensityDay=1.240001 -CloudsIntensitySunset=0.910001 -CloudsIntensityDusk=0.750001 -CloudsIntensityNight=0.440001 +CloudsIntensitySunset=0.940001 +CloudsIntensityDusk=0.860001 +CloudsIntensityNight=0.370001 CloudsIntensityInteriorDay=1.17 CloudsIntensityInteriorNight=0.49 CloudsCurveDawn=0.9 @@ -157,7 +157,7 @@ CloudsCurveSunrise=0.95 CloudsCurveDay=1.0 CloudsCurveSunset=0.97 CloudsCurveDusk=0.91 -CloudsCurveNight=0.86 +CloudsCurveNight=0.84 CloudsCurveInteriorDay=1.02 CloudsCurveInteriorNight=0.83 CloudsDesaturationDawn=0.0 @@ -237,27 +237,27 @@ IgnoreWeatherSystem=true DirectLightingIntensityDawn=1.27 DirectLightingIntensitySunrise=1.47 DirectLightingIntensityDay=1.72 -DirectLightingIntensitySunset=1.47 +DirectLightingIntensitySunset=1.5 DirectLightingIntensityDusk=1.22 DirectLightingIntensityNight=1.17 DirectLightingIntensityInteriorDay=1.64 DirectLightingIntensityInteriorNight=1.19 -DirectLightingDesaturationDawn=0.06 -DirectLightingDesaturationSunrise=0.12 -DirectLightingDesaturationDay=0.14 -DirectLightingDesaturationSunset=0.11 -DirectLightingDesaturationDusk=0.1 -DirectLightingDesaturationNight=0.04 -DirectLightingDesaturationInteriorDay=0.14 -DirectLightingDesaturationInteriorNight=0.04 -DirectLightingColorFilterDawn=0.976, 0.278, 0.231 -DirectLightingColorFilterSunrise=0.988, 0.788, 0.525 +DirectLightingDesaturationDawn=0.18 +DirectLightingDesaturationSunrise=0.27 +DirectLightingDesaturationDay=0.22 +DirectLightingDesaturationSunset=0.28 +DirectLightingDesaturationDusk=0.18 +DirectLightingDesaturationNight=0.23 +DirectLightingDesaturationInteriorDay=0.21 +DirectLightingDesaturationInteriorNight=0.24 +DirectLightingColorFilterDawn=0.984, 0.455, 0.427 +DirectLightingColorFilterSunrise=0.992, 0.824, 0.6 DirectLightingColorFilterDay=1, 1, 1 -DirectLightingColorFilterSunset=0.992, 0.831, 0.553 -DirectLightingColorFilterDusk=0.976, 0.271, 0.192 -DirectLightingColorFilterNight=0.424, 0.569, 0.973 +DirectLightingColorFilterSunset=0.996, 0.824, 0.722 +DirectLightingColorFilterDusk=0.984, 0.451, 0.388 +DirectLightingColorFilterNight=0.663, 0.749, 0.984 DirectLightingColorFilterInteriorDay=1, 1, 1 -DirectLightingColorFilterInteriorNight=0.584, 0.506, 0.984 +DirectLightingColorFilterInteriorNight=0.655, 0.596, 0.988 AmbientLightingIntensityDawn=0.56 AmbientLightingIntensitySunrise=0.73 AmbientLightingIntensityDay=0.88 @@ -270,15 +270,15 @@ AmbientLightingIntensityInteriorNight=0.12 UseIndirectLighting=true SamplingQuality=1 SamplingRange=0.25 -AOIntensity=0.96 -AOIntensityInterior=0.82 +AOIntensity=0.66 +AOIntensityInterior=0.61 AOAmount=1.27 AOAmountInterior=1.2 -ILAmount=1.34 +ILAmount=1.32 ILAmountInterior=1.2 AOMixingType=2 -AOMixingTypeInterior=3 -ResolutionScale=0.5 +AOMixingTypeInterior=2 +ResolutionScale=1.0 SourceTexturesScale=0.5 [FOG] IgnoreWeatherSystem=true diff --git a/enbseries/SMAA/AreaTex.dds b/enbseries/SMAA/AreaTex.dds new file mode 100644 index 0000000..7a3b1f8 Binary files /dev/null and b/enbseries/SMAA/AreaTex.dds differ diff --git a/enbseries/SMAA/LICENSE.txt b/enbseries/SMAA/LICENSE.txt new file mode 100644 index 0000000..dbce0e6 --- /dev/null +++ b/enbseries/SMAA/LICENSE.txt @@ -0,0 +1,24 @@ +Copyright (C) 2013 Jorge Jimenez (jorge@iryoku.com) +Copyright (C) 2013 Jose I. Echevarria (joseignacioechevarria@gmail.com) +Copyright (C) 2013 Belen Masia (bmasia@unizar.es) +Copyright (C) 2013 Fernando Navarro (fernandn@microsoft.com) +Copyright (C) 2013 Diego Gutierrez (diegog@unizar.es) + +Permission is hereby granted, free of charge, to any person obtaining a copy +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. As clarification, there is no +requirement that the copyright notice and permission be included in binary +distributions 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. diff --git a/enbseries/SMAA/SMAA.fxh b/enbseries/SMAA/SMAA.fxh new file mode 100644 index 0000000..a271b5b --- /dev/null +++ b/enbseries/SMAA/SMAA.fxh @@ -0,0 +1,1361 @@ +/** + * Copyright (C) 2013 Jorge Jimenez (jorge@iryoku.com) + * Copyright (C) 2013 Jose I. Echevarria (joseignacioechevarria@gmail.com) + * Copyright (C) 2013 Belen Masia (bmasia@unizar.es) + * Copyright (C) 2013 Fernando Navarro (fernandn@microsoft.com) + * Copyright (C) 2013 Diego Gutierrez (diegog@unizar.es) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * 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. As clarification, there + * is no requirement that the copyright notice and permission be included in + * binary distributions 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. + */ + + +/** + * _______ ___ ___ ___ ___ + * / || \/ | / \ / \ + * | (---- | \ / | / ^ \ / ^ \ + * \ \ | |\/| | / /_\ \ / /_\ \ + * ----) | | | | | / _____ \ / _____ \ + * |_______/ |__| |__| /__/ \__\ /__/ \__\ + * + * E N H A N C E D + * S U B P I X E L M O R P H O L O G I C A L A N T I A L I A S I N G + * + * http://www.iryoku.com/smaa/ + * + * Hi, welcome aboard! + * + * Here you'll find instructions to get the shader up and running as fast as + * possible. + * + * IMPORTANTE NOTICE: when updating, remember to update both this file and the + * precomputed textures! They may change from version to version. + * + * The shader has three passes, chained together as follows: + * + * |input|------------------+ + * v | + * [ SMAA*EdgeDetection ] | + * v | + * |edgesTex| | + * v | + * [ SMAABlendingWeightCalculation ] | + * v | + * |blendTex| | + * v | + * [ SMAANeighborhoodBlending ] <------+ + * v + * |output| + * + * Note that each [pass] has its own vertex and pixel shader. Remember to use + * oversized triangles instead of quads to avoid overshading along the + * diagonal. + * + * You've three edge detection methods to choose from: luma, color or depth. + * They represent different quality/performance and anti-aliasing/sharpness + * tradeoffs, so our recommendation is for you to choose the one that best + * suits your particular scenario: + * + * - Depth edge detection is usually the fastest but it may miss some edges. + * + * - Luma edge detection is usually more expensive than depth edge detection, + * but catches visible edges that depth edge detection can miss. + * + * - Color edge detection is usually the most expensive one but catches + * chroma-only edges. + * + * For quickstarters: just use luma edge detection. + * + * The general advice is to not rush the integration process and ensure each + * step is done correctly (don't try to integrate SMAA T2x with predicated edge + * detection from the start!). Ok then, let's go! + * + * 1. The first step is to create two RGBA temporal render targets for holding + * |edgesTex| and |blendTex|. + * + * In DX10 or DX11, you can use a RG render target for the edges texture. + * In the case of NVIDIA GPUs, using RG render targets seems to actually be + * slower. + * + * On the Xbox 360, you can use the same render target for resolving both + * |edgesTex| and |blendTex|, as they aren't needed simultaneously. + * + * 2. Both temporal render targets |edgesTex| and |blendTex| must be cleared + * each frame. Do not forget to clear the alpha channel! + * + * 3. The next step is loading the two supporting precalculated textures, + * 'areaTex' and 'searchTex'. You'll find them in the 'Textures' folder as + * C++ headers, and also as regular DDS files. They'll be needed for the + * 'SMAABlendingWeightCalculation' pass. + * + * If you use the C++ headers, be sure to load them in the format specified + * inside of them. + * + * You can also compress 'areaTex' and 'searchTex' using BC5 and BC4 + * respectively, if you have that option in your content processor pipeline. + * When compressing then, you get a non-perceptible quality decrease, and a + * marginal performance increase. + * + * 4. All samplers must be set to linear filtering and clamp. + * + * After you get the technique working, remember that 64-bit inputs have + * half-rate linear filtering on GCN. + * + * If SMAA is applied to 64-bit color buffers, switching to point filtering + * when accesing them will increase the performance. Search for + * 'SMAASamplePoint' to see which textures may benefit from point + * filtering, and where (which is basically the color input in the edge + * detection and resolve passes). + * + * 5. All texture reads and buffer writes must be non-sRGB, with the exception + * of the input read and the output write in + * 'SMAANeighborhoodBlending' (and only in this pass!). If sRGB reads in + * this last pass are not possible, the technique will work anyway, but + * will perform antialiasing in gamma space. + * + * IMPORTANT: for best results the input read for the color/luma edge + * detection should *NOT* be sRGB. + * + * 6. Before including SMAA.h you'll have to setup the render target metrics, + * the target and any optional configuration defines. Optionally you can + * use a preset. + * + * You have the following targets available: + * SMAA_HLSL_3 + * SMAA_HLSL_4 + * SMAA_HLSL_4_1 + * SMAA_GLSL_3 * + * SMAA_GLSL_4 * + * + * * (See SMAA_INCLUDE_VS and SMAA_INCLUDE_PS below). + * + * And four presets: + * SMAA_PRESET_LOW (%60 of the quality) + * SMAA_PRESET_MEDIUM (%80 of the quality) + * SMAA_PRESET_HIGH (%95 of the quality) + * SMAA_PRESET_ULTRA (%99 of the quality) + * + * For example: + * #define SMAA_RT_METRICS float4(1.0 / 1280.0, 1.0 / 720.0, 1280.0, 720.0) + * #define SMAA_HLSL_4 + * #define SMAA_PRESET_HIGH + * #include "SMAA.h" + * + * Note that SMAA_RT_METRICS doesn't need to be a macro, it can be a + * uniform variable. The code is designed to minimize the impact of not + * using a constant value, but it is still better to hardcode it. + * + * Depending on how you encoded 'areaTex' and 'searchTex', you may have to + * add (and customize) the following defines before including SMAA.h: + * #define SMAA_AREATEX_SELECT(sample) sample.rg + * #define SMAA_SEARCHTEX_SELECT(sample) sample.r + * + * If your engine is already using porting macros, you can define + * SMAA_CUSTOM_SL, and define the porting functions by yourself. + * + * 7. Then, you'll have to setup the passes as indicated in the scheme above. + * You can take a look into SMAA.fx, to see how we did it for our demo. + * Checkout the function wrappers, you may want to copy-paste them! + * + * 8. It's recommended to validate the produced |edgesTex| and |blendTex|. + * You can use a screenshot from your engine to compare the |edgesTex| + * and |blendTex| produced inside of the engine with the results obtained + * with the reference demo. + * + * 9. After you get the last pass to work, it's time to optimize. You'll have + * to initialize a stencil buffer in the first pass (discard is already in + * the code), then mask execution by using it the second pass. The last + * pass should be executed in all pixels. + * + * + * After this point you can choose to enable predicated thresholding, + * temporal supersampling and motion blur integration: + * + * a) If you want to use predicated thresholding, take a look into + * SMAA_PREDICATION; you'll need to pass an extra texture in the edge + * detection pass. + * + * b) If you want to enable temporal supersampling (SMAA T2x): + * + * 1. The first step is to render using subpixel jitters. I won't go into + * detail, but it's as simple as moving each vertex position in the + * vertex shader, you can check how we do it in our DX10 demo. + * + * 2. Then, you must setup the temporal resolve. You may want to take a look + * into SMAAResolve for resolving 2x modes. After you get it working, you'll + * probably see ghosting everywhere. But fear not, you can enable the + * CryENGINE temporal reprojection by setting the SMAA_REPROJECTION macro. + * Check out SMAA_DECODE_VELOCITY if your velocity buffer is encoded. + * + * 3. The next step is to apply SMAA to each subpixel jittered frame, just as + * done for 1x. + * + * 4. At this point you should already have something usable, but for best + * results the proper area textures must be set depending on current jitter. + * For this, the parameter 'subsampleIndices' of + * 'SMAABlendingWeightCalculationPS' must be set as follows, for our T2x + * mode: + * + * @SUBSAMPLE_INDICES + * + * | S# | Camera Jitter | subsampleIndices | + * +----+------------------+---------------------+ + * | 0 | ( 0.25, -0.25) | float4(1, 1, 1, 0) | + * | 1 | (-0.25, 0.25) | float4(2, 2, 2, 0) | + * + * These jitter positions assume a bottom-to-top y axis. S# stands for the + * sample number. + * + * More information about temporal supersampling here: + * http://iryoku.com/aacourse/downloads/13-Anti-Aliasing-Methods-in-CryENGINE-3.pdf + * + * c) If you want to enable spatial multisampling (SMAA S2x): + * + * 1. The scene must be rendered using MSAA 2x. The MSAA 2x buffer must be + * created with: + * - DX10: see below (*) + * - DX10.1: D3D10_STANDARD_MULTISAMPLE_PATTERN or + * - DX11: D3D11_STANDARD_MULTISAMPLE_PATTERN + * + * This allows to ensure that the subsample order matches the table in + * @SUBSAMPLE_INDICES. + * + * (*) In the case of DX10, we refer the reader to: + * - SMAA::detectMSAAOrder and + * - SMAA::msaaReorder + * + * These functions allow to match the standard multisample patterns by + * detecting the subsample order for a specific GPU, and reordering + * them appropriately. + * + * 2. A shader must be run to output each subsample into a separate buffer + * (DX10 is required). You can use SMAASeparate for this purpose, or just do + * it in an existing pass (for example, in the tone mapping pass, which has + * the advantage of feeding tone mapped subsamples to SMAA, which will yield + * better results). + * + * 3. The full SMAA 1x pipeline must be run for each separated buffer, storing + * the results in the final buffer. The second run should alpha blend with + * the existing final buffer using a blending factor of 0.5. + * 'subsampleIndices' must be adjusted as in the SMAA T2x case (see point + * b). + * + * d) If you want to enable temporal supersampling on top of SMAA S2x + * (which actually is SMAA 4x): + * + * 1. SMAA 4x consists on temporally jittering SMAA S2x, so the first step is + * to calculate SMAA S2x for current frame. In this case, 'subsampleIndices' + * must be set as follows: + * + * | F# | S# | Camera Jitter | Net Jitter | subsampleIndices | + * +----+----+--------------------+-------------------+----------------------+ + * | 0 | 0 | ( 0.125, 0.125) | ( 0.375, -0.125) | float4(5, 3, 1, 3) | + * | 0 | 1 | ( 0.125, 0.125) | (-0.125, 0.375) | float4(4, 6, 2, 3) | + * +----+----+--------------------+-------------------+----------------------+ + * | 1 | 2 | (-0.125, -0.125) | ( 0.125, -0.375) | float4(3, 5, 1, 4) | + * | 1 | 3 | (-0.125, -0.125) | (-0.375, 0.125) | float4(6, 4, 2, 4) | + * + * These jitter positions assume a bottom-to-top y axis. F# stands for the + * frame number. S# stands for the sample number. + * + * 2. After calculating SMAA S2x for current frame (with the new subsample + * indices), previous frame must be reprojected as in SMAA T2x mode (see + * point b). + * + * e) If motion blur is used, you may want to do the edge detection pass + * together with motion blur. This has two advantages: + * + * 1. Pixels under heavy motion can be omitted from the edge detection process. + * For these pixels we can just store "no edge", as motion blur will take + * care of them. + * 2. The center pixel tap is reused. + * + * Note that in this case depth testing should be used instead of stenciling, + * as we have to write all the pixels in the motion blur pass. + * + * That's it! + */ + +//----------------------------------------------------------------------------- +// SMAA Presets + +/** + * Note that if you use one of these presets, the following configuration + * macros will be ignored if set in the "Configurable Defines" section. + */ + +#if defined(SMAA_PRESET_LOW) +#define SMAA_THRESHOLD 0.15 +#define SMAA_MAX_SEARCH_STEPS 4 +#define SMAA_DISABLE_DIAG_DETECTION +#define SMAA_DISABLE_CORNER_DETECTION +#elif defined(SMAA_PRESET_MEDIUM) +#define SMAA_THRESHOLD 0.1 +#define SMAA_MAX_SEARCH_STEPS 8 +#define SMAA_DISABLE_DIAG_DETECTION +#define SMAA_DISABLE_CORNER_DETECTION +#elif defined(SMAA_PRESET_HIGH) +#define SMAA_THRESHOLD 0.1 +#define SMAA_MAX_SEARCH_STEPS 16 +#define SMAA_MAX_SEARCH_STEPS_DIAG 8 +#define SMAA_CORNER_ROUNDING 25 +#elif defined(SMAA_PRESET_ULTRA) +#define SMAA_THRESHOLD 0.05 +#define SMAA_MAX_SEARCH_STEPS 32 +#define SMAA_MAX_SEARCH_STEPS_DIAG 16 +#define SMAA_CORNER_ROUNDING 25 +#endif + +//----------------------------------------------------------------------------- +// Configurable Defines + +/** + * SMAA_THRESHOLD specifies the threshold or sensitivity to edges. + * Lowering this value you will be able to detect more edges at the expense of + * performance. + * + * Range: [0, 0.5] + * 0.1 is a reasonable value, and allows to catch most visible edges. + * 0.05 is a rather overkill value, that allows to catch 'em all. + * + * If temporal supersampling is used, 0.2 could be a reasonable value, as low + * contrast edges are properly filtered by just 2x. + */ +#ifndef SMAA_THRESHOLD +#define SMAA_THRESHOLD 0.1 +#endif + +/** + * SMAA_DEPTH_THRESHOLD specifies the threshold for depth edge detection. + * + * Range: depends on the depth range of the scene. + */ +#ifndef SMAA_DEPTH_THRESHOLD +#define SMAA_DEPTH_THRESHOLD (0.1 * SMAA_THRESHOLD) +#endif + +/** + * SMAA_MAX_SEARCH_STEPS specifies the maximum steps performed in the + * horizontal/vertical pattern searches, at each side of the pixel. + * + * In number of pixels, it's actually the double. So the maximum line length + * perfectly handled by, for example 16, is 64 (by perfectly, we meant that + * longer lines won't look as good, but still antialiased). + * + * Range: [0, 112] + */ +#ifndef SMAA_MAX_SEARCH_STEPS +#define SMAA_MAX_SEARCH_STEPS 16 +#endif + +/** + * SMAA_MAX_SEARCH_STEPS_DIAG specifies the maximum steps performed in the + * diagonal pattern searches, at each side of the pixel. In this case we jump + * one pixel at time, instead of two. + * + * Range: [0, 20] + * + * On high-end machines it is cheap (between a 0.8x and 0.9x slower for 16 + * steps), but it can have a significant impact on older machines. + * + * Define SMAA_DISABLE_DIAG_DETECTION to disable diagonal processing. + */ +#ifndef SMAA_MAX_SEARCH_STEPS_DIAG +#define SMAA_MAX_SEARCH_STEPS_DIAG 8 +#endif + +/** + * SMAA_CORNER_ROUNDING specifies how much sharp corners will be rounded. + * + * Range: [0, 100] + * + * Define SMAA_DISABLE_CORNER_DETECTION to disable corner processing. + */ +#ifndef SMAA_CORNER_ROUNDING +#define SMAA_CORNER_ROUNDING 25 +#endif + +/** + * If there is an neighbor edge that has SMAA_LOCAL_CONTRAST_FACTOR times + * bigger contrast than current edge, current edge will be discarded. + * + * This allows to eliminate spurious crossing edges, and is based on the fact + * that, if there is too much contrast in a direction, that will hide + * perceptually contrast in the other neighbors. + */ +#ifndef SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR +#define SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR 2.0 +#endif + +/** + * Predicated thresholding allows to better preserve texture details and to + * improve performance, by decreasing the number of detected edges using an + * additional buffer like the light accumulation buffer, object ids or even the + * depth buffer (the depth buffer usage may be limited to indoor or short range + * scenes). + * + * It locally decreases the luma or color threshold if an edge is found in an + * additional buffer (so the global threshold can be higher). + * + * This method was developed by Playstation EDGE MLAA team, and used in + * Killzone 3, by using the light accumulation buffer. More information here: + * http://iryoku.com/aacourse/downloads/06-MLAA-on-PS3.pptx + */ +#ifndef SMAA_PREDICATION +#define SMAA_PREDICATION 0 +#endif + +/** + * Threshold to be used in the additional predication buffer. + * + * Range: depends on the input, so you'll have to find the magic number that + * works for you. + */ +#ifndef SMAA_PREDICATION_THRESHOLD +#define SMAA_PREDICATION_THRESHOLD 0.01 +#endif + +/** + * How much to scale the global threshold used for luma or color edge + * detection when using predication. + * + * Range: [1, 5] + */ +#ifndef SMAA_PREDICATION_SCALE +#define SMAA_PREDICATION_SCALE 2.0 +#endif + +/** + * How much to locally decrease the threshold. + * + * Range: [0, 1] + */ +#ifndef SMAA_PREDICATION_STRENGTH +#define SMAA_PREDICATION_STRENGTH 0.4 +#endif + +/** + * Temporal reprojection allows to remove ghosting artifacts when using + * temporal supersampling. We use the CryEngine 3 method which also introduces + * velocity weighting. This feature is of extreme importance for totally + * removing ghosting. More information here: + * http://iryoku.com/aacourse/downloads/13-Anti-Aliasing-Methods-in-CryENGINE-3.pdf + * + * Note that you'll need to setup a velocity buffer for enabling reprojection. + * For static geometry, saving the previous depth buffer is a viable + * alternative. + */ +#ifndef SMAA_REPROJECTION +#define SMAA_REPROJECTION 0 +#endif + +/** + * SMAA_REPROJECTION_WEIGHT_SCALE controls the velocity weighting. It allows to + * remove ghosting trails behind the moving object, which are not removed by + * just using reprojection. Using low values will exhibit ghosting, while using + * high values will disable temporal supersampling under motion. + * + * Behind the scenes, velocity weighting removes temporal supersampling when + * the velocity of the subsamples differs (meaning they are different objects). + * + * Range: [0, 80] + */ +#ifndef SMAA_REPROJECTION_WEIGHT_SCALE +#define SMAA_REPROJECTION_WEIGHT_SCALE 30.0 +#endif + +/** + * On some compilers, discard cannot be used in vertex shaders. Thus, they need + * to be compiled separately. + */ +#ifndef SMAA_INCLUDE_VS +#define SMAA_INCLUDE_VS 1 +#endif +#ifndef SMAA_INCLUDE_PS +#define SMAA_INCLUDE_PS 1 +#endif + +//----------------------------------------------------------------------------- +// Texture Access Defines + +#ifndef SMAA_AREATEX_SELECT +#if defined(SMAA_HLSL_3) +#define SMAA_AREATEX_SELECT(sample) sample.ra +#else +#define SMAA_AREATEX_SELECT(sample) sample.rg +#endif +#endif + +#ifndef SMAA_SEARCHTEX_SELECT +#define SMAA_SEARCHTEX_SELECT(sample) sample.r +#endif + +#ifndef SMAA_DECODE_VELOCITY +#define SMAA_DECODE_VELOCITY(sample) sample.rg +#endif + +//----------------------------------------------------------------------------- +// Non-Configurable Defines + +#define SMAA_AREATEX_MAX_DISTANCE 16 +#define SMAA_AREATEX_MAX_DISTANCE_DIAG 20 +#define SMAA_AREATEX_PIXEL_SIZE (1.0 / float2(160.0, 560.0)) +#define SMAA_AREATEX_SUBTEX_SIZE (1.0 / 7.0) +#define SMAA_SEARCHTEX_SIZE float2(66.0, 33.0) +#define SMAA_SEARCHTEX_PACKED_SIZE float2(64.0, 16.0) +#define SMAA_CORNER_ROUNDING_NORM (float(SMAA_CORNER_ROUNDING) / 100.0) + +//----------------------------------------------------------------------------- +// Porting Functions + +#if defined(SMAA_HLSL_3) +#define SMAATexture2D(tex) sampler2D tex +#define SMAATexturePass2D(tex) tex +#define SMAASampleLevelZero(tex, coord) tex2Dlod(tex, float4(coord, 0.0, 0.0)) +#define SMAASampleLevelZeroPoint(tex, coord) tex2Dlod(tex, float4(coord, 0.0, 0.0)) +#define SMAASampleLevelZeroOffset(tex, coord, offset) tex2Dlod(tex, float4(coord + offset * SMAA_RT_METRICS.xy, 0.0, 0.0)) +#define SMAASample(tex, coord) tex2D(tex, coord) +#define SMAASamplePoint(tex, coord) tex2D(tex, coord) +#define SMAASampleOffset(tex, coord, offset) tex2D(tex, coord + offset * SMAA_RT_METRICS.xy) +#define SMAA_FLATTEN [flatten] +#define SMAA_BRANCH [branch] +#endif +#if defined(SMAA_HLSL_4) || defined(SMAA_HLSL_4_1) +SamplerState LinearSampler { Filter = MIN_MAG_LINEAR_MIP_POINT; AddressU = Clamp; AddressV = Clamp; }; +SamplerState PointSampler { Filter = MIN_MAG_MIP_POINT; AddressU = Clamp; AddressV = Clamp; }; +#define SMAATexture2D(tex) Texture2D tex +#define SMAATexturePass2D(tex) tex +#define SMAASampleLevelZero(tex, coord) tex.SampleLevel(LinearSampler, coord, 0) +#define SMAASampleLevelZeroPoint(tex, coord) tex.SampleLevel(PointSampler, coord, 0) +#define SMAASampleLevelZeroOffset(tex, coord, offset) tex.SampleLevel(LinearSampler, coord, 0, offset) +#define SMAASample(tex, coord) tex.Sample(LinearSampler, coord) +#define SMAASamplePoint(tex, coord) tex.Sample(PointSampler, coord) +#define SMAASampleOffset(tex, coord, offset) tex.Sample(LinearSampler, coord, offset) +#define SMAA_FLATTEN [flatten] +#define SMAA_BRANCH [branch] +#define SMAATexture2DMS2(tex) Texture2DMS tex +#define SMAALoad(tex, pos, sample) tex.Load(pos, sample) +#if defined(SMAA_HLSL_4_1) +#define SMAAGather(tex, coord) tex.Gather(LinearSampler, coord, 0) +#endif +#endif +#if defined(SMAA_GLSL_3) || defined(SMAA_GLSL_4) +#define SMAATexture2D(tex) sampler2D tex +#define SMAATexturePass2D(tex) tex +#define SMAASampleLevelZero(tex, coord) textureLod(tex, coord, 0.0) +#define SMAASampleLevelZeroPoint(tex, coord) textureLod(tex, coord, 0.0) +#define SMAASampleLevelZeroOffset(tex, coord, offset) textureLodOffset(tex, coord, 0.0, offset) +#define SMAASample(tex, coord) texture(tex, coord) +#define SMAASamplePoint(tex, coord) texture(tex, coord) +#define SMAASampleOffset(tex, coord, offset) texture(tex, coord, offset) +#define SMAA_FLATTEN +#define SMAA_BRANCH +#define lerp(a, b, t) mix(a, b, t) +#define saturate(a) clamp(a, 0.0, 1.0) +#if defined(SMAA_GLSL_4) +#define mad(a, b, c) fma(a, b, c) +#define SMAAGather(tex, coord) textureGather(tex, coord) +#else +#define mad(a, b, c) (a * b + c) +#endif +#define float2 vec2 +#define float3 vec3 +#define float4 vec4 +#define int2 ivec2 +#define int3 ivec3 +#define int4 ivec4 +#define bool2 bvec2 +#define bool3 bvec3 +#define bool4 bvec4 +#endif + +#if !defined(SMAA_HLSL_3) && !defined(SMAA_HLSL_4) && !defined(SMAA_HLSL_4_1) && !defined(SMAA_GLSL_3) && !defined(SMAA_GLSL_4) && !defined(SMAA_CUSTOM_SL) +#error you must define the shading language: SMAA_HLSL_*, SMAA_GLSL_* or SMAA_CUSTOM_SL +#endif + +//----------------------------------------------------------------------------- +// Misc functions + +/** + * Gathers current pixel, and the top-left neighbors. + */ +float3 SMAAGatherNeighbours(float2 texcoord, + float4 offset[3], + SMAATexture2D(tex)) { + #ifdef SMAAGather + return SMAAGather(tex, texcoord + SMAA_RT_METRICS.xy * float2(-0.5, -0.5)).grb; + #else + float P = SMAASamplePoint(tex, texcoord).r; + float Pleft = SMAASamplePoint(tex, offset[0].xy).r; + float Ptop = SMAASamplePoint(tex, offset[0].zw).r; + return float3(P, Pleft, Ptop); + #endif +} + +/** + * Adjusts the threshold by means of predication. + */ +float2 SMAACalculatePredicatedThreshold(float2 texcoord, + float4 offset[3], + SMAATexture2D(predicationTex)) { + float3 neighbours = SMAAGatherNeighbours(texcoord, offset, SMAATexturePass2D(predicationTex)); + float2 delta = abs(neighbours.xx - neighbours.yz); + float2 edges = step(SMAA_PREDICATION_THRESHOLD, delta); + return SMAA_PREDICATION_SCALE * SMAA_THRESHOLD * (1.0 - SMAA_PREDICATION_STRENGTH * edges); +} + +/** + * Conditional move: + */ +void SMAAMovc(bool2 cond, inout float2 variable, float2 value) { + SMAA_FLATTEN if (cond.x) variable.x = value.x; + SMAA_FLATTEN if (cond.y) variable.y = value.y; +} + +void SMAAMovc(bool4 cond, inout float4 variable, float4 value) { + SMAAMovc(cond.xy, variable.xy, value.xy); + SMAAMovc(cond.zw, variable.zw, value.zw); +} + + +#if SMAA_INCLUDE_VS +//----------------------------------------------------------------------------- +// Vertex Shaders + +/** + * Edge Detection Vertex Shader + */ +void SMAAEdgeDetectionVS(float2 texcoord, + out float4 offset[3]) { + offset[0] = mad(SMAA_RT_METRICS.xyxy, float4(-1.0, 0.0, 0.0, -1.0), texcoord.xyxy); + offset[1] = mad(SMAA_RT_METRICS.xyxy, float4( 1.0, 0.0, 0.0, 1.0), texcoord.xyxy); + offset[2] = mad(SMAA_RT_METRICS.xyxy, float4(-2.0, 0.0, 0.0, -2.0), texcoord.xyxy); +} + +/** + * Blend Weight Calculation Vertex Shader + */ +void SMAABlendingWeightCalculationVS(float2 texcoord, + out float2 pixcoord, + out float4 offset[3]) { + pixcoord = texcoord * SMAA_RT_METRICS.zw; + + // We will use these offsets for the searches later on (see @PSEUDO_GATHER4): + offset[0] = mad(SMAA_RT_METRICS.xyxy, float4(-0.25, -0.125, 1.25, -0.125), texcoord.xyxy); + offset[1] = mad(SMAA_RT_METRICS.xyxy, float4(-0.125, -0.25, -0.125, 1.25), texcoord.xyxy); + + // And these for the searches, they indicate the ends of the loops: + offset[2] = mad(SMAA_RT_METRICS.xxyy, + float4(-2.0, 2.0, -2.0, 2.0) * float(SMAA_MAX_SEARCH_STEPS), + float4(offset[0].xz, offset[1].yw)); +} + +/** + * Neighborhood Blending Vertex Shader + */ +void SMAANeighborhoodBlendingVS(float2 texcoord, + out float4 offset) { + offset = mad(SMAA_RT_METRICS.xyxy, float4( 1.0, 0.0, 0.0, 1.0), texcoord.xyxy); +} +#endif // SMAA_INCLUDE_VS + +#if SMAA_INCLUDE_PS +//----------------------------------------------------------------------------- +// Edge Detection Pixel Shaders (First Pass) + +/** + * Luma Edge Detection + * + * IMPORTANT NOTICE: luma edge detection requires gamma-corrected colors, and + * thus 'colorTex' should be a non-sRGB texture. + */ +float2 SMAALumaEdgeDetectionPS(float2 texcoord, + float4 offset[3], + SMAATexture2D(colorTex) + #if SMAA_PREDICATION + , SMAATexture2D(predicationTex) + #endif + ) { + // Calculate the threshold: + #if SMAA_PREDICATION + float2 threshold = SMAACalculatePredicatedThreshold(texcoord, offset, SMAATexturePass2D(predicationTex)); + #else + float2 threshold = float2(SMAA_THRESHOLD, SMAA_THRESHOLD); + #endif + + // Calculate lumas: + float3 weights = float3(0.2126, 0.7152, 0.0722); + float L = dot(SMAASamplePoint(colorTex, texcoord).rgb, weights); + + float Lleft = dot(SMAASamplePoint(colorTex, offset[0].xy).rgb, weights); + float Ltop = dot(SMAASamplePoint(colorTex, offset[0].zw).rgb, weights); + + // We do the usual threshold: + float4 delta; + delta.xy = abs(L - float2(Lleft, Ltop)); + float2 edges = step(threshold, delta.xy); + + // Then discard if there is no edge: + if (dot(edges, float2(1.0, 1.0)) == 0.0) + discard; + + // Calculate right and bottom deltas: + float Lright = dot(SMAASamplePoint(colorTex, offset[1].xy).rgb, weights); + float Lbottom = dot(SMAASamplePoint(colorTex, offset[1].zw).rgb, weights); + delta.zw = abs(L - float2(Lright, Lbottom)); + + // Calculate the maximum delta in the direct neighborhood: + float2 maxDelta = max(delta.xy, delta.zw); + + // Calculate left-left and top-top deltas: + float Lleftleft = dot(SMAASamplePoint(colorTex, offset[2].xy).rgb, weights); + float Ltoptop = dot(SMAASamplePoint(colorTex, offset[2].zw).rgb, weights); + delta.zw = abs(float2(Lleft, Ltop) - float2(Lleftleft, Ltoptop)); + + // Calculate the final maximum delta: + maxDelta = max(maxDelta.xy, delta.zw); + float finalDelta = max(maxDelta.x, maxDelta.y); + + // Local contrast adaptation: + edges.xy *= step(finalDelta, SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR * delta.xy); + + return edges; +} + +/** + * Color Edge Detection + * + * IMPORTANT NOTICE: color edge detection requires gamma-corrected colors, and + * thus 'colorTex' should be a non-sRGB texture. + */ +float2 SMAAColorEdgeDetectionPS(float2 texcoord, + float4 offset[3], + SMAATexture2D(colorTex) + #if SMAA_PREDICATION + , SMAATexture2D(predicationTex) + #endif + ) { + // Calculate the threshold: + #if SMAA_PREDICATION + float2 threshold = SMAACalculatePredicatedThreshold(texcoord, offset, predicationTex); + #else + float2 threshold = float2(SMAA_THRESHOLD, SMAA_THRESHOLD); + #endif + + // Calculate color deltas: + float4 delta; + float3 C = SMAASamplePoint(colorTex, texcoord).rgb; + + float3 Cleft = SMAASamplePoint(colorTex, offset[0].xy).rgb; + float3 t = abs(C - Cleft); + delta.x = max(max(t.r, t.g), t.b); + + float3 Ctop = SMAASamplePoint(colorTex, offset[0].zw).rgb; + t = abs(C - Ctop); + delta.y = max(max(t.r, t.g), t.b); + + // We do the usual threshold: + float2 edges = step(threshold, delta.xy); + + // Then discard if there is no edge: + if (dot(edges, float2(1.0, 1.0)) == 0.0) + discard; + + // Calculate right and bottom deltas: + float3 Cright = SMAASamplePoint(colorTex, offset[1].xy).rgb; + t = abs(C - Cright); + delta.z = max(max(t.r, t.g), t.b); + + float3 Cbottom = SMAASamplePoint(colorTex, offset[1].zw).rgb; + t = abs(C - Cbottom); + delta.w = max(max(t.r, t.g), t.b); + + // Calculate the maximum delta in the direct neighborhood: + float2 maxDelta = max(delta.xy, delta.zw); + + // Calculate left-left and top-top deltas: + float3 Cleftleft = SMAASamplePoint(colorTex, offset[2].xy).rgb; + t = abs(C - Cleftleft); + delta.z = max(max(t.r, t.g), t.b); + + float3 Ctoptop = SMAASamplePoint(colorTex, offset[2].zw).rgb; + t = abs(C - Ctoptop); + delta.w = max(max(t.r, t.g), t.b); + + // Calculate the final maximum delta: + maxDelta = max(maxDelta.xy, delta.zw); + float finalDelta = max(maxDelta.x, maxDelta.y); + + // Local contrast adaptation: + edges.xy *= step(finalDelta, SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR * delta.xy); + + return edges; +} + +/** + * Depth Edge Detection + */ +float2 SMAADepthEdgeDetectionPS(float2 texcoord, + float4 offset[3], + SMAATexture2D(depthTex)) { + float3 neighbours = SMAAGatherNeighbours(texcoord, offset, SMAATexturePass2D(depthTex)); + float2 delta = abs(neighbours.xx - float2(neighbours.y, neighbours.z)); + float2 edges = step(SMAA_DEPTH_THRESHOLD, delta); + + if (dot(edges, float2(1.0, 1.0)) == 0.0) + discard; + + return edges; +} + +//----------------------------------------------------------------------------- +// Diagonal Search Functions + +#if !defined(SMAA_DISABLE_DIAG_DETECTION) + +/** + * Allows to decode two binary values from a bilinear-filtered access. + */ +float2 SMAADecodeDiagBilinearAccess(float2 e) { + // Bilinear access for fetching 'e' have a 0.25 offset, and we are + // interested in the R and G edges: + // + // +---G---+-------+ + // | x o R x | + // +-------+-------+ + // + // Then, if one of these edge is enabled: + // Red: (0.75 * X + 0.25 * 1) => 0.25 or 1.0 + // Green: (0.75 * 1 + 0.25 * X) => 0.75 or 1.0 + // + // This function will unpack the values (mad + mul + round): + // wolframalpha.com: round(x * abs(5 * x - 5 * 0.75)) plot 0 to 1 + e.r = e.r * abs(5.0 * e.r - 5.0 * 0.75); + return round(e); +} + +float4 SMAADecodeDiagBilinearAccess(float4 e) { + e.rb = e.rb * abs(5.0 * e.rb - 5.0 * 0.75); + return round(e); +} + +/** + * These functions allows to perform diagonal pattern searches. + */ +float2 SMAASearchDiag1(SMAATexture2D(edgesTex), float2 texcoord, float2 dir, out float2 e) { + float4 coord = float4(texcoord, -1.0, 1.0); + float3 t = float3(SMAA_RT_METRICS.xy, 1.0); + while (coord.z < float(SMAA_MAX_SEARCH_STEPS_DIAG - 1) && + coord.w > 0.9) { + coord.xyz = mad(t, float3(dir, 1.0), coord.xyz); + e = SMAASampleLevelZero(edgesTex, coord.xy).rg; + coord.w = dot(e, float2(0.5, 0.5)); + } + return coord.zw; +} + +float2 SMAASearchDiag2(SMAATexture2D(edgesTex), float2 texcoord, float2 dir, out float2 e) { + float4 coord = float4(texcoord, -1.0, 1.0); + coord.x += 0.25 * SMAA_RT_METRICS.x; // See @SearchDiag2Optimization + float3 t = float3(SMAA_RT_METRICS.xy, 1.0); + while (coord.z < float(SMAA_MAX_SEARCH_STEPS_DIAG - 1) && + coord.w > 0.9) { + coord.xyz = mad(t, float3(dir, 1.0), coord.xyz); + + // @SearchDiag2Optimization + // Fetch both edges at once using bilinear filtering: + e = SMAASampleLevelZero(edgesTex, coord.xy).rg; + e = SMAADecodeDiagBilinearAccess(e); + + // Non-optimized version: + // e.g = SMAASampleLevelZero(edgesTex, coord.xy).g; + // e.r = SMAASampleLevelZeroOffset(edgesTex, coord.xy, int2(1, 0)).r; + + coord.w = dot(e, float2(0.5, 0.5)); + } + return coord.zw; +} + +/** + * Similar to SMAAArea, this calculates the area corresponding to a certain + * diagonal distance and crossing edges 'e'. + */ +float2 SMAAAreaDiag(SMAATexture2D(areaTex), float2 dist, float2 e, float offset) { + float2 texcoord = mad(float2(SMAA_AREATEX_MAX_DISTANCE_DIAG, SMAA_AREATEX_MAX_DISTANCE_DIAG), e, dist); + + // We do a scale and bias for mapping to texel space: + texcoord = mad(SMAA_AREATEX_PIXEL_SIZE, texcoord, 0.5 * SMAA_AREATEX_PIXEL_SIZE); + + // Diagonal areas are on the second half of the texture: + texcoord.x += 0.5; + + // Move to proper place, according to the subpixel offset: + texcoord.y += SMAA_AREATEX_SUBTEX_SIZE * offset; + + // Do it! + return SMAA_AREATEX_SELECT(SMAASampleLevelZero(areaTex, texcoord)); +} + +/** + * This searches for diagonal patterns and returns the corresponding weights. + */ +float2 SMAACalculateDiagWeights(SMAATexture2D(edgesTex), SMAATexture2D(areaTex), float2 texcoord, float2 e, float4 subsampleIndices) { + float2 weights = float2(0.0, 0.0); + + // Search for the line ends: + float4 d; + float2 end; + if (e.r > 0.0) { + d.xz = SMAASearchDiag1(SMAATexturePass2D(edgesTex), texcoord, float2(-1.0, 1.0), end); + d.x += float(end.y > 0.9); + } else + d.xz = float2(0.0, 0.0); + d.yw = SMAASearchDiag1(SMAATexturePass2D(edgesTex), texcoord, float2(1.0, -1.0), end); + + SMAA_BRANCH + if (d.x + d.y > 2.0) { // d.x + d.y + 1 > 3 + // Fetch the crossing edges: + float4 coords = mad(float4(-d.x + 0.25, d.x, d.y, -d.y - 0.25), SMAA_RT_METRICS.xyxy, texcoord.xyxy); + float4 c; + c.xy = SMAASampleLevelZeroOffset(edgesTex, coords.xy, int2(-1, 0)).rg; + c.zw = SMAASampleLevelZeroOffset(edgesTex, coords.zw, int2( 1, 0)).rg; + c.yxwz = SMAADecodeDiagBilinearAccess(c.xyzw); + + // Non-optimized version: + // float4 coords = mad(float4(-d.x, d.x, d.y, -d.y), SMAA_RT_METRICS.xyxy, texcoord.xyxy); + // float4 c; + // c.x = SMAASampleLevelZeroOffset(edgesTex, coords.xy, int2(-1, 0)).g; + // c.y = SMAASampleLevelZeroOffset(edgesTex, coords.xy, int2( 0, 0)).r; + // c.z = SMAASampleLevelZeroOffset(edgesTex, coords.zw, int2( 1, 0)).g; + // c.w = SMAASampleLevelZeroOffset(edgesTex, coords.zw, int2( 1, -1)).r; + + // Merge crossing edges at each side into a single value: + float2 cc = mad(float2(2.0, 2.0), c.xz, c.yw); + + // Remove the crossing edge if we didn't found the end of the line: + SMAAMovc(bool2(step(0.9, d.zw)), cc, float2(0.0, 0.0)); + + // Fetch the areas for this line: + weights += SMAAAreaDiag(SMAATexturePass2D(areaTex), d.xy, cc, subsampleIndices.z); + } + + // Search for the line ends: + d.xz = SMAASearchDiag2(SMAATexturePass2D(edgesTex), texcoord, float2(-1.0, -1.0), end); + if (SMAASampleLevelZeroOffset(edgesTex, texcoord, int2(1, 0)).r > 0.0) { + d.yw = SMAASearchDiag2(SMAATexturePass2D(edgesTex), texcoord, float2(1.0, 1.0), end); + d.y += float(end.y > 0.9); + } else + d.yw = float2(0.0, 0.0); + + SMAA_BRANCH + if (d.x + d.y > 2.0) { // d.x + d.y + 1 > 3 + // Fetch the crossing edges: + float4 coords = mad(float4(-d.x, -d.x, d.y, d.y), SMAA_RT_METRICS.xyxy, texcoord.xyxy); + float4 c; + c.x = SMAASampleLevelZeroOffset(edgesTex, coords.xy, int2(-1, 0)).g; + c.y = SMAASampleLevelZeroOffset(edgesTex, coords.xy, int2( 0, -1)).r; + c.zw = SMAASampleLevelZeroOffset(edgesTex, coords.zw, int2( 1, 0)).gr; + float2 cc = mad(float2(2.0, 2.0), c.xz, c.yw); + + // Remove the crossing edge if we didn't found the end of the line: + SMAAMovc(bool2(step(0.9, d.zw)), cc, float2(0.0, 0.0)); + + // Fetch the areas for this line: + weights += SMAAAreaDiag(SMAATexturePass2D(areaTex), d.xy, cc, subsampleIndices.w).gr; + } + + return weights; +} +#endif + +//----------------------------------------------------------------------------- +// Horizontal/Vertical Search Functions + +/** + * This allows to determine how much length should we add in the last step + * of the searches. It takes the bilinearly interpolated edge (see + * @PSEUDO_GATHER4), and adds 0, 1 or 2, depending on which edges and + * crossing edges are active. + */ +float SMAASearchLength(SMAATexture2D(searchTex), float2 e, float offset) { + // The texture is flipped vertically, with left and right cases taking half + // of the space horizontally: + float2 scale = SMAA_SEARCHTEX_SIZE * float2(0.5, -1.0); + float2 bias = SMAA_SEARCHTEX_SIZE * float2(offset, 1.0); + + // Scale and bias to access texel centers: + scale += float2(-1.0, 1.0); + bias += float2( 0.5, -0.5); + + // Convert from pixel coordinates to texcoords: + // (We use SMAA_SEARCHTEX_PACKED_SIZE because the texture is cropped) + scale *= 1.0 / SMAA_SEARCHTEX_PACKED_SIZE; + bias *= 1.0 / SMAA_SEARCHTEX_PACKED_SIZE; + + // Lookup the search texture: + return SMAA_SEARCHTEX_SELECT(SMAASampleLevelZero(searchTex, mad(scale, e, bias))); +} + +/** + * Horizontal/vertical search functions for the 2nd pass. + */ +float SMAASearchXLeft(SMAATexture2D(edgesTex), SMAATexture2D(searchTex), float2 texcoord, float end) { + /** + * @PSEUDO_GATHER4 + * This texcoord has been offset by (-0.25, -0.125) in the vertex shader to + * sample between edge, thus fetching four edges in a row. + * Sampling with different offsets in each direction allows to disambiguate + * which edges are active from the four fetched ones. + */ + float2 e = float2(0.0, 1.0); + while (texcoord.x > end && + e.g > 0.8281 && // Is there some edge not activated? + e.r == 0.0) { // Or is there a crossing edge that breaks the line? + e = SMAASampleLevelZero(edgesTex, texcoord).rg; + texcoord = mad(-float2(2.0, 0.0), SMAA_RT_METRICS.xy, texcoord); + } + + float offset = mad(-(255.0 / 127.0), SMAASearchLength(SMAATexturePass2D(searchTex), e, 0.0), 3.25); + return mad(SMAA_RT_METRICS.x, offset, texcoord.x); + + // Non-optimized version: + // We correct the previous (-0.25, -0.125) offset we applied: + // texcoord.x += 0.25 * SMAA_RT_METRICS.x; + + // The searches are bias by 1, so adjust the coords accordingly: + // texcoord.x += SMAA_RT_METRICS.x; + + // Disambiguate the length added by the last step: + // texcoord.x += 2.0 * SMAA_RT_METRICS.x; // Undo last step + // texcoord.x -= SMAA_RT_METRICS.x * (255.0 / 127.0) * SMAASearchLength(SMAATexturePass2D(searchTex), e, 0.0); + // return mad(SMAA_RT_METRICS.x, offset, texcoord.x); +} + +float SMAASearchXRight(SMAATexture2D(edgesTex), SMAATexture2D(searchTex), float2 texcoord, float end) { + float2 e = float2(0.0, 1.0); + while (texcoord.x < end && + e.g > 0.8281 && // Is there some edge not activated? + e.r == 0.0) { // Or is there a crossing edge that breaks the line? + e = SMAASampleLevelZero(edgesTex, texcoord).rg; + texcoord = mad(float2(2.0, 0.0), SMAA_RT_METRICS.xy, texcoord); + } + float offset = mad(-(255.0 / 127.0), SMAASearchLength(SMAATexturePass2D(searchTex), e, 0.5), 3.25); + return mad(-SMAA_RT_METRICS.x, offset, texcoord.x); +} + +float SMAASearchYUp(SMAATexture2D(edgesTex), SMAATexture2D(searchTex), float2 texcoord, float end) { + float2 e = float2(1.0, 0.0); + while (texcoord.y > end && + e.r > 0.8281 && // Is there some edge not activated? + e.g == 0.0) { // Or is there a crossing edge that breaks the line? + e = SMAASampleLevelZero(edgesTex, texcoord).rg; + texcoord = mad(-float2(0.0, 2.0), SMAA_RT_METRICS.xy, texcoord); + } + float offset = mad(-(255.0 / 127.0), SMAASearchLength(SMAATexturePass2D(searchTex), e.gr, 0.0), 3.25); + return mad(SMAA_RT_METRICS.y, offset, texcoord.y); +} + +float SMAASearchYDown(SMAATexture2D(edgesTex), SMAATexture2D(searchTex), float2 texcoord, float end) { + float2 e = float2(1.0, 0.0); + while (texcoord.y < end && + e.r > 0.8281 && // Is there some edge not activated? + e.g == 0.0) { // Or is there a crossing edge that breaks the line? + e = SMAASampleLevelZero(edgesTex, texcoord).rg; + texcoord = mad(float2(0.0, 2.0), SMAA_RT_METRICS.xy, texcoord); + } + float offset = mad(-(255.0 / 127.0), SMAASearchLength(SMAATexturePass2D(searchTex), e.gr, 0.5), 3.25); + return mad(-SMAA_RT_METRICS.y, offset, texcoord.y); +} + +/** + * Ok, we have the distance and both crossing edges. So, what are the areas + * at each side of current edge? + */ +float2 SMAAArea(SMAATexture2D(areaTex), float2 dist, float e1, float e2, float offset) { + // Rounding prevents precision errors of bilinear filtering: + float2 texcoord = mad(float2(SMAA_AREATEX_MAX_DISTANCE, SMAA_AREATEX_MAX_DISTANCE), round(4.0 * float2(e1, e2)), dist); + + // We do a scale and bias for mapping to texel space: + texcoord = mad(SMAA_AREATEX_PIXEL_SIZE, texcoord, 0.5 * SMAA_AREATEX_PIXEL_SIZE); + + // Move to proper place, according to the subpixel offset: + texcoord.y = mad(SMAA_AREATEX_SUBTEX_SIZE, offset, texcoord.y); + + // Do it! + return SMAA_AREATEX_SELECT(SMAASampleLevelZero(areaTex, texcoord)); +} + +//----------------------------------------------------------------------------- +// Corner Detection Functions + +void SMAADetectHorizontalCornerPattern(SMAATexture2D(edgesTex), inout float2 weights, float4 texcoord, float2 d) { + #if !defined(SMAA_DISABLE_CORNER_DETECTION) + float2 leftRight = step(d.xy, d.yx); + float2 rounding = (1.0 - SMAA_CORNER_ROUNDING_NORM) * leftRight; + + rounding /= leftRight.x + leftRight.y; // Reduce blending for pixels in the center of a line. + + float2 factor = float2(1.0, 1.0); + factor.x -= rounding.x * SMAASampleLevelZeroOffset(edgesTex, texcoord.xy, int2(0, 1)).r; + factor.x -= rounding.y * SMAASampleLevelZeroOffset(edgesTex, texcoord.zw, int2(1, 1)).r; + factor.y -= rounding.x * SMAASampleLevelZeroOffset(edgesTex, texcoord.xy, int2(0, -2)).r; + factor.y -= rounding.y * SMAASampleLevelZeroOffset(edgesTex, texcoord.zw, int2(1, -2)).r; + + weights *= saturate(factor); + #endif +} + +void SMAADetectVerticalCornerPattern(SMAATexture2D(edgesTex), inout float2 weights, float4 texcoord, float2 d) { + #if !defined(SMAA_DISABLE_CORNER_DETECTION) + float2 leftRight = step(d.xy, d.yx); + float2 rounding = (1.0 - SMAA_CORNER_ROUNDING_NORM) * leftRight; + + rounding /= leftRight.x + leftRight.y; + + float2 factor = float2(1.0, 1.0); + factor.x -= rounding.x * SMAASampleLevelZeroOffset(edgesTex, texcoord.xy, int2( 1, 0)).g; + factor.x -= rounding.y * SMAASampleLevelZeroOffset(edgesTex, texcoord.zw, int2( 1, 1)).g; + factor.y -= rounding.x * SMAASampleLevelZeroOffset(edgesTex, texcoord.xy, int2(-2, 0)).g; + factor.y -= rounding.y * SMAASampleLevelZeroOffset(edgesTex, texcoord.zw, int2(-2, 1)).g; + + weights *= saturate(factor); + #endif +} + +//----------------------------------------------------------------------------- +// Blending Weight Calculation Pixel Shader (Second Pass) + +float4 SMAABlendingWeightCalculationPS(float2 texcoord, + float2 pixcoord, + float4 offset[3], + SMAATexture2D(edgesTex), + SMAATexture2D(areaTex), + SMAATexture2D(searchTex), + float4 subsampleIndices) { // Just pass zero for SMAA 1x, see @SUBSAMPLE_INDICES. + float4 weights = float4(0.0, 0.0, 0.0, 0.0); + + float2 e = SMAASample(edgesTex, texcoord).rg; + + SMAA_BRANCH + if (e.g > 0.0) { // Edge at north + #if !defined(SMAA_DISABLE_DIAG_DETECTION) + // Diagonals have both north and west edges, so searching for them in + // one of the boundaries is enough. + weights.rg = SMAACalculateDiagWeights(SMAATexturePass2D(edgesTex), SMAATexturePass2D(areaTex), texcoord, e, subsampleIndices); + + // We give priority to diagonals, so if we find a diagonal we skip + // horizontal/vertical processing. + SMAA_BRANCH + if (weights.r == -weights.g) { // weights.r + weights.g == 0.0 + #endif + + float2 d; + + // Find the distance to the left: + float3 coords; + coords.x = SMAASearchXLeft(SMAATexturePass2D(edgesTex), SMAATexturePass2D(searchTex), offset[0].xy, offset[2].x); + coords.y = offset[1].y; // offset[1].y = texcoord.y - 0.25 * SMAA_RT_METRICS.y (@CROSSING_OFFSET) + d.x = coords.x; + + // Now fetch the left crossing edges, two at a time using bilinear + // filtering. Sampling at -0.25 (see @CROSSING_OFFSET) enables to + // discern what value each edge has: + float e1 = SMAASampleLevelZero(edgesTex, coords.xy).r; + + // Find the distance to the right: + coords.z = SMAASearchXRight(SMAATexturePass2D(edgesTex), SMAATexturePass2D(searchTex), offset[0].zw, offset[2].y); + d.y = coords.z; + + // We want the distances to be in pixel units (doing this here allow to + // better interleave arithmetic and memory accesses): + d = abs(round(mad(SMAA_RT_METRICS.zz, d, -pixcoord.xx))); + + // SMAAArea below needs a sqrt, as the areas texture is compressed + // quadratically: + float2 sqrt_d = sqrt(d); + + // Fetch the right crossing edges: + float e2 = SMAASampleLevelZeroOffset(edgesTex, coords.zy, int2(1, 0)).r; + + // Ok, we know how this pattern looks like, now it is time for getting + // the actual area: + weights.rg = SMAAArea(SMAATexturePass2D(areaTex), sqrt_d, e1, e2, subsampleIndices.y); + + // Fix corners: + coords.y = texcoord.y; + SMAADetectHorizontalCornerPattern(SMAATexturePass2D(edgesTex), weights.rg, coords.xyzy, d); + + #if !defined(SMAA_DISABLE_DIAG_DETECTION) + } else + e.r = 0.0; // Skip vertical processing. + #endif + } + + SMAA_BRANCH + if (e.r > 0.0) { // Edge at west + float2 d; + + // Find the distance to the top: + float3 coords; + coords.y = SMAASearchYUp(SMAATexturePass2D(edgesTex), SMAATexturePass2D(searchTex), offset[1].xy, offset[2].z); + coords.x = offset[0].x; // offset[1].x = texcoord.x - 0.25 * SMAA_RT_METRICS.x; + d.x = coords.y; + + // Fetch the top crossing edges: + float e1 = SMAASampleLevelZero(edgesTex, coords.xy).g; + + // Find the distance to the bottom: + coords.z = SMAASearchYDown(SMAATexturePass2D(edgesTex), SMAATexturePass2D(searchTex), offset[1].zw, offset[2].w); + d.y = coords.z; + + // We want the distances to be in pixel units: + d = abs(round(mad(SMAA_RT_METRICS.ww, d, -pixcoord.yy))); + + // SMAAArea below needs a sqrt, as the areas texture is compressed + // quadratically: + float2 sqrt_d = sqrt(d); + + // Fetch the bottom crossing edges: + float e2 = SMAASampleLevelZeroOffset(edgesTex, coords.xz, int2(0, 1)).g; + + // Get the area for this direction: + weights.ba = SMAAArea(SMAATexturePass2D(areaTex), sqrt_d, e1, e2, subsampleIndices.x); + + // Fix corners: + coords.x = texcoord.x; + SMAADetectVerticalCornerPattern(SMAATexturePass2D(edgesTex), weights.ba, coords.xyxz, d); + } + + return weights; +} + +//----------------------------------------------------------------------------- +// Neighborhood Blending Pixel Shader (Third Pass) + +float4 SMAANeighborhoodBlendingPS(float2 texcoord, + float4 offset, + SMAATexture2D(colorTex), + SMAATexture2D(blendTex) + #if SMAA_REPROJECTION + , SMAATexture2D(velocityTex) + #endif + ) { + // Fetch the blending weights for current pixel: + float4 a; + a.x = SMAASample(blendTex, offset.xy).a; // Right + a.y = SMAASample(blendTex, offset.zw).g; // Top + a.wz = SMAASample(blendTex, texcoord).xz; // Bottom / Left + + // Is there any blending weight with a value greater than 0.0? + SMAA_BRANCH + if (dot(a, float4(1.0, 1.0, 1.0, 1.0)) < 1e-5) { + float4 color = SMAASampleLevelZero(colorTex, texcoord); + + #if SMAA_REPROJECTION + float2 velocity = SMAA_DECODE_VELOCITY(SMAASampleLevelZero(velocityTex, texcoord)); + + // Pack velocity into the alpha channel: + color.a = sqrt(5.0 * length(velocity)); + #endif + + return color; + } else { + bool h = max(a.x, a.z) > max(a.y, a.w); // max(horizontal) > max(vertical) + + // Calculate the blending offsets: + float4 blendingOffset = float4(0.0, a.y, 0.0, a.w); + float2 blendingWeight = a.yw; + SMAAMovc(bool4(h, h, h, h), blendingOffset, float4(a.x, 0.0, a.z, 0.0)); + SMAAMovc(bool2(h, h), blendingWeight, a.xz); + blendingWeight /= dot(blendingWeight, float2(1.0, 1.0)); + + // Calculate the texture coordinates: + float4 blendingCoord = mad(blendingOffset, float4(SMAA_RT_METRICS.xy, -SMAA_RT_METRICS.xy), texcoord.xyxy); + + // We exploit bilinear filtering to mix current pixel with the chosen + // neighbor: + float4 color = blendingWeight.x * SMAASampleLevelZero(colorTex, blendingCoord.xy); + color += blendingWeight.y * SMAASampleLevelZero(colorTex, blendingCoord.zw); + + #if SMAA_REPROJECTION + // Antialias velocity for proper reprojection in a later stage: + float2 velocity = blendingWeight.x * SMAA_DECODE_VELOCITY(SMAASampleLevelZero(velocityTex, blendingCoord.xy)); + velocity += blendingWeight.y * SMAA_DECODE_VELOCITY(SMAASampleLevelZero(velocityTex, blendingCoord.zw)); + + // Pack velocity into the alpha channel: + color.a = sqrt(5.0 * length(velocity)); + #endif + + return color; + } +} + +//----------------------------------------------------------------------------- +// Temporal Resolve Pixel Shader (Optional Pass) + +float4 SMAAResolvePS(float2 texcoord, + SMAATexture2D(currentColorTex), + SMAATexture2D(previousColorTex) + #if SMAA_REPROJECTION + , SMAATexture2D(velocityTex) + #endif + ) { + #if SMAA_REPROJECTION + // Velocity is assumed to be calculated for motion blur, so we need to + // inverse it for reprojection: + float2 velocity = -SMAA_DECODE_VELOCITY(SMAASamplePoint(velocityTex, texcoord).rg); + + // Fetch current pixel: + float4 current = SMAASamplePoint(currentColorTex, texcoord); + + // Reproject current coordinates and fetch previous pixel: + float4 previous = SMAASamplePoint(previousColorTex, texcoord + velocity); + + // Attenuate the previous pixel if the velocity is different: + float delta = abs(current.a * current.a - previous.a * previous.a) / 5.0; + float weight = 0.5 * saturate(1.0 - sqrt(delta) * SMAA_REPROJECTION_WEIGHT_SCALE); + + // Blend the pixels according to the calculated weight: + return lerp(current, previous, weight); + #else + // Just blend the pixels: + float4 current = SMAASamplePoint(currentColorTex, texcoord); + float4 previous = SMAASamplePoint(previousColorTex, texcoord); + return lerp(current, previous, 0.5); + #endif +} + +//----------------------------------------------------------------------------- +// Separate Multisamples Pixel Shader (Optional Pass) + +#ifdef SMAALoad +void SMAASeparatePS(float4 position, + float2 texcoord, + out float4 target0, + out float4 target1, + SMAATexture2DMS2(colorTexMS)) { + int2 pos = int2(position.xy); + target0 = SMAALoad(colorTexMS, pos, 0); + target1 = SMAALoad(colorTexMS, pos, 1); +} +#endif + +//----------------------------------------------------------------------------- +#endif // SMAA_INCLUDE_PS diff --git a/enbseries/SMAA/SearchTex.dds b/enbseries/SMAA/SearchTex.dds new file mode 100644 index 0000000..f48ec89 Binary files /dev/null and b/enbseries/SMAA/SearchTex.dds differ diff --git a/enbseries/VERSION b/enbseries/VERSION index c149d01..722619b 100644 --- a/enbseries/VERSION +++ b/enbseries/VERSION @@ -1 +1 @@ -3.3.1 "Red Sunset" +3.4.0 "Another Settlement Needs Your Help" diff --git a/enbseries/enbadaptation.fx b/enbseries/enbadaptation.fx index 985789d..5d591cd 100644 --- a/enbseries/enbadaptation.fx +++ b/enbseries/enbadaptation.fx @@ -13,7 +13,7 @@ Texture2D TexturePrevious; SamplerState Sampler0 { - Filter = MIN_MAG_MIP_LINEAR; + Filter = MIN_MAG_MIP_POINT; AddressU = Clamp; AddressV = Clamp; }; @@ -50,7 +50,10 @@ float4 PS_Downsample( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target float4 res = float4(0,0,0,0); int x, y; [unroll] for ( y=-8; y<8; y++ ) [unroll] for ( x=-8; x<8; x++ ) - res += TextureCurrent.Sample(Sampler0,coord+float2(x,y)*ssz); + { + res += TextureCurrent.Sample(Sampler0,coord + +float2(x+0.5,y+0.5)*ssz); + } res /= 256.0; res = luminance(res.rgb); res.w = 1.0; @@ -67,7 +70,8 @@ float4 PS_Adaptation(VS_OUTPUT_POST IN, float4 v0 : SV_Position0) : SV_Target int x, y; [unroll] for ( y=-8; y<8; y++ ) [unroll] for ( x=-8; x<8; x++ ) { - smp = TextureCurrent.Sample(Sampler0,coord+float2(x,y)*ssz).x; + smp = TextureCurrent.Sample(Sampler0,coord + +float2(x+0.5,y+0.5)*ssz).x; smpmax = max(smpmax,smp); res += smp; } diff --git a/enbseries/enbbloom.fx b/enbseries/enbbloom.fx index f58cc12..0e988c6 100644 --- a/enbseries/enbbloom.fx +++ b/enbseries/enbbloom.fx @@ -335,7 +335,7 @@ Texture2D RenderTarget256; Texture2D RenderTarget128; Texture2D RenderTarget64; Texture2D RenderTarget32; -Texture2D RenderTargetRGBA64F; +Texture2D RenderTarget16; SamplerState Sampler { @@ -412,11 +412,7 @@ float4 PS_PrePass( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target return res; } -/* - progressive downsizing of textures, with interpolation. - - First downsample is unnecessary because both textures are the same size. -*/ +/* progressive downsizing of textures, with interpolation. */ float4 PS_Downsize( VS_OUTPUT_POST IN, float4 v0 : SV_Position0, uniform Texture2D intex, uniform float insz ) : SV_Target { @@ -445,7 +441,7 @@ float4 PS_Downsize( VS_OUTPUT_POST IN, float4 v0 : SV_Position0, float4 Anamorphic( float2 coord, Texture2D intex, float insz ) { float4 res = float4(0.0,0.0,0.0,0.0), - base = RenderTargetRGBA64F.Sample(Sampler,coord); + base = RenderTarget1024.Sample(Sampler,coord); int i; float sum = 0.0; float inc = flen/insz; @@ -498,7 +494,7 @@ float4 PS_VerticalBlur( VS_OUTPUT_POST IN, float4 v0 : SV_Position0, float2 coord = IN.txcoord0.xy; float4 res = float4(0.0,0.0,0.0,0.0), - base = RenderTargetRGBA64F.Sample(Sampler,coord); + base = RenderTarget1024.Sample(Sampler,coord); int i; float sum = 0.0; float inc = bloomradiusy/insz; @@ -525,12 +521,12 @@ float4 PS_VerticalBlur( VS_OUTPUT_POST IN, float4 v0 : SV_Position0, float4 PS_PostPass( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target { float2 coord = IN.txcoord0.xy; - float4 res = bloommix1*RenderTarget1024.Sample(Sampler2,coord); - res += bloommix2*RenderTarget512.Sample(Sampler2,coord); - res += bloommix3*RenderTarget256.Sample(Sampler2,coord); - res += bloommix4*RenderTarget128.Sample(Sampler2,coord); - res += bloommix5*RenderTarget64.Sample(Sampler2,coord); - res += bloommix6*RenderTarget32.Sample(Sampler2,coord); + float4 res = bloommix1*RenderTarget512.Sample(Sampler2,coord); + res += bloommix2*RenderTarget256.Sample(Sampler2,coord); + res += bloommix3*RenderTarget128.Sample(Sampler2,coord); + res += bloommix4*RenderTarget64.Sample(Sampler2,coord); + res += bloommix5*RenderTarget32.Sample(Sampler2,coord); + res += bloommix6*RenderTarget16.Sample(Sampler2,coord); res.rgb /= 6.0; res.rgb = clamp(res.rgb,0.0,32768.0); res.a = 1.0; @@ -540,13 +536,13 @@ float4 PS_PostPass( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target float4 PS_SPostPass( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target { float2 coord = IN.txcoord0.xy; - float4 res = bloommixs*RenderTarget128.Sample(Sampler2,coord); + float4 res = bloommixs*RenderTarget64.Sample(Sampler2,coord); res.rgb = clamp(res.rgb,0.0,32768.0); res.a = 1.0; return res; } -technique11 BloomSimplePass +technique11 BloomSimplePass { pass p0 { @@ -554,15 +550,7 @@ technique11 BloomSimplePass -{ - pass p0 - { - SetVertexShader(CompileShader(vs_5_0,VS_Quad())); - SetPixelShader(CompileShader(ps_5_0,PS_Downsize(RenderTargetRGBA64F,0.0))); - } -} -technique11 BloomSimplePass2 +technique11 BloomSimplePass1 { pass p0 { @@ -570,7 +558,7 @@ technique11 BloomSimplePass2 SetPixelShader(CompileShader(ps_5_0,PS_Downsize(RenderTarget1024,1024.0))); } } -technique11 BloomSimplePass3 +technique11 BloomSimplePass2 { pass p0 { @@ -578,7 +566,7 @@ technique11 BloomSimplePass3 SetPixelShader(CompileShader(ps_5_0,PS_Downsize(RenderTarget512,512.0))); } } -technique11 BloomSimplePass4 +technique11 BloomSimplePass3 { pass p0 { @@ -586,20 +574,28 @@ technique11 BloomSimplePass4 SetPixelShader(CompileShader(ps_5_0,PS_Downsize(RenderTarget256,256.0))); } } +technique11 BloomSimplePass4 +{ + pass p0 + { + SetVertexShader(CompileShader(vs_5_0,VS_Quad())); + SetPixelShader(CompileShader(ps_5_0,PS_Downsize(RenderTarget128,128.0))); + } +} technique11 BloomSimplePass5 { pass p0 { SetVertexShader(CompileShader(vs_5_0,VS_Quad())); - SetPixelShader(CompileShader(ps_5_0,PS_HorizontalBlur(RenderTarget128,128.0))); + SetPixelShader(CompileShader(ps_5_0,PS_HorizontalBlur(RenderTarget64,64.0))); } } -technique11 BloomSimplePass6 +technique11 BloomSimplePass6 { pass p0 { SetVertexShader(CompileShader(vs_5_0,VS_Quad())); - SetPixelShader(CompileShader(ps_5_0,PS_VerticalBlur(TextureColor,128.0,3.0))); + SetPixelShader(CompileShader(ps_5_0,PS_VerticalBlur(TextureColor,64.0,3.0))); } } technique11 BloomSimplePass7 @@ -611,7 +607,7 @@ technique11 BloomSimplePass7 } } -technique11 BloomPass +technique11 BloomPass { pass p0 { @@ -619,15 +615,7 @@ technique11 BloomPass -{ - pass p0 - { - SetVertexShader(CompileShader(vs_5_0,VS_Quad())); - SetPixelShader(CompileShader(ps_5_0,PS_Downsize(RenderTargetRGBA64F,0.0))); - } -} -technique11 BloomPass2 +technique11 BloomPass1 { pass p0 { @@ -635,7 +623,7 @@ technique11 BloomPass2 SetPixelShader(CompileShader(ps_5_0,PS_Downsize(RenderTarget1024,1024.0))); } } -technique11 BloomPass3 +technique11 BloomPass2 { pass p0 { @@ -643,7 +631,7 @@ technique11 BloomPass3 SetPixelShader(CompileShader(ps_5_0,PS_Downsize(RenderTarget512,512.0))); } } -technique11 BloomPass4 +technique11 BloomPass3 { pass p0 { @@ -651,7 +639,7 @@ technique11 BloomPass4 SetPixelShader(CompileShader(ps_5_0,PS_Downsize(RenderTarget256,256.0))); } } -technique11 BloomPass5 +technique11 BloomPass4 { pass p0 { @@ -659,7 +647,7 @@ technique11 BloomPass5 SetPixelShader(CompileShader(ps_5_0,PS_Downsize(RenderTarget128,128.0))); } } -technique11 BloomPass6 +technique11 BloomPass5 { pass p0 { @@ -667,23 +655,15 @@ technique11 BloomPass6 SetPixelShader(CompileShader(ps_5_0,PS_Downsize(RenderTarget64,64.0))); } } +technique11 BloomPass6 +{ + pass p0 + { + SetVertexShader(CompileShader(vs_5_0,VS_Quad())); + SetPixelShader(CompileShader(ps_5_0,PS_Downsize(RenderTarget32,32.0))); + } +} technique11 BloomPass7 -{ - pass p0 - { - SetVertexShader(CompileShader(vs_5_0,VS_Quad())); - SetPixelShader(CompileShader(ps_5_0,PS_HorizontalBlur(RenderTarget1024,1024.0))); - } -} -technique11 BloomPass8 -{ - pass p0 - { - SetVertexShader(CompileShader(vs_5_0,VS_Quad())); - SetPixelShader(CompileShader(ps_5_0,PS_VerticalBlur(TextureColor,1024.0,0.0))); - } -} -technique11 BloomPass9 { pass p0 { @@ -691,15 +671,15 @@ technique11 BloomPass9 SetPixelShader(CompileShader(ps_5_0,PS_HorizontalBlur(RenderTarget512,512.0))); } } -technique11 BloomPass10 +technique11 BloomPass8 { pass p0 { SetVertexShader(CompileShader(vs_5_0,VS_Quad())); - SetPixelShader(CompileShader(ps_5_0,PS_VerticalBlur(TextureColor,512.0,1.0))); + SetPixelShader(CompileShader(ps_5_0,PS_VerticalBlur(TextureColor,512.0,0.0))); } } -technique11 BloomPass11 +technique11 BloomPass9 { pass p0 { @@ -707,15 +687,15 @@ technique11 BloomPass11 SetPixelShader(CompileShader(ps_5_0,PS_HorizontalBlur(RenderTarget256,256.0))); } } -technique11 BloomPass12 +technique11 BloomPass10 { pass p0 { SetVertexShader(CompileShader(vs_5_0,VS_Quad())); - SetPixelShader(CompileShader(ps_5_0,PS_VerticalBlur(TextureColor,256.0,2.0))); + SetPixelShader(CompileShader(ps_5_0,PS_VerticalBlur(TextureColor,256.0,1.0))); } } -technique11 BloomPass13 +technique11 BloomPass11 { pass p0 { @@ -723,15 +703,15 @@ technique11 BloomPass13 SetPixelShader(CompileShader(ps_5_0,PS_HorizontalBlur(RenderTarget128,128.0))); } } -technique11 BloomPass14 +technique11 BloomPass12 { pass p0 { SetVertexShader(CompileShader(vs_5_0,VS_Quad())); - SetPixelShader(CompileShader(ps_5_0,PS_VerticalBlur(TextureColor,128.0,3.0))); + SetPixelShader(CompileShader(ps_5_0,PS_VerticalBlur(TextureColor,128.0,2.0))); } } -technique11 BloomPass15 +technique11 BloomPass13 { pass p0 { @@ -739,15 +719,15 @@ technique11 BloomPass15 SetPixelShader(CompileShader(ps_5_0,PS_HorizontalBlur(RenderTarget64,64.0))); } } -technique11 BloomPass16 +technique11 BloomPass14 { pass p0 { SetVertexShader(CompileShader(vs_5_0,VS_Quad())); - SetPixelShader(CompileShader(ps_5_0,PS_VerticalBlur(TextureColor,64.0,4.0))); + SetPixelShader(CompileShader(ps_5_0,PS_VerticalBlur(TextureColor,64.0,3.0))); } } -technique11 BloomPass17 +technique11 BloomPass15 { pass p0 { @@ -755,12 +735,28 @@ technique11 BloomPass17 SetPixelShader(CompileShader(ps_5_0,PS_HorizontalBlur(RenderTarget32,32.0))); } } -technique11 BloomPass18 +technique11 BloomPass16 { pass p0 { SetVertexShader(CompileShader(vs_5_0,VS_Quad())); - SetPixelShader(CompileShader(ps_5_0,PS_VerticalBlur(TextureColor,32.0,5.0))); + SetPixelShader(CompileShader(ps_5_0,PS_VerticalBlur(TextureColor,32.0,4.0))); + } +} +technique11 BloomPass17 +{ + pass p0 + { + SetVertexShader(CompileShader(vs_5_0,VS_Quad())); + SetPixelShader(CompileShader(ps_5_0,PS_HorizontalBlur(RenderTarget16,16.0))); + } +} +technique11 BloomPass18 +{ + pass p0 + { + SetVertexShader(CompileShader(vs_5_0,VS_Quad())); + SetPixelShader(CompileShader(ps_5_0,PS_VerticalBlur(TextureColor,16.0,5.0))); } } technique11 BloomPass19 diff --git a/enbseries/enbbloom.fx.ini b/enbseries/enbbloom.fx.ini index 179d6e4..ad252cf 100644 --- a/enbseries/enbbloom.fx.ini +++ b/enbseries/enbbloom.fx.ini @@ -1,13 +1,13 @@ [ENBBLOOM.FX] TECHNIQUE=2 -Bloom Intensity Night=0.39 -Bloom Intensity Day=0.31 -Bloom Intensity Interior=0.35 -Bloom Contrast Night=0.94 -Bloom Contrast Day=0.99 -Bloom Contrast Interior=0.96 +Bloom Intensity Night=0.26 +Bloom Intensity Day=0.22 +Bloom Intensity Interior=0.19 +Bloom Contrast Night=0.81 +Bloom Contrast Day=0.89 +Bloom Contrast Interior=0.91 Bloom Saturation Night=1.39 -Bloom Saturation Day=1.35 +Bloom Saturation Day=1.33 Bloom Saturation Interior=1.43 Bloom Offset Night=0.0 Bloom Offset Day=0.0 @@ -21,28 +21,28 @@ Blue Shift Night=0.294, 0.424, 0.859 Blue Shift Day=0.22, 0.537, 0.855 Blue Shift Interior=0.337, 0.525, 0.878 Blue Shift Intensity Night=0.32 -Blue Shift Intensity Day=0.2 +Blue Shift Intensity Day=0.22 Blue Shift Intensity Interior=0.31 Blue Shift Luminance Factor Per-pass=0.7 Blue Shift Color Factor Per-pass=0.8 Enable Anamorphic Bloom=true -Anamorphic Bloom Blend Night=0.59 -Anamorphic Bloom Blend Day=0.55 -Anamorphic Bloom Blend Interior=0.64 +Anamorphic Bloom Blend Night=0.92 +Anamorphic Bloom Blend Day=0.86 +Anamorphic Bloom Blend Interior=0.83 Anamorphic Bloom Blue Shift Night=0.553, 0.404, 0.851 Anamorphic Bloom Blue Shift Day=0.424, 0.384, 0.831 Anamorphic Bloom Blue Shift Interior=0.537, 0.475, 0.89 Anamorphic Bloom Blue Shift Intensity Night=1.24 -Anamorphic Bloom Blue Shift Intensity Day=1.16 +Anamorphic Bloom Blue Shift Intensity Day=1.33 Anamorphic Bloom Blue Shift Intensity Interior=1.38 -Anamorphic Bloom Contrast Night=1.41 -Anamorphic Bloom Contrast Day=1.45 -Anamorphic Bloom Contrast Interior=1.36 +Anamorphic Bloom Contrast Night=1.14 +Anamorphic Bloom Contrast Day=1.18 +Anamorphic Bloom Contrast Interior=1.23 Anamorphic Bloom Radius Multiplier=1.0 Bloom Pass 1 Blend=0.11 -Bloom Pass 2 Blend=0.24 +Bloom Pass 2 Blend=0.2 Bloom Pass 3 Blend=0.39 -Bloom Pass 4 Blend=0.53 -Bloom Pass 5 Blend=0.78 -Bloom Pass 6 Blend=0.9 -Bloom Single Pass Blend=0.52 +Bloom Pass 4 Blend=0.58 +Bloom Pass 5 Blend=0.72 +Bloom Pass 6 Blend=0.86 +Bloom Single Pass Blend=0.35 diff --git a/enbseries/enbdepthoffield.fx b/enbseries/enbdepthoffield.fx index f60b835..eac5c37 100644 --- a/enbseries/enbdepthoffield.fx +++ b/enbseries/enbdepthoffield.fx @@ -626,6 +626,163 @@ float edgevradius string UIWidget = "Spinner"; float UIMin = 0.0; > = {1.0}; +bool edgevinv +< + string UIName = "Invert Edgevision"; + string UIWidget = "Checkbox"; +> = {false}; +bool edgevblend +< + string UIName = "Blend Edgevision"; + string UIWidget = "Checkbox"; +> = {false}; +/* use luma edge detection filter */ +string str_com = "Edge Detect"; +bool comenable +< + string UIName = "Enable Edge Detect"; + string UIWidget = "Checkbox"; +> = {false}; +float compow +< + string UIName = "Edge Detect Contrast"; + string UIWidget = "Spinner"; + float UIMin = 0.0; +> = {1.0}; +float commult +< + string UIName = "Edge Detect Intensity"; + string UIWidget = "Spinner"; + float UIMin = 0.0; +> = {1.0}; +float comradius +< + string UIName = "Edge Detect Radius"; + string UIWidget = "Spinner"; + float UIMin = 0.0; +> = {1.0}; +bool cominv +< + string UIName = "Invert Edge Detect"; + string UIWidget = "Checkbox"; +> = {false}; +bool comblend +< + string UIName = "Blend Edge Detect"; + string UIWidget = "Checkbox"; +> = {false}; +/* use edge threshold filter aka "linevision" */ +string str_cont = "Linevision"; +bool contenable +< + string UIName = "Enable Linevision"; + string UIWidget = "Checkbox"; +> = {false}; +/* factors */ +float contfadepow_n +< + string UIName = "Linevision Fade Contrast Night"; + string UIWidget = "Spinner"; + float UIMin = 0.0; +> = {2.0}; +float contfadepow_d +< + string UIName = "Linevision Fade Contrast Day"; + string UIWidget = "Spinner"; + float UIMin = 0.0; +> = {2.0}; +float contfadepow_i +< + string UIName = "Linevision Fade Contrast Interior"; + string UIWidget = "Spinner"; + float UIMin = 0.0; +> = {2.0}; +float contfademult_n +< + string UIName = "Linevision Fade Intensity Night"; + string UIWidget = "Spinner"; + float UIMin = 0.0; +> = {500.0}; +float contfademult_d +< + string UIName = "Linevision Fade Intensity Day"; + string UIWidget = "Spinner"; + float UIMin = 0.0; +> = {500.0}; +float contfademult_i +< + string UIName = "Linevision Fade Intensity Interior"; + string UIWidget = "Spinner"; + float UIMin = 0.0; +> = {500.0}; +float contpow +< + string UIName = "Linevision Contrast"; + string UIWidget = "Spinner"; + float UIMin = 0.0; +> = {1.0}; +float contmult +< + string UIName = "Linevision Intensity"; + string UIWidget = "Spinner"; + float UIMin = 0.0; +> = {2.0}; +float contradius +< + string UIName = "Linevision Radius"; + string UIWidget = "Spinner"; + float UIMin = 0.0; +> = {1.0}; +float contthreshold +< + string UIName = "Linevision Threshold"; + string UIWidget = "Spinner"; + float UIMin = 0.0; +> = {0.05}; +bool continv +< + string UIName = "Invert Linevision"; + string UIWidget = "Checkbox"; +> = {false}; +bool contblend +< + string UIName = "Blend Linevision"; + string UIWidget = "Checkbox"; +> = {false}; +/* fog filter */ +string str_fog = "Custom Fog Filter"; +bool fogenable +< + string UIName = "Enable Custom Fog"; + string UIWidget = "Checkbox"; +> = {false}; +float fogpow +< + string UIName = "Fog Contrast"; + string UIWidget = "Spinner"; + float UIMin = 0.0; +> = {1.0}; +float fogmult +< + string UIName = "Fog Intensity"; + string UIWidget = "Spinner"; + float UIMin = 0.0; +> = {1.0}; +float fogbump +< + string UIName = "Fog Shift"; + string UIWidget = "Spinner"; +> = {0.0}; +float3 fogcolor +< + string UIName = "Fog Color"; + string UIWidget = "Spinner"; +> = {1.0,1.0,1.0}; +bool foglimbo +< + string UIName = "Limbo Mode"; + string UIWidget = "Checkbox"; +> = {false}; /* ssao filter */ string str_ssao = "Ray Marching SSAO"; bool ssaoenable @@ -693,6 +850,11 @@ float ssaopow string UIWidget = "Spinner"; float UIMin = 0.0; > = {1.5}; +float ssaobump +< + string UIName = "SSAO Shift"; + string UIWidget = "Spinner"; +> = {0.0}; float ssaoblend < string UIName = "SSAO Blending"; @@ -979,6 +1141,12 @@ static const float3x3 GY = 0, 0, 0, -1,-2,-1 }; +/* radius: 8, std dev: 3 */ +static const float gauss8[8] = +{ + 0.134598, 0.127325, 0.107778, 0.081638, + 0.055335, 0.033562, 0.018216, 0.008847 +}; /* radius: 16, std dev: 13 */ static const float gauss16[16] = { @@ -988,18 +1156,42 @@ static const float gauss16[16] = 0.026131, 0.024268, 0.022405, 0.020563 }; /* SSAO samples */ -static const float3 ssao_samples[16] = +static const float3 ssao_samples[64] = { - float3( 0.0000,-0.0002, 0.0000),float3(-0.0004, 0.0013, 0.0014), - float3(-0.0030, 0.0048,-0.0034),float3( 0.0147, 0.0046,-0.0026), - float3(-0.0097, 0.0275,-0.0092),float3(-0.0178,-0.0072, 0.0491), - float3( 0.0227,-0.0431,-0.0681),float3( 0.1052, 0.0332,-0.0588), - float3( 0.0997, 0.0056, 0.1473),float3(-0.1252, 0.2019, 0.0564), - float3(-0.1054,-0.2072, 0.2271),float3(-0.0542, 0.3096, 0.2814), - float3( 0.0072,-0.3534, 0.4035),float3(-0.0024,-0.2385, 0.6260), - float3(-0.1940, 0.5722,-0.5602),float3(-0.0910,-0.7548,-0.6497) + float3(-0.0051, 0.0021, 0.0146),float3(-0.0197,-0.0213,-0.0116), + float3( 0.0005,-0.0432,-0.0182),float3(-0.0011,-0.0586,-0.0217), + float3(-0.0549, 0.0461, 0.0309),float3(-0.0448,-0.0764,-0.0306), + float3(-0.0366, 0.0758,-0.0699),float3(-0.0770,-0.0707,-0.0686), + float3( 0.1181,-0.0340,-0.0683),float3(-0.0647, 0.0356, 0.1377), + float3(-0.1167, 0.1262, 0.0024),float3(-0.1353,-0.0861, 0.0971), + float3(-0.0096, 0.0936, 0.1800),float3( 0.1311,-0.1013,-0.1429), + float3(-0.1186,-0.0653, 0.1913),float3( 0.1641, 0.0260, 0.1868), + float3(-0.1225,-0.2319, 0.0424),float3( 0.1036,-0.2000, 0.1684), + float3( 0.1656, 0.2022,-0.1408),float3(-0.1809,-0.1673, 0.1922), + float3(-0.2485,-0.1236, 0.1750),float3( 0.1030,-0.0550, 0.3233), + float3(-0.0405, 0.3068, 0.1827),float3(-0.0576, 0.1632, 0.3327), + float3( 0.0392, 0.3583,-0.1505),float3( 0.0082, 0.2865, 0.2879), + float3( 0.0055,-0.2835, 0.3124),float3(-0.2733, 0.1991,-0.2776), + float3( 0.2667, 0.1127,-0.3486),float3(-0.3326, 0.2740,-0.1844), + float3( 0.2887,-0.3838, 0.0630),float3( 0.1088, 0.1546, 0.4629), + float3( 0.0977,-0.3565, 0.3595),float3(-0.4204, 0.0855, 0.3133), + float3(-0.2237,-0.4932, 0.0759),float3( 0.4245, 0.3169,-0.1891), + float3( 0.0084,-0.5682, 0.1062),float3(-0.1489,-0.5296,-0.2235), + float3( 0.0014,-0.4153,-0.4460),float3( 0.0300,-0.4392, 0.4437), + float3( 0.2627, 0.4518, 0.3704),float3(-0.4945, 0.3659, 0.2285), + float3(-0.2550,-0.5311, 0.3230),float3(-0.4477, 0.0828,-0.5151), + float3( 0.4682, 0.4531,-0.2644),float3(-0.1235,-0.0366, 0.7071), + float3( 0.3545, 0.4559, 0.4536),float3(-0.1037,-0.2199,-0.7095), + float3( 0.4269, 0.5299,-0.3510),float3( 0.7051,-0.1468,-0.3027), + float3( 0.4590,-0.5669,-0.3208),float3( 0.2330, 0.1264, 0.7680), + float3(-0.3954, 0.5619,-0.4622),float3( 0.5977,-0.5110, 0.3059), + float3(-0.5800,-0.6306, 0.0672),float3(-0.2211,-0.0332,-0.8460), + float3(-0.3808,-0.2238,-0.7734),float3(-0.5616, 0.6858,-0.1887), + float3(-0.2995, 0.5165,-0.7024),float3( 0.5042,-0.0537, 0.7885), + float3(-0.6477,-0.3691, 0.5938),float3(-0.3969, 0.8815, 0.0620), + float3(-0.4300,-0.8814,-0.0852),float3(-0.1683, 0.9379, 0.3033) }; -/* For high quality DOF */ +/* For low quality DOF */ static const float2 poisson32[32] = { float2( 0.7284430,-0.1927130),float2( 0.4051600,-0.2312710), @@ -1042,7 +1234,7 @@ Texture2D RenderTargetR32F; /* for DOF */ Texture2D TextureNoise3 < - string ResourceName = "menbnoise2.png"; + string ResourceName = "menbnoise3.png"; >; Texture2D TextureHeat < @@ -1164,7 +1356,7 @@ float4 PS_SSAOPre( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target float sdepth, so, delta; float sclamp = ssaoclamp/100000.0; float sclampmin = ssaoclampmin/100000.0; - [unroll] for ( i=0; i<16; i++ ) + [unroll] for ( i=0; i<64; i++ ) { sample = reflect(ssao_samples[i],rnormal); sample *= sign(dot(normal,sample)); @@ -1175,64 +1367,47 @@ float4 PS_SSAOPre( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target if ( (delta > sclampmin) && (delta < sclamp) ) occ += 1.0-delta; } - float uocc = saturate(occ/16.0); + float uocc = saturate(occ/64.0); float fade = 1.0-depth; uocc *= saturate(pow(max(0,fade),ssaofadepow)*ssaofademult); - uocc = saturate(pow(max(0,uocc),ssaopow)*ssaomult); + uocc = saturate(pow(max(0,uocc),ssaopow)*ssaomult+ssaobump); return saturate(1.0-(uocc*ssaoblend)); } /* - The blur passes use bilateral filtering to mostly preserve borders. + The blur pass uses bilateral filtering to mostly preserve borders. An additional factor using difference of normals was tested, but the performance decrease was too much, so it's gone forever. */ -float4 PS_SSAOBlurH( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target +float4 PS_SSAOBlur( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target { float2 coord = IN.txcoord.xy; - if ( !ssaoenable ) return 0.0; - if ( !ssaobenable ) return TextureColor.Sample(Sampler1,coord); - float bresl = ScreenSize.x; - float bof = (1.0/bresl)*ssaobradius; - float isd, sd, ds, sw, tw = 0; - float res = 0.0; - int i; - isd = TextureDepth.Sample(Sampler1,coord).x; - [unroll] for ( i=-15; i<=15; i++ ) + float4 res = TextureColor.Sample(Sampler1,coord); + float mud = RenderTargetR16F.Sample(Sampler1,coord).x; + if ( !ssaoenable ) return res; + if ( !ssaobenable ) { - sd = TextureDepth.Sample(Sampler1,coord+float2(i,0)*bof).x; + if ( ssaodebug ) return saturate(mud); + return res*mud; + } + float2 bresl = float2(ScreenSize.x,ScreenSize.x*ScreenSize.w); + float2 bof = (1.0/bresl)*ssaobradius; + float isd, sd, ds, sw, tw = 0; + mud = 0.0; + int i, j; + isd = TextureDepth.Sample(Sampler1,coord).x; + [unroll] for ( j=-7; j<=7; j++ ) [unroll] for ( i=-7; i<=7; i++ ) + { + sd = TextureDepth.Sample(Sampler1,coord+float2(i,j)*bof).x; ds = 1.0/pow(1.0+abs(isd-sd),ssaobfact); sw = ds; - sw *= gauss16[abs(i)]; + sw *= gauss8[abs(i)]*gauss8[abs(j)]; tw += sw; - res += sw*TextureColor.Sample(Sampler1,coord+float2(i,0) + mud += sw*RenderTargetR16F.Sample(Sampler1,coord+float2(i,j) *bof).x; } - res /= tw; - return res; -} -float4 PS_SSAOBlurV( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target -{ - float2 coord = IN.txcoord.xy; - if ( !ssaoenable ) return 0.0; - if ( !ssaobenable ) return TextureColor.Sample(Sampler1,coord); - float bresl = ScreenSize.x*ScreenSize.w; - float bof = (1.0/bresl)*ssaobradius; - float isd, sd, ds, sw, tw = 0; - float res = 0.0; - int i; - isd = TextureDepth.Sample(Sampler1,coord).x; - [unroll] for ( i=-15; i<=15; i++ ) - { - sd = TextureDepth.Sample(Sampler1,coord+float2(0,i)*bof).x; - ds = 1.0/pow(1.0+abs(isd-sd),ssaobfact); - sw = ds; - sw *= gauss16[abs(i)]; - tw += sw; - res += sw*TextureColor.Sample(Sampler1,coord+float2(0,i) - *bof).x; - } - res /= tw; - return res; + mud /= tw; + if ( ssaodebug ) return saturate(mud); + return res*mud; } /* precalculate DOF factors */ @@ -1312,9 +1487,97 @@ float3 EdgeView( float3 res, float2 coord ) mdy += GY[2][2]*depths[2][2]; mud = pow(mdx*mdx+mdy*mdy,0.5); float fade = 1.0-TextureDepth.Sample(Sampler1,coord).x; - mud *= saturate(pow(max(0,fade),edgevfadepow)*edgevfademult); - mud = saturate(pow(max(0,mud),edgevpow)*edgevmult); - return mud; + mud *= clamp(pow(max(0,fade),edgevfadepow)*edgevfademult,0.0,1.0); + mud = clamp(pow(max(0,mud),edgevpow)*edgevmult,0.0,1.0); + if ( edgevblend ) return res-(edgevinv?1.0-mud:mud); + return edgevinv?1.0-mud:mud; +} + +/* luminance edge detection */ +float3 EdgeDetect( float3 res, float2 coord ) +{ + float2 bresl = float2(ScreenSize.x,ScreenSize.x*ScreenSize.w); + if ( fixed.x>0 && fixed.y>0 ) bresl = fixed; + float2 bof = float2(1.0/bresl.x,1.0/bresl.y)*comradius; + float mdx = 0, mdy = 0, mud = 0; + float3x3 lums; + float3 col; + col = TextureOriginal.Sample(Sampler1,coord+float2(-1,-1)*bof).rgb; + lums[0][0] = luminance(col); + col = TextureOriginal.Sample(Sampler1,coord+float2(0,-1)*bof).rgb; + lums[0][1] = luminance(col); + col = TextureOriginal.Sample(Sampler1,coord+float2(1,-1)*bof).rgb; + lums[0][2] = luminance(col); + col = TextureOriginal.Sample(Sampler1,coord+float2(-1,0)*bof).rgb; + lums[1][0] = luminance(col); + col = TextureOriginal.Sample(Sampler1,coord+float2(0,0)*bof).rgb; + lums[1][1] = luminance(col); + col = TextureOriginal.Sample(Sampler1,coord+float2(1,0)*bof).rgb; + lums[1][2] = luminance(col); + col = TextureOriginal.Sample(Sampler1,coord+float2(-1,1)*bof).rgb; + lums[2][0] = luminance(col); + col = TextureOriginal.Sample(Sampler1,coord+float2(0,1)*bof).rgb; + lums[2][1] = luminance(col); + col = TextureOriginal.Sample(Sampler1,coord+float2(1,1)*bof).rgb; + lums[2][2] = luminance(col); + mdx += GX[0][0]*lums[0][0]; + mdx += GX[0][1]*lums[0][1]; + mdx += GX[0][2]*lums[0][2]; + mdx += GX[1][0]*lums[1][0]; + mdx += GX[1][1]*lums[1][1]; + mdx += GX[1][2]*lums[1][2]; + mdx += GX[2][0]*lums[2][0]; + mdx += GX[2][1]*lums[2][1]; + mdx += GX[2][2]*lums[2][2]; + mdy += GY[0][0]*lums[0][0]; + mdy += GY[0][1]*lums[0][1]; + mdy += GY[0][2]*lums[0][2]; + mdy += GY[1][0]*lums[1][0]; + mdy += GY[1][1]*lums[1][1]; + mdy += GY[1][2]*lums[1][2]; + mdy += GY[2][0]*lums[2][0]; + mdy += GY[2][1]*lums[2][1]; + mdy += GY[2][2]*lums[2][2]; + mud = pow(max(mdx*mdx+mdy*mdy,0.0),0.5); + mud = clamp(pow(max(mud,0.0),compow)*commult,0.0,1.0); + if ( comblend ) return res-(cominv?1.0-mud:mud); + return cominv?1.0-mud:mud; +} + +/* linevision filter */ +float3 LineView( float3 res, float2 coord ) +{ + float2 bresl = float2(ScreenSize.x,ScreenSize.x*ScreenSize.w); + if ( fixed.x>0 && fixed.y>0 ) bresl = fixed; + float contfadepow = tod_ind(contfadepow); + float contfademult = tod_ind(contfademult); + float2 bof = float2(1.0/bresl.x,1.0/bresl.y)*contradius; + float dep = depthlinear(coord); + float cont = depthlinear(coord+float2(-1,-1)*bof); + cont += depthlinear(coord+float2(0,-1)*bof); + cont += depthlinear(coord+float2(1,-1)*bof); + cont += depthlinear(coord+float2(-1,0)*bof); + cont += depthlinear(coord+float2(1,0)*bof); + cont += depthlinear(coord+float2(-1,1)*bof); + cont += depthlinear(coord+float2(0,1)*bof); + cont += depthlinear(coord+float2(1,1)*bof); + cont /= 8.0; + float mud = 0.0; + if ( abs(cont-dep) > (contthreshold*0.00001) ) mud = 1.0; + float fade = 1.0-TextureDepth.Sample(Sampler1,coord).x; + mud *= clamp(pow(max(0.0,fade),contfadepow)*contfademult,0.0,1.0); + mud = clamp(pow(max(0.0,mud),contpow)*contmult,0.0,1.0); + if ( contblend ) return res-(continv?1.0-mud:mud); + return continv?1.0-mud:mud; +} + +/* fog filter */ +float3 Limbo( float3 res, float2 coord ) +{ + float mud = clamp(pow(max(0.0,depthlinear(coord)),fogpow)*fogmult + +fogbump,0.0,1.0); + if ( foglimbo ) return fogcolor*mud; + return lerp(res,fogcolor,mud); } /* Colour grading based on depth */ @@ -1367,17 +1630,25 @@ float3 DepthGrade( float3 res, float2 coord ) return res; } -/* apply SSAO to screen */ -float4 PS_SSAOApply( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target +float4 PS_DepthGrade( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target { float2 coord = IN.txcoord.xy; - float4 res = TextureOriginal.Sample(Sampler1,coord); - if ( edgevenable ) res.rgb = EdgeView(res.rgb,coord); + float4 res = TextureColor.Sample(Sampler1,coord); res.rgb = DepthGrade(res.rgb,coord); - if ( !ssaoenable ) return res; - float mud = RenderTargetR16F.Sample(Sampler1,coord).x; - if ( ssaodebug ) return saturate(mud); - return res*mud; + res.rgb = max(res.rgb,0.0); + return res; +} + +float4 PS_PreFilters( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target +{ + float2 coord = IN.txcoord.xy; + float4 res = TextureColor.Sample(Sampler1,coord); + if ( edgevenable ) res.rgb = EdgeView(res.rgb,coord); + if ( comenable ) res.rgb = EdgeDetect(res.rgb,coord); + if ( contenable ) res.rgb = LineView(res.rgb,coord); + if ( fogenable ) res.rgb = Limbo(res.rgb,coord); + res.rgb = max(res.rgb,0.0); + return res; } /* Distant hot air refraction. Not very realistic, but does the job. */ @@ -1741,7 +2012,7 @@ technique11 Prepass pass p0 { SetVertexShader(CompileShader(vs_5_0,VS_Quad())); - SetPixelShader(CompileShader(ps_5_0,PS_SSAOPre())); + SetPixelShader(CompileShader(ps_5_0,PS_PreFilters())); } } technique11 Prepass1 @@ -1749,7 +2020,7 @@ technique11 Prepass1 pass p0 { SetVertexShader(CompileShader(vs_5_0,VS_Quad())); - SetPixelShader(CompileShader(ps_5_0,PS_SSAOBlurH())); + SetPixelShader(CompileShader(ps_5_0,PS_DepthGrade())); } } technique11 Prepass2 @@ -1757,15 +2028,15 @@ technique11 Prepass2 pass p0 { SetVertexShader(CompileShader(vs_5_0,VS_Quad())); - SetPixelShader(CompileShader(ps_5_0,PS_SSAOBlurV())); + SetPixelShader(CompileShader(ps_5_0,PS_SSAOPre())); } } -technique11 Prepass3 +technique11 Prepass3 { pass p0 { SetVertexShader(CompileShader(vs_5_0,VS_Quad())); - SetPixelShader(CompileShader(ps_5_0,PS_DoFPrepass())); + SetPixelShader(CompileShader(ps_5_0,PS_Distortion())); } } technique11 Prepass4 @@ -1773,15 +2044,15 @@ technique11 Prepass4 pass p0 { SetVertexShader(CompileShader(vs_5_0,VS_Quad())); - SetPixelShader(CompileShader(ps_5_0,PS_SSAOApply())); + SetPixelShader(CompileShader(ps_5_0,PS_SSAOBlur())); } } -technique11 Prepass5 +technique11 Prepass5 { pass p0 { SetVertexShader(CompileShader(vs_5_0,VS_Quad())); - SetPixelShader(CompileShader(ps_5_0,PS_Distortion())); + SetPixelShader(CompileShader(ps_5_0,PS_DoFPrepass())); } } technique11 Prepass6 @@ -1814,7 +2085,7 @@ technique11 PrepassB pass p0 { SetVertexShader(CompileShader(vs_5_0,VS_Quad())); - SetPixelShader(CompileShader(ps_5_0,PS_SSAOPre())); + SetPixelShader(CompileShader(ps_5_0,PS_PreFilters())); } } technique11 PrepassB1 @@ -1822,7 +2093,7 @@ technique11 PrepassB1 pass p0 { SetVertexShader(CompileShader(vs_5_0,VS_Quad())); - SetPixelShader(CompileShader(ps_5_0,PS_SSAOBlurH())); + SetPixelShader(CompileShader(ps_5_0,PS_DepthGrade())); } } technique11 PrepassB2 @@ -1830,15 +2101,15 @@ technique11 PrepassB2 pass p0 { SetVertexShader(CompileShader(vs_5_0,VS_Quad())); - SetPixelShader(CompileShader(ps_5_0,PS_SSAOBlurV())); + SetPixelShader(CompileShader(ps_5_0,PS_SSAOPre())); } } -technique11 PrepassB3 +technique11 PrepassB3 { pass p0 { SetVertexShader(CompileShader(vs_5_0,VS_Quad())); - SetPixelShader(CompileShader(ps_5_0,PS_DoFPrepass())); + SetPixelShader(CompileShader(ps_5_0,PS_Distortion())); } } technique11 PrepassB4 @@ -1846,15 +2117,15 @@ technique11 PrepassB4 pass p0 { SetVertexShader(CompileShader(vs_5_0,VS_Quad())); - SetPixelShader(CompileShader(ps_5_0,PS_SSAOApply())); + SetPixelShader(CompileShader(ps_5_0,PS_SSAOBlur())); } } -technique11 PrepassB5 +technique11 PrepassB5 { pass p0 { SetVertexShader(CompileShader(vs_5_0,VS_Quad())); - SetPixelShader(CompileShader(ps_5_0,PS_Distortion())); + SetPixelShader(CompileShader(ps_5_0,PS_DoFPrepass())); } } technique11 PrepassB6 diff --git a/enbseries/enbdepthoffield.fx.ini b/enbseries/enbdepthoffield.fx.ini index e02fa2a..712189a 100644 --- a/enbseries/enbdepthoffield.fx.ini +++ b/enbseries/enbdepthoffield.fx.ini @@ -7,13 +7,13 @@ Near Z=0.05 Far Z=3098.0 Distortion Chromatic Aberration=9.5 Enable Hot Air Refraction=true -Heat Texture Size=11.71 -Heat Speed=0.56 -Heat Fade Contrast=235.0 -Heat Fade Intensity=1.14 -Heat Fade Offset=-0.81 -Heat Intensity=0.45 -Heat Contrast=1.19 +Heat Texture Size=16.48 +Heat Speed=0.69 +Heat Fade Contrast=47.670006 +Heat Fade Intensity=1.08 +Heat Fade Offset=-0.97 +Heat Intensity=0.82 +Heat Contrast=0.55 Heat Factor Dawn=-0.17 Heat Factor Sunrise=0.62 Heat Factor Day=1.06 @@ -60,14 +60,14 @@ DOF Fixed Focus Blend Day=1.0 DOF Fixed Focus Blend Interior=1.0 DOF Fixed Focus Depth=0.01 DOF Fixed Focus Cap=0.01 -DOF Fixed Unfocus Intensity Night=1.13 -DOF Fixed Unfocus Intensity Day=1.06 -DOF Fixed Unfocus Intensity Interior=1.24 +DOF Fixed Unfocus Intensity Night=1.11 +DOF Fixed Unfocus Intensity Day=1.07 +DOF Fixed Unfocus Intensity Interior=1.15 DOF Fixed Unfocus Contrast Night=96.980003 DOF Fixed Unfocus Contrast Day=134.399994 DOF Fixed Unfocus Contrast Interior=65.19001 -DOF Fixed Unfocus Shift Night=-0.95 -DOF Fixed Unfocus Shift Day=-1.16 +DOF Fixed Unfocus Shift Night=-0.96 +DOF Fixed Unfocus Shift Day=-1.06 DOF Fixed Unfocus Shift Interior=-0.78 DOF Fixed Unfocus Blend Night=1.0 DOF Fixed Unfocus Blend Day=1.0 @@ -103,8 +103,8 @@ SSAO Fade Contrast Interior=0.65 SSAO Fade Intensity Night=10.5 SSAO Fade Intensity Day=12.5 SSAO Fade Intensity Interior=11.5 -SSAO Intensity=1.25 -SSAO Contrast=0.65 +SSAO Intensity=1.5 +SSAO Contrast=0.5 SSAO Blending=0.8 SSAO Blur=true SSAO Bilateral Factor=1500.0 @@ -175,7 +175,7 @@ Grading Saturation Contrast Night=1.11 Grading Saturation Contrast Day=1.05 Grading Saturation Contrast Interior=1.07 Grading Value Intensity Night=0.88 -Grading Value Intensity Day=0.87 +Grading Value Intensity Day=0.88 Grading Value Intensity Interior=0.84 Grading Value Contrast Night=0.72 Grading Value Contrast Day=0.68 @@ -190,3 +190,37 @@ Grading Contrast Interior=1.02, 0.98, 0.92 Grading Color Night=-0.32, -0.54, -1.19 Grading Color Day=-0.91, -0.4, -0.67 Grading Color Interior=-0.66, -0.33, -0.93 +Invert Edgevision=false +Blend Edgevision=false +Enable Edge Detect=false +Edge Detect Contrast=1.0 +Edge Detect Intensity=1.0 +Edge Detect Radius=1.0 +Invert Edge Detect=false +Blend Edge Detect=false +Enable Linevision=false +Linevision Fade Contrast Night=2.0 +Linevision Fade Contrast Day=2.0 +Linevision Fade Contrast Interior=2.0 +Linevision Fade Intensity Night=700.0 +Linevision Fade Intensity Day=800.0 +Linevision Fade Intensity Interior=600.0 +Linevision Contrast=1.0 +Linevision Intensity=1.0 +Linevision Radius=1.0 +Linevision Threshold=0.1 +Invert Linevision=false +Blend Linevision=false +Enable Custom Fog=false +Fog Contrast=1.0 +Fog Intensity=1.0 +Fog Shift=0.0 +Fog ColorX=1.0 +Fog ColorY=1.0 +Fog ColorZ=1.0 +Limbo Mode=false +SSAO Shift=-0.5 +Luma Sharpen Enable=true +Luma Sharpen Radius=0.8 +Luma Sharpen Clamp=0.1 +Luma Sharpen Blending=8.0 diff --git a/enbseries/enbeffect.fx b/enbseries/enbeffect.fx index ef5bd28..79e064c 100644 --- a/enbseries/enbeffect.fx +++ b/enbseries/enbeffect.fx @@ -192,6 +192,33 @@ bool nbt string UIName = "Apply Grain Before Tone Mapping"; string UIWidget = "Checkbox"; > = {true}; +/* old dirt filter */ +string str_dirt = "Screen Dirt"; +bool dirtenable +< + string UIName = "Enable Dirt"; + string UIWidget = "Checkbox"; +> = {false}; +float dirtcfactor +< + string UIName = "Dirt Coord Factor"; + string UIWidget = "Spinner"; +> = {0.1}; +float dirtlfactor +< + string UIName = "Dirt Luminance Factor"; + string UIWidget = "Spinner"; +> = {0.0}; +float dirtmc +< + string UIName = "Dirt Coord Zoom"; + string UIWidget = "Spinner"; +> = {3.0}; +float dirtml +< + string UIName = "Dirt Luminance Zoom"; + string UIWidget = "Spinner"; +> = {1.0}; /* eye adaptation */ string str_adaptation = "Eye Adaptation"; bool aenable @@ -536,29 +563,6 @@ float lutblend_i string UIName = "LUT Blend Interior"; string UIWidget = "Spinner"; > = {1.0}; -#ifdef LUTMODE_LEGACY -int clut_n -< - string UIName = "LUT Preset Night"; - string UIWidget = "Spinner"; - int UIMin = 0; - int UIMax = 63; -> = {1}; -int clut_d -< - string UIName = "LUT Preset Day"; - string UIWidget = "Spinner"; - int UIMin = 0; - int UIMax = 63; -> = {1}; -int clut_i -< - string UIName = "LUT Preset Interior"; - string UIWidget = "Spinner"; - int UIMin = 0; - int UIMax = 63; -> = {1}; -#endif /* technicolor shader */ string str_tech = "Technicolor"; bool techenable @@ -654,48 +658,30 @@ Texture2D TextureColor; Texture2D TextureBloom; Texture2D TextureAdaptation; -Texture2D TextureNoise2 +Texture2D TextureNoise1 < string ResourceName = "menbnoise1.png"; >; -Texture2D TextureNoise3 +Texture2D TextureNoise2 < string ResourceName = "menbnoise2.png"; >; -#ifdef LUTMODE_LEGACY -Texture2D TextureLUT +Texture2D TextureNoise3 < - string ResourceName = "menblutpreset.png"; + string ResourceName = "menbnoise3.png"; >; -#else -Texture2D TextureLUTN +Texture3D TextureLUTN < -#ifdef LUTMODE_16 - string ResourceName = "menblut16_night.png"; -#endif -#ifdef LUTMODE_64 - string ResourceName = "menblut64_night.png"; -#endif + string ResourceName = "menblut_night.dds"; >; -Texture2D TextureLUTD +Texture3D TextureLUTD < -#ifdef LUTMODE_16 - string ResourceName = "menblut16_day.png"; -#endif -#ifdef LUTMODE_64 - string ResourceName = "menblut64_day.png"; -#endif + string ResourceName = "menblut_day.dds"; >; -Texture2D TextureLUTI +Texture3D TextureLUTI < -#ifdef LUTMODE_16 - string ResourceName = "menblut16_interior.png"; -#endif -#ifdef LUTMODE_64 - string ResourceName = "menblut64_interior.png"; -#endif + string ResourceName = "menblut_interior.dds"; >; -#endif Texture2D TextureTonemap < string ResourceName = "menbfilmlut.png"; @@ -727,30 +713,12 @@ SamplerState Sampler2 AddressU = Wrap; AddressV = Wrap; }; - SamplerState SamplerLUT { Filter = MIN_MAG_MIP_LINEAR; - AddressU = Wrap; - AddressV = Wrap; - MaxLOD = 0; - MinLOD = 0; -}; -SamplerState SamplerNoise2 -{ - Filter = MIN_LINEAR_MAG_MIP_POINT; - AddressU = Wrap; - AddressV = Wrap; - MaxLOD = 0; - MinLOD = 0; -}; -SamplerState SamplerNoise3 -{ - Filter = MIN_MAG_MIP_LINEAR; - AddressU = Wrap; - AddressV = Wrap; - MaxLOD = 0; - MinLOD = 0; + AddressU = Clamp; + AddressV = Clamp; + AddressW = Clamp; }; struct VS_INPUT_POST @@ -914,58 +882,13 @@ float3 GradingHSV( float3 res ) /* LUT colour grading */ float3 GradingLUT( float3 res ) { - /* - gross hacks were needed to "fix" the way direct3d interpolates on - sampling, and to manually interpolate on the blue channel - - this could be alleviated if I could have all the LUTs as volume - maps, but I think ENB can't load them. - */ - float3 tcol = clamp(res,0.0001,0.9999); - tcol.rg = tcol.rg*0.5+0.25; -#ifdef LUTMODE_LEGACY - float2 lc1 = float2(tcol.r/16.0+floor(tcol.b*16.0)/16.0,tcol.g/64.0); - float2 lc2 = float2(tcol.r/16.0+ceil(tcol.b*16.0)/16.0,tcol.g/64.0); - float dec = (ceil(tcol.b*16.0)==16.0)?(0.0):frac(tcol.b*16.0); - /* night samples */ - float3 tcl1_n = TextureLUT.Sample(SamplerLUT,lc1 - +float2(0,clut_n/64.0)).rgb; - float3 tcl2_n = TextureLUT.Sample(SamplerLUT,lc2 - +float2(0,clut_n/64.0)).rgb; - /* day samples */ - float3 tcl1_d = TextureLUT.Sample(SamplerLUT,lc1 - +float2(0,clut_d/64.0)).rgb; - float3 tcl2_d = TextureLUT.Sample(SamplerLUT,lc2 - +float2(0,clut_d/64.0)).rgb; - /* interior samples */ - float3 tcl1_i = TextureLUT.Sample(SamplerLUT,lc1 - +float2(0,clut_i/64.0)).rgb; - float3 tcl2_i = TextureLUT.Sample(SamplerLUT,lc2 - +float2(0,clut_i/64.0)).rgb; -#else -#ifdef LUTMODE_16 - float2 lc1 = float2(tcol.r,tcol.g/16.0+floor(tcol.b*16.0)/16.0); - float2 lc2 = float2(tcol.r,tcol.g/16.0+ceil(tcol.b*16.0)/16.0); - float dec = (ceil(tcol.b*16.0)==16.0)?(0.0):frac(tcol.b*16.0); -#endif -#ifdef LUTMODE_64 - float2 lc1 = float2(tcol.r,tcol.g/64.0+floor(tcol.b*64.0)/64.0); - float2 lc2 = float2(tcol.r,tcol.g/64.0+ceil(tcol.b*64.0)/64.0); - float dec = (ceil(tcol.b*64.0)==64.0)?(0.0):frac(tcol.b*64.0); -#endif - /* night samples */ - float3 tcl1_n = TextureLUTN.Sample(SamplerLUT,lc1).rgb; - float3 tcl2_n = TextureLUTN.Sample(SamplerLUT,lc2).rgb; - /* day samples */ - float3 tcl1_d = TextureLUTD.Sample(SamplerLUT,lc1).rgb; - float3 tcl2_d = TextureLUTD.Sample(SamplerLUT,lc2).rgb; - /* interior samples */ - float3 tcl1_i = TextureLUTI.Sample(SamplerLUT,lc1).rgb; - float3 tcl2_i = TextureLUTI.Sample(SamplerLUT,lc2).rgb; -#endif - float3 tcl1 = tod_ind(tcl1); - float3 tcl2 = tod_ind(tcl2); - tcol = lerp(tcl1,tcl2,dec); + /* night sample */ + float3 tcl_n = TextureLUTN.Sample(SamplerLUT,res).rgb; + /* day sample */ + float3 tcl_d = TextureLUTD.Sample(SamplerLUT,res).rgb; + /* interior sample */ + float3 tcl_i = TextureLUTI.Sample(SamplerLUT,res).rgb; + float3 tcol = tod_ind(tcl); float lutblend = tod_ind(lutblend); return lerp(res,tcol,lutblend); } @@ -998,21 +921,21 @@ float3 FilmGrain( float3 res, float2 coord ) */ if ( np ) { - n1 = TextureNoise2.Sample(SamplerNoise2,s1*nm1.x*nr).r; - n2 = TextureNoise2.Sample(SamplerNoise2,s2*nm1.y*nr).g; - n3 = TextureNoise2.Sample(SamplerNoise2,s3*nm1.z*nr).b; + n1 = TextureNoise2.Sample(Sampler2,s1*nm1.x*nr).r; + n2 = TextureNoise2.Sample(Sampler2,s2*nm1.y*nr).g; + n3 = TextureNoise2.Sample(Sampler2,s3*nm1.z*nr).b; s1 = tcs+float2(ts+n1*nk,n2*nk); s2 = tcs+float2(n2,ts+n3*nk); s3 = tcs+float2(ts+n3*nk,ts+n1*nk); - n1 = TextureNoise2.Sample(SamplerNoise2,s1*nm2.x*nr).r; - n2 = TextureNoise2.Sample(SamplerNoise2,s2*nm2.y*nr).g; - n3 = TextureNoise2.Sample(SamplerNoise2,s3*nm2.z*nr).b; + n1 = TextureNoise2.Sample(Sampler2,s1*nm2.x*nr).r; + n2 = TextureNoise2.Sample(Sampler2,s2*nm2.y*nr).g; + n3 = TextureNoise2.Sample(Sampler2,s3*nm2.z*nr).b; } else { - n1 = TextureNoise3.Sample(SamplerNoise3,s1*nm.x*nr).r; - n2 = TextureNoise3.Sample(SamplerNoise3,s2*nm.y*nr).g; - n3 = TextureNoise3.Sample(SamplerNoise3,s3*nm.z*nr).b; + n1 = TextureNoise3.Sample(Sampler2,s1*nm.x*nr).r; + n2 = TextureNoise3.Sample(Sampler2,s2*nm.y*nr).g; + n3 = TextureNoise3.Sample(Sampler2,s3*nm.z*nr).b; } float n4 = (n1+n2+n3)/3; float3 ng = float3(n4,n4,n4); @@ -1098,6 +1021,20 @@ float2 ScreenFrost( float2 coord ) return coord+ofs; } +/* Old MariENB 0.x screen dirt filter, updated */ +float3 ScreenDirt( float3 res, float2 coord ) +{ + float2 nr = float2(ScreenSize.x,ScreenSize.x*ScreenSize.w)/256.0; + float3 ncolc = TextureNoise1.Sample(Sampler2,coord*dirtmc*nr).rgb; + float2 ds = float2(res.r+res.g,res.g+res.b)/2.0; + float3 ncoll = TextureNoise1.Sample(Sampler2,ds*dirtml).rgb; + res = lerp(res,(ncolc.r+1.0)*res,dirtcfactor + *saturate(1.0-(ds.x+ds.y)*0.25)); + res = lerp(res,(ncoll.r+1.0)*res,dirtlfactor + *saturate(1.0-(ds.x+ds.y)*0.25)); + return res; +} + float4 PS_Draw( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target { float2 coord = IN.txcoord0.xy; @@ -1105,41 +1042,28 @@ float4 PS_Draw( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target if ( (fixed.x > 0) && (fixed.y > 0) ) bresl = fixed; else bresl = float2(ScreenSize.x,ScreenSize.x*ScreenSize.w); float4 res, mud; - [branch] if ( frostenable ) + if ( frostenable ) { float2 ofs = ScreenFrost(coord); ofs -= coord; - if ( (distcha != 0.0) && (length(ofs) != 0.0) ) - { - float2 ofr, ofg, ofb; - ofr = ofs*(1.0-distcha*0.01); - ofg = ofs; - ofb = ofs*(1.0+distcha*0.01); - res = float4(TextureColor.Sample(Sampler0,coord+ofr).r, - TextureColor.Sample(Sampler0,coord+ofg).g, - TextureColor.Sample(Sampler0,coord+ofb).b,1.0); + float2 ofr, ofg, ofb; + ofr = ofs*(1.0-distcha*0.01); + ofg = ofs; + ofb = ofs*(1.0+distcha*0.01); + res = float4(TextureColor.Sample(Sampler0,coord+ofr).r, + TextureColor.Sample(Sampler0,coord+ofg).g, + TextureColor.Sample(Sampler0,coord+ofb).b,1.0); #ifdef SKYRIMSE - mud = float4(TextureBloom.Sample(Sampler1,coord+ofr).r, - TextureBloom.Sample(Sampler1,coord+ofg).g, - TextureBloom.Sample(Sampler1,coord+ofb).b,1.0); + mud = float4(TextureBloom.Sample(Sampler1,coord+ofr).r, + TextureBloom.Sample(Sampler1,coord+ofg).g, + TextureBloom.Sample(Sampler1,coord+ofb).b,1.0); #else - mud = float4(TextureBloom.Sample(Sampler1, - Params01[4].zw*(coord+ofr)).r, - TextureBloom.Sample(Sampler1,Params01[4].zw - *(coord+ofg)).g,TextureBloom.Sample(Sampler1, - Params01[4].zw*(coord+ofb)).b,1.0); + mud = float4(TextureBloom.Sample(Sampler1, + Params01[4].zw*(coord+ofr)).r, + TextureBloom.Sample(Sampler1,Params01[4].zw + *(coord+ofg)).g,TextureBloom.Sample(Sampler1, + Params01[4].zw*(coord+ofb)).b,1.0); #endif - } - else - { - res = TextureColor.Sample(Sampler0,coord+ofs); -#ifdef SKYRIMSE - mud = TextureBloom.Sample(Sampler1,coord+ofs); -#else - mud = TextureBloom.Sample(Sampler1,Params01[4].zw - *(coord+ofs)); -#endif - } float2 nc = coord*(bresl/FROSTSIZE)*frostsize; float bmp = pow(max(0,TextureFrost.SampleLevel(Sampler2,nc, 0).z),frostbpow); @@ -1168,6 +1092,7 @@ float4 PS_Draw( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target res.rgb += bcol; if ( aenable ) res.rgb *= adapt.x; if ( nbt && ne ) res.rgb = FilmGrain(res.rgb,coord); + if ( dirtenable ) res.rgb = ScreenDirt(res.rgb,coord); res.rgb = Tonemap(res.rgb); if ( vgradeenable ) res.rgb = GradingGame(res.rgb,adapt.y); if ( gradeenable1 ) res.rgb = GradingRGB(res.rgb); diff --git a/enbseries/enbeffect.fx.ini b/enbseries/enbeffect.fx.ini index caedb26..8308752 100644 --- a/enbseries/enbeffect.fx.ini +++ b/enbseries/enbeffect.fx.ini @@ -34,28 +34,28 @@ Grain Contrast=8.450001 Apply Grain Before Tone Mapping=true Enable Adaptation=true Tonemapping Method=3 -Tonemap Exposure Night=1.17 -Tonemap Exposure Day=1.33 +Tonemap Exposure Night=1.18 +Tonemap Exposure Day=1.31 Tonemap Exposure Interior=1.23 Tonemap Blend Night=1.0 Tonemap Blend Day=1.0 Tonemap Blend Interior=1.0 -Uncharted2 Shoulder Strength Night=0.32 +Uncharted2 Shoulder Strength Night=0.17 Uncharted2 Shoulder Strength Day=0.28 Uncharted2 Shoulder Strength Interior=0.22 -Uncharted2 Linear Strength Night=1.49 +Uncharted2 Linear Strength Night=1.58 Uncharted2 Linear Strength Day=1.54 -Uncharted2 Linear Strength Interior=1.45 -Uncharted2 Linear Angle Night=0.66 -Uncharted2 Linear Angle Day=0.75 -Uncharted2 Linear Angle Interior=0.71 -Uncharted2 Toe Strength Night=0.9 +Uncharted2 Linear Strength Interior=1.55 +Uncharted2 Linear Angle Night=0.71 +Uncharted2 Linear Angle Day=0.77 +Uncharted2 Linear Angle Interior=0.74 +Uncharted2 Toe Strength Night=0.95 Uncharted2 Toe Strength Day=1.05 Uncharted2 Toe Strength Interior=1.17 Uncharted2 Toe Numerator Night=0.22 Uncharted2 Toe Numerator Day=0.27 Uncharted2 Toe Numerator Interior=0.25 -Uncharted2 Toe Denominator Night=1.2 +Uncharted2 Toe Denominator Night=1.19 Uncharted2 Toe Denominator Day=1.25 Uncharted2 Toe Denominator Interior=1.22 Uncharted2 Linear White Night=38.509998 @@ -90,29 +90,29 @@ Enable Vibrance Grading=true Grading Color Night=-0.2, -0.31, -0.62 Grading Color Day=-0.84, -0.19, -0.3 Grading Color Interior=-0.19, -0.04, -0.7 -Grading Color Factor Night=-0.11 +Grading Color Factor Night=-0.21 Grading Color Factor Day=-0.15 Grading Color Factor Interior=-0.09 Enable HSV Grading=true -Grading Saturation Intensity Night=1.05 +Grading Saturation Intensity Night=1.12 Grading Saturation Intensity Day=1.09 -Grading Saturation Intensity Interior=1.02 -Grading Saturation Contrast Night=1.12 -Grading Saturation Contrast Day=1.23 +Grading Saturation Intensity Interior=1.06 +Grading Saturation Contrast Night=1.13 +Grading Saturation Contrast Day=1.12 Grading Saturation Contrast Interior=1.18 -Grading Value Intensity Night=0.92 +Grading Value Intensity Night=0.98 Grading Value Intensity Day=0.94 Grading Value Intensity Interior=0.88 -Grading Value Contrast Night=1.09 -Grading Value Contrast Day=1.12 -Grading Value Contrast Interior=1.05 +Grading Value Contrast Night=1.18 +Grading Value Contrast Day=1.14 +Grading Value Contrast Interior=1.13 Colorize After HSV=true Enable LUT Grading=true -LUT Blend Night=0.32 -LUT Blend Day=0.36 +LUT Blend Night=0.31 +LUT Blend Day=0.35 LUT Blend Interior=0.28 Enable Technicolor=true -Technicolor Blend=0.5 +Technicolor Blend=0.6 Enable Vanilla Imagespace=true Vanilla Tint Contrast=1.14 Vanilla Tint Strength=1.0 @@ -123,3 +123,8 @@ Vanilla Vibrance Blend=0.91 Vanilla Contrast Blend=0.96 Display Bloom=false Display Adaptation=false +Enable Dirt=false +Dirt Coord Factor=0.08 +Dirt Luminance Factor=0.0 +Dirt Coord Zoom=2.49 +Dirt Luminance Zoom=1.0 diff --git a/enbseries/enbeffectpostpass.fx b/enbseries/enbeffectpostpass.fx index 4d3995f..9b070ed 100644 --- a/enbseries/enbeffectpostpass.fx +++ b/enbseries/enbeffectpostpass.fx @@ -6,143 +6,50 @@ */ #include "menbglobaldefs.fx" -/* BlockGFX filter, I'm proud of it */ -string str_block = "BlockGFX Suite"; -bool useblock +/* Paint filter */ +string str_paint = "Painting Filter"; +bool oilenable < - string UIName = "Enable Block GFX"; + string UIName = "Enable Oil Filter"; string UIWidget = "Checkbox"; > = {false}; -/* - emulated resolution: - 0 or 1 : real resolution - <1 and >0 : multiple of real resolution (e.g.: 0.5 is half resolution) - >1 : this resolution (e.g.: 320x200 is good ol' Mode 13h) -*/ -float2 bres +/* legacy FXAA filter */ +string str_fxaa = "FXAA"; +bool fxaaenable < - string UIName = "Emulated Resolution"; - string UIWidget = "Vector"; - float2 UIMin = {0.0,0.0}; -> = {0.5,0.5}; -/* zooming factors (<=0 for stretch) */ -float2 sres + string UIName = "Enable FXAA"; + string UIWidget = "Checkbox"; +> = {false}; +float fxaaspanmax < - string UIName = "Zoom Factor"; - string UIWidget = "Vector"; - float2 UIMin = {0.0,0.0}; -> = {0.0,0.0}; -/* - palette type: - -1 : disable - 0 : CGA (320x200 4-color, or 640x200 monochrome) - 1 : EGA (320x200, 16 colors) - 2 : RGB2 (64-color quarter VGA palette, used in AOS) - 3 : VGA (256 colors) - 4 : RGB565 (ol' 16-bit "true color") -*/ -int paltype + string UIName = "FXAA Span Max"; + string UIWidget = "Checkbox"; +> = {4.0}; +float fxaareducemul < - string UIName = "Palette Type"; - string UIWidget = "Spinner"; - int UIMin = -1; - int UIMax = 4; -> = {1}; -/* - CGA palette to use: - 0 : black, white. - 1 : black, cyan, magenta, white. low contrast - 2 : black, cyan, magenta, white. high contrast - 3 : black, green, red, brown. low contrast - 4 : black, green, red, brown. high contrast - 5 : black, cyan, red, white. low contrast - 6 : black, cyan, red, white. high contrast -*/ -int cgapal + string UIName = "FXAA Reduce Mul"; + string UIWidget = "Checkbox"; +> = {16.0}; +float fxaareducemin < - string UIName = "CGA Palette"; + string UIName = "FXAA Reduce Min"; + string UIWidget = "Checkbox"; +> = {128.0}; +/* new SMAA filter */ +string str_smaa = "SMAA"; +bool smaaenable +< + string UIName = "Enable SMAA"; + string UIWidget = "Checkbox"; +> = {false}; +int smaadebug +< + string UIName = "SMAA Debugging"; string UIWidget = "Spinner"; int UIMin = 0; - int UIMax = 6; -> = {1}; -/* - EGA palette to use: - 0 : Standard EGA - 1 : AOS EGA (it's designed for text, but looks well on images too) -*/ -int egapal -< - string UIName = "EGA Palette"; - string UIWidget = "Spinner"; - int UIMin = 0; - int UIMax = 1; -> = {0}; -/* - VGA palette to use: - 0 : Standard VGA - 1 : Amulets & Armor - 2 : Blood - 3 : Doom - 4 : Duke Nukem 3D - 5 : Hacx 2.0 - 6 : Heretic - 7 : Hexen - 8 : Hexen 2 - 9 : Quake - 10 : Quake 2 - 11 : Rise of the Triad - 12 : Shadow Warrior - 13 : Strife - 14 : Wolfenstein 3D - TODO Project .Blank palette (when the design is finished) -*/ -int vgapal -< - string UIName = "VGA Palette"; - string UIWidget = "Spinner"; - int UIMin = 0; - int UIMax = 14; -> = {0}; -/* - Dithering mode: - -1 : No dithering, just raw banding - 0 : 2x2 checkerboard dithering, looks like ass - 1 : 2x2 ordered dithering - 2 : 8x8 ordered dithering -*/ -int dither -< - string UIName = "Dithering Pattern"; - string UIWidget = "Spinner"; - int UIMin = -1; int UIMax = 2; -> = {2}; -/* gamma modifier for base color, lower values raise midtones and viceversa */ -float bgamma -< - string UIName = "Contrast Modifier"; - string UIWidget = "Spinner"; - float UIMin = 0.0; -> = {0.35}; -/* saturation modifier for base color, helps with limited palettes */ -float bsaturation -< - string UIName = "Saturation Modifier"; - string UIWidget = "Spinner"; -> = {1.1}; -/* base brightness bump for the dither grid */ -float bdbump -< - string UIName = "Dither Offset"; - string UIWidget = "Spinner"; -> = {-0.1}; -/* range multiplier for the dither grid */ -float bdmult -< - string UIName = "Dither Range"; - string UIWidget = "Spinner"; - float UIMin = 0.0; -> = {0.25}; +> = {0}; +/* Depth-cutting chroma key */ string str_mask = "Depth Chroma Key"; bool maskenable < @@ -161,6 +68,78 @@ float maskd float UIMin = 0.0; float UIMax = 1.0; > = {0.5}; +/* tilting */ +float masktiltxcenter +< + string UIName = "Chroma Key Depth Horizontal Tilt Center"; + string UIWidget = "Spinner"; + float UIMin = 0.0; + float UIMax = 1.0; +> = {0.5}; +float masktiltycenter +< + string UIName = "Chroma Key Depth Vertical Tilt Center"; + string UIWidget = "Spinner"; + float UIMin = 0.0; + float UIMax = 1.0; +> = {0.5}; +float masktiltx +< + string UIName = "Chroma Key Depth Horizontal Tilt"; + string UIWidget = "Spinner"; +> = {0.0}; +float masktilty +< + string UIName = "Chroma Key Depth Vertical Tilt"; + string UIWidget = "Spinner"; +> = {0.0}; +/* luma sharpen because of reasons */ +string str_lsharp = "Luma Sharpen"; +bool lsharpenable +< + string UIName = "Luma Sharpen Enable"; + string UIWidget = "Checkbox"; +> = {false}; +float lsharpradius +< + string UIName = "Luma Sharpen Radius"; + string UIWidget = "Spinner"; + float UIMin = 0.0; +> = {0.8}; +float lsharpclamp +< + string UIName = "Luma Sharpen Clamp"; + string UIWidget = "Spinner"; + float UIMin = 0.0; +> = {0.02}; +float lsharpblend +< + string UIName = "Luma Sharpen Blending"; + string UIWidget = "Spinner"; + float UIMin = 0.0; +> = {1.2}; +/* lens curve with chromatic aberration */ +string str_curve = "Lens Curvature"; +bool curveenable +< + string UIName = "Enable Curvature"; + string UIWidget = "Checkbox"; +> = {false}; +float chromaab +< + string UIName = "Curve Chromatic Aberration"; + string UIWidget = "Spinner"; +> = {0.0}; +float lenszoom +< + string UIName = "Curve Zooming"; + string UIWidget = "Spinner"; +> = {50.0}; +float lensdist +< + string UIName = "Curve Distortion"; + string UIWidget = "Spinner"; +> = {0.0}; /* BlurSharpShift, some people are obsessed with this nonsense */ string str_bss = "BlurSharpShift"; bool bssblurenable @@ -202,31 +181,6 @@ float bssshiftradius string UIWidget = "Spinner"; float UIMin = 0.0; > = {0.75}; -/* luma sharpen because of reasons */ -string str_lsharp = "Luma Sharpen"; -bool lsharpenable -< - string UIName = "Luma Sharpen Enable"; - string UIWidget = "Checkbox"; -> = {false}; -float lsharpradius -< - string UIName = "Luma Sharpen Radius"; - string UIWidget = "Spinner"; - float UIMin = 0.0; -> = {0.8}; -float lsharpclamp -< - string UIName = "Luma Sharpen Clamp"; - string UIWidget = "Spinner"; - float UIMin = 0.0; -> = {0.02}; -float lsharpblend -< - string UIName = "Luma Sharpen Blending"; - string UIWidget = "Spinner"; - float UIMin = 0.0; -> = {1.2}; /* very cinematic black bars */ string str_box = "Black Bars"; bool boxenable @@ -319,6 +273,225 @@ float bblurradius string UIWidget = "Spinner"; float UIMin = 0.0; > = {1.0}; +/* colour matrix */ +string str_cmat = "Color Matrix"; +bool cmatenable +< + string UIName = "Enable Color Matrix"; + string UIWidget = "Checkbox"; +> = {false}; +float cmat_rr +< + string UIName = "Color Matrix Red Red"; + string UIWidget = "Spinner"; +> = {1.0}; +float cmat_rg +< + string UIName = "Color Matrix Red Green"; + string UIWidget = "Spinner"; +> = {0.0}; +float cmat_rb +< + string UIName = "Color Matrix Red Blue"; + string UIWidget = "Spinner"; +> = {0.0}; +float cmat_gr +< + string UIName = "Color Matrix Green Red"; + string UIWidget = "Spinner"; +> = {0.0}; +float cmat_gg +< + string UIName = "Color Matrix Green Green"; + string UIWidget = "Spinner"; +> = {1.0}; +float cmat_gb +< + string UIName = "Color Matrix Green Blue"; + string UIWidget = "Spinner"; +> = {0.0}; +float cmat_br +< + string UIName = "Color Matrix Blue Red"; + string UIWidget = "Spinner"; +> = {0.0}; +float cmat_bg +< + string UIName = "Color Matrix Blue Green"; + string UIWidget = "Spinner"; +> = {0.0}; +float cmat_bb +< + string UIName = "Color Matrix Blue Blue"; + string UIWidget = "Spinner"; +> = {1.0}; +bool cmatnormalize +< + string UIName = "Normalize Matrix"; + string UIWidget = "Checkbox"; +> = {false}; +/* hue-saturation */ +string str_hs = "Hue-Saturation"; +bool hsenable +< + string UIName = "Enable Hue-Saturation"; + string UIWidget = "Checkbox"; +> = {false}; +float hsover +< + string UIName = "Overlap"; + string UIWidget = "Spinner"; + float UIMin = 0.0; + float UIMax = 0.5; +> = {0.0}; +float hshue_a +< + string UIName = "Global Hue"; + string UIWidget = "Spinner"; + float UIMin = -1.0; + float UIMax = 1.0; +> = {0.0}; +float hssat_a +< + string UIName = "Global Saturation"; + string UIWidget = "Spinner"; + float UIMin = -1.0; + float UIMax = 1.0; +> = {0.0}; +float hsval_a +< + string UIName = "Global Value"; + string UIWidget = "Spinner"; + float UIMin = -1.0; + float UIMax = 1.0; +> = {0.0}; +float hshue_r +< + string UIName = "Red Hue"; + string UIWidget = "Spinner"; + float UIMin = -1.0; + float UIMax = 1.0; +> = {0.0}; +float hssat_r +< + string UIName = "Red Saturation"; + string UIWidget = "Spinner"; + float UIMin = -1.0; + float UIMax = 1.0; +> = {0.0}; +float hsval_r +< + string UIName = "Red Value"; + string UIWidget = "Spinner"; + float UIMin = -1.0; + float UIMax = 1.0; +> = {0.0}; +float hshue_y +< + string UIName = "Yellow Hue"; + string UIWidget = "Spinner"; + float UIMin = -1.0; + float UIMax = 1.0; +> = {0.0}; +float hssat_y +< + string UIName = "Yellow Saturation"; + string UIWidget = "Spinner"; + float UIMin = -1.0; + float UIMax = 1.0; +> = {0.0}; +float hsval_y +< + string UIName = "Yellow Value"; + string UIWidget = "Spinner"; + float UIMin = -1.0; + float UIMax = 1.0; +> = {0.0}; +float hshue_g +< + string UIName = "Green Hue"; + string UIWidget = "Spinner"; + float UIMin = -1.0; + float UIMax = 1.0; +> = {0.0}; +float hssat_g +< + string UIName = "Green Saturation"; + string UIWidget = "Spinner"; + float UIMin = -1.0; + float UIMax = 1.0; +> = {0.0}; +float hsval_g +< + string UIName = "Green Value"; + string UIWidget = "Spinner"; + float UIMin = -1.0; + float UIMax = 1.0; +> = {0.0}; +float hshue_c +< + string UIName = "Cyan Hue"; + string UIWidget = "Spinner"; + float UIMin = -1.0; + float UIMax = 1.0; +> = {0.0}; +float hssat_c +< + string UIName = "Cyan Saturation"; + string UIWidget = "Spinner"; + float UIMin = -1.0; + float UIMax = 1.0; +> = {0.0}; +float hsval_c +< + string UIName = "Cyan Value"; + string UIWidget = "Spinner"; + float UIMin = -1.0; + float UIMax = 1.0; +> = {0.0}; +float hshue_b +< + string UIName = "Blue Hue"; + string UIWidget = "Spinner"; + float UIMin = -1.0; + float UIMax = 1.0; +> = {0.0}; +float hssat_b +< + string UIName = "Blue Saturation"; + string UIWidget = "Spinner"; + float UIMin = -1.0; + float UIMax = 1.0; +> = {0.0}; +float hsval_b +< + string UIName = "Blue Value"; + string UIWidget = "Spinner"; + float UIMin = -1.0; + float UIMax = 1.0; +> = {0.0}; +float hshue_m +< + string UIName = "Magenta Hue"; + string UIWidget = "Spinner"; + float UIMin = -1.0; + float UIMax = 1.0; +> = {0.0}; +float hssat_m +< + string UIName = "Magenta Saturation"; + string UIWidget = "Spinner"; + float UIMin = -1.0; + float UIMax = 1.0; +> = {0.0}; +float hsval_m +< + string UIName = "Magenta Value"; + string UIWidget = "Spinner"; + float UIMin = -1.0; + float UIMax = 1.0; +> = {0.0}; +/* colour balance */ /* gaussian blur matrices */ /* radius: 4, std dev: 1.5 */ @@ -326,52 +499,11 @@ static const float gauss4[4] = { 0.270682, 0.216745, 0.111281, 0.036633 }; -/* - dithering threshold maps - don't touch unless you know what you're doing -*/ -static const float checkers[4] = -{ - 1.0,0.0, - 0.0,1.0 -}; -#define d(x) x/4.0 -static const float ordered2[4] = -{ - d(0),d(2), - d(4),d(2) -}; -#undef d -#define d(x) x/64.0 -static const float ordered8[64] = -{ - d( 0),d(48),d(12),d(60),d( 3),d(51),d(15),d(63), - d(32),d(16),d(44),d(28),d(35),d(19),d(47),d(31), - d( 8),d(56),d( 4),d(52),d(11),d(59),d( 7),d(55), - d(40),d(24),d(36),d(20),d(43),d(27),d(39),d(23), - d( 2),d(50),d(14),d(62),d( 1),d(49),d(13),d(61), - d(34),d(18),d(46),d(30),d(33),d(17),d(45),d(29), - d(10),d(58),d( 6),d(54),d( 9),d(57),d( 5),d(53), - d(42),d(26),d(38),d(22),d(41),d(25),d(37),d(21) -}; -#undef d float4 ScreenSize; Texture2D TextureOriginal; Texture2D TextureColor; Texture2D TextureDepth; -Texture2D TextureCGA -< - string ResourceName = "menbcgalut.png"; ->; -Texture2D TextureEGA -< - string ResourceName = "menbegalut.png"; ->; -Texture2D TextureVGA -< - string ResourceName = "menbvgalut.png"; ->; Texture2D TextureVignette < #ifdef VIGNETTE_DDS @@ -393,14 +525,6 @@ SamplerState SamplerB AddressU = Border; AddressV = Border; }; -SamplerState SamplerLUT -{ - Filter = MIN_MAG_MIP_POINT; - AddressU = Clamp; - AddressV = Clamp; - MaxLOD = 0; - MinLOD = 0; -}; struct VS_INPUT_POST { @@ -442,125 +566,44 @@ float3 hsv2rgb( float3 c ) return c.z*lerp(K.x,saturate(p-K.x),c.y); } -/* prepass */ -float4 ReducePrepass( in float4 col, in float2 coord ) -{ - float3 hsv = rgb2hsv(col.rgb); - hsv.y = clamp(hsv.y*bsaturation,0.0,1.0); - hsv.z = pow(max(0,hsv.z),bgamma); - col.rgb = hsv2rgb(saturate(hsv)); - if ( dither == 0 ) - col += bdbump+checkers[int(coord.x%2)+2*int(coord.y%2)]*bdmult; - else if ( dither == 1 ) - col += bdbump+ordered2[int(coord.x%2)+2*int(coord.y%2)]*bdmult; - else if ( dither == 2 ) - col += bdbump+ordered8[int(coord.x%8)+8*int(coord.y%8)]*bdmult; - col = saturate(col); - return col; -} -/* - CGA had seven graphic modes (320x200 modes have low/high contrast versions): - - 640x200 monochrome, which doesn't really need a palette here, as it can - be done procedurally with minimum effort. - - 320x200 black/cyan/magenta/white - - 320x200 black/green/red/brown - - 320x200 black/cyan/red/white -*/ -float4 ReduceCGA( in float4 color, in float2 coord ) -{ - float4 dac = clamp(ReducePrepass(color,coord)+0.005,0.005,0.995); - float2 lc = float2((dac.r+cgapal)/7.0, - dac.g/64.0+floor(dac.b*64.0)/64.0); - return TextureCGA.Sample(SamplerLUT,lc); -} -/* - EGA technically only had the 320x200 16-colour graphic mode, but when VGA - came out, it was possible to tweak the DAC, allowing for custom palettes. - AOS EGA is a palette based on my terminal colour scheme on Linux, which I - also use for AliceOS. -*/ -float4 ReduceEGA( in float4 color, in float2 coord ) -{ - float4 dac = clamp(ReducePrepass(color,coord)+0.005,0.005,0.995); - float2 lc = float2((dac.r+egapal)/2.0, - dac.g/64.0+floor(dac.b*64.0)/64.0); - return TextureEGA.Sample(SamplerLUT,lc); -} -/* A two bits per channel mode that can usually fit VGA mode 13h and mode x */ -float4 ReduceRGB2( in float4 color, in float2 coord ) -{ - float4 dac = ReducePrepass(color,coord); - color.rgb = trunc(dac.rgb*4.0)/4.0; - return color; -} -/* - The classic 16-bit colour mode everyone from my generation would remember, - especially that subtle green tint and the banding due to lack of dithering - in most games and GPUs at that time. -*/ -float4 ReduceRGB565( in float4 color, in float2 coord ) -{ - float4 dac = ReducePrepass(color,coord); - color.rgb = trunc(dac.rgb*float3(32.0,64.0,32.0)) - /float3(32.0,64.0,32.0); - return color; -} -/* Various VGA 256-colour palettes */ -float4 ReduceVGA( in float4 color, in float2 coord ) -{ - float4 dac = clamp(ReducePrepass(color,coord)+0.005,0.005,0.995); - float2 lc = float2((dac.r+vgapal)/15.0, - dac.g/64.0+floor(dac.b*64.0)/64.0); - return TextureVGA.Sample(SamplerLUT,lc); -} - -/* Retro rockets */ -float4 PS_Retro( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target -{ - float2 coord = IN.txcoord.xy; - float4 res = TextureColor.Sample(Sampler,coord); - if ( !useblock ) return res; - float2 rresl = float2(ScreenSize.x,ScreenSize.x*ScreenSize.w); - float4 tcol; - float2 bresl = rresl; - if ( bres.x <= 0 || bres.y <= 0 ) bresl = rresl; - else - { - if ( bres.x <= 1.0 ) bresl.x = rresl.x*bres.x; - else bresl.x = bres.x; - if ( bres.y <= 1.0 ) bresl.y = rresl.y*bres.y; - else bresl.y = bres.y; - } - float2 sresl = sres; - if ( sres.x <= 0 ) sresl.x = rresl.x/bresl.x; - if ( sres.y <= 0 ) sresl.y = rresl.y/bresl.y; - float2 ncoord = coord*(rresl/bresl); - ncoord = (-0.5/sresl)*(rresl/bresl)+ncoord/sresl+0.5; - ncoord = floor(ncoord*bresl)/bresl; - if ( bres.x <= 0 || bres.y <= 0 ) ncoord = coord; - tcol = TextureOriginal.Sample(Sampler,ncoord); - if ( paltype == 0 ) res = ReduceCGA(tcol,(coord*rresl)/sresl); - else if ( paltype == 1 ) res = ReduceEGA(tcol,(coord*rresl)/sresl); - else if ( paltype == 2 ) res = ReduceRGB2(tcol,(coord*rresl)/sresl); - else if ( paltype == 3 ) res = ReduceVGA(tcol,(coord*rresl)/sresl); - else if ( paltype == 4 ) res = ReduceRGB565(tcol,(coord*rresl)/sresl); - else res = tcol; - if ( ncoord.x < 0 || ncoord.x >= 1 || ncoord.y < 0 || ncoord.y >= 1 ) - res *= 0; - res.a = 1.0; - return res; -} - float4 PS_ChromaKey( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target { float2 coord = IN.txcoord.xy; float4 res = TextureColor.Sample(Sampler,coord); if ( !maskenable ) return res; - if ( TextureDepth.Sample(Sampler,coord).x > maskd ) + float msd = maskd; + msd = maskd+0.01*masktiltx*(masktiltxcenter-coord.x) + +0.01*masktilty*(masktiltycenter-coord.y); + if ( TextureDepth.Sample(Sampler,coord).x > msd ) return float4(mask.r,mask.g,mask.b,1.0); return res; } +/* that's right, CRT curvature */ +float4 PS_Curvature( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target +{ + float2 coord = IN.txcoord.xy; + float4 res = TextureColor.Sample(Sampler,coord); + if ( !curveenable ) return res; + float3 eta = float3(1+chromaab*0.009,1+chromaab*0.006,1+chromaab + *0.003); + float2 center = float2(coord.x-0.5,coord.y-0.5); + float zfact = 100.0/lenszoom; + float r2 = center.x*center.x+center.y*center.y; + float f = 1+r2*lensdist*0.01; + float x = f*zfact*center.x+0.5; + float y = f*zfact*center.y+0.5; + float2 rcoord = (f*eta.r)*zfact*(center.xy*0.5)+0.5; + float2 gcoord = (f*eta.g)*zfact*(center.xy*0.5)+0.5; + float2 bcoord = (f*eta.b)*zfact*(center.xy*0.5)+0.5; + int i,j; + float3 idist = float3(TextureColor.Sample(SamplerB,rcoord).r, + TextureColor.Sample(SamplerB,gcoord).g, + TextureColor.Sample(SamplerB,bcoord).b); + res.rgb = idist.rgb; + return res; +} + /* Why am I doing this */ float4 PS_Blur( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target { @@ -671,7 +714,7 @@ float4 PS_Vignette( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target /* box vignette */ float2 uv = coord.xy*(1.0-coord.yx)*4.0; vigdata.a = 1.0-(uv.x*uv.y); - vigdata.a = clamp(pow(vigdata.a,vigpow)*vigmul+vigbump, + vigdata.a = clamp(pow(max(vigdata.a,0.0),vigpow)*vigmul+vigbump, 0.0,1.0); vigdata.rgb = vigcolor; } @@ -692,7 +735,7 @@ float4 PS_Vignette( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target [unroll] for ( i=-3; i<4; i++ ) [unroll] for ( j=-3; j<4; j++ ) res.rgb += gauss4[abs(i)]*gauss4[abs(j)] *TextureColor.Sample(Sampler,coord - +float2(i,j)*bof); + +float2(i,j)*bof).rgb; } /* apply color */ if ( vigenable ) @@ -709,13 +752,234 @@ float4 PS_Vignette( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target return clamp(res,0.0,1.0); } -/* TODO paint filter */ -/*float4 PS_Oily( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target +/* paint filter */ +float4 PS_Kuwahara( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target { float2 coord = IN.txcoord.xy; float4 res = TextureColor.Sample(Sampler,coord); + if ( !oilenable ) return res; + float2 bresl = float2(ScreenSize.x,ScreenSize.x*ScreenSize.w); + float2 bof = 1.0/bresl; + float n = 16.0; + float3 m[4] = + { + float3(0,0,0),float3(0,0,0),float3(0,0,0),float3(0,0,0) + }, s[4] = + { + float3(0,0,0),float3(0,0,0),float3(0,0,0),float3(0,0,0) + }, c; + int i, j; + [loop] for ( i=-3; i<=0; i++ ) [loop] for ( j=-3; j<=0; j++ ) + { + c = TextureColor.Sample(Sampler,coord+float2(i,j)*bof).rgb; + m[0] += c; + s[0] += c*c; + } + [loop] for ( i=-3; i<=0; i++ ) [loop] for ( j=0; j<=3; j++ ) + { + c = TextureColor.Sample(Sampler,coord+float2(i,j)*bof).rgb; + m[1] += c; + s[1] += c*c; + } + [loop] for ( i=0; i<=3; i++ ) [loop] for ( j=-3; j<=0; j++ ) + { + c = TextureColor.Sample(Sampler,coord+float2(i,j)*bof).rgb; + m[2] += c; + s[2] += c*c; + } + [loop] for ( i=0; i<=3; i++ ) [loop] for ( j=0; j<=3; j++ ) + { + c = TextureColor.Sample(Sampler,coord+float2(i,j)*bof).rgb; + m[3] += c; + s[3] += c*c; + } + float min_sigma2 = 1e+2, sigma2; + [unroll] for ( i=0; i<4; i++ ) + { + m[i] /= n; + s[i] = abs(s[i]/n-m[i]*m[i]); + sigma2 = s[i].r+s[i].g+s[i].b; + if ( sigma2 >= min_sigma2 ) continue; + min_sigma2 = sigma2; + res.rgb = m[i]; + } return res; -}*/ +} +/* remove speckles from kuwahara filter */ +float4 PS_Median( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target +{ + float2 coord = IN.txcoord.xy; + float4 res = TextureColor.Sample(Sampler,coord); + if ( !oilenable ) return res; + float2 bresl = float2(ScreenSize.x,ScreenSize.x*ScreenSize.w); + float2 bof = 1.0/bresl; + float3 m1, m2, m3; + float3 a, b, c; + a = TextureColor.Sample(Sampler,coord+float2(-1,-1)*bof).rgb; + b = TextureColor.Sample(Sampler,coord+float2( 0,-1)*bof).rgb; + c = TextureColor.Sample(Sampler,coord+float2( 1,-1)*bof).rgb; + m1 = (luminance(a) lumaMax) ) res.rgb = rgbA; + else res.rgb = rgbB; + res.a = 1.0; + return res; +} + +/* Colour matrix */ +float3 ColorMatrix( float3 res ) +{ + float3x3 cmat = float3x3(cmat_rr,cmat_rg,cmat_rb, + cmat_gr,cmat_gg,cmat_gb, + cmat_br,cmat_bg,cmat_bb); + res = mul(res,cmat); + if ( cmatnormalize ) + { + float cmscale = (cmat._11+cmat._12+cmat._13+cmat._21 + +cmat._22+cmat._23+cmat._31+cmat._32+cmat._33)/3.0; + res /= cmscale; + } + return res; +} + +/* Hue-Saturation filter from GIMP */ +float hs_hue_overlap( float hue_p, float hue_s, float res ) +{ + float v = hue_p+hue_s; + res += (hshue_a+v)/2.0; + return res%1.0; +} +float hs_hue( float hue, float res ) +{ + res += (hshue_a+hue)/2.0; + return res%1.0; +} +float hs_sat( float sat, float res ) +{ + float v = hssat_a+sat; + res *= v+1.0; + return clamp(res,0.0,1.0); +} +float hs_val( float val, float res ) +{ + float v = (hsval_a+val)/2.0; + if ( v < 0.0 ) return res*(v+1.0); + return res+(v*(1.0-res)); +} +float3 HueSaturation( float3 res ) +{ + float3 hsv = rgb2hsv(res); + float ch = hsv.x*6.0; + int ph = 0, sh = 0; + float pv = 0.0, sv = 0.0; + bool usesh = false; + float hues[6] = {hshue_r,hshue_y,hshue_g,hshue_c,hshue_b,hshue_m}; + float sats[6] = {hssat_r,hssat_y,hssat_g,hssat_c,hssat_b,hssat_m}; + float vals[6] = {hsval_r,hsval_y,hsval_g,hsval_c,hsval_b,hsval_m}; + float v; + [loop] for ( float h=0.0; h<7.0; h+=1.0 ) + { + float ht = h+0.5; + if ( ch < ht+hsover ) + { + ph = floor(h); + if ( (hsover > 0.0) && (ch > ht-hsover) ) + { + usesh = true; + sh = ph+1; + sv = (ch-ht+hsover)/(2.0*hsover); + pv = 1.0-sv; + } + else usesh = false; + break; + } + } + if ( ph >= 6 ) + { + ph = 0; + usesh = false; + } + if ( sh >= 6 ) sh = 0; + if ( usesh ) + { + hsv.x = hs_hue_overlap(hues[ph]*pv,hues[sh]*sv,hsv.x); + hsv.y = hs_sat(sats[ph],hsv.y)*pv+hs_sat(sats[sh],hsv.y)*sv; + hsv.z = hs_val(vals[ph],hsv.z)*pv+hs_val(vals[sh],hsv.z)*sv; + } + else + { + hsv.x = hs_hue(hues[ph],hsv.x); + hsv.y = hs_sat(sats[ph],hsv.y); + hsv.z = hs_val(vals[ph],hsv.z); + } + return hsv2rgb(hsv); +} + +/* Colour Balance filter from GIMP */ + +/* Additional filters that don't fit in enbeffect */ +float4 PS_Append( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target +{ + float2 coord = IN.txcoord.xy; + float4 res = TextureColor.Sample(Sampler,coord); + if ( cmatenable ) res.rgb = ColorMatrix(res.rgb); + if ( hsenable ) res.rgb = HueSaturation(res.rgb); + res.rgb = max(res.rgb,0.0); + res.a = 1.0; + return res; +} /* ultimate super-cinematic immersive black bars */ float4 PS_Cinematic( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target @@ -735,12 +999,119 @@ float4 PS_Cinematic( VS_OUTPUT_POST IN, float4 v0 : SV_Position0 ) : SV_Target return res; } +/* begin SMAA integration code */ + +Texture2D RenderTargetRGBA32; // for edges +Texture2D RenderTargetRGBA64; // for blend +Texture2D TextureArea +< + string ResourceName = "SMAA/AreaTex.dds"; +>; +Texture2D TextureSearch +< + string ResourceName = "SMAA/SearchTex.dds"; +>; + +#define SMAA_RT_METRICS float4(1.0/ScreenSize.x,1.0/(ScreenSize.x*ScreenSize.w),ScreenSize.x,ScreenSize.x*ScreenSize.w) +#define SMAA_HLSL_4_1 + +#include "SMAA/SMAA.fxh" + +DepthStencilState DisableDepthReplaceStencil +{ + DepthEnable = FALSE; + StencilEnable = TRUE; + FrontFaceStencilPass = REPLACE; +}; +DepthStencilState DisableDepthUseStencil +{ + DepthEnable = FALSE; + StencilEnable = TRUE; + FrontFaceStencilFunc = EQUAL; +}; +BlendState NoBlending +{ + AlphaToCoverageEnable = FALSE; + BlendEnable[0] = FALSE; +}; + +VS_OUTPUT_POST SMAAEdgeDetectionWrapVS( VS_INPUT_POST IN, + out float4 offset[3] : TEXCOORD1 ) +{ + VS_OUTPUT_POST OUT = VS_PostProcess(IN); + if ( smaaenable ) SMAAEdgeDetectionVS(IN.txcoord.xy,offset); + return OUT; +} +VS_OUTPUT_POST SMAABlendingWeightCalculationWrapVS( VS_INPUT_POST IN, + out float2 pixcoord : TEXCOORD1, out float4 offset[3] : TEXCOORD2 ) +{ + VS_OUTPUT_POST OUT = VS_PostProcess(IN); + if ( smaaenable ) + SMAABlendingWeightCalculationVS(IN.txcoord.xy,pixcoord,offset); + return OUT; +} +VS_OUTPUT_POST SMAANeighborhoodBlendingWrapVS( VS_INPUT_POST IN, + out float4 offset : TEXCOORD1 ) +{ + VS_OUTPUT_POST OUT = VS_PostProcess(IN); + if ( smaaenable ) SMAANeighborhoodBlendingVS(IN.txcoord.xy,offset); + return OUT; +} + +float4 SMAAEdgeDetectionWrapPS( VS_OUTPUT_POST IN, + float4 offset[3] : TEXCOORD1 ) : SV_Target +{ + if ( !smaaenable ) return float4(0.0,0.0,0.0,1.0); + float2 coord = IN.txcoord.xy; + float2 edges; + //edges = SMAADepthEdgeDetectionPS(coord,offset,TextureDepth); + //edges = SMAALumaEdgeDetectionPS(coord,offset,TextureColor); + edges = SMAAColorEdgeDetectionPS(coord,offset,TextureColor); + return float4(edges,0.0,1.0); +} +float4 SMAABlendingWeightCalculationWrapPS( VS_OUTPUT_POST IN, + float2 pixcoord : TEXCOORD1, float4 offset[3] : TEXCOORD2 ) : SV_Target +{ + if ( !smaaenable ) return float4(0.0,0.0,0.0,1.0); + return SMAABlendingWeightCalculationPS(IN.txcoord.xy,pixcoord,offset, + RenderTargetRGBA32,TextureArea,TextureSearch,0.0); +} +float4 SMAANeighborhoodBlendingWrapPS( VS_OUTPUT_POST IN, + float4 offset : TEXCOORD1 ) : SV_Target +{ + float2 coord = IN.txcoord.xy; + float4 res; + if ( !smaaenable ) res = TextureColor.Sample(Sampler,coord); + else res = SMAANeighborhoodBlendingPS(coord,offset,TextureColor, + RenderTargetRGBA64); + float3 RGB = res.rgb*(res.rgb*(res.rgb*0.305306011+0.682171111) + +0.012522878); + res.rgb = RGB; + res.a = 1.0; + if ( smaadebug == 1 ) return RenderTargetRGBA32.Sample(Sampler,coord); + if ( smaadebug == 2 ) return RenderTargetRGBA64.Sample(Sampler,coord); + return res; +} +float4 PS_ToSRGB( VS_OUTPUT_POST IN ) : SV_Target +{ + float4 res = TextureColor.Sample(Sampler,IN.txcoord.xy); + float3 S1 = sqrt(res.rgb); + float3 S2 = sqrt(S1); + float3 S3 = sqrt(S2); + float3 sRGB = 0.662002687*S1+0.684122060*S2-0.323583601*S3 + -0.0225411470*res.rgb; + res.rgb = sRGB; + return res; +} + +/* end SMAA integration code */ + technique11 ExtraFilters { pass p0 { SetVertexShader(CompileShader(vs_5_0,VS_PostProcess())); - SetPixelShader(CompileShader(ps_5_0,PS_LumaSharp())); + SetPixelShader(CompileShader(ps_5_0,PS_Append())); } } technique11 ExtraFilters1 @@ -748,7 +1119,7 @@ technique11 ExtraFilters1 pass p0 { SetVertexShader(CompileShader(vs_5_0,VS_PostProcess())); - SetPixelShader(CompileShader(ps_5_0,PS_Blur())); + SetPixelShader(CompileShader(ps_5_0,PS_Kuwahara())); } } technique11 ExtraFilters2 @@ -756,23 +1127,27 @@ technique11 ExtraFilters2 pass p0 { SetVertexShader(CompileShader(vs_5_0,VS_PostProcess())); - SetPixelShader(CompileShader(ps_5_0,PS_Sharp())); + SetPixelShader(CompileShader(ps_5_0,PS_Median())); } } -technique11 ExtraFilters3 +technique11 ExtraFilters3 { pass p0 { - SetVertexShader(CompileShader(vs_5_0,VS_PostProcess())); - SetPixelShader(CompileShader(ps_5_0,PS_Shift())); + SetVertexShader(CompileShader(vs_5_0,SMAAEdgeDetectionWrapVS())); + SetPixelShader(CompileShader(ps_5_0,SMAAEdgeDetectionWrapPS())); + SetDepthStencilState(DisableDepthReplaceStencil,1); + SetBlendState(NoBlending,float4(0.0,0.0,0.0,0.0),0xFFFFFFFF); } } -technique11 ExtraFilters4 +technique11 ExtraFilters4 { pass p0 { - SetVertexShader(CompileShader(vs_5_0,VS_PostProcess())); - SetPixelShader(CompileShader(ps_5_0,PS_ChromaKey())); + SetVertexShader(CompileShader(vs_5_0,SMAABlendingWeightCalculationWrapVS())); + SetPixelShader(CompileShader(ps_5_0,SMAABlendingWeightCalculationWrapPS())); + SetDepthStencilState(DisableDepthUseStencil,1); + SetBlendState(NoBlending, float4(0.0,0.0,0.0,0.0),0xFFFFFFFF); } } technique11 ExtraFilters5 @@ -780,19 +1155,82 @@ technique11 ExtraFilters5 pass p0 { SetVertexShader(CompileShader(vs_5_0,VS_PostProcess())); - SetPixelShader(CompileShader(ps_5_0,PS_Vignette())); + SetPixelShader(CompileShader(ps_5_0,PS_ToSRGB())); } } -/* Paint will go between these two */ technique11 ExtraFilters6 { pass p0 { - SetVertexShader(CompileShader(vs_5_0,VS_PostProcess())); - SetPixelShader(CompileShader(ps_5_0,PS_Retro())); + SetVertexShader(CompileShader(vs_5_0,SMAANeighborhoodBlendingWrapVS())); + SetPixelShader(CompileShader(ps_5_0,SMAANeighborhoodBlendingWrapPS())); } } technique11 ExtraFilters7 +{ + pass p0 + { + SetVertexShader(CompileShader(vs_5_0,VS_PostProcess())); + SetPixelShader(CompileShader(ps_5_0,PS_FXAA())); + } +} +technique11 ExtraFilters8 +{ + pass p0 + { + SetVertexShader(CompileShader(vs_5_0,VS_PostProcess())); + SetPixelShader(CompileShader(ps_5_0,PS_LumaSharp())); + } +} +technique11 ExtraFilters9 +{ + pass p0 + { + SetVertexShader(CompileShader(vs_5_0,VS_PostProcess())); + SetPixelShader(CompileShader(ps_5_0,PS_Blur())); + } +} +technique11 ExtraFilters10 +{ + pass p0 + { + SetVertexShader(CompileShader(vs_5_0,VS_PostProcess())); + SetPixelShader(CompileShader(ps_5_0,PS_Sharp())); + } +} +technique11 ExtraFilters11 +{ + pass p0 + { + SetVertexShader(CompileShader(vs_5_0,VS_PostProcess())); + SetPixelShader(CompileShader(ps_5_0,PS_Shift())); + } +} +technique11 ExtraFilters12 +{ + pass p0 + { + SetVertexShader(CompileShader(vs_5_0,VS_PostProcess())); + SetPixelShader(CompileShader(ps_5_0,PS_ChromaKey())); + } +} +technique11 ExtraFilters13 +{ + pass p0 + { + SetVertexShader(CompileShader(vs_5_0,VS_PostProcess())); + SetPixelShader(CompileShader(ps_5_0,PS_Vignette())); + } +} +technique11 ExtraFilters14 +{ + pass p0 + { + SetVertexShader(CompileShader(vs_5_0,VS_PostProcess())); + SetPixelShader(CompileShader(ps_5_0,PS_Curvature())); + } +} +technique11 ExtraFilters15 { pass p0 { diff --git a/enbseries/enbeffectpostpass.fx.ini b/enbseries/enbeffectpostpass.fx.ini index 8dac524..9efc217 100644 --- a/enbseries/enbeffectpostpass.fx.ini +++ b/enbseries/enbeffectpostpass.fx.ini @@ -15,13 +15,13 @@ Dither Range=0.1 Enable Chroma Key=false Chroma Key Red=0, 1, 0 Chroma Key Depth=0.99 -Enable Blur=true +Enable Blur=false Blur Sampling Range=0.2 -Enable Sharp=true +Enable Sharp=false Sharp Sampling Range=0.41 Sharpening Amount=1.76 Enable Shift=false -Shift Sampling Range=0.6 +Shift Sampling Range=0.5 Luma Sharpen Enable=true Luma Sharpen Radius=0.8 Luma Sharpen Clamp=0.1 @@ -44,3 +44,53 @@ Border Blur Intensity=3.74 Border Blur Shift=0.0 Border Blur Radius=1.0 Vignette Color=-0.03, -0.05, -0.07 +Enable Oil Filter=false +Enable FXAA=false +FXAA Span Max=4.0 +FXAA Reduce Mul=16.0 +FXAA Reduce Min=128.0 +Chroma Key Depth Horizontal Tilt Center=0.5 +Chroma Key Depth Vertical Tilt Center=0.5 +Chroma Key Depth Horizontal Tilt=0.0 +Chroma Key Depth Vertical Tilt=0.0 +Enable Curvature=false +Curve Chromatic Aberration=0.0 +Curve Zooming=50.0 +Curve Distortion=0.0 +Enable Color Matrix=false +Color Matrix Red Red=1.0 +Color Matrix Red Green=0.0 +Color Matrix Red Blue=0.0 +Color Matrix Green Red=0.0 +Color Matrix Green Green=1.0 +Color Matrix Green Blue=0.0 +Color Matrix Blue Red=0.0 +Color Matrix Blue Green=0.0 +Color Matrix Blue Blue=1.0 +Normalize Matrix=false +Enable Hue-Saturation=false +Overlap=0.5 +Global Hue=0.0 +Global Saturation=0.0 +Global Value=0.0 +Red Hue=0.0 +Red Saturation=0.0 +Red Value=0.0 +Yellow Hue=0.0 +Yellow Saturation=0.0 +Yellow Value=0.0 +Green Hue=0.0 +Green Saturation=0.0 +Green Value=0.0 +Cyan Hue=0.0 +Cyan Saturation=0.0 +Cyan Value=0.0 +Blue Hue=0.0 +Blue Saturation=0.0 +Blue Value=0.0 +Magenta Hue=0.0 +Magenta Saturation=0.0 +Magenta Value=0.0 +Enable SMAA=true +SMAA Edge Detection Mode=2 +SMAA Debugging=0 diff --git a/enbseries/menbcgalut.png b/enbseries/menbcgalut.png deleted file mode 100644 index 55cccbc..0000000 Binary files a/enbseries/menbcgalut.png and /dev/null differ diff --git a/enbseries/menbegalut.png b/enbseries/menbegalut.png deleted file mode 100644 index 9615797..0000000 Binary files a/enbseries/menbegalut.png and /dev/null differ diff --git a/enbseries/menbglobaldefs.fx b/enbseries/menbglobaldefs.fx index 839e899..7071417 100644 --- a/enbseries/menbglobaldefs.fx +++ b/enbseries/menbglobaldefs.fx @@ -68,12 +68,12 @@ #define NOISESIZE 256.0 #define HEATSIZE 1024.0 #define FROSTSIZE 1024.0 -/* LUT mode (use only one) - The 256px option was discarded for size reasons */ -//#define LUTMODE_LEGACY -//#define LUTMODE_16 -#define LUTMODE_64 /* some textures can be provided as DDS rather than PNG to save space */ //#define HEAT_DDS //#define FROST_DDS -//#define FROSTBUMP_DDS //#define VIGNETTE_DDS +/* SMAA quality */ +//#define SMAA_PRESET_LOW +//#define SMAA_PRESET_MEDIUM +//#define SMAA_PRESET_HIGH +#define SMAA_PRESET_ULTRA diff --git a/enbseries/menblut64_day.png b/enbseries/menblut64_day.png deleted file mode 100644 index d16da25..0000000 Binary files a/enbseries/menblut64_day.png and /dev/null differ diff --git a/enbseries/menblut64_interior.png b/enbseries/menblut64_interior.png deleted file mode 100644 index 203f948..0000000 Binary files a/enbseries/menblut64_interior.png and /dev/null differ diff --git a/enbseries/menblut64_night.png b/enbseries/menblut64_night.png deleted file mode 100644 index 986f12e..0000000 Binary files a/enbseries/menblut64_night.png and /dev/null differ diff --git a/enbseries/menblut_day.dds b/enbseries/menblut_day.dds new file mode 100644 index 0000000..4f723da Binary files /dev/null and b/enbseries/menblut_day.dds differ diff --git a/enbseries/menblut_interior.dds b/enbseries/menblut_interior.dds new file mode 100644 index 0000000..4144165 Binary files /dev/null and b/enbseries/menblut_interior.dds differ diff --git a/enbseries/menblut_night.dds b/enbseries/menblut_night.dds new file mode 100644 index 0000000..ed1b189 Binary files /dev/null and b/enbseries/menblut_night.dds differ diff --git a/enbseries/menbnoise1.png b/enbseries/menbnoise1.png index 3e915eb..2d794f5 100644 Binary files a/enbseries/menbnoise1.png and b/enbseries/menbnoise1.png differ diff --git a/enbseries/menbnoise2.png b/enbseries/menbnoise2.png index 450769f..3e915eb 100644 Binary files a/enbseries/menbnoise2.png and b/enbseries/menbnoise2.png differ diff --git a/enbseries/menbnoise3.png b/enbseries/menbnoise3.png new file mode 100644 index 0000000..450769f Binary files /dev/null and b/enbseries/menbnoise3.png differ diff --git a/enbseries/menbvgalut.png b/enbseries/menbvgalut.png deleted file mode 100644 index b7d5e90..0000000 Binary files a/enbseries/menbvgalut.png and /dev/null differ