Advertisement
Guest User

Praise the Sun v1.1

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