Advertisement
Guest User

ReShade - Tomb Raider

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