Guest User

Tales of Zestiria ReShade/MasterEffect profile

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