Guest User

ReShade

a guest
Jan 15th, 2015
450
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 119.79 KB | None | 0 0
  1. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. // ReShade effect file
  3. // visit facebook.com/MartyMcModding for news/updates
  4. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  5. // MasterEffect ReBorn 1.0.302 public beta by Marty McFly (Unofficial hotfixes by Matsilagi)
  6. // Continuation of MasterEffect 1.6.1
  7. // Copyright © 2008-2015 Marty McFly
  8. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  9.  
  10. // NOT COMPATIBLE TO ENBSERIES ANYMORE! THIS IS ONLY FOR RESHADE BY CROSIRE!
  11.  
  12. #define VK_SCROLL 0x91
  13.  
  14. #define ReShade_ToggleKey VK_SCROLL
  15.  
  16. #define USE_SPLITSCREEN 0 //[0 or 1] Splitscreen: Disables all effects on the right half of the screen to show changes.
  17. #define USE_DEPTHBUFFER_OUTPUT 0 //[0 or 1] Depth Buffer Output: Shows you the pixel depth, this is for debugging or depth map creation only.
  18. #define USE_TILTSHIFT 1 //[0 or 1] Tilt Shift: Photographic effect which blurs the screen to simulate focus. Results in game world looking tiny when viewed from above.
  19. #define USE_LUT 0 //[0 or 1] Color Lookup Table: Uses a gradient texture to adjust the colors of the image.
  20. #define USE_LENSDIRT 0 //[0 or 1] Lensdirt: Simulates a dirty camera lens. IMPORTANT: bloom threshold and amount have influence on the intensity of the dirt!
  21. #define USE_GAUSSIAN_ANAMFLARE 0 //[0 or 1] Gaussian Anamflare: Applies a horizontal light beam to bright pixels.
  22. #define USE_BLOOM 1 //[0 or 1] Bloom: Makes bright lights bleed their light into their surroundings. NOT the SweetFX way to do bloom but a more proper way.
  23. #define USE_SSAO 0 //[0 or 1] SSAO: Enables Screen-Space Ambient Occlusion, a non-physically correct but realistic shading algorithm
  24. #define USE_PETKAGTADOF 0 //[0 or 1] Matso DOF: Enables PetkaGtA's Depth of Field, originally of Blender.
  25. #define USE_MATSODOF 0 //[0 or 1] Matso DOF: Enables Matso's Depth of Field.
  26. #define USE_GP65CJ042DOF 0 //[0 or 1] gp65cj042 DOF: Enables Depth of Field shader, this version is originally by user gp65cj042, ME uses an optimized version by me (Marty McFly).
  27. #define USE_EXPLOSION 0 //[0 or 1] Explosion : Scatters the pixels, making the image look fuzzy.
  28. #define USE_CARTOON 0 //[0 or 1] Cartoon : "Toon"s the image.
  29. #define USE_SHARPENING 0 //[0 or 1] Sharpen: Sharps the image but may increase aliasing
  30. #define USE_LEVELS 1 //[0 or 1] Levels : Sets a new black and white point. This increases contrast but causes clipping. Use Curves instead if you want to avoid that.
  31. #define USE_TECHNICOLOR 0 //[0 or 1] Technicolor : Attempts to mimic the look of an old movie using the Technicolor three-strip color process. Algorithm from prod80
  32. #define USE_SWFX_TECHNICOLOR 0 //[0 or 1] Technicolor : Attempts to mimic the look of an old movie using the Technicolor three-strip color process. Algorithm from SweetFX
  33. #define USE_DPX 1 //[0 or 1] Cineon DPX : Should make the image look like it's been converted to DXP Cineon - basically it's another movie-like look similar to technicolor.
  34. #define USE_MONOCHROME 0 //[0 or 1] Monochrome : Monochrome makes the colors disappear. No control values.
  35. #define USE_LIFTGAMMAGAIN 0 //[0 or 1] Lift Gamma Gain : Adjust brightness and color of shadows, midtones and highlights.
  36. #define USE_TONEMAP 0 //[0 or 1] Tonemap : Adjust gamma, exposure, saturation, bleach and defog. (may cause clipping).
  37. #define USE_VIBRANCE 0 //[0 or 1] Vibrance : Intelligently saturates (or desaturates if you use negative values) the pixels depending on their original saturation.
  38. #define USE_CURVES 1 //[0 or 1] Curves : Contrast adjustments using S-curves.
  39. #define USE_SEPIA 0 //[0 or 1] Sepia : Sepia tones the image.
  40. #define USE_SKYRIMTONEMAP 0 //[0 or 1] Skyrim Tonemap: Applies color correction/tonemapping based on tonemappers of popular Skyrim ENB's.
  41. #define USE_COLORMOOD 0 //[0 or 1] Color Mood: Applies a "mood" to the color, tinting mainly the dark colors.
  42. #define USE_CROSSPROCESS 0 //[0 or 1] Cross Processing: Simulates wrong chemistry in color processing.
  43. #define USE_FILMICPASS 0 //[0 or 1] Filmic Pass: Applies some common color adjustments to mimic a more cinema-like look.
  44. #define USE_REINHARD 0 //[0 or 1] Reinhard: This is the Reinhard tonemapping shader, if you are interested, google how it works.
  45. #define USE_REINHARDLINEAR 0 //[0 or 1] Reinhard: Reinhard mixed with some linear tonemapping.
  46. #define USE_COLORMOD 0 //[0 or 1] Colormod: Contrast, Saturation and Brightness ported from colormod.asi.
  47. #define USE_SPHERICALTONEMAP 0 //[0 or 1] Spherical Tonemap: Another approach on tonemapping, uses some sphere algorithms.
  48. #define USE_HPD 0 //[0 or 1] Haarm Peter Duiker Filmic Tonemapping: Tonemapping used in Watch Dogs, ripped from the Watch Dogs shaders themselves.
  49. #define USE_FILMICCURVE 0 //[0 or 1] Filmic Curve: Improved version of the well-known Uncharted 2 filmic curve, first seen in iCEnhancer 0.3.
  50. #define USE_SINCITY 0 //[0 or 1] Sin City: Effect from the movie "Sin City" - everything else than red is grey.
  51. #define USE_GODRAYS 0 //[0 or 1] Godrays: Adds some light rays rotating around screen center.
  52. #define USE_ANAMFLARE 0 //[0 or 1] Anamorphic Lensflare: adds some horizontal light flare, simulating the use of an anamorphic lens while recording.
  53. #define USE_CHROMATICABBERATION 0 //[0 or 1] Chromatic Abberation & Lens Distord: Adds some RGB shift in colors and distorts image to look like the "fisheye" effect.
  54. #define USE_LENZFLARE 0 //[0 or 1] Lenz Flare: Boris Vorontsov's Skyrim Lensflare with custom offsets, ported to MasterEffect.
  55. #define USE_GRAIN 0 //[0 or 1] Grain: Adds some image grain, looks like when a TV has no signal.
  56. #define USE_HD6_VIGNETTE 0 //[0 or 1] HeliosDoubleSix Vignette: Adds some advanced vignette (darkening shader) to lead focus to screen center
  57. #define USE_BORISVIGNETTE 0 //[0 or 1] Boris Vorontsov Vignette: Simple colorable version of vignette, darkens/tints the image at the corners
  58. #define USE_BORDER 0 //[0 or 1] Adds a 1 pixel black border around the screen to compensate white outlining caused by excessive sharpening
  59. #define USE_MOVIEBARS 0 //[0 or 1] Movie Bars: blackens the image on the top and bottom, simulating a higher aspect ratio. Default set to 21:9 aspect ratio.
  60. #define USE_LEIFX 0 //[0 or 1] LeifFX: Simulates use of old 3dfx render engines, read here for more info: http://leileilol.mancubus.net/shaders/
  61. #define USE_COLORHUEFX 0 //[0 or 1] Color Hue FX: Desaturates everything but colors from a fixed hue mid and the range around it. Similiar to Sin City but much better. Thanks, prod80!
  62.  
  63. //TILT SHIFT
  64. #define TiltShiftAxis 0.45 //[0.0 to 90.0] Rotation of Tilt shift axis. 0.0 means horizontal focus line, 90.0 means vertical.
  65. #define TiltShiftOffset 0.5 //[0.0 to 1.0] Position of Tilt Shift axis. 0.5 is screen center. You may adjust this value when changing the axis value.
  66. #define TiltShiftCurve 2 //[0.0 to 2.0] Power of Tilt Shift blurring.
  67. #define TiltShiftMult 3.0 //[1.0 to 7.0] Multiplicator if Tilt Shift blurring. Do not set too high, otherwise the single blur taps are visible.
  68.  
  69. //LENSDIRT
  70. #define fLensdirtIntensity 1.0 //[0.0 to 2.0] Intensity of lensdirt.
  71.  
  72. //GAUSSIAN ANAMORPHIC LENSFLARE
  73. #define fAnamFlareThreshold 0.90 //[0.1 to 1.0] Every pixel brighter than this value gets a flare.
  74. #define fAnamFlareWideness 1.0 //[1.0 to 2.5] Horizontal wideness of flare. Don't set too high, otherwise the single samples are visible
  75. #define fAnamFlareAmount 1.0 //[1.0 to 20.0] Intensity of anamorphic flare.
  76. #define fAnamFlareCurve 1.2 //[1.0 to 2.0] Intensity curve of flare with distance from source
  77. #define fAnamFlareColor float3(0.012,0.313,0.588) //[0.0 to 1.0] R, G and B components of anamorphic flare. Flare is always same color.
  78.  
  79. //BLOOM
  80. #define BLOOM_MIXMODE 2 //[1 to 2] 1: Linear add | 2: Screen add | 3: Screen/Lighten/Opacity | 4: Lighten
  81. #define fBloomThreshold 0.60 //[0.1 to 1.0] Every pixel brighter than this value triggers bloom.
  82. #define fBloomAmount 0.15 //[1.0 to 20.0] Intensity of bloom.
  83. #define fBloomSaturation 1.2 //[0.0 to 2.0] Bloom saturation. 0.0 means white bloom, 2.0 means very very colorful bloom.
  84. #define fBloomTint float3(0.7,0.8,1.0) //[0.0 to 1.0] R, G and B components of bloom tintcolor the bloom color gets shifted to.
  85.  
  86. //SCREEN SPACE AMBIENT OCCLUSION
  87. #define SSAO_Debug 0 //[0 or 1] Enables raw SSAO output for debugging purposes.
  88. #define SSAO_Smoothening 0.4 //[0.05 to 0.5] Amount of post blur applied on raw, noisy SSAO.
  89. #define SSAO_Samples 64 //[32 to 128] Amount of samples. Don't set too high or shader compilation time goes through the roof.
  90. #define SSAO_Range 30.0 //[10.0 to 50.0] SSAO sampling range. High range values might need more samples so raise both.
  91. #define SSAO_SampleRangeClipMin 0.01 //[0.005 to 0.05] SSAO sampling min range clip. This should eliminate artifacts from objects that have very low depth difference.
  92. #define SSAO_SampleRangeClipMax 0.1 //[0.1 to 0.5] SSAO sampling max range clip. This should prevent objects from occluding others which are far away from each other.
  93. #define SSAO_DarkeningAmount 4.5 //[0.0 to 5.0] Amount of SSAO corner darkening
  94. #define SSAO_BrighteningAmount 3.0 //[0.0 to 5.0] Amount of SSAO edge brightening
  95.  
  96. //PETKAGTA DEPTH OF FIELD
  97. #define DOF_VIGNETTING 0 //[0 or 1] Enables vignetting (darkens edges). There is a better shader for that in ME but I decided to keep it
  98. #define DOF_MANUAL 1 //[0 or 1] Enables Manual DOF focussing
  99. #define DOF_AUTO 0 //[0 or 1] Enables Autofocus
  100. #define DOF_PENTAGONSHAPE 0 //[0 or 1] Enables Pentagonal DOF shape (bugged, dunno how to fix, better use GP DOF for polygonal shapes)
  101. #define focalDepth 2000.5 //[10.0 to X] Depth of focal plane for manual DOF
  102. #define focalLength 200.0 //[10.0 to X] Length of focus area for manual DOF
  103. #define fstop 150.5 //[10.0 to X] fStop for manual DOF
  104. #define vignint 4 //[0 to X] Amount if vignetting applied
  105. #define fdofstart 20 //[0.0001 to 0.05] Distance where far blur starts
  106. #define fdofdist 1500 //[0.1 to 1.0] Distance where far blur ends
  107. #define focus float2(0.5,0.5) //[0.0 to 1.0] Screen coordinates of focus point. First value is horizontal, second value is vertical position. 0 is left/upper, 1 is right/lower.
  108. #define CoC 0.4 //[0.01 to 0.3] table is here http://en.wikipedia.org/wiki/Circle_of_confusion
  109. #define namount 0.00004 //[0.00000 to 0.0005] Amount of noise applied. This is no grain, rather some kind of DOF offset jittering
  110. #define DOFdownsample 4.0 //[0 to 10] This should downsample the blurred areas but Boris and his unsupported stuff...
  111. #define maxblur 2.5 //[1.0 to 10.0] Maximum amount of blurring
  112. #define samples 6 //[5 to 30] Samples on the first ring. The other rings around have more samples
  113. #define rings 4 //[1 to 8] Ring count
  114. #define threshold 2.5 //[0.8 to 2.0] Threshold for bokeh brightening. Above this value, everything gets much much brighter. 1.0 is maximum value for LDR games like GTASA, higher values work only on HDR games like Skyrim etc.
  115. #define gain 0.1 //[0.1 to 2.0] Amount of brightening for pixels brighter than threshold.
  116. #define bias 0.2 //[0.1 to 2.0] bokeh bias.
  117. #define fringe 0.5 //[0.0 to 1.0] Amount of chromatic abberation
  118. #define znear 100.0 //[20 to 200] camera clipping start.
  119. #define zfar 3500.0 //[1500 to 8000] camera clipping end.
  120. #define feather 1.1 //[0.1 to 2.0] pentagon shape feather.
  121.  
  122. //MATSO DEPTH OF FIELD
  123. #define USE_CHROMA_DOF 1 //[0 or 1] Enables Chromatic Abberation.
  124. #define USE_SMOOTH_DOF 1 //[0 or 1] Enables smoother DOF
  125. #define USE_BOKEH_DOF 1 //[0 or 1] Enables Bokeh DOF. Disabling it screws the shape up, leave it on
  126. #define USE_AUTOFOCUS 1 //[0 or 1] Enables Autofocus
  127. #define CHROMA_POW 65.0 //[10 to 100] Controls amount of chromatic abberation
  128. #define DOF_SCALE 2356.1944901923449288469825374596 //LEAVE IT
  129. #define FIRST_PASS 2 //LEAVE IT
  130. #define SECOND_PASS 3 //LEAVE IT
  131. #define THIRD_PASS 0 //LEAVE IT
  132. #define FOURTH_PASS 1 //LEAVE IT
  133. #define DOF(sd,sf) fApertureScale * smoothstep(fApertureBias, fApertureCutoff, abs(sd - sf)) //LEAVE IT
  134. #define fvChroma float3(0.995, 1.000, 1.005) //Displacement of colors for chromatic abberation. 1.0 is original position
  135. #define fBaseRadius 2
  136. #define fFalloffRadius 1.8
  137. #define fChromaPower 1.0
  138. #define fvTexelSize float2(1.0 / 1920.0, 1.0 / 1080.0)
  139. #define fFocusBias 0.045
  140. #define fApertureScale 0.004
  141. #define fApertureCutoff 0.25
  142. #define fApertureBias 0.07
  143. #define fBokehCurve 8.0
  144. #define fBokehLight 0.012
  145.  
  146. //GP65CJ042 DEPTH OF FIELD
  147. #define NOT_BLURRING_SKY_MODE 0 //[0 or 1] Prevents the DOF of blurring the sky. Probably doesn't work on 0.076 due to SA's stupid depth calculation
  148. #define DEPTH_OF_FIELD_QULITY 7 //[0 to 7] 0: only slight gaussian farblur but no bokeh. 1-7 bokeh blur, higher means better quality of blur but less fps.
  149. #define AUTO_FOCUS 0 //[0 or 1] Enables automatic focal plane detection, for focussing FocusPoint is used.
  150. #define TILT_SHIFT 0 //[0 or 1] Enables Tilt shifting. Google it!
  151. #define POLYGONAL_BOKEH 1 //[0 or 1] Enables polygonal bokeh shape, e.g. POLYGON_NUM 5 means pentagonal bokeh shape. Setting this value to 0 results in circular bokeh shape.
  152. #define POLYGON_NUM 8 //[3 to 9] Controls the amount pf polygons for polygonal bokeh shape. 3 = triangular, 4 = square, 5 = pentagonal etc.
  153. #define FocusPoint float2(0.5, 0.5); //[0.0 to 1.0] Screen coordinates of focus point. First value is horizontal, second value is vertical position. 0 is left/upper, 1 is right/lower.
  154. #define FocusSampleRange 1.00 //[0.0 to 10.0] Autofocus samples 4 additional points around FocusPoint and averages focal plane. This value controls search radius of these 4 points.
  155. #define NearBlurCurve 100.00 //[0.0 to X] Blur curve of objects closer to camera than focal plane. Raise for less blur. Set to insane values for no blur.
  156. #define FarBlurCurve 1.00 //[0.0 to X] Blur curve of objects beyond focal plane. Raise for less blur. Set to insane values for no blur.
  157. #define DepthClip 150.0 //[10.0 to 1000.0] After this distance depth if max, no matter how far something really is.
  158. #define ManualFocusDepth 10.0 //[0.0 to 1000.0] Manual focus distance rougly in meters. Active only when AUTO_FOCUS 0.
  159. #define TiltShiftAngle 30.0 //[0.0 to 360.0] Angle of autofocus. I highly recommend to google that effect if you wanna know what it does.
  160. #define BokehBias 10.00 //[0.0 to 20.0] Shifts bokeh weighting to bokeh shape edge. Set to 0 for even bright bokeh shapes, raise it for darker bokeh shapes in center and brighter on edge.
  161. #define BokehBiasCurve 1.50 //[0.0 to 3.0] Power of Bokeh Bias. Raise for more defined bokeh outlining on bokeh shape edge.
  162. #define BokehBrightnessThreshold 0.8 //[0.6 to 2.0] Threshold for bokeh brightening. Above this value, everything gets much much brighter. 1.0 is maximum value for LDR games like GTASA, higher values work only on HDR games like Skyrim etc.
  163. #define BokehBrightnessMultipiler 1.00 //[0.0 to 2.0] Amount of brightening for pixels brighter than BokehBrightnessThreshold.
  164. #define RadiusSacleMultipiler 2.00 //[0.5 to 10.0] Overall blur multiplier, higher results in more blur. Do not set too high, otherwise the single taps will be visible. If that happens, raise quality.
  165. #define BokehPostBlur 0.50 //[0.5 to 3.0] Radius in pixels for post gaussian blur after bokeh blur to smoothen shape.
  166. #define ChromaticAberrationAmount 0.00 //[0.00 to 0.4] Amount of color shifting applied on blurred areas.
  167.  
  168. //EXPLOSION
  169. #define Explosion_Radius 10.5 //[0.2 to 100.0] Amount of effect you want.
  170.  
  171. //CARTOON
  172. #define CartoonPower 1.5 //[0.1 to 10.0] Amount of effect you want.
  173. #define CartoonEdgeSlope 1.5 //[0.1 to 8.0] Raise this to filter out fainter edges. You might need to increase the power to compensate. Whole numbers are faster.
  174.  
  175. //SHARPEN
  176. #define SharpBias 0.1 //[0.05 to 1.0] How big the sharpen offset is (used to compare neighbor pixels to get sharpen amount
  177. #define SharpStrength 0.3 //[0.05 to 1.0] Amount of sharpening you want.
  178. #define SharpClamp 0.5 //[0.2 to 2.0] Clamps the sharpening to a maximum amount to prevent aliasing
  179.  
  180. //LEVELS
  181. #define Levels_black_point 5 //[0 to 255] The black point is the new black - literally. Everything darker than this will become completely black. Default is 16.0
  182. #define Levels_white_point 250 //[0 to 255] The new white point. Everything brighter than this becomes completely white. Default is 235.0
  183.  
  184. //TECHNICOLOR
  185. #define ColStrengthR 0.2 //[0.05 to 1.0] Color Strength of Red channel. Higher means darker and more intense colors.
  186. #define ColStrengthG 0.2 //[0.05 to 1.0] Color Strength of Green channel. Higher means darker and more intense colors.
  187. #define ColStrengthB 0.2 //[0.05 to 1.0] Color Strength of Blue channel. Higher means darker and more intense colors.
  188. #define TechniBrightness 1.0 //[0.5 to 1.5] Brightness Adjustment, higher means brighter image.
  189. #define TechniStrength 1.0 //[0.0 to 1.0] Strength of Technicolor effect. 0.0 means original image.
  190. #define TechniSat 0.7 //[0.0 to 1.5] Additional saturation control since technicolor tends to oversaturate the image.
  191.  
  192. //SWEETFX TECHNICOLOR
  193. #define TechniAmount 0.4 //[0.00 to 1.00] Amount of color change you want
  194. #define TechniPower 4.0 //[0.00 to 8.00] Power of color change
  195. #define redNegativeAmount 0.88 //[0.00 to 1.00] controls for different technicolor power on the respective color channels
  196. #define greenNegativeAmount 0.88 //[0.00 to 1.00]
  197. #define blueNegativeAmount 0.88 //[0.00 to 1.00]
  198.  
  199. //DPX
  200. #define DPXRed 8.0 //[1.0 to 15.0] Amount of DPX applies on Red color channel
  201. #define DPXGreen 8.0 //[1.0 to 15.0] ""
  202. #define DPXBlue 8.0 //[1.0 to 15.0] ""
  203. #define DPXColorGamma 2.5 //[0.1 to 2.5] Adjusts the colorfulness of the effect in a manner similar to Vibrance. 1.0 is neutral.
  204. #define DPXSaturation 3.0 //[0.0 to 8.0] Adjust saturation of the effect. 1.0 is neutral.
  205. #define DPXRedC 0.36 //[0.60 to 0.20]
  206. #define DPXGreenC 0.36 //[0.60 to 0.20]
  207. #define DPXBlueC 0.34 //[0.60 to 0.20]
  208. #define DPXBlend 0.2 //[0.00 to 1.00] How strong the effect should be.
  209.  
  210. //LIFTGAMMAGAIN
  211. #define RGB_Lift float3(1.000, 1.000, 1.000) //[0.000 to 2.000] Adjust shadows for Red, Green and Blue.
  212. #define RGB_Gamma float3(1.000, 2.000, 1.000) //[0.000 to 2.000] Adjust midtones for Red, Green and Blue
  213. #define RGB_Gain float3(1.000, 1.000, 1.000) //[0.000 to 2.000] Adjust highlights for Red, Green and Blue
  214.  
  215. //TONEMAP
  216. #define Gamma 1.000 //[0.000 to 2.000] Adjust midtones. 1.000 is neutral. This setting does exactly the same as the one in Lift Gamma Gain, only with less control.
  217. #define Exposure 0.000 //[-1.000 to 1.000] Adjust exposure
  218. #define Saturation 0.000 //[-1.000 to 1.000] Adjust saturation
  219. #define Bleach 0.000 //[0.000 to 1.000] Brightens the shadows and fades the colors
  220. #define Defog 0.000 //[0.000 to 1.000] How much of the color tint to remove
  221. #define FogColor float3(0.00, 0.00, 2.55) //[0.00 to 2.55, 0.00 to 2.55, 0.00 to 2.55] What color to remove - default is blue
  222.  
  223. //VIBRANCE
  224. #define Vibrance 1.15 //[-1.00 to 1.00] Intelligently saturates (or desaturates if you use negative values) the pixels depending on their original saturation.
  225. #define Vibrance_RGB_balance float3(1.00, 1.00, 1.00) //[-10.00 to 10.00,-10.00 to 10.00,-10.00 to 10.00] A per channel multiplier to the Vibrance strength so you can give more boost to certain colors over others
  226.  
  227. //CURVES
  228. #define Curves_mode 2 //[0|1|2] Choose what to apply contrast to. 0 = Luma, 1 = Chroma, 2 = both Luma and Chroma. Default is 0 (Luma)
  229. #define Curves_contrast 0.3 //[-1.00 to 1.00] The amount of contrast you want
  230.  
  231. // -- Advanced curve settings --
  232. #define Curves_formula 2 //[1|2|3|4|5|6|7|8|9|10] The contrast s-curve you want to use.
  233. //1 = Sine, 2 = Abs split, 3 = Smoothstep, 4 = Exp formula, 5 = Simplified Catmull-Rom (0,0,1,1), 6 = Perlins Smootherstep
  234. //7 = Abs add, 8 = Techicolor Cinestyle, 9 = Parabola, 10 = Half-circles.
  235. //Note that Technicolor Cinestyle is practically identical to Sine, but runs slower. In fact I think the difference might only be due to rounding errors.
  236. //I prefer 2 myself, but 3 is a nice alternative with a little more effect (but harsher on the highlight and shadows) and it's the fastest formula.
  237.  
  238. //SEPIA
  239. #define ColorTone float3(1.40, 1.10, 0.90) //[0.00 to 2.55, 0.00 to 2.55, 0.00 to 2.55] What color to tint the image
  240. #define GreyPower 0.11 //[0.00 to 1.00] How much desaturate the image before tinting it
  241. #define SepiaPower 0.58 //[0.00 to 1.00] How much to tint the image
  242.  
  243. //SKYRIM TONEMAPPING
  244. #define POSTPROCESS 6 //[1 to 6] Mode of postprocessing you want. Mode 1 uses V1 values, Mode 2 uses V2 values etc
  245. //
  246. #define EAdaptationMinV1 0.05
  247. #define EAdaptationMaxV1 0.125
  248. #define EContrastV1 1.0
  249. #define EColorSaturationV1 1.0
  250. #define EToneMappingCurveV1 6.0
  251. //
  252. #define EAdaptationMinV2 0.36
  253. #define EAdaptationMaxV2 0.29
  254. #define EToneMappingCurveV2 8.0
  255. #define EIntensityContrastV2 2.5
  256. #define EColorSaturationV2 3.2
  257. #define EToneMappingOversaturationV2 180.0
  258. //
  259. #define EAdaptationMinV3 0.001
  260. #define EAdaptationMaxV3 0.025
  261. #define EToneMappingCurveV3 30.0
  262. #define EToneMappingOversaturationV3 111160.0
  263. //
  264. #define EAdaptationMinV4 0.2
  265. #define EAdaptationMaxV4 0.125
  266. #define EBrightnessCurveV4 0.7
  267. #define EBrightnessMultiplierV4 0.45
  268. #define EBrightnessToneMappingCurveV4 0.3
  269. //
  270. #define EAdaptationMinV5 0.08
  271. #define EAdaptationMaxV5 0.20
  272. #define EToneMappingCurveV5 8
  273. #define EIntensityContrastV5 3.475
  274. #define EColorSaturationV5 4
  275. #define HCompensateSatV5 2
  276. #define EToneMappingOversaturationV5 180.0
  277. //
  278. #define EBrightnessV6Day 2.5
  279. #define EIntensityContrastV6Day 1.5
  280. #define EColorSaturationV6Day 2.0
  281. #define HCompensateSatV6Day 3.0
  282. #define EAdaptationMinV6Day 0.64
  283. #define EAdaptationMaxV6Day 0.24
  284. #define EToneMappingCurveV6Day 8
  285. #define EToneMappingOversaturationV6Day 2500.0
  286.  
  287. //COLORMOOD
  288. #define fRatio 2.0 //[0.00 to 3.00] Amount of moody coloring you want
  289. #define moodR 1.0 //[0.0 to 2.0] How strong dark red colors shall be boosted
  290. #define moodG 1.1 //[0.0 to 2.0] How strong dark green colors shall be boosted
  291. #define moodB 0.5 //[0.0 to 2.0] How strong dark blue colors shall be boosted
  292.  
  293. //CROSSPROCESS
  294. #define CrossContrast 0.95 //[0.5 to 2.00] The names of these values should explain their functions
  295. #define CrossSaturation 1.12 //[0.5 to 2.00]
  296. #define CrossBrightness -0.052 //[-0.3 to 0.30]
  297. #define CrossAmount 1.0 //[0.05 to 1.5]
  298.  
  299. //FILMICPASS
  300. #define Strenght 0.725 //[0.05 to 1.5] Strength of the color curve altering
  301. #define BaseGamma 1.6 //[0.7 to 2.0] Gamma Curve
  302. #define Fade 0.2 //[0.0 to 0.6] Decreases contrast to imitate faded image
  303. #define Contrast 1.0 //[0.5 to 2.0] Contrast.
  304. #define FSaturation -0.15
  305. #define FBleach 0.005 //[-0.5 to 1.0] More bleach means more contrasted and less colorful image
  306. #define FRedCurve 6.0
  307. #define FGreenCurve 6.0
  308. #define FBlueCurve 6.0
  309. #define BaseCurve 1.5
  310. #define EffectGammaR 1.0
  311. #define EffectGammaG 1.0
  312. #define EffectGammaB 1.0
  313. #define EffectGamma 0.75
  314. #define Linearization 1.3 //[0.5 to 2.0] Linearizes the color curve
  315.  
  316. //REINHARD TONEMAP
  317. #define ReinhardWhitepoint 4.0 //[1.0 to 10.0] Point above which everything is pure white
  318. #define ReinhardScale 0.5 //[0.0 to 2.0] Amount of applied tonemapping
  319.  
  320. //REINHARD LINEAR TONEMAP
  321. #define ReinhardLinearWhitepoint 4.4
  322. #define ReinhardLinearPoint 0.06
  323. #define ReinhardLinearSlope 2.25 //[1.0 to 5.0] how steep the color curve is at linear point. You need color curve understanding to know what this means, just experiment.
  324.  
  325. //COLORMOD
  326. #define ColormodChroma 0.78 // Saturation
  327. #define ColormodGammaR 1.05 // Gamma for Red color channel
  328. #define ColormodGammaG 1.05 // Gamma for Green color channel
  329. #define ColormodGammaB 1.05 // Gamma for Blue color channel
  330. #define ColormodContrastR 0.50 // Contrast for Red color channel
  331. #define ColormodContrastG 0.50 // ...
  332. #define ColormodContrastB 0.50 // ...
  333. #define ColormodBrightnessR -0.08 // Brightness for Red color channel
  334. #define ColormodBrightnessG -0.08 // ...
  335. #define ColormodBrightnessB -0.08 // ...
  336.  
  337. //SPHERICAL TONEMAP
  338. #define sphericalAmount 1.0 //[0.0 to 2.0] Amount of spherical tonemapping applied...sort of
  339.  
  340. //GODRAYS
  341. #define GODRAYDEPTHCHECK 1 //[0 or 1] if 1, only pixels with depth = 1 get godrays, this prevents white objects from getting godray source which would normally happen in LDR
  342. #define GodraySamples 128 //[2^x format] How many samples the godrays get
  343. #define GodrayDecay 0.96 //[0.5 to 0.9999] How fast they decay. It's logarithmic, 1.0 means infinite long rays which will cover whole screen
  344. #define GodrayExposure 1.0 //[0.7 to 1.5] Upscales the godray's brightness
  345. #define GodrayWeight 1.25 //[0.8 to 1.7] weighting
  346. #define GodrayDensity 1.0 //[0.2 to 2.0] Density of rays, higher means more and brighter rays
  347. #define GodrayThreshold 0.9 //[0.6 to 1.0] Minimum brightness an object must have to cast godrays
  348.  
  349. //ANAMORPHIC LENSFLARE
  350. #define ANAMFLAREDEPTHCHECK 1 //[0 or 1] if 1, only pixels with depth = 1 get an anamflare, this prevents white objects from getting flare source which would normally happen in LDR
  351. #define fFlareLuminance 0.95 //[0.6 to 1.0] bright pass luminance value
  352. #define fFlareBlur 200.0 // [1.0 to 9999999] manages the size of the flare
  353. #define fFlareIntensity 2.07 // [0.2 to 5.0] effect intensity
  354. #define fFlareTint float3(0.137, 0.216, 1.0) // [0.0 to 2.0] effect tint RGB
  355.  
  356. //CHROMATICABBERATION
  357. #define ChromaticAmount 0.009 //[0.005 to 0.03] Amount of color shifting
  358. #define LensSize 0.55 //[0.5 to 1.0] some lens zoom to hide bugged edges due to texcoord modification
  359. #define LensDistortion 0.05 //[-0.3 to 0.3] distortion of image, fish eye effect
  360. #define LensDistortionCubic 0.05 //[-0.3 to 0.3] distortion of image, fish eye effect, cube based
  361.  
  362. //LENZ FLARE
  363. #define LENZDEPTHCHECK 1 //[0 or 1] if 1, only pixels with depth = 1 get lens flare, this prevents white objects from getting flare source which would normally happen in LDR
  364. #define LenzIntensity 1.5 //[0.2 to 3.0] power of lens flare effect
  365. #define LenzThreshold 0.8 //[0.6 to 1.0] Minimum brightness an object must have to cast lensflare
  366.  
  367. //NOISE GRAIN
  368. #define fGrainMotion 0.001 //[0.0 to 0.1] speed of noise change rate, 0.0 means static noise
  369. #define fGrainSaturation 0.05 //[0.05 to 1.0] brightness and chroma difference between the single noise pixels, 0 would mean plain black image added to original image resulting in no noise at all.
  370. #define fGrainIntensity 0.05 //[0.05 to 1.0] Power of noise
  371.  
  372. #define GrainIntensityBright 0.0 //[0.0 to 2.0] Intensity of Grain in bright areas.
  373. #define GrainIntensityMid 0.0 //[0.0 to 2.0] Intensity of Grain in midtone areas.
  374. #define GrainIntensityDark 10.0 //[0.0 to 2.0] Intensity of Grain in dark areas.
  375.  
  376. //HD6VIGNETTE
  377. #define LEFTANDRIGHT 0 //[0 or 1] self-explaining, I think. Keep only one of these 3 booleans enabled!!
  378. #define TOPANDBOTTOM 1 //[0 or 1] self-explaining, I think. Keep only one of these 3 booleans enabled!!
  379. #define CORNERDARKEN 0 //[0 or 1] self-explaining, I think. Keep only one of these 3 booleans enabled!!
  380. #define SquareTop 0.58
  381. #define SquareBottom 0.58
  382. #define CircularPower 0.0 //[0.0 to 100000.0] amount of circularism (new word invented hoho), 0 means linear vignette, 100000.0 means rougly total circle
  383. #define ColorDistortion 0.0 //[0.0 to 5.0] distorts the colors a bit
  384. #define ContrastSharpen 11.6
  385. #define VignetteBorder 6.5
  386.  
  387. //STANDARDVIGNETTE
  388. #define EVignetteAmount 2.9 //[0.0 to 5.0] self-explaining variable name
  389. #define EVignetteCurve 1.5 //[0.0 to 5.0] self-explaining variable name
  390. #define EVignetteRadius 0.8 //[0.0 to 5.0] self-explaining variable name
  391. #define VIGNCOLORING 0 //[0 or 1] enables color override, RGB controls below.
  392. #define VIGNREDAMOUNT 0.0
  393. #define VIGNGREENAMOUNT 5.0
  394. #define VIGNBLUEAMOUNT 0.0
  395.  
  396. //COLOR HUE FX
  397. #define USE_COLORSAT 0 //[0 or 1] This will use original color saturation as an added limiter to the strength of the effect
  398. #define hueMid 0.6 //[0.0 to 1.0] Hue (rotation around the color wheel) of the color which you want to keep
  399. #define hueRange 0.1 //[0.0 to 1.0] Range of different hue's around the hueMid that will also kept. Using a max range of 1.0 will allow the reverse of the effect where it will only filter a specific hue to B&W
  400. #define satLimit 2.9 //[0.0 to 4.0] Saturation control, better keep it higher than 0 for strong colors in contrast to the gray stuff around
  401. #define fxcolorMix 0.8 //[0.0 to 1.0] Interpolation between the original and the effect, 0 means full original image, 1 means full grey-color image.
  402.  
  403.  
  404.  
  405. //+++++++++++++++++++++++++++++
  406.  
  407. uniform float4 Timer < string source = "framecount";>;
  408. uniform float4 Timer2 < string source = "timer";>;
  409. #define ScreenSize float4(BUFFER_WIDTH, BUFFER_RCP_WIDTH, float(BUFFER_WIDTH) / float(BUFFER_HEIGHT), float(BUFFER_HEIGHT) / float(BUFFER_WIDTH)) //x=Width, y=1/Width, z=ScreenScaleY, w=1/ScreenScaleY
  410. static const float3 LumCoeff = float3(0.212656, 0.715158, 0.072186);
  411. static const float PI = 3.1415972;
  412.  
  413. //textures
  414. texture2D texColor : COLOR;
  415.  
  416. texture texColorHDR1 { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; MipLevels = 1; Format = RGBA32F;}; //ping
  417. texture texColorHDR2 { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; MipLevels = 1; Format = RGBA32F;}; //pong
  418.  
  419. texture2D texDepth : DEPTH;
  420.  
  421. texture texBloom1 { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; MipLevels = 1; Format = RGBA32F;};
  422. texture texBloom2 { Width = BUFFER_WIDTH/2; Height = BUFFER_HEIGHT/2; MipLevels = 1;Format = RGBA32F;};
  423. texture texBloom3 { Width = BUFFER_WIDTH/4; Height = BUFFER_HEIGHT/4; MipLevels = 1;Format = RGBA32F;};
  424. texture texBloom4 { Width = BUFFER_WIDTH/8; Height = BUFFER_HEIGHT/8; MipLevels = 1;Format = RGBA32F;};
  425. texture texBloom5 { Width = BUFFER_WIDTH/16; Height = BUFFER_HEIGHT/16; MipLevels = 1;Format = RGBA32F;};
  426.  
  427. texture texNoise < string source = "mcnoise.png"; >
  428. {
  429. Width = 1920;
  430. Height = 1080;
  431. MipLevels = 1;
  432. Format = RGBA8;
  433. };
  434. texture texDirt < string source = "mcdirt.png"; >
  435. {
  436. Width = 1920;
  437. Height = 1080;
  438. MipLevels = 1;
  439. Format = RGBA8;
  440. };
  441. texture texLut < string source = "mclut.png"; >
  442. {
  443. Width = 256;
  444. Height = 1;
  445. MipLevels = 1;
  446. Format = RGBA8;
  447. };
  448.  
  449. sampler2D SamplerColorLDR
  450. {
  451. Texture = texColor;
  452. MinFilter = LINEAR;
  453. MagFilter = LINEAR;
  454. MipFilter = LINEAR;
  455. AddressU = Clamp;
  456. AddressV = Clamp;
  457. SRGBTexture=FALSE;
  458. MaxMipLevel=8;
  459. MipMapLodBias=0;
  460. };
  461.  
  462. sampler2D SamplerColorHDR1
  463. {
  464. Texture = texColorHDR1;
  465. MinFilter = LINEAR;
  466. MagFilter = LINEAR;
  467. MipFilter = LINEAR;
  468. AddressU = Clamp;
  469. AddressV = Clamp;
  470. SRGBTexture=FALSE;
  471. MaxMipLevel=8;
  472. MipMapLodBias=0;
  473. };
  474.  
  475. sampler2D SamplerColorHDR2
  476. {
  477. Texture = texColorHDR2;
  478. MinFilter = LINEAR;
  479. MagFilter = LINEAR;
  480. MipFilter = LINEAR;
  481. AddressU = Clamp;
  482. AddressV = Clamp;
  483. SRGBTexture=FALSE;
  484. MaxMipLevel=8;
  485. MipMapLodBias=0;
  486. };
  487.  
  488. sampler2D SamplerDepth
  489. {
  490. Texture = texDepth;
  491. MinFilter = LINEAR;
  492. MagFilter = LINEAR;
  493. MipFilter = NONE;
  494. AddressU = Clamp;
  495. AddressV = Clamp;
  496. SRGBTexture=FALSE;
  497. MaxMipLevel=0;
  498. MipMapLodBias=0;
  499. };
  500.  
  501. sampler2D SamplerNoise
  502. {
  503. Texture = texNoise;
  504. MinFilter = POINT;
  505. MagFilter = POINT;
  506. MipFilter = NONE;
  507. AddressU = Clamp;
  508. AddressV = Clamp;
  509. SRGBTexture=FALSE;
  510. MaxMipLevel=0;
  511. MipMapLodBias=0;
  512. };
  513.  
  514. sampler2D SamplerDirt
  515. {
  516. Texture = texDirt;
  517. MinFilter = LINEAR;
  518. MagFilter = LINEAR;
  519. MipFilter = NONE;
  520. AddressU = Clamp;
  521. AddressV = Clamp;
  522. SRGBTexture=FALSE;
  523. MaxMipLevel=0;
  524. MipMapLodBias=0;
  525. };
  526.  
  527. sampler2D SamplerLut
  528. {
  529. Texture = texLut;
  530. MinFilter = LINEAR;
  531. MagFilter = LINEAR;
  532. MipFilter = NONE;
  533. AddressU = Clamp;
  534. AddressV = Clamp;
  535. SRGBTexture=FALSE;
  536. MaxMipLevel=0;
  537. MipMapLodBias=0;
  538. };
  539.  
  540. sampler SamplerBloom1 { Texture = texBloom1; };
  541. sampler SamplerBloom2 { Texture = texBloom2; };
  542. sampler SamplerBloom3 { Texture = texBloom3; };
  543. sampler SamplerBloom4 { Texture = texBloom4; };
  544. sampler SamplerBloom5 { Texture = texBloom5; };
  545.  
  546. struct VS_OUTPUT_POST
  547. {
  548. float4 vpos : SV_Position;
  549. float2 txcoord : TEXCOORD0;
  550. };
  551.  
  552. struct VS_INPUT_POST
  553. {
  554. uint id : SV_VertexID;
  555. };
  556.  
  557. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  558. // Vertex shader
  559. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  560.  
  561. VS_OUTPUT_POST VS_PostProcess(VS_INPUT_POST IN)
  562. {
  563. VS_OUTPUT_POST OUT;
  564. OUT.txcoord.x = (IN.id == 2) ? 2.0 : 0.0;
  565. OUT.txcoord.y = (IN.id == 1) ? 2.0 : 0.0;
  566. OUT.vpos = float4(OUT.txcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
  567. return OUT;
  568. }
  569.  
  570. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  571. // Functions
  572. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  573.  
  574. float GrayScale (in float3 input)
  575. {
  576. return dot(input, float3(0.3, 0.59, 0.11));
  577. }
  578.  
  579. float random(in float2 uv)
  580. {
  581. float2 noise = (frac(sin(dot(uv , float2(12.9898,78.233) * 2.0)) * 43758.5453));
  582. return abs(noise.x + noise.y) * 0.5;
  583. }
  584.  
  585.  
  586. float Luminance( float3 c )
  587. {
  588. return dot( c, float3(0.22, 0.707, 0.071) );
  589. }
  590.  
  591. float vignette(float2 coord, float _int)
  592. {
  593. float2 coords = coord;
  594. coords = (coords - 0.5) * 2.0;
  595. float coordDot = dot (coords,coords);
  596. return 1.0 - coordDot * _int * 0.1;
  597. }
  598.  
  599. float linearize(float depth)
  600. {
  601. return -zfar * znear / (depth * (zfar - znear) - zfar);
  602. }
  603.  
  604. float2 rand(float2 coord) //generating noise/pattern texture for dithering
  605. {
  606. float noiseX = ((frac(3.0-coord.x*(ScreenSize.x/0.2))*3.25)+(frac(coord.y*(ScreenSize.x*ScreenSize.z/0.2))*3.75))*0.1-0.2;
  607. float noiseY = ((frac(3.0-coord.x*(ScreenSize.x/0.2))*3.75)+(frac(coord.y*(ScreenSize.x*ScreenSize.z/0.2))*3.25))*0.1-0.2;
  608.  
  609. return float2(noiseX,noiseY);
  610. }
  611.  
  612. #define fFlareAxis 0 // blur axis
  613. //people should not change that due to changes I made to the shader (blur in y direction so vertical flares would get no blur
  614. //too lazy to adapt that so I'll keep it here
  615.  
  616. float3 BrightPass(float2 tex)
  617. {
  618. float3 c = tex2D(SamplerColorHDR2, tex).rgb;
  619. float3 bC = max(c - float3(fFlareLuminance, fFlareLuminance, fFlareLuminance), 0.0);
  620. float bright = dot(bC, 1.0);
  621. bright = smoothstep(0.0f, 0.5, bright);
  622. float3 result = lerp(0.0, c, bright);
  623.  
  624. #if (ANAMFLAREDEPTHCHECK == 1)
  625. float checkdepth = tex2D(SamplerDepth, tex).x;
  626. if(checkdepth < 0.99999) result = 0;
  627. #endif
  628.  
  629. return result;
  630.  
  631. }
  632.  
  633. float3 AnamorphicSample(int axis, float2 tex, float blur)
  634. {
  635. tex = 2.0 * tex - 1.0;
  636. if (!axis) tex.x /= -blur;
  637. else tex.y /= -blur;
  638. tex = 0.5 * tex + 0.5;
  639. return BrightPass(tex);
  640. }
  641.  
  642. float mod(float x, float y)
  643. {
  644. return x - y * floor (x/y);
  645. }
  646.  
  647. float smootherstep(float edge0, float edge1, float x)
  648. {
  649. x = clamp((x - edge0)/(edge1 - edge0), 0.0, 1.0);
  650. return x*x*x*(x*(x*6 - 15) + 10);
  651. }
  652.  
  653. float3 Hue(in float3 RGB)
  654. {
  655. // Based on work by Sam Hocevar and Emil Persson
  656. float Epsilon = 1e-10;
  657. float4 P = (RGB.g < RGB.b) ? float4(RGB.bg, -1.0, 2.0/3.0) : float4(RGB.gb, 0.0, -1.0/3.0);
  658. float4 Q = (RGB.r < P.x) ? float4(P.xyw, RGB.r) : float4(RGB.r, P.yzx);
  659. float C = Q.x - min(Q.w, Q.y);
  660. float H = abs((Q.w - Q.y) / (6 * C + Epsilon) + Q.z);
  661. return float3(H, C, Q.x);
  662. }
  663. /*
  664. float4 ChromaticAberrationPass(float2 tex, float outOfFocus)
  665. {
  666. float d = distance(tex, float2(0.5, 0.5));
  667. float f = smoothstep(fBaseRadius, fFalloffRadius, d + outOfFocus * d);
  668. float3 chroma = pow(f + fvChroma, fChromaPower);
  669.  
  670. float2 tr = ((2.0 * tex - 1.0) * chroma.r) * 0.5 + 0.5;
  671. float2 tg = ((2.0 * tex - 1.0) * chroma.g) * 0.5 + 0.5;
  672. float2 tb = ((2.0 * tex - 1.0) * chroma.b) * 0.5 + 0.5;
  673.  
  674. float3 color = float3(tex2D(SamplerColor, tr).r, tex2D(SamplerColor, tg).g, tex2D(SamplerColor, tb).b) * (1.0 - f);
  675.  
  676. return float4(color, 1.0);
  677. }
  678. */
  679. float4 ChromaticAberrationFocusPass(float2 tex, float outOfFocus, sampler inputsampler)
  680. {
  681. float3 chroma = pow(fvChroma, CHROMA_POW * outOfFocus);
  682.  
  683. float2 tr = ((2.0 * tex - 1.0) * chroma.r) * 0.5 + 0.5;
  684. float2 tg = ((2.0 * tex - 1.0) * chroma.g) * 0.5 + 0.5;
  685. float2 tb = ((2.0 * tex - 1.0) * chroma.b) * 0.5 + 0.5;
  686.  
  687. float3 color = float3(tex2D(inputsampler, tr).r, tex2D(inputsampler, tg).g, tex2D(inputsampler, tb).b) * (1.0 - outOfFocus);
  688.  
  689. return float4(color, 1.0);
  690. }
  691.  
  692. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  693. // Passes
  694. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  695.  
  696. float penta(float2 coords) //pentagonal shape
  697. {
  698. float scale = float(rings) - 1.5;
  699. float4 HS0 = float4( -20.0, -15.0, -15.0, -20.0);
  700. float4 HS1 = float4( -20.0, -15.0, -15.0, -20.0);
  701. float4 HS2 = float4( -20.0, -15.0, -15.0, -20.0);
  702. float4 HS3 = float4( -20.0, -15.0, -15.0, -20.0);
  703. float4 HS4 = float4( -20.0, -15.0, -15.0, -20.0);
  704. float4 HS5 = float4( -20.0, -15.0, -15.0, -20.0);
  705.  
  706. float4 one = float4(8.0, 8.0, 8.0, 8.0);
  707.  
  708. float4 P = float4(coords,float2(scale, scale));
  709.  
  710. float4 dist = float4(4.0, 4.0, 4.0, 4.0);
  711. float inorout = 0.0;
  712.  
  713. dist.x = dot( P, HS0 );
  714. dist.y = dot( P, HS1 );
  715. dist.z = dot( P, HS2 );
  716. dist.w = dot( P, HS3 );
  717.  
  718. dist = smoothstep( -feather, feather, dist );
  719.  
  720. inorout += dot( dist, one );
  721.  
  722. dist.x = dot( P, HS4 );
  723. dist.y = HS5.w - abs( P.z );
  724.  
  725. dist = smoothstep( -feather, feather, dist );
  726. inorout += dist.x;
  727.  
  728. return saturate( inorout );
  729. }
  730.  
  731. float4 colorDof(float2 coords,float blur) //processing the sample
  732. {
  733. float4 colDF = float4(1,1,1,1);
  734.  
  735. float2 pixelsize = ScreenSize.y;
  736. pixelsize.y *= ScreenSize.z;
  737.  
  738. colDF.x = tex2Dlod(SamplerColorHDR1,float4(coords + float2(0.0,1.0)*pixelsize*fringe*blur,0,0)).x;
  739. colDF.y = tex2Dlod(SamplerColorHDR1,float4(coords + float2(-0.866,-0.5)*pixelsize*fringe*blur,0,0)).y;
  740. colDF.z = tex2Dlod(SamplerColorHDR1,float4(coords + float2(0.866,-0.5)*pixelsize*fringe*blur,0,0)).z;
  741.  
  742. float3 lumcoeff = float3(0.299,0.587,0.114);
  743. float lum = dot(colDF.xyz,lumcoeff);
  744. float thresh = max((lum-threshold)*gain, 0.0);
  745. float3 nullcol = float3(0,0,0);
  746. colDF.xyz +=max(0,lerp(nullcol.xyz,colDF.xyz,thresh*blur));
  747. return colDF;
  748. }
  749.  
  750. float3 ExplosionPass( float3 colorInput, float2 tex, float2 pixelsize )
  751. {
  752.  
  753. // -- pseudo random number generator --
  754. float2 sine_cosine;
  755. sincos(dot(tex, float2(12.9898,78.233)),sine_cosine.x,sine_cosine.y);
  756. sine_cosine = sine_cosine * 43758.5453 + tex;
  757. float2 noise = frac(sine_cosine);
  758.  
  759. tex = (-Explosion_Radius * pixelsize) + tex; //Slightly faster this way because it can be calculated while we calculate noise.
  760.  
  761. colorInput.rgb = tex2D(SamplerColorHDR2, (2.0 * Explosion_Radius * pixelsize) * noise + tex).rgb;
  762.  
  763.  
  764. return colorInput;
  765. }
  766.  
  767. float3 CartoonPass( float3 colorInput, float2 tex, float2 pixelsize )
  768. {
  769.  
  770. float diff1 = dot(LumCoeff,tex2D(SamplerColorHDR1, tex + pixelsize).rgb);
  771. diff1 = dot(float4(LumCoeff,-1.0),float4(tex2D(SamplerColorHDR1, tex - pixelsize).rgb , diff1));
  772.  
  773. float diff2 = dot(LumCoeff,tex2D(SamplerColorHDR1, tex +float2(pixelsize.x,-pixelsize.y)).rgb);
  774. diff2 = dot(float4(LumCoeff,-1.0),float4(tex2D(SamplerColorHDR1, tex +float2(-pixelsize.x,pixelsize.y)).rgb , diff2));
  775.  
  776. float edge = dot(float2(diff1,diff2),float2(diff1,diff2));
  777.  
  778. colorInput.rgb = pow(edge,CartoonEdgeSlope) * -CartoonPower + colorInput.rgb;
  779.  
  780. return saturate(colorInput);
  781. }
  782.  
  783. float3 SharpPass( float3 colorInput, float2 tex, float2 pixelsize )
  784. {
  785.  
  786. float3 blur_ori = tex2D(SamplerColorHDR1, tex + float2(0.5 * pixelsize.x,-pixelsize.y * SharpBias)).rgb*0.25; // South South East
  787. blur_ori += tex2D(SamplerColorHDR1, tex + float2(SharpBias * -pixelsize.x,0.5 * -pixelsize.y)).rgb*0.25; // West South West
  788. blur_ori += tex2D(SamplerColorHDR1, tex + float2(SharpBias * pixelsize.x,0.5 * pixelsize.y)).rgb*0.25; // East North East
  789. blur_ori += tex2D(SamplerColorHDR1, tex + float2(0.5 * -pixelsize.x,pixelsize.y * SharpBias)).rgb*0.25; // North North West
  790.  
  791. float3 sharp = colorInput - blur_ori;
  792. float sharp_luma = dot(sharp, SharpStrength);
  793.  
  794. sharp_luma = clamp(sharp_luma, -SharpClamp, SharpClamp);
  795.  
  796. float3 done = tex2D(SamplerColorHDR1, tex).rgb + sharp_luma;
  797.  
  798. colorInput = done;
  799.  
  800. return colorInput;
  801. }
  802.  
  803. float3 LevelsPass( float3 colorInput )
  804. {
  805. #define black_point_float ( Levels_black_point / 255.0 )
  806. #define white_point_float ( 255.0 / (Levels_white_point - Levels_black_point))
  807.  
  808. colorInput.rgb = colorInput.rgb * white_point_float - (black_point_float * white_point_float);
  809. return colorInput;
  810. }
  811.  
  812. float3 TechniPass_prod80(float3 colorInput)
  813. {
  814.  
  815. float3 colStrength = float3(ColStrengthR,ColStrengthG,ColStrengthB);
  816. float3 tsource = saturate(colorInput.rgb);
  817. float3 ttemp = 1 - tsource;
  818. float3 ttarget = ttemp.grg;
  819. float3 ttarget2 = ttemp.bbr;
  820. float3 ttemp2 = tsource.rgb * ttarget.rgb;
  821. ttemp2.rgb *= ttarget2.rgb;
  822.  
  823. ttemp.rgb = ttemp2.rgb * colStrength;
  824. ttemp2.rgb *= TechniBrightness;
  825.  
  826. ttarget.rgb = ttemp.grg;
  827. ttarget2.rgb = ttemp.bbr;
  828.  
  829. ttemp.rgb = tsource.rgb - ttarget.rgb;
  830. ttemp.rgb += ttemp2.rgb;
  831. ttemp2.rgb = ttemp.rgb - ttarget2.rgb;
  832.  
  833. colorInput.rgb = lerp(tsource.rgb, ttemp2.rgb, TechniStrength);
  834.  
  835. colorInput.rgb = lerp(dot(colorInput.rgb, 0.333), colorInput.rgb, TechniSat);
  836.  
  837. return colorInput.rgb;
  838.  
  839. }
  840.  
  841. float3 TechnicolorPass( float3 colorInput )
  842. {
  843.  
  844. #define cyanfilter float3(0.0, 1.30, 1.0)
  845. #define magentafilter float3(1.0, 0.0, 1.05)
  846. #define yellowfilter float3(1.6, 1.6, 0.05)
  847.  
  848. #define redorangefilter float2(1.05, 0.620) //RG_
  849. #define greenfilter float2(0.30, 1.0) //RG_
  850. #define magentafilter2 magentafilter.rb //R_B
  851.  
  852. float3 tcol = colorInput.rgb;
  853.  
  854. float2 rednegative_mul = tcol.rg * (1.0 / (redNegativeAmount * TechniPower));
  855. float2 greennegative_mul = tcol.rg * (1.0 / (greenNegativeAmount * TechniPower));
  856. float2 bluenegative_mul = tcol.rb * (1.0 / (blueNegativeAmount * TechniPower));
  857.  
  858. float rednegative = dot( redorangefilter, rednegative_mul );
  859. float greennegative = dot( greenfilter, greennegative_mul );
  860. float bluenegative = dot( magentafilter2, bluenegative_mul );
  861.  
  862. float3 redoutput = rednegative.rrr + cyanfilter;
  863. float3 greenoutput = greennegative.rrr + magentafilter;
  864. float3 blueoutput = bluenegative.rrr + yellowfilter;
  865.  
  866. float3 result = redoutput * greenoutput * blueoutput;
  867. colorInput.rgb = lerp(tcol, result, TechniAmount);
  868. return colorInput;
  869. }
  870.  
  871. float3 DPXPass(float3 InputColor){
  872.  
  873.  
  874. float3x3 RGB =
  875. float3x3(
  876. 2.67147117265996,-1.26723605786241,-0.410995602172227,
  877. -1.02510702934664,1.98409116241089,0.0439502493584124,
  878. 0.0610009456429445,-0.223670750812863,1.15902104167061
  879. );
  880.  
  881. float3x3 XYZ =
  882. float3x3(
  883. 0.500303383543316,0.338097573222739,0.164589779545857,
  884. 0.257968894274758,0.676195259144706,0.0658358459823868,
  885. 0.0234517888692628,0.1126992737203,0.866839673124201
  886. );
  887.  
  888. float DPXContrast = 0.1;
  889. float DPXGamma = 1.0;
  890.  
  891. float RedCurve = DPXRed;
  892. float GreenCurve = DPXGreen;
  893. float BlueCurve = DPXBlue;
  894.  
  895. float3 RGB_Curve = float3(DPXRed,DPXGreen,DPXBlue);
  896. float3 RGB_C = float3(DPXRedC,DPXGreenC,DPXBlueC);
  897.  
  898. float3 B = InputColor.rgb;
  899. B = pow(B, 1.0/DPXGamma);
  900. B = B * (1.0 - DPXContrast) + (0.5 * DPXContrast);
  901.  
  902. float3 Btemp = (1.0 / (1.0 + exp(RGB_Curve / 2.0)));
  903. B = ((1.0 / (1.0 + exp(-RGB_Curve * (B - RGB_C)))) / (-2.0 * Btemp + 1.0)) + (-Btemp / (-2.0 * Btemp + 1.0));
  904.  
  905. float value = max(max(B.r, B.g), B.b);
  906. float3 color = B / value;
  907. color = saturate(color);
  908. color = pow(color, 1.0/DPXColorGamma);
  909.  
  910. float3 c0 = color * value;
  911. c0 = mul(XYZ, c0);
  912.  
  913. float luma = dot(c0, float3(0.30, 0.59, 0.11)); //Use BT 709 instead?
  914. c0 = (1.0 - DPXSaturation) * luma + DPXSaturation * c0;
  915. c0 = mul(RGB, c0);
  916.  
  917. InputColor.rgb = lerp(InputColor.rgb, c0, DPXBlend);
  918.  
  919. return InputColor;
  920. }
  921.  
  922. float3 LiftGammaGainPass( float3 colorInput )
  923. {
  924. // -- Get input --
  925. float3 color = colorInput.rgb;
  926.  
  927. // -- Lift --
  928. color = color * (1.5-0.5 * RGB_Lift) + 0.5 * RGB_Lift - 0.5;
  929. color = saturate(color); //isn't strictly necessary, but doesn't cost performance.
  930.  
  931. // -- Gain --
  932. color *= RGB_Gain;
  933.  
  934. // -- Gamma --
  935. colorInput.rgb = pow(color, 1.0 / RGB_Gamma); //Gamma
  936.  
  937. // -- Return output --
  938. //return (colorInput);
  939. return saturate(colorInput);
  940. }
  941.  
  942. float3 TonemapPass( float3 colorInput )
  943. {
  944. float3 color = colorInput.rgb;
  945.  
  946. color = saturate(color - Defog * FogColor); // Defog
  947.  
  948. color *= pow(2.0f, Exposure); // Exposure
  949.  
  950. color = pow(color, Gamma); // Gamma -- roll into the first gamma correction in main.h ?
  951.  
  952. float lum = dot(LumCoeff, color.rgb);
  953.  
  954. float3 blend = lum.rrr; //dont use float3
  955.  
  956. float L = saturate( 10.0 * (lum - 0.45) );
  957.  
  958. float3 result1 = 2.0f * color.rgb * blend;
  959. float3 result2 = 1.0f - 2.0f * (1.0f - blend) * (1.0f - color.rgb);
  960.  
  961. float3 newColor = lerp(result1, result2, L);
  962. float3 A2 = Bleach * color.rgb; //why use a float for A2 here and then multiply by color.rgb (a float3)?
  963. float3 mixRGB = A2 * newColor;
  964.  
  965. color.rgb += ((1.0f - A2) * mixRGB);
  966.  
  967. float3 middlegray = dot(color,(1.0/3.0)); //1fps slower than the original on nvidia, 2 fps faster on AMD
  968.  
  969. float3 diffcolor = color - middlegray; //float 3 here
  970. colorInput.rgb = (color + diffcolor * Saturation)/(1+(diffcolor*Saturation)); //saturation
  971.  
  972. return colorInput;
  973. }
  974.  
  975. float3 VibrancePass( float3 colorInput )
  976. {
  977. #define Vibrance_coeff float3(Vibrance_RGB_balance * Vibrance)
  978.  
  979. float3 color = colorInput; //original input color
  980. float3 lumCoeff = float3(0.212656, 0.715158, 0.072186); //Values to calculate luma with
  981.  
  982. float luma = dot(LumCoeff, color.rgb); //calculate luma (grey)
  983.  
  984. float max_color = max(colorInput.r, max(colorInput.g,colorInput.b)); //Find the strongest color
  985. float min_color = min(colorInput.r, min(colorInput.g,colorInput.b)); //Find the weakest color
  986.  
  987. float color_saturation = max_color - min_color; //The difference between the two is the saturation
  988.  
  989. color.rgb = lerp(luma, color.rgb, (1.0 + (Vibrance_coeff * (1.0 - (sign(Vibrance_coeff) * color_saturation))))); //extrapolate between luma and original by 1 + (1-saturation) - current
  990.  
  991. return color; //return the result
  992. }
  993.  
  994. float3 CurvesPass( float3 colorInput )
  995. {
  996. float Curves_contrast_blend = Curves_contrast;
  997.  
  998.  
  999. /*-----------------------------------------------------------.
  1000. / Separation of Luma and Chroma /
  1001. '-----------------------------------------------------------*/
  1002.  
  1003. // -- Calculate Luma and Chroma if needed --
  1004. #if Curves_mode != 2
  1005.  
  1006. //calculate luma (grey)
  1007. float luma = dot(LumCoeff, colorInput.rgb);
  1008.  
  1009. //calculate chroma
  1010. float3 chroma = colorInput.rgb - luma;
  1011. #endif
  1012.  
  1013. // -- Which value to put through the contrast formula? --
  1014. // I name it x because makes it easier to copy-paste to Graphtoy or Wolfram Alpha or another graphing program
  1015. #if Curves_mode == 2
  1016. float3 x = colorInput.rgb; //if the curve should be applied to both Luma and Chroma
  1017. #elif Curves_mode == 1
  1018. float3 x = chroma; //if the curve should be applied to Chroma
  1019. x = x * 0.5 + 0.5; //adjust range of Chroma from -1 -> 1 to 0 -> 1
  1020. #else // Curves_mode == 0
  1021. float x = luma; //if the curve should be applied to Luma
  1022. #endif
  1023.  
  1024. /*-----------------------------------------------------------.
  1025. / Contrast formulas /
  1026. '-----------------------------------------------------------*/
  1027.  
  1028. // -- Curve 1 --
  1029. #if Curves_formula == 1
  1030. x = sin(PI * 0.5 * x); // Sin - 721 amd fps, +vign 536 nv
  1031. x *= x;
  1032.  
  1033. //x = 0.5 - 0.5*cos(PI*x);
  1034. //x = 0.5 * -sin(PI * -x + (PI*0.5)) + 0.5;
  1035. #endif
  1036.  
  1037. // -- Curve 2 --
  1038. #if Curves_formula == 2
  1039. x = x - 0.5;
  1040. x = ( x / (0.5 + abs(x)) ) + 0.5;
  1041.  
  1042. //x = ( (x - 0.5) / (0.5 + abs(x-0.5)) ) + 0.5;
  1043. #endif
  1044.  
  1045. // -- Curve 3 --
  1046. #if Curves_formula == 3
  1047. //x = smoothstep(0.0,1.0,x); //smoothstep
  1048. x = x*x*(3.0-2.0*x); //faster smoothstep alternative - 776 amd fps, +vign 536 nv
  1049. //x = x - 2.0 * (x - 1.0) * x* (x- 0.5); //2.0 is contrast. Range is 0.0 to 2.0
  1050. #endif
  1051.  
  1052. // -- Curve 4 --
  1053. #if Curves_formula == 4
  1054. x = (1.0524 * exp(6.0 * x) - 1.05248) / (20.0855 + exp(6.0 * x)); //exp formula
  1055. #endif
  1056.  
  1057. // -- Curve 5 --
  1058. #if Curves_formula == 5
  1059. //x = 0.5 * (x + 3.0 * x * x - 2.0 * x * x * x); //a simplified catmull-rom (0,0,1,1) - btw smoothstep can also be expressed as a simplified catmull-rom using (1,0,1,0)
  1060. //x = (0.5 * x) + (1.5 -x) * x*x; //estrin form - faster version
  1061. x = x * (x * (1.5-x) + 0.5); //horner form - fastest version
  1062.  
  1063. Curves_contrast_blend = Curves_contrast * 2.0; //I multiply by two to give it a strength closer to the other curves.
  1064. #endif
  1065.  
  1066. // -- Curve 6 --
  1067. #if Curves_formula == 6
  1068. x = x*x*x*(x*(x*6.0 - 15.0) + 10.0); //Perlins smootherstep
  1069. #endif
  1070.  
  1071. // -- Curve 7 --
  1072. #if Curves_formula == 7
  1073. //x = ((x-0.5) / ((0.5/(4.0/3.0)) + abs((x-0.5)*1.25))) + 0.5;
  1074. x = x - 0.5;
  1075. x = x / ((abs(x)*1.25) + 0.375 ) + 0.5;
  1076. //x = ( (x-0.5) / ((abs(x-0.5)*1.25) + (0.5/(4.0/3.0))) ) + 0.5;
  1077. #endif
  1078.  
  1079. // -- Curve 8 --
  1080. #if Curves_formula == 8
  1081. x = (x * (x * (x * (x * (x * (x * (1.6 * x - 7.2) + 10.8) - 4.2) - 3.6) + 2.7) - 1.8) + 2.7) * x * x; //Techicolor Cinestyle - almost identical to curve 1
  1082. #endif
  1083.  
  1084. // -- Curve 9 --
  1085. #if Curves_formula == 9
  1086. x = -0.5 * (x*2.0-1.0) * (abs(x*2.0-1.0)-2.0) + 0.5; //parabola
  1087. #endif
  1088.  
  1089. // -- Curve 10 --
  1090. #if Curves_formula == 10 //Half-circles
  1091.  
  1092. #if Curves_mode == 0
  1093. float xstep = step(x,0.5);
  1094. float xstep_shift = (xstep - 0.5);
  1095. float shifted_x = x + xstep_shift;
  1096. #else
  1097. float3 xstep = step(x,0.5);
  1098. float3 xstep_shift = (xstep - 0.5);
  1099. float3 shifted_x = x + xstep_shift;
  1100. #endif
  1101.  
  1102. x = abs(xstep - sqrt(-shifted_x * shifted_x + shifted_x) ) - xstep_shift;
  1103.  
  1104. //x = abs(step(x,0.5)-sqrt(-(x+step(x,0.5)-0.5)*(x+step(x,0.5)-0.5)+(x+step(x,0.5)-0.5)))-(step(x,0.5)-0.5); //single line version of the above
  1105.  
  1106. //x = 0.5 + (sign(x-0.5)) * sqrt(0.25-(x-trunc(x*2))*(x-trunc(x*2))); //worse
  1107.  
  1108. /* // if/else - even worse
  1109. if (x-0.5)
  1110. x = 0.5-sqrt(0.25-x*x);
  1111. else
  1112. x = 0.5+sqrt(0.25-(x-1)*(x-1));
  1113. */
  1114.  
  1115. //x = (abs(step(0.5,x)-clamp( 1-sqrt(1-abs(step(0.5,x)- frac(x*2%1)) * abs(step(0.5,x)- frac(x*2%1))),0 ,1))+ step(0.5,x) )*0.5; //worst so far
  1116.  
  1117. //TODO: Check if I could use an abs split instead of step. It might be more efficient
  1118.  
  1119. Curves_contrast_blend = Curves_contrast * 0.5; //I divide by two to give it a strength closer to the other curves.
  1120. #endif
  1121.  
  1122. // -- Curve 11 --
  1123. #if Curves_formula == 11 //Cubic catmull
  1124. float a = 1.00; //control point 1
  1125. float b = 0.00; //start point
  1126. float c = 1.00; //endpoint
  1127. float d = 0.20; //control point 2
  1128. x = 0.5 * ((-a + 3*b -3*c + d)*x*x*x + (2*a -5*b + 4*c - d)*x*x + (-a+c)*x + 2*b); //A customizable cubic catmull-rom spline
  1129. #endif
  1130.  
  1131. // -- Curve 12 --
  1132. #if Curves_formula == 12 //Cubic Bezier spline
  1133. float a = 0.00; //start point
  1134. float b = 0.00; //control point 1
  1135. float c = 1.00; //control point 2
  1136. float d = 1.00; //endpoint
  1137.  
  1138. float r = (1-x);
  1139. float r2 = r*r;
  1140. float r3 = r2 * r;
  1141. float x2 = x*x;
  1142. float x3 = x2*x;
  1143. //x = dot(float4(a,b,c,d),float4(r3,3*r2*x,3*r*x2,x3));
  1144.  
  1145. //x = a * r*r*r + r * (3 * b * r * x + 3 * c * x*x) + d * x*x*x;
  1146. //x = a*(1-x)*(1-x)*(1-x) +(1-x) * (3*b * (1-x) * x + 3 * c * x*x) + d * x*x*x;
  1147. x = a*(1-x)*(1-x)*(1-x) + 3*b*(1-x)*(1-x)*x + 3*c*(1-x)*x*x + d*x*x*x;
  1148. #endif
  1149.  
  1150. // -- Curve 13 --
  1151. #if Curves_formula == 13 //Cubic Bezier spline - alternative implementation.
  1152. float3 a = float3(0.00,0.00,0.00); //start point
  1153. float3 b = float3(0.25,0.15,0.85); //control point 1
  1154. float3 c = float3(0.75,0.85,0.15); //control point 2
  1155. float3 d = float3(1.00,1.00,1.00); //endpoint
  1156.  
  1157. float3 ab = lerp(a,b,x); // point between a and b
  1158. float3 bc = lerp(b,c,x); // point between b and c
  1159. float3 cd = lerp(c,d,x); // point between c and d
  1160. float3 abbc = lerp(ab,bc,x); // point between ab and bc
  1161. float3 bccd = lerp(bc,cd,x); // point between bc and cd
  1162. float3 dest = lerp(abbc,bccd,x); // point on the bezier-curve
  1163. x = dest;
  1164. #endif
  1165.  
  1166. // -- Curve 14 --
  1167. #if Curves_formula == 14
  1168. x = 1.0 / (1.0 + exp(-(x * 10.0 - 5.0))); //alternative exp formula
  1169. #endif
  1170.  
  1171. /*-----------------------------------------------------------.
  1172. / Joining of Luma and Chroma /
  1173. '-----------------------------------------------------------*/
  1174.  
  1175. #if Curves_mode == 2 //Both Luma and Chroma
  1176. float3 color = x; //if the curve should be applied to both Luma and Chroma
  1177. colorInput.rgb = lerp(colorInput.rgb, color, Curves_contrast_blend); //Blend by Curves_contrast
  1178.  
  1179. #elif Curves_mode == 1 //Only Chroma
  1180. x = x * 2.0 - 1.0; //adjust the Chroma range back to -1 -> 1
  1181. float3 color = luma + x; //Luma + Chroma
  1182. colorInput.rgb = lerp(colorInput.rgb, color, Curves_contrast_blend); //Blend by Curves_contrast
  1183.  
  1184. #else // Curves_mode == 0 //Only Luma
  1185. x = lerp(luma, x, Curves_contrast_blend); //Blend by Curves_contrast
  1186. colorInput.rgb = x + chroma; //Luma + Chroma
  1187.  
  1188. #endif
  1189.  
  1190. //Return the result
  1191. return colorInput;
  1192. }
  1193.  
  1194. float3 SepiaPass( float3 colorInput )
  1195. {
  1196. float3 sepia = colorInput.rgb;
  1197.  
  1198. // calculating amounts of input, grey and sepia colors to blend and combine
  1199. float grey = dot(sepia, LumCoeff);
  1200. sepia *= ColorTone;
  1201.  
  1202. float3 blend2 = (grey * GreyPower) + (colorInput.rgb / (GreyPower + 1));
  1203.  
  1204. colorInput.rgb = lerp(blend2, sepia, SepiaPower);
  1205. // returning the final color
  1206. return colorInput;
  1207. }
  1208.  
  1209. float3 SkyrimTonemapPass( float3 color )
  1210. {
  1211. float grayadaptation = dot(color.xyz, LumCoeff);
  1212.  
  1213. #if (POSTPROCESS==1)
  1214. color.xyz = color.xyz / (grayadaptation * EAdaptationMaxV1 + EAdaptationMinV1);
  1215. float cgray = dot( color.xyz, LumCoeff);
  1216. cgray = pow(cgray, EContrastV1);
  1217. float3 poweredcolor = pow( abs(color.xyz), EColorSaturationV1);
  1218. float newgray = dot(poweredcolor.xyz, LumCoeff);
  1219. color.xyz = poweredcolor.xyz * cgray / (newgray + 0.0001);
  1220. float3 luma = color.xyz;
  1221. float lumamax = 300.0;
  1222. color.xyz = ( color.xyz * (1.0 + color.xyz / lumamax)) / ( color.xyz + EToneMappingCurveV1);
  1223. #endif
  1224.  
  1225. #if (POSTPROCESS==2)
  1226. color.xyz = color.xyz / (grayadaptation * EAdaptationMaxV2 + EAdaptationMinV2);
  1227. float3 xncol = normalize( color.xyz);
  1228. float3 scl = color.xyz / xncol.xyz;
  1229. scl = pow(scl, EIntensityContrastV2);
  1230. xncol.xyz = pow(xncol.xyz, EColorSaturationV2);
  1231. color.xyz = scl*xncol.xyz;
  1232. float lumamax = EToneMappingOversaturationV2;
  1233. color.xyz = ( color.xyz * (1.0 + color.xyz / lumamax)) / ( color.xyz + EToneMappingCurveV2);
  1234. color.xyz*=4;
  1235. #endif
  1236.  
  1237. #if (POSTPROCESS==3)
  1238. color.xyz *= 35;
  1239. float lumamax = EToneMappingOversaturationV3;
  1240. color.xyz = ( color.xyz * (1.0 + color.xyz / lumamax)) / ( color.xyz + EToneMappingCurveV3);
  1241. #endif
  1242.  
  1243. #if (POSTPROCESS == 4)
  1244. color.xyz = color.xyz / (grayadaptation * EAdaptationMaxV4 + EAdaptationMinV4);
  1245. float Y = dot( color.xyz, float3(0.299, 0.587, 0.114)); //0.299 * R + 0.587 * G + 0.114 * B;
  1246. float U = dot( color.xyz, float3(-0.14713, -0.28886, 0.436)); //-0.14713 * R - 0.28886 * G + 0.436 * B;
  1247. float V = dot( color.xyz, float3(0.615, -0.51499, -0.10001)); //0.615 * R - 0.51499 * G - 0.10001 * B;
  1248. Y = pow(Y, EBrightnessCurveV4);
  1249. Y = Y * EBrightnessMultiplierV4;
  1250. color.xyz = V * float3(1.13983, -0.58060, 0.0) + U * float3(0.0, -0.39465, 2.03211) + Y;
  1251. color.xyz = max( color.xyz, 0.0);
  1252. color.xyz = color.xyz / ( color.xyz + EBrightnessToneMappingCurveV4);
  1253. #endif
  1254.  
  1255. #if (POSTPROCESS == 5)
  1256. float hnd = 1;
  1257. float2 hndtweak = float2( 3.1 , 1.5 );
  1258. color.xyz *= lerp( hndtweak.x, hndtweak.y, hnd );
  1259. float3 xncol = normalize( color.xyz);
  1260. float3 scl = color.xyz/xncol.xyz;
  1261. scl = pow(scl, EIntensityContrastV5);
  1262. xncol.xyz = pow(xncol.xyz, EColorSaturationV5);
  1263. color.xyz = scl*xncol.xyz;
  1264. color.xyz *= HCompensateSatV5; // compensate for darkening caused my EcolorSat above
  1265. color.xyz = color.xyz / ( color.xyz + EToneMappingCurveV5);
  1266. color.xyz *= 4;
  1267. #endif
  1268.  
  1269. #if (POSTPROCESS==6)
  1270. //Postprocessing V6 by Kermles
  1271. //tuned by the master himself for ME 1.4, thanks man!!!
  1272. //hd6/ppv2///////////////////////////////////////////
  1273. float EIntensityContrastV6 = EIntensityContrastV6Day;
  1274. float EColorSaturationV6 = EColorSaturationV6Day;
  1275. float HCompensateSatV6 = HCompensateSatV6Day;
  1276. float EToneMappingCurveV6 = EToneMappingCurveV6Day;
  1277. float EBrightnessV6 = EBrightnessV6Day;
  1278. float EToneMappingOversaturationV6 = EToneMappingOversaturationV6Day;
  1279. float EAdaptationMaxV6 = EAdaptationMaxV6Day;
  1280. float EAdaptationMinV6 = EAdaptationMinV6Day;
  1281. float lumamax = EToneMappingOversaturationV6;
  1282. //kermles////////////////////////////////////////////
  1283. float4 ncolor; //temporary variable for color adjustments
  1284. //begin pp code/////////////////////////////////////////////////
  1285. //ppv2 modified by kermles//////////////////////////////////////
  1286.  
  1287. grayadaptation = clamp(grayadaptation, 0, 50);
  1288. color.xyz *= EBrightnessV6;
  1289. float3 xncol = normalize( color.xyz);
  1290. float3 scl = color.xyz/xncol.xyz;
  1291. scl = pow(saturate(scl), EIntensityContrastV6);
  1292. xncol.xyz = pow(xncol.xyz, EColorSaturationV6);
  1293. color.xyz = scl*xncol.xyz;
  1294. color.xyz *= HCompensateSatV6;
  1295. color.xyz = ( color.xyz * (1.0 + color.xyz/lumamax))/( color.xyz + EToneMappingCurveV6);
  1296. color.xyz /= grayadaptation*EAdaptationMaxV6+EAdaptationMinV6;
  1297. //rerun ppv2////////////////////////////////////////////////////
  1298. color.xyz *= EBrightnessV6;
  1299. xncol = normalize( color.xyz);
  1300. scl = color.xyz/xncol.xyz;
  1301. scl = saturate(scl);
  1302. scl = pow(scl, EIntensityContrastV6);
  1303. xncol.xyz = pow(xncol.xyz, EColorSaturationV6);
  1304. color.xyz = scl*xncol.xyz;
  1305. color.xyz *= HCompensateSatV6;
  1306. color.xyz = ( color.xyz * (1.0 + color.xyz/lumamax))/( color.xyz + EToneMappingCurveV6);
  1307. #endif
  1308.  
  1309. return color;
  1310.  
  1311. }
  1312.  
  1313. float3 MoodPass( float3 colorInput )
  1314. {
  1315. float3 colInput = colorInput;
  1316. float3 colMood = 1.0f;
  1317. colMood.r = moodR;
  1318. colMood.g = moodG;
  1319. colMood.b = moodB;
  1320. float fLum = ( colInput.r + colInput.g + colInput.b ) / 3;
  1321. colMood = lerp(0, colMood, saturate(fLum * 2.0));
  1322. colMood = lerp(colMood, 1, saturate(fLum - 0.5) * 2.0);
  1323. float3 colOutput = lerp(colInput, colMood, saturate(fLum * fRatio));
  1324. colorInput=max(0, colOutput);
  1325. return colorInput;
  1326. }
  1327.  
  1328. float3 CrossPass(float3 color)
  1329. {
  1330. float2 CrossMatrix [3] = {
  1331. float2 (1.03, 0.04),
  1332. float2 (1.09, 0.01),
  1333. float2 (0.78, 0.13),
  1334. };
  1335.  
  1336. float3 image1 = color;
  1337. float3 image2 = color;
  1338. float gray = dot(float3(0.5,0.5,0.5), image1);
  1339. image1 = lerp (gray, image1,CrossSaturation);
  1340. image1 = lerp (0.35, image1,CrossContrast);
  1341. image1 +=CrossBrightness;
  1342. image2.r = image1.r * CrossMatrix[0].x + CrossMatrix[0].y;
  1343. image2.g = image1.g * CrossMatrix[1].x + CrossMatrix[1].y;
  1344. image2.b = image1.b * CrossMatrix[2].x + CrossMatrix[2].y;
  1345. color = lerp(image1, image2, CrossAmount);
  1346. return color;
  1347. }
  1348.  
  1349. float3 FilmPass(float3 B)
  1350. {
  1351. float3 G = B;
  1352. float3 H = 0.01;
  1353.  
  1354. B = saturate(B);
  1355. B = pow(B, Linearization);
  1356. B = lerp(H, B, Contrast);
  1357.  
  1358. float A = dot(B.rgb, LumCoeff);
  1359. float3 D = A;
  1360.  
  1361. B = pow(B, 1.0 / BaseGamma);
  1362.  
  1363. float a = FRedCurve;
  1364. float b = FGreenCurve;
  1365. float c = FBlueCurve;
  1366. float d = BaseCurve;
  1367.  
  1368. float y = 1.0 / (1.0 + exp(a / 2.0));
  1369. float z = 1.0 / (1.0 + exp(b / 2.0));
  1370. float w = 1.0 / (1.0 + exp(c / 2.0));
  1371. float v = 1.0 / (1.0 + exp(d / 2.0));
  1372.  
  1373. float3 C = B;
  1374.  
  1375. D.r = (1.0 / (1.0 + exp(-a * (D.r - 0.5))) - y) / (1.0 - 2.0 * y);
  1376. D.g = (1.0 / (1.0 + exp(-b * (D.g - 0.5))) - z) / (1.0 - 2.0 * z);
  1377. D.b = (1.0 / (1.0 + exp(-c * (D.b - 0.5))) - w) / (1.0 - 2.0 * w);
  1378.  
  1379. D = pow(D, 1.0 / EffectGamma);
  1380.  
  1381. float3 Di = 1.0 - D;
  1382.  
  1383. D = lerp(D, Di, FBleach);
  1384.  
  1385. D.r = pow(abs(D.r), 1.0 / EffectGammaR);
  1386. D.g = pow(abs(D.g), 1.0 / EffectGammaG);
  1387. D.b = pow(abs(D.b), 1.0 / EffectGammaB);
  1388.  
  1389. if (D.r < 0.5)
  1390. C.r = (2.0 * D.r - 1.0) * (B.r - B.r * B.r) + B.r;
  1391. else
  1392. C.r = (2.0 * D.r - 1.0) * (sqrt(B.r) - B.r) + B.r;
  1393.  
  1394. if (D.g < 0.5)
  1395. C.g = (2.0 * D.g - 1.0) * (B.g - B.g * B.g) + B.g;
  1396. else
  1397. C.g = (2.0 * D.g - 1.0) * (sqrt(B.g) - B.g) + B.g;
  1398. //if (AgainstAllAutority)
  1399. if (D.b < 0.5)
  1400. C.b = (2.0 * D.b - 1.0) * (B.b - B.b * B.b) + B.b;
  1401. else
  1402. C.b = (2.0 * D.b - 1.0) * (sqrt(B.b) - B.b) + B.b;
  1403.  
  1404. float3 F = lerp(B, C, Strenght);
  1405.  
  1406. F = (1.0 / (1.0 + exp(-d * (F - 0.5))) - v) / (1.0 - 2.0 * v);
  1407.  
  1408. float r2R = 1.0 - FSaturation;
  1409. float g2R = 0.0 + FSaturation;
  1410. float b2R = 0.0 + FSaturation;
  1411.  
  1412. float r2G = 0.0 + FSaturation;
  1413. float g2G = (1.0 - Fade) - FSaturation;
  1414. float b2G = (0.0 + Fade) + FSaturation;
  1415.  
  1416. float r2B = 0.0 + FSaturation;
  1417. float g2B = (0.0 + Fade) + FSaturation;
  1418. float b2B = (1.0 - Fade) - FSaturation;
  1419.  
  1420. float3 iF = F;
  1421.  
  1422. F.r = (iF.r * r2R + iF.g * g2R + iF.b * b2R);
  1423. F.g = (iF.r * r2G + iF.g * g2G + iF.b * b2G);
  1424. F.b = (iF.r * r2B + iF.g * g2B + iF.b * b2B);
  1425.  
  1426. float N = dot(F.rgb, LumCoeff);
  1427. float3 Cn = F;
  1428.  
  1429. if (N < 0.5)
  1430. Cn = (2.0 * N - 1.0) * (F - F * F) + F;
  1431. else
  1432. Cn = (2.0 * N - 1.0) * (sqrt(F) - F) + F;
  1433.  
  1434. Cn = pow(max(Cn,0), 1.0 / Linearization);
  1435.  
  1436. float3 Fn = lerp(B, Cn, Strenght);
  1437. return Fn;
  1438. }
  1439.  
  1440. float3 ReinhardToneMapping(in float3 x)
  1441. {
  1442. const float W = ReinhardWhitepoint; // Linear White Point Value
  1443. const float K = ReinhardScale; // Scale
  1444.  
  1445. // gamma space or not?
  1446. return (1 + K * x / (W * W)) * x / (x + K);
  1447. }
  1448.  
  1449. float3 ReinhardLinearToneMapping(in float3 x)
  1450. {
  1451. const float W = ReinhardLinearWhitepoint; // Linear White Point Value
  1452. const float L = ReinhardLinearPoint; // Linear point
  1453. const float C = ReinhardLinearSlope; // Slope of the linear section
  1454. const float K = (1 - L * C) / C; // Scale (fixed so that the derivatives of the Reinhard and linear functions are the same at x = L)
  1455. float3 reinhard = L * C + (1 - L * C) * (1 + K * (x - L) / ((W - L) * (W - L))) * (x - L) / (x - L + K);
  1456.  
  1457. // gamma space or not?
  1458. return (x > L) ? reinhard : C * x;
  1459. }
  1460.  
  1461. float3 HaarmPeterDuikerFilmicToneMapping(in float3 x)
  1462. {
  1463. x = max( (float3)0.0f, x - 0.004f );
  1464. return pow( abs( ( x * ( 6.2f * x + 0.5f ) ) / ( x * ( 6.2f * x + 1.7f ) + 0.06 ) ), 2.2f );
  1465. }
  1466.  
  1467. float3 CustomToneMapping(in float3 x)
  1468. {
  1469. const float A = 0.665f;
  1470. const float B = 0.09f;
  1471. const float C = 0.004f;
  1472. const float D = 0.445f;
  1473. const float E = 0.26f;
  1474. const float F = 0.025f;
  1475. const float G = 0.16f;//0.145f;
  1476. const float H = 1.1844f;//1.15f;
  1477.  
  1478. // gamma space or not?
  1479. return (((x*(A*x+B)+C)/(x*(D*x+E)+F))-G) / H;
  1480. }
  1481.  
  1482. float3 ColormodPass( float3 color )
  1483. {
  1484. color.xyz = (color.xyz - dot(color.xyz, 0.333)) * ColormodChroma + dot(color.xyz, 0.333);
  1485. color.xyz = saturate(color.xyz);
  1486. color.x = (pow(color.x, ColormodGammaR) - 0.5) * ColormodContrastR + 0.5 + ColormodBrightnessR;
  1487. color.y = (pow(color.y, ColormodGammaG) - 0.5) * ColormodContrastG + 0.5 + ColormodBrightnessB;
  1488. color.z = (pow(color.z, ColormodGammaB) - 0.5) * ColormodContrastB + 0.5 + ColormodBrightnessB;
  1489. return color;
  1490. }
  1491.  
  1492. float3 SphericalPass( float3 color )
  1493. {
  1494. float3 signedColor = color.rgb * 2.0 - 1.0;
  1495. float3 sphericalColor = sqrt(1.0 - signedColor.rgb * signedColor.rgb);
  1496. sphericalColor = sphericalColor * 0.5 + 0.5;
  1497. sphericalColor *= color.rgb;
  1498. color.rgb += sphericalColor.rgb * sphericalAmount;
  1499. color.rgb *= 0.95;
  1500. return color;
  1501. }
  1502.  
  1503. float4 LeiFX_Reduct( float4 colorInput, float2 tex )
  1504. {
  1505.  
  1506. float2 res;
  1507. res.x = ScreenSize.x;
  1508. res.y = ScreenSize.x*ScreenSize.z;
  1509. float2 what;
  1510. what.x = 1 / ScreenSize.x;
  1511. what.y = 1 / (ScreenSize.x*ScreenSize.z);
  1512.  
  1513. float2 dithet = tex.xy * res.xy;
  1514.  
  1515. dithet.x = tex.x * res.x;
  1516. dithet.y = tex.y * res.y;
  1517.  
  1518. float2 ditheu = tex.xy * res.xy;
  1519.  
  1520. ditheu.x = tex.x * res.x;
  1521. ditheu.y = tex.y * res.y;
  1522.  
  1523. // 2x2 matrix?
  1524.  
  1525. float vertline1 = (mod(dithet.x, 2.0));
  1526. float vertline2 = (mod(dithet.x+1, 2.0));
  1527. float vertline3 = (mod(dithet.x+1, 4.0));
  1528. float vertline4 = (mod(dithet.x+1, 4.0));
  1529. float vertline5 = (mod(dithet.x-1, 4.0));
  1530. float horzline1 = (mod(dithet.y, 2.0));
  1531. float horzline2 = (mod(dithet.y+1, 2.0));
  1532. float horzline3 = (mod(dithet.y, 4.0));
  1533. float horzline4 = (mod(dithet.y+1, 4.0));
  1534. float horzline5 = (mod(dithet.y-1, 4.0));
  1535.  
  1536. float vertline3a = (mod(dithet.x+3, 4.0));
  1537. float horzline3a = (mod(dithet.y+2, 4.0));
  1538.  
  1539.  
  1540. float dithone = vertline1 + horzline2;
  1541. float dithtwo = vertline2 + horzline1;
  1542. float diththree = vertline3 + horzline3;
  1543. float dithfour = vertline4 + horzline5;
  1544. float dithfive = vertline3 + horzline3;
  1545. float dithsix = vertline3 + horzline3;
  1546. float dithsixy = vertline3a + horzline3a;
  1547.  
  1548. float3 ditherX, dithero, ditherv, ditherg, ditherx;
  1549.  
  1550. dithone = dithone * 0.3;
  1551. dithtwo = dithtwo * 0.3 + 1;
  1552. dithone *= dithtwo;
  1553.  
  1554. dithfour = dithfour * 0.3;
  1555. dithfour *= dithfive;
  1556.  
  1557.  
  1558. dithsix *= dithtwo;
  1559. dithsixy *= dithtwo;
  1560.  
  1561. dithfive *= dithtwo;
  1562.  
  1563. dithfour = pow(dithfour, 2.0f);
  1564.  
  1565.  
  1566. // Lamest crudest 'dither matrix' ever.
  1567.  
  1568. // The estimated dither pattern
  1569.  
  1570. // . X . o . X . o . X . o . X
  1571. // v g x . v g x . v g x . v g
  1572. // . o . o . o . o . o . o . o
  1573. // x . v g x . v g x . v g x .
  1574. // . X . o . X . o . X . o . X
  1575. // v g v . v g v . v g v . v g
  1576.  
  1577. float3 dithapick;
  1578. float3 XX, oo, vv, xx, gg;
  1579.  
  1580.  
  1581. XX = 0.018f;
  1582. vv = 0.02f;
  1583. xx = 0.015f;
  1584. oo = -0.003f;
  1585. gg = -60.93f;
  1586.  
  1587.  
  1588. ditherX = dithone;
  1589. if (ditherX.b < 1.0f) ditherX.rgb = 0;
  1590. else ditherX.rgb = XX.rgb;
  1591.  
  1592. ditherx = diththree;
  1593. if (ditherx.r > 1.3f) ditherx.rgb = 0;
  1594. else ditherx.rgb = xx.rgb;
  1595.  
  1596. ditherv = dithone;
  1597. if (ditherv.b < 0.7f) ditherv.rgb = vv.rgb;
  1598. else ditherv.rgb = 0;
  1599.  
  1600.  
  1601.  
  1602.  
  1603. dithero = dithsix;
  1604. if (dithero.r > 2.2f) dithero.rgb = 0;
  1605. else dithero.rgb = -0.018f;
  1606.  
  1607. ditherg = dithsixy;
  1608. if (ditherg.r > 2.2f) ditherg.rgb = 0;
  1609. else ditherg.rgb = -0.006f;
  1610.  
  1611.  
  1612. dithapick = ditherv;
  1613. dithapick = ditherx + ditherX + ditherv + ditherg + dithero;
  1614.  
  1615. // This is the stupidest set of hacks ever to get just this stupid dither
  1616. // pattern. It obviously could be done better, but eh.......
  1617. // i'm bad at math :(
  1618.  
  1619. // Matrix numbers....
  1620. float3 dithonme;
  1621. float3 dithonyou;
  1622.  
  1623. //dithonyou = dithapick.r + dithapick.g + dithapick.b;
  1624. dithapick.b = dithapick.r;
  1625. dithonme.r = colorInput.r + dithapick.r;
  1626. dithonme.g = colorInput.g + dithapick.g;
  1627. dithonme.b = colorInput.b + dithapick.b;
  1628.  
  1629.  
  1630. float eeee = 0.034f;
  1631.  
  1632. dithonyou.rgb = colorInput.rgb;
  1633.  
  1634. if (dithonyou.r > dithonme.r) dithonme.r = dithonyou.r;
  1635. if (dithonyou.g > dithonme.g) dithonme.g = dithonyou.g;
  1636. if (dithonyou.b > dithonme.b) dithonme.b = dithonyou.b;
  1637.  
  1638. if (dithonyou.r < dithonme.r) dithonyou.r = dithonme.r;
  1639. if (dithonyou.g < dithonme.g) dithonyou.g = dithonme.g;
  1640. if (dithonyou.b < dithonme.b) dithonyou.b = dithonme.b;
  1641.  
  1642. if (colorInput.r > 0) colorInput.r = dithonyou.r;
  1643. if (colorInput.g > 0) colorInput.g = dithonyou.g;
  1644. if (colorInput.b > 0) colorInput.b = dithonyou.b;
  1645.  
  1646. //
  1647. // Reduce to 16-bit color
  1648. //
  1649.  
  1650. float why = 1;
  1651. float3 reduceme = 1;
  1652. float radooct = 32; // 32 is usually the proper value
  1653.  
  1654. reduceme.r = pow(colorInput.r, why);
  1655. reduceme.r *= radooct;
  1656. reduceme.r = int(floor(reduceme.r));
  1657. reduceme.r /= radooct;
  1658. reduceme.r = pow(reduceme.r, why);
  1659.  
  1660. reduceme.g = pow(colorInput.g, why);
  1661. reduceme.g *= radooct * 2;
  1662. reduceme.g = int(floor(reduceme.g));
  1663. reduceme.g /= radooct * 2;
  1664. reduceme.g = pow(reduceme.g, why);
  1665.  
  1666. reduceme.b = pow(colorInput.b, why);
  1667. reduceme.b *= radooct;
  1668. reduceme.b = int(floor(reduceme.b));
  1669. reduceme.b /= radooct;
  1670. reduceme.b = pow(reduceme.b, why);
  1671.  
  1672. colorInput.rgb = reduceme.rgb;
  1673.  
  1674. {
  1675. float leifx_linegamma = 0.005;
  1676. float horzline1 = (mod(ditheu.y, 2.0));
  1677. if (horzline1 < 1) leifx_linegamma = 0;
  1678.  
  1679. colorInput.r += leifx_linegamma;
  1680. colorInput.b += leifx_linegamma;
  1681. }
  1682.  
  1683. // END REDUCTION
  1684.  
  1685. // colorInput.r *= 1.1;
  1686.  
  1687. return colorInput;
  1688. }
  1689.  
  1690. #define COP
  1691. #define YRI
  1692. #define GHT
  1693. #define BY
  1694. #define MAR
  1695. #define TY
  1696. #define MC
  1697. #define FLY
  1698.  
  1699. /*
  1700. float4 LeiFX_Filter( float4 colorInput, float2 tex )
  1701. {
  1702. // Sample things.
  1703. float3 pixel1 = myTex2D(Peww, tex + float2((pixel.x * 1.0f), 0)).rgb; // Left Pixel
  1704. float3 pixel2 = myTex2D(Peww, tex + float2(-pixel.x * 1.0f, 0)).rgb; // Right Pixel
  1705.  
  1706. // New filter
  1707. {
  1708. float3 pixeldiff;
  1709. float3 pixelmake;
  1710. float3 pixeldiffleft;
  1711.  
  1712. pixelmake.rgb = 0;
  1713. pixeldiff.rgb = pixel2.rgb- colorInput.rgb;
  1714.  
  1715. pixeldiffleft.rgb = pixel1.rgb - colorInput.rgb;
  1716.  
  1717. if (pixeldiff.r > FILTCAP) pixeldiff.r = FILTCAP;
  1718. if (pixeldiff.g > FILTCAPG) pixeldiff.g = FILTCAPG;
  1719. if (pixeldiff.b > FILTCAP) pixeldiff.b = FILTCAP;
  1720.  
  1721. if (pixeldiff.r < -FILTCAP) pixeldiff.r = -FILTCAP;
  1722. if (pixeldiff.g < -FILTCAPG) pixeldiff.g = -FILTCAPG;
  1723. if (pixeldiff.b < -FILTCAP) pixeldiff.b = -FILTCAP;
  1724.  
  1725. if (pixeldiffleft.r > FILTCAP) pixeldiffleft.r = FILTCAP;
  1726. if (pixeldiffleft.g > FILTCAPG) pixeldiffleft.g = FILTCAPG;
  1727. if (pixeldiffleft.b > FILTCAP) pixeldiffleft.b = FILTCAP;
  1728.  
  1729. if (pixeldiffleft.r < -FILTCAP) pixeldiffleft.r = -FILTCAP;
  1730. if (pixeldiffleft.g < -FILTCAPG) pixeldiffleft.g = -FILTCAPG;
  1731. if (pixeldiffleft.b < -FILTCAP) pixeldiffleft.b = -FILTCAP;
  1732.  
  1733. pixelmake.rgb = (pixeldiff.rgb / 4) + (pixeldiffleft.rgb / 16);
  1734. colorInput.rgb = (colorInput.rgb + pixelmake.rgb);
  1735. }
  1736.  
  1737. return colorInput; // and that's it. holy crap, why didn't i do this earlier?
  1738. }
  1739. */
  1740.  
  1741. float4 LeiFX_Gamma( float4 colorInput, float2 tex )
  1742. {
  1743. // moved the '4x1 line' stuff into here
  1744. float2 res;
  1745. res.x = ScreenSize.x;
  1746. res.y = ScreenSize.x*ScreenSize.z;
  1747. float gammaed = 0.15;
  1748. float leifx_linegamma = gammaed;
  1749. float2 dithet = tex.xy * res.xy;
  1750. dithet.y = tex.y * res.y;
  1751. float horzline1 = (mod(dithet.y, 2.0));
  1752. if (horzline1 < 1) leifx_linegamma = 0;
  1753. float leifx_gamma = 1.3 - gammaed + leifx_linegamma;
  1754.  
  1755. colorInput.rgb = max(colorInput.rgb, 0);
  1756. colorInput.r = pow(colorInput.r, 1.0 / leifx_gamma);
  1757. colorInput.g = pow(colorInput.g, 1.0 / leifx_gamma);
  1758. colorInput.b = pow(colorInput.b, 1.0 / leifx_gamma);
  1759.  
  1760. return colorInput;
  1761. }
  1762.  
  1763.  
  1764. float4 GaussBlur22(float2 coord, sampler tex, float mult, float lodlevel, int axis) //texcoord, texture, blurmult in pixels, tex2dlod level, axis (0=horiz, 1=vert)
  1765. {
  1766. float4 sum = 0;
  1767. float weight[11] = {0.082607, 0.080977, 0.076276, 0.069041, 0.060049, 0.050187, 0.040306, 0.031105, 0.023066, 0.016436, 0.011254};
  1768.  
  1769. for(int i=1; i < 11; i++)
  1770. {
  1771. if(axis == 0)
  1772. {
  1773. sum += tex2Dlod(tex, float4(coord.xy + float2(i * BUFFER_RCP_WIDTH * mult,0),0,lodlevel)) * weight[i];
  1774. sum += tex2Dlod(tex, float4(coord.xy - float2(i * BUFFER_RCP_WIDTH * mult,0),0,lodlevel)) * weight[i];
  1775. }
  1776. if(axis == 1)
  1777. {
  1778. sum += tex2Dlod(tex, float4(coord.xy + float2(0,i * BUFFER_RCP_HEIGHT * mult),0,lodlevel)) * weight[i];
  1779. sum += tex2Dlod(tex, float4(coord.xy - float2(0,i * BUFFER_RCP_HEIGHT * mult),0,lodlevel)) * weight[i];
  1780. }
  1781. }
  1782.  
  1783. sum += tex2Dlod(tex, float4(coord.xy,0,lodlevel)) * weight[0];
  1784.  
  1785. return sum;
  1786.  
  1787. }
  1788.  
  1789.  
  1790. float3 colorhuefx_prod80( float3 color )
  1791. {
  1792.  
  1793. float3 fxcolor = saturate( color.xyz );
  1794. float greyVal = dot( fxcolor.xyz, LumCoeff.xyz );
  1795. float3 HueSat = Hue( fxcolor.xyz );
  1796. float colorHue = HueSat.x;
  1797. float colorInt = HueSat.z - HueSat.y * 0.5;
  1798. float colorSat = HueSat.y / ( 1.0 - abs( colorInt * 2.0 - 1.0 ) * 1e-10 );
  1799.  
  1800. //When color intensity not based on original saturation level
  1801. if ( USE_COLORSAT == 0 ) colorSat = 1.0f;
  1802.  
  1803. float hueMin_1 = hueMid - hueRange;
  1804. float hueMax_1 = hueMid + hueRange;
  1805. float hueMin_2 = 0.0f;
  1806. float hueMax_2 = 0.0f;
  1807.  
  1808.  
  1809. if ( hueMin_1 < 0.0 )
  1810. {
  1811. hueMin_2 = 1.0f + hueMin_1;
  1812. hueMax_2 = 1.0f + hueMid;
  1813.  
  1814. if ( colorHue >= hueMin_1 && colorHue <= hueMid )
  1815. fxcolor.xyz = lerp( greyVal.xxx, fxcolor.xyz, smootherstep( hueMin_1, hueMid, colorHue ) * ( colorSat * satLimit ));
  1816. else if ( colorHue >= hueMid && colorHue <= hueMax_1 )
  1817. fxcolor.xyz = lerp( greyVal.xxx, fxcolor.xyz, ( 1.0f - smootherstep( hueMid, hueMax_1, colorHue )) * ( colorSat * satLimit ));
  1818. else if ( colorHue >= hueMin_2 && colorHue <= hueMax_2 )
  1819. fxcolor.xyz = lerp( greyVal.xxx, fxcolor.xyz, smootherstep( hueMin_2, hueMax_2, colorHue ) * ( colorSat * satLimit ));
  1820. else
  1821. fxcolor.xyz = greyVal.xxx;
  1822. }
  1823.  
  1824. else if ( hueMax_1 > 1.0 )
  1825. {
  1826. hueMin_2 = 0.0f - ( 1.0f - hueMid );
  1827. hueMax_2 = hueMax_1 - 1.0f;
  1828.  
  1829. if ( colorHue >= hueMin_1 && colorHue <= hueMid )
  1830. fxcolor.xyz = lerp( greyVal.xxx, fxcolor.xyz, smootherstep( hueMin_1, hueMid, colorHue ) * ( colorSat * satLimit ));
  1831. else if ( colorHue >= hueMid && colorHue <= hueMax_1 )
  1832. fxcolor.xyz = lerp( greyVal.xxx, fxcolor.xyz, ( 1.0f - smootherstep( hueMid, hueMax_1, colorHue )) * ( colorSat * satLimit ));
  1833. else if ( colorHue >= hueMin_2 && colorHue <= hueMax_2 )
  1834. fxcolor.xyz = lerp( greyVal.xxx, fxcolor.xyz, ( 1.0f - smootherstep( hueMin_2, hueMax_2, colorHue )) * ( colorSat * satLimit ));
  1835. else
  1836. fxcolor.xyz = greyVal.xxx;
  1837. }
  1838.  
  1839. else
  1840. {
  1841. if ( colorHue >= hueMin_1 && colorHue <= hueMid )
  1842. fxcolor.xyz = lerp( greyVal.xxx, fxcolor.xyz, smootherstep( hueMin_1, hueMid, colorHue ) * ( colorSat * satLimit ));
  1843. else if ( colorHue > hueMid && colorHue <= hueMax_1 )
  1844. fxcolor.xyz = lerp( greyVal.xxx, fxcolor.xyz, ( 1.0f - smootherstep( hueMid, hueMax_1, colorHue )) * ( colorSat * satLimit ));
  1845. else
  1846. fxcolor.xyz = greyVal.xxx;
  1847. }
  1848.  
  1849. color.xyz = lerp( color.xyz, fxcolor.xyz, fxcolorMix );
  1850.  
  1851. return color.xyz;
  1852.  
  1853. }
  1854.  
  1855.  
  1856. static const float zF = 1000;
  1857. static const float zN = 0.15;
  1858.  
  1859. float linearlizeDepth(float zB)
  1860. {
  1861. return zF * zN / (zF + zB * ( zN - zF));
  1862. }
  1863.  
  1864.  
  1865. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1866. // Pixel shaders
  1867. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1868.  
  1869. float4 PS_BloomPrePass(VS_OUTPUT_POST IN) : COLOR
  1870. {
  1871.  
  1872. float2 pixelSize=ScreenSize.y;
  1873. pixelSize.y*=ScreenSize.z;
  1874.  
  1875. pixelSize.xy *= 2;
  1876.  
  1877. float4 bloom=0.0;
  1878. float2 bloomuv;
  1879.  
  1880. float2 offset[4]=
  1881. {
  1882. float2(1.0, 1.0),
  1883. float2(1.0, 1.0),
  1884. float2(-1.0, 1.0),
  1885. float2(-1.0, -1.0)
  1886. };
  1887.  
  1888. for (int i=0; i<4; i++)
  1889. {
  1890. bloomuv.xy=offset[i]*pixelSize.xy;
  1891. bloomuv.xy=IN.txcoord.xy + bloomuv.xy;
  1892. float4 tempbloom=tex2D(SamplerColorLDR, bloomuv.xy);
  1893. tempbloom.w = max(0,dot(tempbloom.xyz,0.333)-fAnamFlareThreshold);
  1894. tempbloom.xyz = max(0, tempbloom.xyz-fBloomThreshold);
  1895. bloom+=tempbloom;
  1896. }
  1897.  
  1898. bloom *= 0.25;
  1899.  
  1900. return bloom;
  1901. }
  1902.  
  1903. float4 PS_BloomPass1(VS_OUTPUT_POST IN) : COLOR
  1904. {
  1905.  
  1906. float2 pixelSize=ScreenSize.y;
  1907. pixelSize.y*=ScreenSize.z;
  1908.  
  1909. pixelSize.xy *= 4;
  1910.  
  1911. float4 bloom=0.0;
  1912. float2 bloomuv;
  1913.  
  1914. float2 offset[8]=
  1915. {
  1916. float2(1.0, 1.0),
  1917. float2(0.0, -1.0),
  1918. float2(-1.0, 1.0),
  1919. float2(-1.0, -1.0),
  1920. float2(0.0, 1.0),
  1921. float2(0.0, -1.0),
  1922. float2(1.0, 0.0),
  1923. float2(-1.0, 0.0)
  1924. };
  1925.  
  1926. for (int i=0; i<8; i++)
  1927. {
  1928. bloomuv.xy=offset[i]*pixelSize.xy;
  1929. bloomuv.xy=IN.txcoord.xy + bloomuv.xy;
  1930. float4 tempbloom=tex2Dlod(SamplerBloom1, float4(bloomuv.xy,0,0));
  1931. bloom+=tempbloom;
  1932. }
  1933.  
  1934. bloom *= 0.125;
  1935. return bloom;
  1936. }
  1937.  
  1938. float4 PS_BloomPass2(VS_OUTPUT_POST IN) : COLOR
  1939. {
  1940.  
  1941. float2 pixelSize=ScreenSize.y;
  1942. pixelSize.y*=ScreenSize.z;
  1943.  
  1944. float4 bloom=0.0;
  1945. float2 bloomuv;
  1946.  
  1947. pixelSize.xy *= 8;
  1948.  
  1949. float2 offset[8]=
  1950. {
  1951. float2(0.707, 0.707),
  1952. float2(0.707, -0.707),
  1953. float2(-0.707, 0.707),
  1954. float2(-0.707, -0.707),
  1955. float2(0.0, 1.0),
  1956. float2(0.0, -1.0),
  1957. float2(1.0, 0.0),
  1958. float2(-1.0, 0.0)
  1959. };
  1960.  
  1961. for (int i=0; i<8; i++)
  1962. {
  1963. bloomuv.xy=offset[i]*pixelSize.xy;
  1964. bloomuv.xy=IN.txcoord.xy + bloomuv.xy;
  1965. float4 tempbloom=tex2Dlod(SamplerBloom2, float4(bloomuv.xy,0,0));
  1966. bloom+=tempbloom;
  1967. }
  1968.  
  1969. bloom *= 0.5; //to brighten up the sample, it will lose brightness in H/V gaussian blur
  1970.  
  1971. return bloom;
  1972. }
  1973.  
  1974.  
  1975. float4 PS_BloomPass3(VS_OUTPUT_POST IN) : COLOR
  1976. {
  1977. float4 bloom;
  1978. bloom = GaussBlur22(IN.txcoord.xy, SamplerBloom3, 16, 0, 0);
  1979. bloom.a *= fAnamFlareAmount;
  1980. bloom.xyz *= fBloomAmount;
  1981. return bloom;
  1982. }
  1983.  
  1984. float4 PS_BloomPass4(VS_OUTPUT_POST IN) : COLOR
  1985. {
  1986. float4 bloom;
  1987. bloom.xyz = GaussBlur22(IN.txcoord.xy, SamplerBloom4, 16, 0, 1).xyz*2.5;
  1988. bloom.w = GaussBlur22(IN.txcoord.xy, SamplerBloom4, 32*fAnamFlareWideness, 0, 0).w*2.5; //to have anamflare texture (bloom.w) avoid vertical blur
  1989. return bloom;
  1990. }
  1991.  
  1992.  
  1993. #if (USE_PETKAGTADOF == 1)
  1994. float4 PS_ProcessDoFBokeh(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
  1995. {
  1996. float depth = linearize(tex2D(SamplerDepth,IN.txcoord.xy).x);
  1997.  
  1998. float fDepth = focalDepth;
  1999.  
  2000. #if (DOF_AUTO == 1)
  2001. fDepth = linearize(tex2D(SamplerDepth,focus).x);
  2002. #endif
  2003.  
  2004. float blur = 2.0;
  2005. #if (DOF_MANUAL == 1)
  2006. float a = depth-fDepth; //focal plane
  2007. float b = (a-fdofstart)/fdofdist; //far DoF
  2008. blur = b;
  2009. #else
  2010. float f = focalLength; //focal length in mm
  2011. float d = fDepth*1000.0; //focal plane in mm
  2012. float o = depth*1000.0; //depth in mm
  2013.  
  2014. float a = (o*f)/(o-f);
  2015. float b = (d*f)/(d-f);
  2016. float c = (d-f)/(d*fstop*CoC);
  2017.  
  2018. blur = abs(a-b)*c;
  2019. #endif
  2020. blur = saturate(blur);
  2021. float2 noise = rand(IN.txcoord.xy)*namount*blur;
  2022.  
  2023. float w = (1.0/ScreenSize.x)*blur*maxblur+noise.x;
  2024. float h = (1.0/ScreenSize.x*ScreenSize.z)*blur*maxblur+noise.y;
  2025.  
  2026. float4 col = float4(0,0,0,1);
  2027.  
  2028. if(blur < 0.05) //some optimization thingy
  2029. {
  2030. col = tex2D(SamplerColorHDR1, IN.txcoord.xy);
  2031. }
  2032. else
  2033. {
  2034. col = tex2D(SamplerColorHDR1, IN.txcoord.xy);
  2035. float s = 1.0;
  2036. int ringsamples;
  2037. float origdepth = tex2D(SamplerDepth, IN.txcoord.xy).x;
  2038.  
  2039. [loop]
  2040. for (int g = 1; g <= rings; g += 1)
  2041. {
  2042. ringsamples = g * samples;
  2043. [loop]
  2044. for (int j = 0 ; j < ringsamples ; j += 1)
  2045. {
  2046. float step = PI*2.0 / ringsamples;
  2047. float pw = cos(j*step)*g;
  2048. float ph = sin(j*step)*g;
  2049. float p = 1.0;
  2050. float2 samplecoord = IN.txcoord.xy +float2(pw*w,ph*h);
  2051.  
  2052. #if (DOF_PENTAGONSHAPE == 1)
  2053. p = penta(float2(pw,ph));
  2054. #endif
  2055.  
  2056. float sampledepth = tex2Dlod(SamplerDepth, float4(samplecoord,0,0)).x;
  2057. if(sampledepth > origdepth*(1-origdepth*0.05))
  2058. {
  2059. col.xyz += colorDof(samplecoord,blur).xyz*lerp(1.0,g/rings,bias)*p;
  2060. s += 1.0*lerp(1.0,g/rings,bias)*p;
  2061. }
  2062. }
  2063. }
  2064. col = col/s; //divide by sample count
  2065. }
  2066.  
  2067. #if( DOF_VIGNETTING == 1)
  2068. col *= vignette(IN.txcoord.xy,vignint);
  2069. #endif
  2070.  
  2071. return col;
  2072. }
  2073. #endif
  2074.  
  2075. #if (USE_MATSODOF==1)
  2076.  
  2077. // Fast depth of field pixel shader (Matso code)
  2078. float4 PS_ProcessPass_FastDoF1(VS_OUTPUT_POST IN) : COLOR
  2079. {
  2080.  
  2081. float4 res;
  2082. float2 coord = IN.txcoord.xy;
  2083. float4 tcol = tex2D(SamplerColorHDR1, coord.xy);
  2084. float sd = tex2D(SamplerDepth, coord).x;
  2085. int axis = FIRST_PASS;
  2086. float sf = 0;
  2087.  
  2088. #if (USE_AUTOFOCUS == 1)
  2089. sf = tex2D(SamplerDepth, 0.5).x;
  2090. #endif
  2091.  
  2092. #if ( USE_SMOOTH_DOF == 1)
  2093. sf -= fFocusBias * 2.0;
  2094. #else
  2095. sf -= fFocusBias;
  2096. #endif
  2097.  
  2098. float outOfFocus = DOF(sd, sf);
  2099.  
  2100. float offset[4] = { -1.282, -0.524, 0.524, 1.282 };
  2101. float2 tdirs[4] = { float2(1.0, 0.0), float2(0.0, 1.0), float2(0.707, 0.707), float2(-0.707, 0.707) };
  2102. //float2 taps[4] = { float2(-1.282, 0.524), float2(0.524, -1.282), float2(-1.282, -0.524), float2(0.524, 1.282) };
  2103. float blur = DOF_SCALE * outOfFocus;
  2104. #if (USE_BOKEH_DOF==1)
  2105. float wValue = (1.0 + pow(length(tcol.rgb) + 0.1, fBokehCurve)) * (1.0 - fBokehLight); // special recipe from papa Matso ;)
  2106. #else
  2107. float wValue = 1.0;
  2108. #endif
  2109.  
  2110. tdirs[axis].x *= fvTexelSize.x;
  2111. tdirs[axis].y *= fvTexelSize.y;
  2112.  
  2113. #if( USE_BOKEH_DOF == 1)
  2114. blur *= 0.25;
  2115. #endif
  2116.  
  2117. for (int i = 0; i < 4; i++)
  2118. {
  2119. //float2 t = taps[f] * fvTexelSize;
  2120.  
  2121. float2 tdir = offset[i] * tdirs[axis] * blur;
  2122. coord.xy = IN.txcoord.xy + tdir.xy;
  2123. #if (USE_CHROMA_DOF == 1)
  2124. float4 ct = ChromaticAberrationFocusPass(coord.xy, outOfFocus, SamplerColorHDR1);
  2125. #else
  2126. float4 ct = tex2D(SamplerColorHDR1, coord.xy);
  2127. #endif
  2128.  
  2129. #if (USE_BOKEH_DOF == 0)
  2130. float w = 1.0 + abs(offset[i]); // weight blur for better effect
  2131. #else
  2132. float ds = tex2D(SamplerDepth, coord.xy).x;
  2133. float offs = DOF(ds, sf);
  2134.  
  2135. #if (USE_BOKEH_DOF == 1) // my own pseudo-bokeh weighting
  2136. float b = GrayScale(ct.rgb) + length(ct.rgb) + 0.1;
  2137. float w = pow(b, fBokehCurve) + abs(offset[i]);
  2138. #endif
  2139. #endif
  2140. tcol += ct * w;
  2141. wValue += w;
  2142. }
  2143.  
  2144. tcol /= wValue;
  2145.  
  2146. #if (USE_SPLITSCREEN==1)
  2147. return (IN.txcoord.x > 0.5) ? tex2D(SamplerColorHDR1, IN.txcoord) : tcol;
  2148. #endif
  2149.  
  2150. res.xyz = tcol.xyz;
  2151.  
  2152.  
  2153.  
  2154. res.w = 1.0;
  2155. return res;
  2156. }
  2157.  
  2158. float4 PS_ProcessPass_FastDoF2(VS_OUTPUT_POST IN) : COLOR
  2159. {
  2160.  
  2161. float4 res;
  2162. float2 coord = IN.txcoord.xy;
  2163. float4 tcol = tex2D(SamplerColorHDR2, coord.xy);
  2164. float sd = tex2D(SamplerDepth, coord).x;
  2165. int axis = SECOND_PASS;
  2166. float sf = 0;
  2167.  
  2168. #if (USE_AUTOFOCUS == 1)
  2169. sf = tex2D(SamplerDepth, 0.5).x;
  2170. #endif
  2171.  
  2172. #if ( USE_SMOOTH_DOF == 1)
  2173. sf -= fFocusBias * 2.0;
  2174. #else
  2175. sf -= fFocusBias;
  2176. #endif
  2177.  
  2178. float outOfFocus = DOF(sd, sf);
  2179.  
  2180. float offset[4] = { -1.282, -0.524, 0.524, 1.282 };
  2181. float2 tdirs[4] = { float2(1.0, 0.0), float2(0.0, 1.0), float2(0.707, 0.707), float2(-0.707, 0.707) };
  2182. //float2 taps[4] = { float2(-1.282, 0.524), float2(0.524, -1.282), float2(-1.282, -0.524), float2(0.524, 1.282) };
  2183. float blur = DOF_SCALE * outOfFocus;
  2184. #if (USE_BOKEH_DOF==1)
  2185. float wValue = (1.0 + pow(length(tcol.rgb) + 0.1, fBokehCurve)) * (1.0 - fBokehLight); // special recipe from papa Matso ;)
  2186. #else
  2187. float wValue = 1.0;
  2188. #endif
  2189.  
  2190. tdirs[axis].x *= fvTexelSize.x;
  2191. tdirs[axis].y *= fvTexelSize.y;
  2192.  
  2193. #if( USE_BOKEH_DOF == 1)
  2194. blur *= 0.25;
  2195. #endif
  2196.  
  2197. for (int i = 0; i < 4; i++)
  2198. {
  2199. //float2 t = taps[i] * fvTexelSize;
  2200.  
  2201. float2 tdir = offset[i] * tdirs[axis] * blur;
  2202. //float2 tdir = blur * (tdirs[axis] + t);
  2203. coord.xy = IN.txcoord.xy + tdir.xy;
  2204. #if (USE_CHROMA_DOF == 1)
  2205. float4 ct = ChromaticAberrationFocusPass(coord.xy, outOfFocus, SamplerColorHDR2);
  2206. #else
  2207. float4 ct = tex2D(SamplerColorHDR2, coord.xy);
  2208. #endif
  2209.  
  2210. #if (USE_BOKEH_DOF == 0)
  2211. float w = 1.0 + abs(offset[i]); // weight blur for better effect
  2212. #else
  2213. float ds = tex2D(SamplerDepth, coord.xy).x;
  2214. float offs = DOF(ds, sf);
  2215.  
  2216. #if (USE_BOKEH_DOF == 1) // my own pseudo-bokeh weighting
  2217. float b = GrayScale(ct.rgb) + length(ct.rgb) + 0.1;
  2218. float w = pow(b, fBokehCurve) + abs(offset[i]);
  2219. #endif
  2220. #endif
  2221. tcol += ct * w;
  2222. wValue += w;
  2223. }
  2224.  
  2225. tcol /= wValue;
  2226.  
  2227. #if (USE_SPLITSCREEN==1)
  2228. return (IN.txcoord.x > 0.5) ? tex2D(SamplerColorHDR2, IN.txcoord) : tcol;
  2229. #endif
  2230.  
  2231. res.xyz = tcol.xyz;
  2232.  
  2233.  
  2234.  
  2235. res.w = 1.0;
  2236. return res;
  2237. }
  2238.  
  2239. float4 PS_ProcessPass_FastDoF3(VS_OUTPUT_POST IN) : COLOR
  2240. {
  2241.  
  2242. float4 res;
  2243. float2 coord = IN.txcoord.xy;
  2244. float4 tcol = tex2D(SamplerColorHDR1, coord.xy);
  2245. float sd = tex2D(SamplerDepth, coord).x;
  2246. int axis = THIRD_PASS;
  2247. float sf = 0;
  2248.  
  2249. #if (USE_AUTOFOCUS == 1)
  2250. sf = tex2D(SamplerDepth, 0.5).x;
  2251. #endif
  2252.  
  2253. #if ( USE_SMOOTH_DOF == 1)
  2254. sf -= fFocusBias * 2.0;
  2255. #else
  2256. sf -= fFocusBias;
  2257. #endif
  2258.  
  2259. float outOfFocus = DOF(sd, sf);
  2260.  
  2261. float offset[4] = { -1.282, -0.524, 0.524, 1.282 };
  2262. float2 tdirs[4] = { float2(1.0, 0.0), float2(0.0, 1.0), float2(0.707, 0.707), float2(-0.707, 0.707) };
  2263. //float2 taps[4] = { float2(-1.282, 0.524), float2(0.524, -1.282), float2(-1.282, -0.524), float2(0.524, 1.282) };
  2264. float blur = DOF_SCALE * outOfFocus;
  2265. #if (USE_BOKEH_DOF==1)
  2266. float wValue = (1.0 + pow(length(tcol.rgb) + 0.1, fBokehCurve)) * (1.0 - fBokehLight); // special recipe from papa Matso ;)
  2267. #else
  2268. float wValue = 1.0;
  2269. #endif
  2270.  
  2271. tdirs[axis].x *= fvTexelSize.x;
  2272. tdirs[axis].y *= fvTexelSize.y;
  2273.  
  2274. #if( USE_BOKEH_DOF == 1)
  2275. blur *= 0.25;
  2276. #endif
  2277.  
  2278. for (int i = 0; i < 4; i++)
  2279. {
  2280. //float2 t = taps[i] * fvTexelSize;
  2281.  
  2282. float2 tdir = offset[i] * tdirs[axis] * blur;
  2283. //float2 tdir = blur * (tdirs[axis] + t);
  2284. coord.xy = IN.txcoord.xy + tdir.xy;
  2285. #if (USE_CHROMA_DOF == 1)
  2286. float4 ct = ChromaticAberrationFocusPass(coord.xy, outOfFocus, SamplerColorHDR1);
  2287. #else
  2288. float4 ct = tex2D(SamplerColorHDR1, coord.xy);
  2289. #endif
  2290.  
  2291. #if (USE_BOKEH_DOF == 0)
  2292. float w = 1.0 + abs(offset[i]); // weight blur for better effect
  2293. #else
  2294. float ds = tex2D(SamplerDepth, coord.xy).x;
  2295. float offs = DOF(ds, sf);
  2296.  
  2297. #if (USE_BOKEH_DOF == 1) // my own pseudo-bokeh weighting
  2298. float b = GrayScale(ct.rgb) + length(ct.rgb) + 0.1;
  2299. float w = pow(b, fBokehCurve) + abs(offset[i]);
  2300. #endif
  2301. #endif
  2302. tcol += ct * w;
  2303. wValue += w;
  2304. }
  2305.  
  2306. tcol /= wValue;
  2307.  
  2308. #if (USE_SPLITSCREEN==1)
  2309. return (IN.txcoord.x > 0.5) ? tex2D(SamplerColorHDR1, IN.txcoord) : tcol;
  2310. #endif
  2311.  
  2312. res.xyz = tcol.xyz;
  2313.  
  2314.  
  2315.  
  2316. res.w = 1.0;
  2317. return res;
  2318. }
  2319.  
  2320. float4 PS_ProcessPass_FastDoF4(VS_OUTPUT_POST IN) : COLOR
  2321. {
  2322.  
  2323. float4 res;
  2324. float2 coord = IN.txcoord.xy;
  2325. float4 tcol = tex2D(SamplerColorHDR2, coord.xy);
  2326. float sd = tex2D(SamplerDepth, coord).x;
  2327. int axis = FOURTH_PASS;
  2328. float sf = 0;
  2329.  
  2330. #if (USE_AUTOFOCUS == 1)
  2331. sf = tex2D(SamplerDepth, 0.5).x;
  2332. #endif
  2333.  
  2334. #if ( USE_SMOOTH_DOF == 1)
  2335. sf -= fFocusBias * 2.0;
  2336. #else
  2337. sf -= fFocusBias;
  2338. #endif
  2339.  
  2340. float outOfFocus = DOF(sd, sf);
  2341.  
  2342. float offset[4] = { -1.282, -0.524, 0.524, 1.282 };
  2343. float2 tdirs[4] = { float2(1.0, 0.0), float2(0.0, 1.0), float2(0.707, 0.707), float2(-0.707, 0.707) };
  2344. //float2 taps[4] = { float2(-1.282, 0.524), float2(0.524, -1.282), float2(-1.282, -0.524), float2(0.524, 1.282) };
  2345. float blur = DOF_SCALE * outOfFocus;
  2346. #if (USE_BOKEH_DOF==1)
  2347. float wValue = (1.0 + pow(length(tcol.rgb) + 0.1, fBokehCurve)) * (1.0 - fBokehLight); // special recipe from papa Matso ;)
  2348. #else
  2349. float wValue = 1.0;
  2350. #endif
  2351.  
  2352. tdirs[axis].x *= fvTexelSize.x;
  2353. tdirs[axis].y *= fvTexelSize.y;
  2354.  
  2355. #if( USE_BOKEH_DOF == 1)
  2356. blur *= 0.25;
  2357. #endif
  2358.  
  2359. for (int i = 0; i < 4; i++)
  2360. {
  2361. //float2 t = taps[i] * fvTexelSize;
  2362.  
  2363. float2 tdir = offset[i] * tdirs[axis] * blur;
  2364. //float2 tdir = blur * (tdirs[axis] + t);
  2365. coord.xy = IN.txcoord.xy + tdir.xy;
  2366. #if (USE_CHROMA_DOF == 1)
  2367. float4 ct = ChromaticAberrationFocusPass(coord.xy, outOfFocus, SamplerColorHDR2);
  2368. #else
  2369. float4 ct = tex2D(SamplerColorHDR2, coord.xy);
  2370. #endif
  2371.  
  2372. #if (USE_BOKEH_DOF == 0)
  2373. float w = 1.0 + abs(offset[i]); // weight blur for better effect
  2374. #else
  2375. float ds = tex2D(SamplerDepth, coord.xy).x;
  2376. float offs = DOF(ds, sf);
  2377.  
  2378. #if (USE_BOKEH_DOF == 1) // my own pseudo-bokeh weighting
  2379. float b = GrayScale(ct.rgb) + length(ct.rgb) + 0.1;
  2380. float w = pow(b, fBokehCurve) + abs(offset[i]);
  2381. #endif
  2382. #endif
  2383. tcol += ct * w;
  2384. wValue += w;
  2385. }
  2386.  
  2387. tcol /= wValue;
  2388.  
  2389. #if (USE_SPLITSCREEN==1)
  2390. return (IN.txcoord.x > 0.5) ? tex2D(SamplerColorHDR2, IN.txcoord) : tcol;
  2391. #endif
  2392.  
  2393. res.xyz = tcol.xyz;
  2394.  
  2395.  
  2396.  
  2397. res.w = 1.0;
  2398. return res;
  2399. }
  2400.  
  2401. #endif
  2402.  
  2403.  
  2404. #if( USE_GP65CJ042DOF == 1)
  2405.  
  2406. float4 PS_GPDOFFocus(VS_OUTPUT_POST IN) : COLOR
  2407. {
  2408. float4 res;
  2409. float2 coord=IN.txcoord.xy;
  2410.  
  2411. #if (USE_SPLITSCREEN == 1)
  2412. if(IN.txcoord.x > 0.5) return tex2D(SamplerColorHDR1, coord.xy);
  2413. #endif
  2414.  
  2415. float2 uvsrc=FocusPoint;
  2416.  
  2417. float2 pixelSize=ScreenSize.y;
  2418. pixelSize.y*=ScreenSize.z;
  2419.  
  2420. const float2 offset[4]=
  2421. {
  2422. float2(0.0, 1.0),
  2423. float2(0.0, -1.0),
  2424. float2(1.0, 0.0),
  2425. float2(-1.0, 0.0)
  2426. };
  2427.  
  2428. float resdepth=linearlizeDepth(tex2D(SamplerDepth, uvsrc.xy).x);
  2429. for (int i=0; i<4; i++)
  2430. {
  2431. uvsrc.xy=uvsrc.xy;
  2432. uvsrc.xy+=offset[i] * pixelSize.xy * FocusSampleRange;
  2433. #if (NOT_BLURRING_SKY_MODE==1)
  2434. resdepth+=linearlizeDepth(tex2D(SamplerDepth, uvsrc).x);
  2435. #else
  2436. resdepth+=min(linearlizeDepth(tex2D(SamplerDepth, uvsrc).x), DepthClip);
  2437. #endif
  2438. }
  2439. resdepth*=0.2;
  2440.  
  2441. float scenefocus=resdepth;
  2442.  
  2443. #if (AUTO_FOCUS == 0)
  2444. scenefocus = ManualFocusDepth; //+1 damit es bei 0 nicht 0 ist denn 1 ist das Niedrigste was sein kann ohne bugs
  2445. #endif
  2446.  
  2447. float4 origcolor=tex2D(SamplerColorHDR1, coord.xy);
  2448. float scenedepth=tex2D(SamplerDepth, IN.txcoord.xy).x;
  2449.  
  2450. res.xyz=origcolor.xyz;
  2451.  
  2452. float depth=linearlizeDepth(scenedepth);
  2453.  
  2454. float focalPlaneDepth=scenefocus;
  2455. float farBlurDepth=scenefocus*pow(4.0, FarBlurCurve);
  2456.  
  2457.  
  2458. #if( TILT_SHIFT == 1)
  2459. float shiftAngle=(frac(TiltShiftAngle / 90.0) == 0) ? 0.0 : TiltShiftAngle;
  2460. float depthShift=1.0 + (0.5 - coord.x)*tan(-shiftAngle * 0.017453292);
  2461. focalPlaneDepth*=depthShift;
  2462. farBlurDepth*=depthShift;
  2463. #endif
  2464.  
  2465.  
  2466. if(depth < focalPlaneDepth)
  2467. res.w=(depth - focalPlaneDepth)/focalPlaneDepth;
  2468. else
  2469. {
  2470. res.w=(depth - focalPlaneDepth)/(farBlurDepth - focalPlaneDepth);
  2471. res.w=saturate(res.w);
  2472. }
  2473.  
  2474. res.w=res.w * 0.5 + 0.5;
  2475.  
  2476. #if ( NOT_BLURRING_SKY_MODE == 1)
  2477. #define DEPTH_OF_FIELD_QULITY 0
  2478. res.w=(depth > 1000.0) ? 0.5 : res.w;
  2479. #endif
  2480.  
  2481. float blurAmount=abs(res.w * 2.0 - 1.0);
  2482.  
  2483. float discRadius=blurAmount * float(DEPTH_OF_FIELD_QULITY) * RadiusSacleMultipiler;
  2484.  
  2485. discRadius*=(depth < 0.5) ? (1.0 / max(NearBlurCurve, 1.0)) : 1.0;
  2486.  
  2487. float3 distortion=float3(-1.0, 0.0, 1.0);
  2488. distortion*=ChromaticAberrationAmount*discRadius;
  2489.  
  2490. origcolor=tex2D(SamplerColorHDR1, coord.xy + pixelSize.xy*distortion.x);
  2491. origcolor.w=smoothstep(0.0, depth, origcolor.w);
  2492. res.x=lerp(res.x, origcolor.x, origcolor.w);
  2493.  
  2494. origcolor=tex2D(SamplerColorHDR1, coord.xy + pixelSize.xy*distortion.z);
  2495. origcolor.w=smoothstep(0.0, depth, origcolor.w);
  2496. res.z=lerp(res.z, origcolor.z, origcolor.w);
  2497.  
  2498. return res;
  2499. }
  2500.  
  2501. float4 PS_GPDOFBokehblur(VS_OUTPUT_POST IN) : COLOR
  2502. {
  2503. float4 res;
  2504.  
  2505. float2 coord=IN.txcoord.xy;
  2506.  
  2507. float4 origcolor=tex2D(SamplerColorHDR2, coord.xy);
  2508.  
  2509. #if (USE_SPLITSCREEN == 1)
  2510. if(IN.txcoord.x > 0.5) return origcolor;
  2511. #endif
  2512.  
  2513. float centerDepth=origcolor.w;
  2514.  
  2515. float2 pixelSize=ScreenSize.y;
  2516. pixelSize.y*=ScreenSize.z;
  2517.  
  2518. float blurAmount=abs(centerDepth * 2.0 - 1.0);
  2519. float discRadius=blurAmount * float(DEPTH_OF_FIELD_QULITY);
  2520. discRadius*=RadiusSacleMultipiler;
  2521.  
  2522. discRadius*=(centerDepth < 0.5) ? (1.0 / max(NearBlurCurve, 1.0)) : 1.0;
  2523.  
  2524. res.xyz=origcolor.xyz;
  2525. res.w=dot(res.xyz, 0.3333);
  2526. res.w=max((res.w - BokehBrightnessThreshold) * BokehBrightnessMultipiler, 0.0);
  2527. res.xyz*=1.0 + res.w*blurAmount;
  2528.  
  2529. res.w=1.0;
  2530.  
  2531. int sampleCycle=0;
  2532. int sampleCycleCounter=0;
  2533. int sampleCounterInCycle=0;
  2534.  
  2535. #if ( POLYGONAL_BOKEH == 1)
  2536. float basedAngle=360.0 / POLYGON_NUM;
  2537. float2 currentVertex;
  2538. float2 nextVertex;
  2539.  
  2540. int dofTaps=DEPTH_OF_FIELD_QULITY * (DEPTH_OF_FIELD_QULITY + 1) * POLYGON_NUM / 2.0;
  2541. #else
  2542. int dofTaps=DEPTH_OF_FIELD_QULITY * (DEPTH_OF_FIELD_QULITY + 1) * 4;
  2543. #endif
  2544.  
  2545.  
  2546. for(int i=0; i < dofTaps; i++)
  2547. {
  2548. if(sampleCounterInCycle % (sampleCycle+1) == 0 )
  2549. {
  2550. sampleCounterInCycle=0;
  2551. sampleCycleCounter++;
  2552.  
  2553. #if ( POLYGONAL_BOKEH == 1)
  2554. sampleCycle+=POLYGON_NUM;
  2555. currentVertex.xy=float2(1.0 , 0.0);
  2556. sincos(basedAngle* 0.017453292, nextVertex.y, nextVertex.x);
  2557. #else
  2558. sampleCycle+=8;
  2559. #endif
  2560. }
  2561. sampleCounterInCycle++;
  2562.  
  2563. #if (POLYGONAL_BOKEH==1)
  2564. float sampleAngle=basedAngle / float(sampleCycleCounter) * sampleCounterInCycle;
  2565. float remainAngle=frac(sampleAngle / basedAngle) * basedAngle;
  2566.  
  2567. if(remainAngle == 0)
  2568. {
  2569. currentVertex=nextVertex;
  2570. sincos((sampleAngle + basedAngle) * 0.017453292, nextVertex.y, nextVertex.x);
  2571. }
  2572.  
  2573. float2 sampleOffset=lerp(currentVertex.xy, nextVertex.xy, remainAngle / basedAngle);
  2574. #else
  2575. float sampleAngle=0.78539816 / float(sampleCycleCounter) * sampleCounterInCycle;
  2576. float2 sampleOffset;
  2577. sincos(sampleAngle, sampleOffset.y, sampleOffset.x);
  2578. #endif
  2579.  
  2580. sampleOffset*=sampleCycleCounter / float(DEPTH_OF_FIELD_QULITY);
  2581. float2 coordLow=coord.xy + (pixelSize.xy * sampleOffset.xy * discRadius);
  2582. float4 tap=tex2D(SamplerColorHDR2, coordLow.xy);
  2583.  
  2584. float weight=(tap.w >= centerDepth) ? 1.0 : abs(tap.w * 2.0 - 1.0);
  2585.  
  2586. float luma=dot(tap.xyz, 0.3333);
  2587. float brightMultipiler=max((luma - BokehBrightnessThreshold) * BokehBrightnessMultipiler, 0.0);
  2588. tap.xyz*=1.0 + brightMultipiler*abs(tap.w*2.0 - 1.0);
  2589.  
  2590. weight*=1.0 + BokehBias * pow(float(sampleCycleCounter)/float(DEPTH_OF_FIELD_QULITY), BokehBiasCurve);
  2591.  
  2592.  
  2593. res.xyz+=tap.xyz * weight;
  2594. res.w+=weight;
  2595. }
  2596.  
  2597. res.xyz /= res.w;
  2598.  
  2599. res.w=centerDepth;
  2600.  
  2601.  
  2602. return res;
  2603. }
  2604.  
  2605.  
  2606. float4 PS_GPDOFGaussianH(VS_OUTPUT_POST IN) : COLOR
  2607. {
  2608. float2 coord=IN.txcoord.xy;
  2609.  
  2610. float2 pixelSize=ScreenSize.y;
  2611. pixelSize.y*=ScreenSize.z;
  2612.  
  2613. float4 origcolor=tex2D(SamplerColorHDR1, coord.xy);
  2614.  
  2615. #if (USE_SPLITSCREEN == 1)
  2616. if(IN.txcoord.x > 0.5) return origcolor;
  2617. #endif
  2618.  
  2619. float depth=origcolor.w;
  2620. float blurAmount=abs(depth*2.0 - 1.0);
  2621.  
  2622. #if (DEPTH_OF_FIELD_QULITY > 0)
  2623. blurAmount*=(depth < 0.5) ? (1.0 / max(NearBlurCurve, 1.0)) : 1.0;
  2624. blurAmount=smoothstep(0.15, 1.0, blurAmount);
  2625. #endif
  2626.  
  2627. blurAmount *= BokehPostBlur;
  2628.  
  2629. float weight[5] = {0.2270270270, 0.1945945946, 0.1216216216, 0.0540540541,
  2630. 0.0162162162};
  2631.  
  2632. float4 res=origcolor * weight[0];
  2633.  
  2634. for(int i=1; i < 5; i++)
  2635. {
  2636. res+=tex2D(SamplerColorHDR1, coord.xy + float2(i*pixelSize.x*blurAmount, 0)) * weight[i];
  2637. res+=tex2D(SamplerColorHDR1, coord.xy - float2(i*pixelSize.x*blurAmount, 0)) * weight[i];
  2638. }
  2639.  
  2640.  
  2641. res.w=depth;
  2642.  
  2643. return res;
  2644. }
  2645.  
  2646. float4 PS_GPDOFGaussianV(VS_OUTPUT_POST IN) : COLOR
  2647. {
  2648. float2 coord=IN.txcoord.xy;
  2649.  
  2650. float2 pixelSize=ScreenSize.y;
  2651. pixelSize.y*=ScreenSize.z;
  2652.  
  2653.  
  2654. float4 origcolor=tex2D(SamplerColorHDR2, coord.xy);
  2655.  
  2656. #if (USE_SPLITSCREEN == 1)
  2657. if(IN.txcoord.x > 0.5) return origcolor;
  2658. #endif
  2659.  
  2660. float depth=origcolor.w;
  2661. float blurAmount=abs(depth*2.0 - 1.0);
  2662.  
  2663. #if (DEPTH_OF_FIELD_QULITY > 0)
  2664. blurAmount*=(depth < 0.5) ? (1.0 / max(NearBlurCurve, 1.0)) : 1.0;
  2665. blurAmount=smoothstep(0.15, 1.0, blurAmount);
  2666. #endif
  2667.  
  2668. blurAmount *= BokehPostBlur;
  2669.  
  2670. float weight[5] = {0.2270270270, 0.1945945946, 0.1216216216, 0.0540540541,
  2671. 0.0162162162};
  2672. float4 res=origcolor * weight[0];
  2673.  
  2674. for(int i=1; i < 5; i++)
  2675. {
  2676. res+=tex2D(SamplerColorHDR2, coord.xy + float2(0, i*pixelSize.y*blurAmount)) * weight[i];
  2677. res+=tex2D(SamplerColorHDR2, coord.xy - float2(0, i*pixelSize.y*blurAmount)) * weight[i];
  2678. }
  2679.  
  2680. res.w=depth;
  2681.  
  2682. return res;
  2683. }
  2684.  
  2685. #endif
  2686.  
  2687.  
  2688. float4 PS_Colors(VS_OUTPUT_POST IN) : COLOR
  2689. {
  2690.  
  2691. //global variables
  2692. float2 pixelsize = float2(ScreenSize.y,ScreenSize.y*ScreenSize.z);
  2693.  
  2694. float4 color = tex2D(SamplerColorHDR1, IN.txcoord.xy);
  2695.  
  2696. #if (USE_SPLITSCREEN == 1)
  2697. if(IN.txcoord.x > 0.5) return color;
  2698. #endif
  2699.  
  2700. #if (USE_CARTOON == 1)
  2701. color.xyz = CartoonPass(color.xyz, IN.txcoord.xy, pixelsize.xy);
  2702. #endif
  2703.  
  2704. //colors
  2705.  
  2706. #if (USE_LUT == 1)
  2707. color.x = tex2D(SamplerLut, float2(color.x, 1.0)).x;
  2708. color.y = tex2D(SamplerLut, float2(color.y, 1.0)).y;
  2709. color.z = tex2D(SamplerLut, float2(color.z, 1.0)).z;
  2710. #endif
  2711.  
  2712. #if (USE_LEVELS== 1)
  2713. color.xyz = LevelsPass(color.xyz);
  2714. #endif
  2715.  
  2716. #if (USE_TECHNICOLOR == 1)
  2717. color.xyz = TechniPass_prod80(color.xyz);
  2718. #endif
  2719.  
  2720. #if (USE_SWFX_TECHNICOLOR == 1)
  2721. color.xyz = TechnicolorPass(color.xyz);
  2722. #endif
  2723.  
  2724. #if (USE_DPX == 1)
  2725. color.xyz = DPXPass(color.xyz);
  2726. #endif
  2727.  
  2728. #if (USE_MONOCHROME == 1)
  2729. color.xyz = dot(color.xyz, 0.333);
  2730. #endif
  2731.  
  2732. #if (USE_LIFTGAMMAGAIN == 1)
  2733. color.xyz = LiftGammaGainPass(color.xyz);
  2734. #endif
  2735.  
  2736. #if (USE_TONEMAP == 1)
  2737. color.xyz = TonemapPass(color.xyz);
  2738. #endif
  2739.  
  2740. #if (USE_VIBRANCE == 1)
  2741. color.xyz = VibrancePass(color.xyz);
  2742. #endif
  2743.  
  2744. #if (USE_CURVES == 1)
  2745. color.xyz = CurvesPass(color.xyz);
  2746. #endif
  2747.  
  2748. #if (USE_SEPIA == 1)
  2749. color.xyz = SepiaPass(color.xyz);
  2750. #endif
  2751.  
  2752. #if (USE_SKYRIMTONEMAP == 1)
  2753. color.xyz = SkyrimTonemapPass(color.xyz);
  2754. #endif
  2755.  
  2756. #if (USE_COLORMOOD == 1)
  2757. color.xyz = MoodPass(color.xyz);
  2758. #endif
  2759.  
  2760. #if (USE_CROSSPROCESS == 1)
  2761. color.xyz = CrossPass(color.xyz);
  2762. #endif
  2763.  
  2764. #if (USE_FILMICPASS == 1)
  2765. color.xyz = FilmPass(color.xyz);
  2766. #endif
  2767.  
  2768. #if (USE_REINHARDLINEAR == 1)
  2769. color.xyz = ReinhardLinearToneMapping(color.xyz);
  2770. #endif
  2771.  
  2772. #if (USE_REINHARD == 1)
  2773. color.xyz = ReinhardToneMapping(color.xyz);
  2774. #endif
  2775.  
  2776. #if (USE_HPD == 1)
  2777. color.xyz = HaarmPeterDuikerFilmicToneMapping(color.xyz);
  2778. #endif
  2779.  
  2780. #if (USE_FILMICCURVE == 1)
  2781. color.xyz = CustomToneMapping(color.xyz);
  2782. #endif
  2783.  
  2784. #if (USE_COLORMOD == 1)
  2785. color.xyz = ColormodPass(color.xyz);
  2786. #endif
  2787.  
  2788. #if (USE_SPHERICALTONEMAP == 1)
  2789. color.xyz = SphericalPass(color.xyz);
  2790. #endif
  2791.  
  2792. #if (USE_LEIFX == 1)
  2793. color = LeiFX_Reduct(color, IN.txcoord.xy);
  2794. #endif
  2795.  
  2796. #if (__RENDERER__ == 0x061 && __VENDOR__ == 0x10DE)
  2797. color.rgb = color.bgr;
  2798. #endif
  2799.  
  2800. return color;
  2801.  
  2802. }
  2803.  
  2804. float4 PS_Distort(VS_OUTPUT_POST IN) : COLOR
  2805. {
  2806.  
  2807. //global variables
  2808. float2 pixelsize = float2(ScreenSize.y,ScreenSize.y*ScreenSize.z);
  2809.  
  2810. float4 color = tex2D(SamplerColorHDR2, IN.txcoord.xy);
  2811. float depth = tex2D(SamplerDepth, IN.txcoord.xy).x;
  2812.  
  2813. #if (USE_SPLITSCREEN == 1)
  2814. if(IN.txcoord.x > 0.5) return color;
  2815. #endif
  2816.  
  2817. float4 coord=0.0;
  2818. coord.xy=IN.txcoord.xy;
  2819. coord.w=0.0;
  2820. float3 eta = float3(1.0+ChromaticAmount*0.9,1.0+ChromaticAmount*0.6,1.0+ChromaticAmount*0.3);
  2821. float2 center;
  2822. center.x = coord.x-0.5;
  2823. center.y = coord.y-0.5;
  2824. float LensZoom = 1.0/LensSize;
  2825.  
  2826. float r2 = (IN.txcoord.x-0.5) * (IN.txcoord.x-0.5) + (IN.txcoord.y-0.5) * (IN.txcoord.y-0.5);
  2827. float f = 0;
  2828.  
  2829. if( LensDistortionCubic == 0.0){
  2830. f = 1 + r2 * LensDistortion;
  2831. }else{
  2832. f = 1 + r2 * (LensDistortion + LensDistortionCubic * sqrt(r2));
  2833. };
  2834.  
  2835. float x = f*LensZoom*(coord.x-0.5)+0.5;
  2836. float y = f*LensZoom*(coord.y-0.5)+0.5;
  2837. float2 rCoords = (f*eta.r)*LensZoom*(center.xy*0.5)+0.5;
  2838. float2 gCoords = (f*eta.g)*LensZoom*(center.xy*0.5)+0.5;
  2839. float2 bCoords = (f*eta.b)*LensZoom*(center.xy*0.5)+0.5;
  2840.  
  2841. float4 inputDistord = float4(tex2D(SamplerColorHDR2,rCoords).r , tex2D(SamplerColorHDR2,gCoords).g ,tex2D(SamplerColorHDR2,bCoords).b, tex2D(SamplerColorHDR2,float2(x,y)).a);
  2842.  
  2843. float4 schmotzcolor = float4(inputDistord.r,inputDistord.g,inputDistord.b,1);
  2844.  
  2845. color.xyz = schmotzcolor.xyz;
  2846.  
  2847. return color;
  2848.  
  2849. }
  2850.  
  2851.  
  2852. float4 PS_Lighting(VS_OUTPUT_POST IN) : COLOR
  2853. {
  2854.  
  2855. //global variables
  2856. float2 pixelsize = float2(ScreenSize.y,ScreenSize.y*ScreenSize.z);
  2857.  
  2858. float4 color = tex2D(SamplerColorHDR2, IN.txcoord.xy);
  2859. float depth = tex2D(SamplerDepth, IN.txcoord.xy).x;
  2860.  
  2861. #if (USE_SPLITSCREEN == 1)
  2862. if(IN.txcoord.x > 0.5) return color;
  2863. #endif
  2864.  
  2865. #if( USE_GODRAYS == 1)
  2866. float2 ScreenLightPos = float2(0.5, 0.5);
  2867. float2 texCoord = IN.txcoord.xy;
  2868. float2 deltaTexCoord = (texCoord.xy - ScreenLightPos.xy);
  2869. deltaTexCoord *= 1.0 / (float)GodraySamples * GodrayDensity;
  2870.  
  2871.  
  2872. float illuminationDecay = 1.0;
  2873.  
  2874. for(int g = 0; g < GodraySamples; g++) {
  2875.  
  2876. texCoord -= deltaTexCoord;;
  2877. float4 sample2 = tex2D(SamplerColorHDR2, texCoord.xy);
  2878. float sampledepth = tex2D(SamplerDepth, texCoord.xy).x;
  2879. sample2.w = saturate(dot(sample2.xyz, 0.3333) - GodrayThreshold);
  2880. sample2.r *= 1.0;
  2881. sample2.g *= 0.95;
  2882. sample2.b *= 0.85;
  2883. sample2 *= illuminationDecay * GodrayWeight;
  2884. #if (GODRAYDEPTHCHECK == 1)
  2885. if(sampledepth>0.97) color.xyz += sample2.xyz*sample2.w;
  2886. #else
  2887. color += sample2;
  2888. #endif
  2889. illuminationDecay *= GodrayDecay;
  2890. }
  2891. #endif
  2892.  
  2893. #if (USE_LENZFLARE == 1)
  2894.  
  2895. float3 lfoffset[19]={
  2896. float3(0.9, 0.01, 4),
  2897. float3(0.7, 0.25, 25),
  2898. float3(0.3, 0.25, 15),
  2899. float3(1, 1.0, 5),
  2900. float3(-0.15, 20, 1),
  2901. float3(-0.3, 20, 1),
  2902. float3(6, 6, 6),
  2903. float3(7, 7, 7),
  2904. float3(8, 8, 8),
  2905. float3(9, 9, 9),
  2906. float3(0.24, 1, 10),
  2907. float3(0.32, 1, 10),
  2908. float3(0.4, 1, 10),
  2909. float3(0.5, -0.5, 2),
  2910. float3(2, 2, -5),
  2911. float3(-5, 0.2, 0.2),
  2912. float3(20, 0.5, 0),
  2913. float3(0.4, 1, 10),
  2914. float3(0.00001, 10, 20)
  2915. };
  2916.  
  2917. float3 lffactors[19]={
  2918. float3(1.5, 1.5, 0),
  2919. float3(0, 1.5, 0),
  2920. float3(0, 0, 1.5),
  2921. float3(0.2, 0.25, 0),
  2922. float3(0.15, 0, 0),
  2923. float3(0, 0, 0.15),
  2924. float3(1.4, 0, 0),
  2925. float3(1, 1, 0),
  2926. float3(0, 1, 0),
  2927. float3(0, 0, 1.4),
  2928. float3(1, 0.3, 0),
  2929. float3(1, 1, 0),
  2930. float3(0, 2, 4),
  2931. float3(0.2, 0.1, 0),
  2932. float3(0, 0, 1),
  2933. float3(1, 1, 0),
  2934. float3(1, 1, 0),
  2935. float3(0, 0, 0.2),
  2936. float3(0.012,0.313,0.588)
  2937. };
  2938.  
  2939. float3 lenstemp = 0;
  2940.  
  2941. float2 lfcoord = float2(0,0);
  2942. float2 distfact=(IN.txcoord.xy-0.5);
  2943. distfact.x *= ScreenSize.z;
  2944.  
  2945. for (int i=0; i<19; i++)
  2946. {
  2947. lfcoord.xy=lfoffset[i].x*distfact;
  2948. lfcoord.xy*=pow(2.0*length(float2(distfact.x,distfact.y)), lfoffset[i].y*3.5);
  2949. lfcoord.xy*=lfoffset[i].z;
  2950. lfcoord.xy=0.5-lfcoord.xy;
  2951. float2 tempfact = (lfcoord.xy-0.5)*2;
  2952. float templensmult = clamp(1.0-dot(tempfact,tempfact),0,1);
  2953. float3 lenstemp1 = dot(tex2D(SamplerColorHDR2, lfcoord.xy).xyz,0.333);
  2954.  
  2955. #if (LENZDEPTHCHECK == 1)
  2956. float templensdepth = tex2D(SamplerDepth, lfcoord.xy).x;
  2957. if(templensdepth < 0.97) lenstemp1 = 0;
  2958. #endif
  2959.  
  2960. lenstemp1 = max(0,lenstemp1.xyz - LenzThreshold);
  2961. lenstemp1 *= lffactors[i].xyz*templensmult;
  2962.  
  2963. lenstemp += lenstemp1;
  2964. }
  2965.  
  2966. color.xyz += lenstemp.xyz*LenzIntensity;
  2967.  
  2968. #endif
  2969.  
  2970.  
  2971. #if(USE_ANAMFLARE == 1)
  2972.  
  2973. float3 anamFlare = AnamorphicSample(0, IN.txcoord.xy, fFlareBlur) * fFlareTint;
  2974. float gaussweight[5] = {0.2270270270, 0.1945945946, 0.1216216216, 0.0540540541, 0.0162162162};
  2975.  
  2976. for(int z=0; z < 5; z++)
  2977. {
  2978. anamFlare+=AnamorphicSample(0, IN.txcoord.xy + float2(0, z * pixelsize.y), fFlareBlur) * fFlareTint* gaussweight[z];
  2979. anamFlare+=AnamorphicSample(0, IN.txcoord.xy - float2(0, z * pixelsize.y), fFlareBlur) * fFlareTint* gaussweight[z];
  2980. }
  2981.  
  2982.  
  2983. color.xyz += anamFlare * fFlareIntensity;
  2984.  
  2985. #endif
  2986.  
  2987. #if (USE_BLOOM == 1)
  2988. float3 colorbloom=0;
  2989.  
  2990. //colorbloom.xyz += tex2D(SamplerBloom1, IN.txcoord.xy).xyz*1.0;
  2991. //colorbloom.xyz += tex2D(SamplerBloom2, IN.txcoord.xy).xyz*2.0;
  2992. colorbloom.xyz += tex2D(SamplerBloom3, IN.txcoord.xy).xyz*1.0;
  2993. colorbloom.xyz += tex2D(SamplerBloom5, IN.txcoord.xy).xyz*9.0;
  2994. colorbloom.xyz *= 0.1;
  2995.  
  2996. colorbloom.xyz = saturate(colorbloom.xyz);
  2997. float colorbloomgray = dot(colorbloom.xyz, 0.333);
  2998. colorbloom.xyz = lerp(colorbloomgray, colorbloom.xyz, fBloomSaturation);
  2999. colorbloom.xyz *= fBloomTint;
  3000. float colorgray = dot(color.xyz, 0.333);
  3001.  
  3002. if(BLOOM_MIXMODE == 1) color.xyz = color.xyz + colorbloom.xyz;
  3003. if(BLOOM_MIXMODE == 2) color.xyz = 1-(1-color.xyz)*(1-colorbloom.xyz);
  3004. if(BLOOM_MIXMODE == 3) color.xyz = max(0.0f,max(color.xyz,lerp(color.xyz,(1.0f - (1.0f - saturate(colorbloom.xyz)) *(1.0f - saturate(colorbloom.xyz * 1.0))),1.0)));
  3005. if(BLOOM_MIXMODE == 4) color.xyz = max(color.xyz, colorbloom.xyz);
  3006. #endif
  3007.  
  3008. #if(USE_GAUSSIAN_ANAMFLARE == 1)
  3009. float3 anamflare = tex2D(SamplerBloom5, IN.txcoord.xy).w*2*fAnamFlareColor;
  3010. anamflare.xyz = max(anamflare.xyz,0);
  3011. color.xyz += pow(anamflare.xyz,1/fAnamFlareCurve);
  3012. #endif
  3013.  
  3014. #if(USE_LENSDIRT == 1)
  3015. float lensdirtmult = dot(tex2D(SamplerBloom5, IN.txcoord.xy).xyz,0.333);
  3016. float3 dirttex = tex2D(SamplerDirt, IN.txcoord.xy).xyz;
  3017. float3 lensdirt = dirttex.xyz*lensdirtmult*fLensdirtIntensity;
  3018. color.xyz += lensdirt.xyz;
  3019. #endif
  3020.  
  3021. return color;
  3022.  
  3023. }
  3024.  
  3025. float4 PS_Image(VS_OUTPUT_POST IN) : COLOR
  3026. {
  3027.  
  3028. //global variables
  3029. float2 pixelsize = float2(ScreenSize.y,ScreenSize.y*ScreenSize.z);
  3030.  
  3031. float4 color = tex2D(SamplerColorHDR1, IN.txcoord.xy);
  3032.  
  3033. #if (USE_SPLITSCREEN == 1)
  3034. if(IN.txcoord.x > 0.5) return color;
  3035. #endif
  3036.  
  3037. #if (USE_SHARPENING == 1)
  3038. color.xyz = SharpPass(color.xyz, IN.txcoord.xy, pixelsize.xy);
  3039. #endif
  3040.  
  3041. //color.xyz = abs(frac(Timer.x*0.9999)-0.5);
  3042.  
  3043. #if(USE_GRAIN == 1)
  3044.  
  3045.  
  3046. float GrainTimerSeed = abs(frac(Timer.x*(1.0-fGrainMotion))-0.5);
  3047.  
  3048.  
  3049. float2 GrainTexCoordSeed = cos(IN.txcoord.y*1.235229)+tan(IN.txcoord.x/1.97) * 0.1;
  3050. float2 GrainSeed1 = GrainTexCoordSeed + float2( 0.0, GrainTimerSeed );
  3051. float2 GrainSeed2 = GrainTexCoordSeed + float2( GrainTimerSeed, 0.0 );
  3052. float2 GrainSeed3 = GrainTexCoordSeed + float2( GrainTimerSeed, GrainTimerSeed );
  3053. float GrainNoise1 = random( GrainSeed1 );
  3054. float GrainNoise2 = random( GrainSeed2 );
  3055. float GrainNoise3 = random( GrainSeed3 );
  3056. float GrainNoise4 = ( GrainNoise1 + GrainNoise2 + GrainNoise3 ) * 0.333333333;
  3057. float3 GrainNoise = float3( GrainNoise4, GrainNoise4, GrainNoise4 );
  3058. float3 GrainColor = float3( GrainNoise1, GrainNoise2, GrainNoise3 );
  3059.  
  3060. float ColorLuma = dot(color.xyz, 0.333);
  3061.  
  3062. float GrainIntensityMult = GrainIntensityMid;
  3063.  
  3064. if(ColorLuma > 0.6) GrainIntensityMult = lerp(GrainIntensityMid, GrainIntensityBright, saturate((ColorLuma - 0.6) * 5 ));
  3065. if(ColorLuma < 0.4) GrainIntensityMult = lerp(GrainIntensityDark, GrainIntensityMid, saturate(ColorLuma * 2.5));
  3066.  
  3067. color.rgb += GrainIntensityMult * (( lerp( GrainNoise, GrainColor, fGrainSaturation ) * fGrainIntensity ) - ( fGrainIntensity * 0.5));
  3068.  
  3069. #endif
  3070.  
  3071. return color;
  3072.  
  3073. }
  3074.  
  3075.  
  3076. float4 PS_Overlay(VS_OUTPUT_POST IN) : COLOR
  3077. {
  3078.  
  3079. //global variables
  3080. float2 pixelsize = float2(ScreenSize.y,ScreenSize.y*ScreenSize.z);
  3081.  
  3082. float4 color = tex2D(SamplerColorHDR2, IN.txcoord.xy);
  3083.  
  3084. #if (USE_SPLITSCREEN == 1)
  3085. if(IN.txcoord.x > 0.5) return color;
  3086. #endif
  3087.  
  3088. #if (USE_LEIFX == 1)
  3089. color = LeiFX_Gamma(color,IN.txcoord.xy);
  3090. #endif
  3091.  
  3092. #if (USE_EXPLOSION == 1)
  3093. color.xyz = ExplosionPass(color.xyz, IN.txcoord.xy, pixelsize.xy);
  3094. #endif
  3095.  
  3096. #if (USE_SINCITY == 1)
  3097. float sinlumi = dot(color.rgb, float3(0.30f,0.59f,0.11f));
  3098. if(color.r > (color.g + 0.2f) && color.r > (color.b + 0.025f))
  3099. {
  3100. color.rgb = float3(sinlumi, 0, 0)*1.5;
  3101. }
  3102. else
  3103. {
  3104. color.rgb = sinlumi;
  3105. }
  3106. #endif
  3107.  
  3108. #if (USE_COLORHUEFX == 1)
  3109. color.xyz = colorhuefx_prod80(color.xyz);
  3110. #endif
  3111.  
  3112. #if (USE_BORISVIGNETTE==1)
  3113. float2 uv=(IN.txcoord-0.5)*EVignetteRadius;
  3114. float vignetteold=saturate(dot(uv.xy, uv.xy));
  3115. vignetteold=pow(vignetteold, EVignetteCurve);
  3116. #if (VIGNCOLORING==1)
  3117. float3 EVignetteColor=float3(VIGNREDAMOUNT, VIGNGREENAMOUNT, VIGNBLUEAMOUNT);
  3118. #else
  3119. float3 EVignetteColor=float3(0.0, 0.0, 0.0);
  3120. #endif
  3121. color.xyz=lerp(color.xyz, EVignetteColor, vignetteold*EVignetteAmount);
  3122. #endif
  3123.  
  3124. #if (USE_HD6_VIGNETTE==1)
  3125. float rovigpwr = CircularPower; //for a circular vignette
  3126. float2 sqvigpwr = float2( SquareTop, SquareBottom ); // for the top and bottom of the screen
  3127. float vsatstrength = ColorDistortion; // color distortion
  3128. float vignettepow = ContrastSharpen; // increases the contrast and sharpness
  3129. float vstrengthatnight = VignetteBorder;
  3130.  
  3131. float2 inTex = IN.txcoord;
  3132. float vhnd = 0.5;
  3133. float4 voriginal = color;
  3134. float4 vcolor = voriginal;
  3135. vcolor.xyz=1;
  3136. inTex -= 0.5; // center
  3137. inTex.y += 0.01; // offset from the center
  3138. float vignette = saturate(1.0 - dot( inTex, inTex ));
  3139. vcolor *= pow( vignette, vignettepow );
  3140.  
  3141. float4 rvigtex = vcolor;
  3142. rvigtex.xyz = pow( vcolor.xyz, 1 );
  3143. rvigtex.xyz = lerp(float3(0.5, 0.5, 0.5), rvigtex.xyz, 2.25); // contrast
  3144. rvigtex.xyz = lerp(float3(1,1,1),rvigtex.xyz,rovigpwr); // strength of the circular vinetty
  3145.  
  3146. //darken the top and bottom
  3147. float4 vigtex = vcolor;
  3148. vcolor.xyz = float3(1,1,1);
  3149.  
  3150. #if (LEFTANDRIGHT==1)
  3151. float3 topv = min((inTex.x+0.5)*2,1.5) * 2; // top
  3152. float3 botv = min(((0-inTex.x)+0.5)*2,1.5) * 2; // botton
  3153. topv= lerp(float3(1,1,1), topv, sqvigpwr.x);
  3154. botv= lerp(float3(1,1,1), botv, sqvigpwr.y);
  3155. vigtex.xyz = (topv)*(botv);
  3156. #endif
  3157. #if (TOPANDBOTTOM==1)
  3158. float3 topv = min((inTex.y+0.5)*2,1.5) * 2; // top
  3159. float3 botv = min(((0-inTex.y)+0.5)*2,1.5) * 2; // botton
  3160. topv= lerp(float3(1,1,1), topv, sqvigpwr.x);
  3161. botv= lerp(float3(1,1,1), botv, sqvigpwr.y);
  3162. vigtex.xyz = (topv)*(botv);
  3163. #endif
  3164. #if (CORNERDARKEN==1)
  3165. float3 rightv = min((inTex.x+0.5)*2,1.5) * 2;
  3166. float3 leftv = min(((0-inTex.x)+0.5)*2,1.5) * 2;
  3167. float3 topv = min((inTex.y+0.5)*2,1.5) * 2;
  3168. float3 botv = min(((0-inTex.y)+0.5)*2,1.5) * 2;
  3169. rightv= lerp(float3(1,1,1), rightv, sqvigpwr.y);
  3170. leftv= lerp(float3(1,1,1), leftv, sqvigpwr.x);
  3171. topv= lerp(float3(1,1,1), topv, sqvigpwr.x);
  3172. botv= lerp(float3(1,1,1), botv, sqvigpwr.y);
  3173. vigtex.xyz = (topv)*(botv)*(rightv)*(leftv);
  3174. #endif
  3175.  
  3176. // mix the two types of vignettes
  3177. vigtex.xyz*=rvigtex.xyz;
  3178. vigtex.xyz = lerp(vigtex.xyz,float3(1,1,1),(vhnd-vstrengthatnight*vhnd)); //for a dark screen
  3179. vigtex.xyz = min(vigtex.xyz,1);
  3180. vigtex.xyz = max(vigtex.xyz,0);
  3181. float3 vtintensity = dot(voriginal.xyz, float3(0.2125, 0.7154, 0.0721));
  3182. color.xyz = lerp(vtintensity, voriginal.xyz, ((((1-(vigtex.xyz*2))+2)-1)*vsatstrength)+1 );
  3183. color.xyz *= (vigtex.xyz);
  3184. #endif
  3185.  
  3186. #if (USE_BORDER==1)
  3187. float2 distancefromcenter = abs(IN.txcoord.xy - 0.5);
  3188. bool2 screen_border = step(0.5 - pixelsize,distancefromcenter);
  3189. color.xyz = (!dot(screen_border, 1.0)) ? color.xyz : 0.0;
  3190. #endif
  3191.  
  3192. #if (USE_MOVIEBARS == 1)
  3193. color.xyz = IN.txcoord.y > 0.12 && IN.txcoord.y < 0.88 ? color.xyz : 0.0;
  3194. #endif
  3195.  
  3196. #if(USE_DEPTHBUFFER_OUTPUT == 1)
  3197. color.xyz = pow(saturate(tex2D(SamplerDepth, IN.txcoord.xy).x),50);
  3198. #endif
  3199.  
  3200. return color;
  3201.  
  3202. }
  3203.  
  3204. float2 aorand(in float2 coord) //generating noise/pattern texture for dithering
  3205. {
  3206. float noiseX = ((frac(1.0-coord.x*(BUFFER_WIDTH/2.0))*0.25)+(frac(coord.y*(BUFFER_HEIGHT/2.0))*0.75))*2.0-1.0;
  3207. float noiseY = ((frac(1.0-coord.x*(BUFFER_WIDTH/2.0))*0.75)+(frac(coord.y*(BUFFER_HEIGHT/2.0))*0.25))*2.0-1.0;
  3208. return float2(noiseX,noiseY)*0.01;
  3209. }
  3210.  
  3211.  
  3212. float4 PS_SSAOGen(VS_OUTPUT_POST IN) : COLOR
  3213. {
  3214.  
  3215. //global variables
  3216. float2 pixelsize = float2(ScreenSize.y,ScreenSize.y*ScreenSize.z);
  3217. float4 color = tex2D(SamplerColorHDR1, IN.txcoord.xy);
  3218.  
  3219. #if (USE_SPLITSCREEN == 1)
  3220. if(IN.txcoord.x > 0.5) return color;
  3221. #endif
  3222.  
  3223. if(tex2D(SamplerDepth, IN.txcoord.xy).x > 0.999) return float4(color.xyz, 0.5);
  3224.  
  3225. float offsetScale = SSAO_Range/10000;
  3226. float fSSAODepthClip = 10000000.0;
  3227. float fSSAONoiseAmp = 2.0;
  3228.  
  3229. float GTS = abs(frac(Timer.x)-0.5);
  3230. float2 GTCS = cos(IN.txcoord.y)+tan(IN.txcoord.x) * 0.1;
  3231. float2 GS1 = GTCS + float2( 0.0, GTS );
  3232. float2 GS2 = GTCS + float2( GTS, 0.0 );
  3233. float2 GS3 = GTCS + float2( GTS, GTS );
  3234. float GN1 = random( GS1 );
  3235. float GN2 = random( GS2 );
  3236. float GN3 = random( GS3 );
  3237. float GN4 = ( GN1 + GN2 + GN3 ) * 0.333333333;
  3238. float3 GN = float3( GN4, GN4, GN4 );
  3239. float2 Randomized = float2( lerp(GN1,GN3,0.5), lerp(GN2,GN3,0.5));
  3240.  
  3241.  
  3242. float2 randfromTC = aorand(IN.txcoord.xy);
  3243. float2 rotationTC = ((IN.txcoord.xy + Randomized*3) * randfromTC) / 4.0f;
  3244. float3 vRotation = tex2Dlod(SamplerNoise, float4(rotationTC, 0, 0)).rgb - 0.5f;
  3245.  
  3246. float3x3 matRotate;
  3247.  
  3248. float hao = 1.0f / (1.0f + vRotation.z);
  3249.  
  3250. matRotate._m00 = hao * vRotation.y * vRotation.y + vRotation.z;
  3251. matRotate._m01 = -hao * vRotation.y * vRotation.x;
  3252. matRotate._m02 = -vRotation.x;
  3253. matRotate._m10 = -hao * vRotation.y * vRotation.x;
  3254. matRotate._m11 = hao * vRotation.x * vRotation.x + vRotation.z;
  3255. matRotate._m12 = -vRotation.y;
  3256. matRotate._m20 = vRotation.x;
  3257. matRotate._m21 = vRotation.y;
  3258. matRotate._m22 = vRotation.z;
  3259.  
  3260. float fSceneDepthP = linearlizeDepth(tex2Dlod(SamplerDepth, float4(IN.txcoord.xy,0,0)).x);
  3261. float fOffsetScaleStep = 1.0f + 2.4f / SSAO_Samples;
  3262. float fAccessibility = 0;
  3263.  
  3264. [loop]
  3265. for (int i = 0 ; i < (SSAO_Samples / 8) ; i++)
  3266. for (int x = -1 ; x <= 1 ; x += 2)
  3267. for (int y = -1 ; y <= 1 ; y += 2)
  3268. for (int z = -1 ; z <= 1 ; z += 2) {
  3269. //Create offset vector
  3270. float3 vOffset = normalize(float3(x, y, z)) * (offsetScale *= fOffsetScaleStep);
  3271. //Rotate the offset vector
  3272. float3 vRotatedOffset = mul(vOffset, matRotate);
  3273.  
  3274. //Center pixel's coordinates in screen space
  3275. float3 vSamplePos = float3(IN.txcoord.xy, fSceneDepthP);
  3276.  
  3277. //Offset sample point
  3278. vSamplePos += float3(vRotatedOffset.xy, vRotatedOffset.z * fSceneDepthP);
  3279.  
  3280. //Read sample point depth
  3281. float fSceneDepthS = linearlizeDepth(tex2Dlod(SamplerDepth, float4(vSamplePos.xy,0,0)).x);
  3282. //Discard if depth equals max
  3283. if (fSceneDepthS >= fSSAODepthClip)
  3284. fAccessibility += 1.0f;
  3285. else {
  3286. //Compute accessibility factor
  3287. float fDepthDist = fSceneDepthP - fSceneDepthS;
  3288. float fRangeIsInvalid = saturate(fDepthDist);
  3289. if(abs(fDepthDist)<SSAO_SampleRangeClipMin) fRangeIsInvalid = 1.0;
  3290. if(abs(fDepthDist)>SSAO_SampleRangeClipMax) fRangeIsInvalid = 1.0;
  3291. fAccessibility += lerp(fSceneDepthS > vSamplePos.z, 0.5f, fRangeIsInvalid);
  3292. }
  3293. }
  3294.  
  3295. //Compute average accessibility
  3296. fAccessibility = fAccessibility / SSAO_Samples;
  3297.  
  3298. //if(abs(fAccessibility-0.5) < 0.04 ) fAccessibility = 0.5;
  3299.  
  3300. color.w = fAccessibility;
  3301.  
  3302. return color;
  3303.  
  3304. }
  3305.  
  3306.  
  3307. float4 PS_SSAOBlurH(VS_OUTPUT_POST IN) : COLOR
  3308. {
  3309.  
  3310. //global variables
  3311. float2 pixelsize = float2(ScreenSize.y,ScreenSize.y*ScreenSize.z);
  3312. float4 color = tex2D(SamplerColorHDR2, IN.txcoord.xy);
  3313.  
  3314. #if (USE_SPLITSCREEN == 1)
  3315. if(IN.txcoord.x > 0.5) return color;
  3316. #endif
  3317.  
  3318. float weight[11] = {0.082607, 0.080977, 0.076276, 0.069041, 0.060049, 0.050187, 0.040306, 0.031105, 0.023066, 0.016436, 0.011254};
  3319.  
  3320. color.a *= weight[0];
  3321.  
  3322. for(int i=1; i < 11; i++)
  3323. {
  3324. color.a += tex2D(SamplerColorHDR2, IN.txcoord.xy + float2(0, i * pixelsize.x * SSAO_Smoothening)).a * weight[i];
  3325. color.a += tex2D(SamplerColorHDR2, IN.txcoord.xy - float2(0, i * pixelsize.x * SSAO_Smoothening)).a * weight[i];
  3326. }
  3327.  
  3328. return color;
  3329.  
  3330. }
  3331.  
  3332. float4 PS_SSAOBlurV(VS_OUTPUT_POST IN) : COLOR
  3333. {
  3334.  
  3335. //global variables
  3336. float2 pixelsize = float2(ScreenSize.y,ScreenSize.y*ScreenSize.z);
  3337. float4 color = tex2D(SamplerColorHDR1, IN.txcoord.xy);
  3338.  
  3339. #if (USE_SPLITSCREEN == 1)
  3340. if(IN.txcoord.x > 0.5) return color;
  3341. #endif
  3342.  
  3343. float weight[11] = {0.082607, 0.080977, 0.076276, 0.069041, 0.060049, 0.050187, 0.040306, 0.031105, 0.023066, 0.016436, 0.011254};
  3344.  
  3345. color.a *= weight[0];
  3346.  
  3347. for(int i=1; i < 11; i++)
  3348. {
  3349. color.a += tex2D(SamplerColorHDR1, IN.txcoord.xy + float2(i * pixelsize.y * SSAO_Smoothening, 0)).a * weight[i];
  3350. color.a += tex2D(SamplerColorHDR1, IN.txcoord.xy - float2(i * pixelsize.y * SSAO_Smoothening, 0)).a * weight[i];
  3351. }
  3352.  
  3353. float AOresult = color.a;
  3354.  
  3355. AOresult -= 0.5;
  3356. if(AOresult < 0) AOresult *= SSAO_DarkeningAmount;
  3357. if(AOresult > 0) AOresult *= SSAO_BrighteningAmount;
  3358. AOresult = 2.0*saturate(AOresult+0.5);
  3359.  
  3360. #if(SSAO_Debug == 0)
  3361. color.xyz *= AOresult;
  3362. #else
  3363. color.xyz = AOresult*0.5;
  3364. #endif
  3365.  
  3366. color.a = 1.0;
  3367.  
  3368. return color;
  3369.  
  3370. }
  3371.  
  3372. float4 PS_TiltShiftCoC(VS_OUTPUT_POST IN) : COLOR
  3373. {
  3374. float4 color;
  3375. color = tex2D(SamplerColorHDR1, IN.txcoord.xy);
  3376.  
  3377. #if (USE_SPLITSCREEN == 1)
  3378. if(IN.txcoord.x > 0.5) return color;
  3379. #endif
  3380.  
  3381. float2 orthogonal = float2(tan(TiltShiftAxis * 0.0174533), -ScreenSize.w);
  3382. float2 samplepos = orthogonal * TiltShiftOffset * ScreenSize.z;
  3383. float TS_Dist = abs(dot(IN.txcoord.xy + samplepos, orthogonal) / length(orthogonal));
  3384. float TS_BlurAmount = pow(saturate(TS_Dist), TiltShiftCurve);
  3385. color.a = TS_BlurAmount;
  3386. return color;
  3387. }
  3388.  
  3389. float4 PS_TiltShiftH(VS_OUTPUT_POST IN) : COLOR
  3390. {
  3391. float4 res = tex2D(SamplerColorHDR2, IN.txcoord.xy);
  3392.  
  3393. #if (USE_SPLITSCREEN == 1)
  3394. if(IN.txcoord.x > 0.5) return res;
  3395. #endif
  3396.  
  3397. float4 color = GaussBlur22(IN.txcoord.xy, SamplerColorHDR2, res.a*TiltShiftMult, 0, 0);
  3398. return color;
  3399. }
  3400.  
  3401. float4 PS_TiltShiftV(VS_OUTPUT_POST IN) : COLOR
  3402. {
  3403. float4 res = tex2D(SamplerColorHDR1, IN.txcoord.xy);
  3404.  
  3405. #if (USE_SPLITSCREEN == 1)
  3406. if(IN.txcoord.x > 0.5) return res;
  3407. #endif
  3408.  
  3409. float4 color = GaussBlur22(IN.txcoord.xy, SamplerColorHDR1, res.a*TiltShiftMult, 0, 1);
  3410. return color;
  3411. }
  3412.  
  3413.  
  3414. float4 PS_EmptyPassInit(VS_OUTPUT_POST IN) : COLOR
  3415. {
  3416. return tex2D(SamplerColorLDR, IN.txcoord.xy);
  3417. }
  3418.  
  3419. float4 PS_EmptyPassHDR1(VS_OUTPUT_POST IN) : COLOR //braucht tex2 als input
  3420. {
  3421. return tex2D(SamplerColorHDR2, IN.txcoord.xy);
  3422. }
  3423.  
  3424. float4 PS_EmptyPassHDR2(VS_OUTPUT_POST IN) : COLOR //braucht tex1 als input
  3425. {
  3426. return tex2D(SamplerColorHDR1, IN.txcoord.xy);
  3427. }
  3428.  
  3429. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  3430. // Techniques
  3431. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  3432.  
  3433.  
  3434. technique MasterEffect < bool enabled = true; int toggle = ReShade_ToggleKey; >
  3435. {
  3436. #if (USE_BLOOM == 1 || USE_GAUSSIAN_ANAMFLARE == 1 || USE_LENSDIRT == 1)
  3437. pass BloomPrePass
  3438. {
  3439. VertexShader = VS_PostProcess;
  3440. PixelShader = PS_BloomPrePass;
  3441. RenderTarget = texBloom1;
  3442. }
  3443.  
  3444. pass BloomPass1
  3445. {
  3446. VertexShader = VS_PostProcess;
  3447. PixelShader = PS_BloomPass1;
  3448. RenderTarget = texBloom2;
  3449. }
  3450.  
  3451. pass BloomPass2
  3452. {
  3453. VertexShader = VS_PostProcess;
  3454. PixelShader = PS_BloomPass2;
  3455. RenderTarget = texBloom3;
  3456. }
  3457.  
  3458. pass BloomPass3
  3459. {
  3460. VertexShader = VS_PostProcess;
  3461. PixelShader = PS_BloomPass3;
  3462. RenderTarget = texBloom4;
  3463. }
  3464.  
  3465. pass BloomPass4
  3466. {
  3467. VertexShader = VS_PostProcess;
  3468. PixelShader = PS_BloomPass4;
  3469. RenderTarget = texBloom5;
  3470. }
  3471. #endif
  3472.  
  3473. pass MasterEffectInitHDR
  3474. {
  3475. VertexShader = VS_PostProcess;
  3476. PixelShader = PS_EmptyPassInit;
  3477. RenderTarget = texColorHDR1;
  3478. }
  3479.  
  3480. #if (USE_SSAO == 1)
  3481. pass SSAOGen
  3482. {
  3483. VertexShader = VS_PostProcess;
  3484. PixelShader = PS_SSAOGen; //tex2
  3485. RenderTarget = texColorHDR2;
  3486. }
  3487.  
  3488. pass SSAOBlurH
  3489. {
  3490. VertexShader = VS_PostProcess;
  3491. PixelShader = PS_SSAOBlurH; //tex1
  3492. RenderTarget = texColorHDR1;
  3493. }
  3494.  
  3495. pass SSAOBlurV
  3496. {
  3497. VertexShader = VS_PostProcess;
  3498. PixelShader = PS_SSAOBlurV; //tex2
  3499. RenderTarget = texColorHDR2;
  3500. }
  3501.  
  3502. pass EmptyHDR1
  3503. {
  3504. VertexShader = VS_PostProcess;
  3505. PixelShader = PS_EmptyPassHDR1;
  3506. RenderTarget = texColorHDR1;
  3507. }
  3508. #endif
  3509.  
  3510. #if (USE_GP65CJ042DOF == 0 && USE_MATSODOF == 0 && USE_PETKAGTADOF == 1)
  3511. pass PETKADOF
  3512. {
  3513. VertexShader = VS_PostProcess;
  3514. PixelShader = PS_ProcessDoFBokeh;
  3515. RenderTarget = texColorHDR2;
  3516. } //tex2
  3517.  
  3518. pass EmptyHDR2
  3519. {
  3520. VertexShader = VS_PostProcess;
  3521. PixelShader = PS_EmptyPassHDR1;
  3522. RenderTarget = texColorHDR1;
  3523. }
  3524. #endif
  3525.  
  3526. #if (USE_GP65CJ042DOF == 0 && USE_MATSODOF == 1 && USE_PETKAGTADOF == 0)
  3527. pass MATSODOF1
  3528. {
  3529. VertexShader = VS_PostProcess;
  3530. PixelShader = PS_ProcessPass_FastDoF1; //tex2
  3531. RenderTarget = texColorHDR2;
  3532. }
  3533. pass MATSODOF2
  3534. {
  3535. VertexShader = VS_PostProcess;
  3536. PixelShader = PS_ProcessPass_FastDoF2; //tex1
  3537. RenderTarget = texColorHDR1;
  3538. }
  3539. pass MATSODOF3
  3540. {
  3541. VertexShader = VS_PostProcess;
  3542. PixelShader = PS_ProcessPass_FastDoF3; //tex2
  3543. RenderTarget = texColorHDR2;
  3544. }
  3545. pass MATSODOF4
  3546. {
  3547. VertexShader = VS_PostProcess;
  3548. PixelShader = PS_ProcessPass_FastDoF4; //tex1
  3549. RenderTarget = texColorHDR1;
  3550. }
  3551. #endif
  3552.  
  3553. #if (USE_GP65CJ042DOF == 1 && USE_MATSODOF == 0 && USE_PETKAGTADOF == 0)
  3554. pass GPDOF1
  3555. {
  3556. VertexShader = VS_PostProcess;
  3557. PixelShader = PS_GPDOFFocus;//tex2
  3558. RenderTarget = texColorHDR2;
  3559. }
  3560. pass GPDOF2
  3561. {
  3562. VertexShader = VS_PostProcess;
  3563. PixelShader = PS_GPDOFBokehblur;//tex1
  3564. RenderTarget = texColorHDR1;
  3565. }
  3566. pass GPDOF3
  3567. {
  3568. VertexShader = VS_PostProcess;
  3569. PixelShader = PS_GPDOFGaussianH;//tex2
  3570. RenderTarget = texColorHDR2;
  3571. }
  3572. pass GPDOF4
  3573. {
  3574. VertexShader = VS_PostProcess;
  3575. PixelShader = PS_GPDOFGaussianV;//tex1
  3576. RenderTarget = texColorHDR1;
  3577. }
  3578. #endif
  3579.  
  3580. #if(USE_TILTSHIFT == 1)
  3581. pass TiltShiftCoC
  3582. {
  3583. VertexShader = VS_PostProcess;
  3584. PixelShader = PS_TiltShiftCoC; //tex2
  3585. RenderTarget = texColorHDR2;
  3586. }
  3587. pass TiltShiftH
  3588. {
  3589. VertexShader = VS_PostProcess;
  3590. PixelShader = PS_TiltShiftH; //tex1
  3591. RenderTarget = texColorHDR1;
  3592. }
  3593. pass TiltShiftV
  3594. {
  3595. VertexShader = VS_PostProcess;
  3596. PixelShader = PS_TiltShiftV; //tex2
  3597. RenderTarget = texColorHDR2;
  3598. }
  3599.  
  3600. pass EmptyHDR3
  3601. {
  3602. VertexShader = VS_PostProcess;
  3603. PixelShader = PS_EmptyPassHDR1;
  3604. RenderTarget = texColorHDR1;
  3605. }
  3606. #endif
  3607.  
  3608. pass Image
  3609. {
  3610. VertexShader = VS_PostProcess;
  3611. PixelShader = PS_Image; //tex2
  3612. RenderTarget = texColorHDR2;
  3613. }
  3614.  
  3615. #if (USE_CHROMATICABBERATION == 1)
  3616. pass Distort
  3617. {
  3618. VertexShader = VS_PostProcess;
  3619. PixelShader = PS_Distort; //tex1
  3620. RenderTarget = texColorHDR1;
  3621. }
  3622.  
  3623. pass EmptyHDR4
  3624. {
  3625. VertexShader = VS_PostProcess;
  3626. PixelShader = PS_EmptyPassHDR2;
  3627. RenderTarget = texColorHDR2;
  3628. }
  3629. #endif
  3630.  
  3631. pass Lighting
  3632. {
  3633. VertexShader = VS_PostProcess;
  3634. PixelShader = PS_Lighting;
  3635. RenderTarget = texColorHDR1;
  3636. } //tex1
  3637.  
  3638. pass Colors
  3639. {
  3640. VertexShader = VS_PostProcess;
  3641. PixelShader = PS_Colors;
  3642. RenderTarget = texColorHDR2;
  3643. }//tex2
  3644.  
  3645. pass Overlay
  3646. {
  3647. VertexShader = VS_PostProcess;
  3648. PixelShader = PS_Overlay;
  3649. }//nix
  3650. }
Advertisement
Add Comment
Please, Sign In to add comment