robgrab

Saint's Row IV ReShade Preset

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