Advertisement
midhras

Midhrastic HD6 PP3/PP2 enbeffect.fx

Jul 1st, 2013
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 83.68 KB | None | 0 0
  1. // M I D H R A S T I C   E N B   F O R   F A L L O U T   3
  2.  
  3. //++++++++++++++++++++++++++++++++++++++++++++
  4. // ENBSeries effect file
  5. // visit http://enbdev.com for updates
  6. // Copyright (c) 2007-2011 Boris Vorontsov
  7. //
  8. // Using decompiled shader of TES Skyrim
  9. //++++++++++++++++++++++++++++++++++++++++++++
  10.  
  11. //++++++++++++++++++++++++++++++++++++++++++++
  12. // Additions and Tweaking by HD6 (HeliosDoubleSix) v11.3
  13. // MOD by HD6: http://www.skyrimnexus.com/downloads/file.php?id=4142
  14. // MOD by ENB: http://www.skyrimnexus.com/downloads/file.php?id=2971
  15. // these are typically denoted by 'HD6'
  16. // given I have no shader writing experience,
  17. // will undoubtedly be retarded to a seasoned professional, I welcome any advice!
  18. // thanks Boris!
  19. //++++++++++++++++++++++++++++++++++++++++++++
  20.  
  21. // Remove or add '//' infront of '#define' below to disable / enable the various options
  22.  
  23. ////
  24.  
  25. // ENB - values could be 1, 2, 3 or 4. v4 gives unrealistic, kind of artwork style, v5 is added by HD6
  26.     #define POSTPROCESS 3
  27. //
  28.  
  29. // ENB - use original game processing first, then mine
  30.     //#define APPLYGAMECOLORCORRECTION
  31. //
  32.  
  33. // ENB - use original game processing only, with vanilla bloom (basically turns everything off)
  34.     //#define ENB_FLIPTECHNIQUE
  35. //
  36.  
  37. ////
  38.  
  39. // HD6 - Color Balance and Brightness, Contrast adjustment
  40.     //
  41.     #define HD6_COLOR_TWEAKS
  42.     #define HD6_DARKER_NIGHTS
  43.     // Right now if you do NOT darken the nights, the night sky will be very bright unless changes in enbseries.ini
  44.     //
  45.     // Put // or remove the // infront of "#define HD6_DARKER_NIGHTS" above, to darken the nights or not.. // will put nights back to normal
  46.     //
  47.     // This is by default and for examples sake set to make the nights even darker
  48.     // When you decrease brightness you will need to increase contrast or it will look washed out
  49.     // and if you increrase contrast that naturally increases saturation so you need to reduce saturation
  50.     // this is just the nature of color correction :-)
  51.     //
  52.     // Note nights and days are being desaturated per channel(RGB) using: HD6_COLORSAT_DAYNIGHT elsewhere
  53.     // Note Bloom is not affected by this and gets its own color/contrast adjustment in HD6_BLOOM_CRISP and HD6_BLOOM_DEBLUEIFY if used
  54.     //
  55.     // If the 3 numbers in rgb below do not add up to 3 it will either be darker or lighter than before
  56.     float3 rgbd     = float3(1, 1, 1 );         // RGB balance day
  57.     float3 rgbn     = float3( 1.9, 2.1, 2.2 );      // RGB balance night
  58.     //
  59.     // First column of the 3 here is for key control only during night
  60.     // ie you can press number '1' with pageup or pagedown to alter the brightness while playing
  61.     // As you press pagedown it moves further towards the values in this first column.
  62.     // As a helpful indicator you can see if you have moved away from default values by
  63.     // noticing a very small white dot in top left corner of screen.
  64.     // Adjust with keys till this dot vanishes, then it is back to default
  65.     // The Keycontrol ONLY affects the night right now. So dont try using it during the day it wont do anything.
  66.    
  67.    
  68.         // Darker Nights ( Night Keypress 1+Pageup/down, Night, Day )
  69.         // Only uses these values if "#define HD6_DARKER_NIGHTS" does not have '//' infront
  70.        
  71.         //      keypress 1,2:     night, day        night, day
  72.         float4 uctbrt1  = float4( 0.30, 0.30,       0.925, 1.05 );  // Brightness Night, Day (Alters before contrast adjustment)
  73.         float4 uctbrt2  = float4( 0.30, 0.30,       0.975, 1.10 );  // Brightness Night, Day (Alters after contrast adjustment)
  74.         float4 uctcon   = float4( 1.05, 1.05,       1.150, 1.25 );  // Contrast Night, Day, v11.2: 1.0, 0.97, 0.85
  75.         float4 uctsat   = float4( 1.00, 0.8,        1.150, 0.72 );  // Saturation Night, Day (Remember if using HD6_COLORSAT_DAYNIGHT that will also be desaturating the night)
  76.    
  77.     #ifdef HD6_DARKER_NIGHTS
  78.         float4 darkenby1 = float4( 0.30, 0.30,  0.2, 0.40 );
  79.     #endif
  80.    
  81.            
  82.     //
  83.     // I have stopped relying on the palette map to darken nights, now I do all darkening here
  84.     // When reducing brightness it seems increasing saturation is needed to restore color, anda slight increase in contrast to maintain bright spots/flames etc
  85.     // Remember this is not darkening the bloom, which in itself has as impact on the overall brightness and hazyness of the scene
  86.     //
  87.     // Palette map right now is increasing contrast so I have compensated by reducing contrast here (lazy)
  88. //
  89. //HD6 - Enable Vignette - darkens and blurs edges of the screen which increasesfocus on center, film/camera type effect/look
  90.     // didnt bother adding blur, could do without muddying and fuzzing things really
  91.     // and the effect is only meant to be super subtle not a pin hole camera -_-
  92.     //
  93.     //#define HD6_VIGNETTE
  94.     //
  95.     // Defaults below, I darken the corners and the bottom only, leaving the top light
  96.     // darkening all sides feels ike you are trapping/closing in the view too much, so it is not a normal vignette
  97.     // And it is subtle, till you turn it off I doubt you would ever even notice it
  98.     // Also is turned off at night
  99.     //
  100.     float rovigpwr = 360.0; // For Round vignette // 0.2
  101.     float2 sqvigpwr = float2( 1.975, 1.975 ); // For square vignette: (top, bottom)
  102.     //
  103.     float vsatstrength = 0; // How saturated vignette is
  104.     float vignettepow = 0; // For Round vignette, higher pushes it to the corners and increases contrast/sharpness
  105.     //
  106.     float vstrengthatnight = 360.0; // How strong vignette is as night, 0-1
  107.  
  108. // HD6 - Desaturate Nights, can alter saturation seperately from day and night, will affect caves and indoors also for now
  109.     //
  110.     #define HD6_COLORSAT_DAYNIGHT
  111.     //
  112.     // Nighttime Saturation, Red, Green, Blue
  113.     float3 dnsatn = float3(1.35, 1.35, 1.35 );
  114.     //
  115.     // Daytime Saturation, Red, Green, Blue
  116.     float3 dnsatd = float3(2.8, 2.75, 2.75);
  117. //
  118.  
  119. // HD6 - removes blue tint from bloom, most apparent in distant fog
  120.     //
  121.     #define HD6_BLOOM_DEBLUEIFY
  122.     //
  123.     // HeliosDoubleSix cobbled code to deblueify bloom without loosing brightness huzah! - First time writing shader code so be gentle
  124.     // desaturates bloom, to do this you cant just remove a color or tone it down you need to redistribute it evenly across all channels to make it grey
  125.     // well evenly would make sense but the eye has different sensetivities to color so its actually RGB (0.3, 0.59, 0.11) to achieve greyscale
  126.     // Careful as removing too muchblue can send snow and early morning pink   
  127.     //
  128.     //float3 nsat=float3(0.6,0.118,0.22);
  129.     float3 nsat = float3(1.27, 1.33, 1.03);
  130. //
  131.  
  132. // HD6 - Enable Bloom - disable bloom with this if you turn it off in enbseries, compensates for darkening
  133.     #define USEBLOOM
  134. //
  135.  
  136. //  Pick one or none:
  137. // HD6 - BLOOM 1 - alternate crisp bloom, no hazey mud
  138.     //#define HD6_BLOOM_CRISP
  139. // HD6 - BLOOM 2 - alternate bloom (using screen mode) I have abadoned this code
  140.     //#define HD6_BLOOM_SCREEN
  141. //
  142.  
  143. // HD6 - old weird serendipitous code to defuzz bloom
  144.     //#define HD6_BLOOM_DEFUZZ
  145. //
  146.  
  147. // HD6 - remove black from bloom, not working very well
  148. //  #define HD6_BLOOM_NOBLACK
  149. //
  150.  
  151. // Keyboard controlled temporary variables (in some versions exists in the config file).
  152. // Press and hold key 1,2,3...8 together with PageUp or PageDown to modify. By default all set to 1.0
  153.     float4  tempF1; // 0,1,2,3
  154.     float4  tempF2; // 5,6,7,8
  155.     float4  tempF3; // 9,0
  156.  
  157. // x=generic timer in range 0..1, period of 16777216 ms (4.6 hours), w=frame time elapsed (in seconds)
  158.     float4  Timer;
  159. // x=Width, y=1/Width, z=ScreenScaleY, w=1/ScreenScaleY
  160.     float4  ScreenSize;
  161. // changes in range 0..1, 0 means that night time, 1 - day time
  162.     float   ENightDayFactor;
  163.    
  164. // enb version of bloom applied, ignored if original post processing used
  165.     float   EBloomAmount;
  166.  
  167. //+++++++++++++++++++++++++++++
  168. //POSTPROCESS 1
  169.     float   EAdaptationMinV1 = 0.05;
  170.     float   EAdaptationMaxV1 = 0.125;
  171.     float   EContrastV1 = 1.0;
  172.     float   EColorSaturationV1 = 1.3;
  173.     float   EToneMappingCurveV1 = 3.0;
  174. //+++++++++++++++++++++++++++++
  175.  
  176. //+++++++++++++++++++++++++++++
  177. //POSTPROCESS 2
  178. #if (POSTPROCESS==2)
  179. float   EBrightnessV2=1.05;
  180. float   EAdaptationMinV2=0.535;
  181. float   EAdaptationMaxV2=0.75;
  182. float   EToneMappingCurveV2=1.05;
  183. float   EIntensityContrastV2=1.05;
  184. float   EColorSaturationV2=1.35;
  185. float   EToneMappingOversaturationV2=75; //250;
  186. #endif
  187. //+++++++++++++++++++++++++++++
  188.  
  189. //+++++++++++++++++++++++++++++
  190. //POSTPROCESS 5 by HD6
  191. #if (POSTPROCESS==5)
  192.     // HD6 - Adaptation is now ignored by my choice
  193.     float   EAdaptationMinV2 = 0.28; // 0.28 // lower gets brighter
  194.    
  195.     // Increase this to darken days, but darkening them will kill the sky a bit unless you enable the SKY overirde in enberies.ini
  196.     float   EAdaptationMaxV2 = 0.30; // 0.30 // 0.65 // 0.35 // 0.29
  197.  
  198.     // Set ridiculously high, was 8, was in attempt to keep hair colour intact
  199.     float   EToneMappingCurveV2 = 7; // 130
  200.  
  201.     // Adjusting this will throw out all the other values, icreased to high levels to combat how high I increased ToneMappingCurve to bring some contrast back in to daytime
  202.     float   EIntensityContrastV2 = 1.0; // 3.375 // 4.75 // 3.975
  203.  
  204.     // high saturation also helps pop the pink/orange sunsets/mornings at 6.30pm and 7.30am, but also nights then get very blue
  205.     // Increasing this will darken things in the process
  206.     // v11.2 = 3.0, 1.0 increased to put even more color into the game
  207.     float   EColorSaturationV2 = 1.65; // 1.65;
  208.     float   HCompensateSat = 5; // Compensate for darkening caused by increasing EColorSaturationV2
  209.  
  210.     // Not using this now anymore
  211.     float   EToneMappingOversaturationV2 = 100.0;
  212. #endif
  213. //+++++++++++++++++++++++++++++
  214.  
  215. //+++++++++++++++++++++++++++++
  216. //POSTPROCESS 3
  217. float   EAdaptationMinV3=0.11; //0.535;
  218. float   EAdaptationMaxV3=0.125; //0.85;
  219. float   EToneMappingCurveV3=4.0; //0.995;
  220. float   EToneMappingOversaturationV3=100; //100;
  221. //+++++++++++++++++++++++++++++
  222.  
  223. //+++++++++++++++++++++++++++++
  224. //POSTPROCESS 4
  225.     float   EAdaptationMinV4 = 1.1;
  226.     float   EAdaptationMaxV4 = 1.325;
  227.     float   EBrightnessCurveV4 = 1.0;
  228.     float   EBrightnessMultiplierV4 = 0.8;
  229.     float   EBrightnessToneMappingCurveV4 = 0.4;
  230. //+++++++++++++++++++++++++++++
  231.  
  232. //+++++++++++++++++++++++++++++
  233. //external parameters, do not modify
  234. //+++++++++++++++++++++++++++++
  235.     texture2D texs0; // color
  236.     texture2D texs1; // bloom skyrim
  237.     texture2D texs2; // adaptation skyrim
  238.     texture2D texs3; // bloom enb
  239.     texture2D texs4; // adaptation enb
  240.     texture2D texs7; // palette enb
  241.  
  242. sampler2D _s0 = sampler_state {
  243.     Texture   = <texs0>;
  244.     MinFilter = POINT;
  245.     MagFilter = POINT;
  246.     MipFilter = NONE; // LINEAR;
  247.     AddressU  = Clamp;
  248.     AddressV  = Clamp;
  249.     SRGBTexture=FALSE;
  250.     MaxMipLevel=0;
  251.     MipMapLodBias=0;
  252. };
  253.  
  254. sampler2D _s1 = sampler_state {
  255.     Texture   = <texs1>;
  256.     MinFilter = LINEAR;
  257.     MagFilter = LINEAR;
  258.     MipFilter = NONE; // LINEAR;
  259.     AddressU  = Clamp;
  260.     AddressV  = Clamp;
  261.     SRGBTexture=FALSE;
  262.     MaxMipLevel=0;
  263.     MipMapLodBias=0;
  264. };
  265.  
  266. sampler2D _s2 = sampler_state {
  267.     Texture   = <texs2>;
  268.     MinFilter = LINEAR;
  269.     MagFilter = LINEAR;
  270.     MipFilter = NONE; // LINEAR;
  271.     AddressU  = Clamp;
  272.     AddressV  = Clamp;
  273.     SRGBTexture=FALSE;
  274.     MaxMipLevel=0;
  275.     MipMapLodBias=0;
  276. };
  277.  
  278. sampler2D _s3 = sampler_state {
  279.     Texture   = <texs3>;
  280.     MinFilter = LINEAR;
  281.     MagFilter = LINEAR;
  282.     MipFilter = NONE; // LINEAR;
  283.     AddressU  = Clamp;
  284.     AddressV  = Clamp;
  285.     SRGBTexture=FALSE;
  286.     MaxMipLevel=0;
  287.     MipMapLodBias=0;
  288. };
  289.  
  290. sampler2D _s4 = sampler_state {
  291.     Texture   = <texs4>;
  292.     MinFilter = LINEAR;
  293.     MagFilter = LINEAR;
  294.     MipFilter = NONE; // LINEAR;
  295.     AddressU  = Clamp;
  296.     AddressV  = Clamp;
  297.     SRGBTexture=FALSE;
  298.     MaxMipLevel=0;
  299.     MipMapLodBias=0;
  300. };
  301.  
  302. sampler2D _s7 = sampler_state {
  303.     Texture   = <texs7>;
  304.     MinFilter = LINEAR;
  305.     MagFilter = LINEAR;
  306.     MipFilter = NONE;
  307.     AddressU  = Clamp;
  308.     AddressV  = Clamp;
  309.     SRGBTexture=FALSE;
  310.     MaxMipLevel=0;
  311.     MipMapLodBias=0;
  312. };
  313.  
  314. struct VS_OUTPUT_POST {
  315.     float4 vpos     : POSITION;
  316.     float2 txcoord0 : TEXCOORD0;
  317. };
  318.  
  319. struct VS_INPUT_POST {
  320.     float3 pos      : POSITION;
  321.     float2 txcoord0 : TEXCOORD0;
  322. };
  323.  
  324. VS_OUTPUT_POST VS_Quad(VS_INPUT_POST IN){
  325.     VS_OUTPUT_POST OUT;
  326.     OUT.vpos=float4(IN.pos.x,IN.pos.y,IN.pos.z,1.0);
  327.     OUT.txcoord0.xy=IN.txcoord0.xy;
  328.     return OUT;
  329. };
  330.  
  331. //skyrim shader specific externals, do not modify
  332.     float4 _c1 : register(c1); float4 _c2 : register(c2); float4 _c3 : register(c3);
  333.     float4 _c4 : register(c4); float4 _c5 : register(c5);
  334.  
  335. float4 PS_D6EC7DD1(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR {
  336.     float4 _oC0 = 0.0; // output
  337.     float4 _c6 = float4(0, 0, 0, 0);
  338.     float4 _c7 = float4(0.212500006, 0.715399981, 0.0720999986, 1.0);
  339.     float4 r0; float4 r1; float4 r2; float4 r3; float4 r4; float4 r5; float4 r6;
  340.     float4 r7; float4 r8; float4 r9; float4 r10; float4 r11; float4 _v0=0.0;
  341.     _v0.xy = IN.txcoord0.xy;
  342.     r1=tex2D(_s0, _v0.xy); // color
  343.     r11=r1; // my bypass
  344.     _oC0.xyz=r1.xyz; // for future use without game color corrections
  345.    
  346.     // HD6 - You can play with the night/day value here, not that its advisable to :-D
  347.     // Visualize this with 'debug triangle' further down
  348.     float hnd = ENightDayFactor;
  349.     //hnd-=0.4;
  350.     //hnd = hnd - (0.5-hnd);
  351.     //hnd = max(hnd,0);
  352.     //hnd = min(hnd,1);
  353.     //hnd=1;
  354.    
  355.     float2 hndtweak = float2( 3.1 , 1.5 );
  356.     float vhnd = hnd; // effects vignette stregth;
  357.     float bchnd = hnd; // effects hd6 bloom crisp
  358.     float cdhnd = hnd; // effects hd6 colorsat daynight
  359.    
  360.     // Some caves are seen as daytime, so I set key 3 to force nightime
  361.     // This doesnt work very well >_<
  362.     hnd = tempF1.z < 1 ? 0 : hnd;
  363.     hndtweak.x = tempF1.z < 1 ? hndtweak.y : hndtweak.x; // Dont ask, I have no idea why I need this lol
  364.    
  365.    
  366.     // HD6 - Alter Brightness using keyboard during gameplay
  367.        
  368.         float4 tuctbrt1 = uctbrt1;
  369.         float4 tuctbrt2 = uctbrt2;
  370.         float4 tuctcon  = uctcon;
  371.         float4 tuctsat  = uctsat;
  372.        
  373.         #ifdef HD6_DARKER_NIGHTS
  374.             tuctbrt1 -= darkenby1;
  375.         #endif
  376.                
  377.         float h1 = lerp(-1,1,tempF1.x); // Increases speed it changes by when pressing key     
  378.         h1 = lerp( h1, 1, hnd ); // Removes affect during day      
  379.         h1 = h1 - (h1 % 0.1); // Changes it so incriments are in steps, remove this if you want smooth changes when pressing keys
  380.         //float hbs = EBloomAmount;
  381.         float hbs = lerp( EBloomAmount/2, EBloomAmount, h1); // Reduce bloom as it gets darker, otherwise it just gets hazier, higher number reduces bloom more as it gets darker
  382.        
  383.         float h2 = lerp(-1,1,tempF1.y); // Increases speed it changes by when pressing key
  384.         h2 = lerp( 1, h2, hnd ); // Removes affect during night
  385.         h2 = h2 - (h2 % 0.1); // Changes it so incriments are in steps, remove this if you want smooth changes when pressing keys
  386.         hbs = lerp( (hbs/2)-1, hbs, h2); // Reduce bloom as it gets darker, otherwise it just gets hazier, higher number reduces bloom more as it gets darker
  387.         hbs = max(0,hbs);
  388.         hbs = min(2,hbs); // should be able to go above 1, but not 2
  389.        
  390.         vhnd = lerp(-2,hnd,h2);
  391.         vhnd = max(0,vhnd); // do not go below 0;
  392.         vhnd = min(1,vhnd); // not above 1, just incase people like surface of sun
  393.  
  394.         cdhnd=bchnd=vhnd;
  395.         //cdhnd=0;
  396.         //bchnd=0;
  397.         //vhnd=0;
  398.        
  399.         #ifdef HD6_COLOR_TWEAKS
  400.             //float2 uctbrt1t =     float2( lerp( tuctbrt1.x,   tuctbrt1.y, h1), tuctbrt1.z );
  401.             //float2 uctbrt2t =     float2( lerp( tuctbrt2.x,   tuctbrt2.y, h1), tuctbrt2.y );         
  402.             //float2 uctcont  = float2( lerp( tuctcon.x,    tuctcon.y,  h1), tuctcon.z );
  403.             //float2 uctsatt  = float2( lerp( tuctsat.x,    tuctsat.y,  h1), tuctsat.z );
  404.             float2 uctbrt1t =   float2( lerp( tuctbrt1.x,   tuctbrt1.z, h1), lerp( tuctbrt1.y,  tuctbrt1.w, h2) );
  405.             float2 uctbrt2t =   float2( lerp( tuctbrt2.x,   tuctbrt2.z, h1), lerp( tuctbrt2.y,  tuctbrt2.w, h2) );         
  406.             float2 uctcont  =   float2( lerp( tuctcon.x,    tuctcon.z,  h1), lerp( tuctcon.y,   tuctcon.w, h2) );
  407.             float2 uctsatt  =   float2( lerp( tuctsat.x,    tuctsat.z,  h1), lerp( tuctsat.y,   tuctsat.w, h2) );
  408.         #endif
  409.        
  410.     ////
  411.    
  412.    
  413.    
  414.     #ifdef APPLYGAMECOLORCORRECTION
  415.         //apply original
  416.         r0.x=1.0/_c2.y;
  417.         r1=tex2D(_s2, _v0);
  418.  
  419.         r1.xyz = lerp( 0.18, 1.1, hnd ); // HD6 - disable vanilla adapation... because it drives me CRAAAZY!!!!! >_<
  420.         r1.xyz+=1.0;
  421.         r1.xyz = lerp( min( 0.015, r1.xyz ), 0.007, hnd ); // Ligthen if dark, but do not darken if too light, we do this elsewhere for extreme bright situations
  422.         // No seriously it screws up when looking at bright lights at night and the sky during day
  423.        
  424.        
  425.        
  426.         r0.yz=r1.xy * _c1.y;
  427.         r0.w=1.0/r0.y;
  428.         r0.z=r0.w * r0.z;
  429.         r1=tex2D(_s0, _v0);
  430.         r1.xyz=r1 * _c1.y;
  431.         r0.w=dot(_c7.xyz, r1.xyz);
  432.         r1.w=r0.w * r0.z;
  433.         r0.z=r0.z * r0.w + _c7.w;
  434.         r0.z=1.0/r0.z;
  435.         r0.x=r1.w * r0.x + _c7.w;
  436.         r0.x=r0.x * r1.w;
  437.         r0.x=r0.z * r0.x;
  438.         if (r0.w<0) r0.x=_c6.x;
  439.         r0.z=1.0/r0.w;
  440.         r0.z=r0.z * r0.x;
  441.         r0.x=saturate(-r0.x + _c2.x);
  442.  
  443.         //r2=tex2D(_s3, _v0); // enb bloom
  444.         r2=tex2D(_s1, _v0);//skyrim bloom
  445.        
  446.         #ifdef USEBLOOM
  447.             r2.xyz=min(r2,0.5); // HD6 code to stop bloom causing glitches, inverting
  448.             r2.xyz=max(r2,0.1);
  449.         #else
  450.             r2.xyz=0.0; // compensate for lack of bloom
  451.         #endif
  452.         r2.xyz=0.00; // Screw it bloom should not happen here at all so just set to 0
  453.         r2+=0.000; // HD6 - I add 0.1 to lighten it a bit, probably not great place to do it now
  454.  
  455.             //r2=tex2D(_s1, _v0); // skyrim bloom
  456.         r2.xyz=r2 * _c1.y;
  457.         r2.xyz=r0.x * r2;
  458.                
  459.         r1.xyz=r1 * r0.z + r2;
  460.         r0.x=dot(r1.xyz, _c7.xyz);
  461.         r1.w=_c7.w;
  462.        
  463.         r2=lerp(r0.x, r1, _c3.x);
  464.            
  465.         r1=r0.x * _c4 - r2;
  466.         r1=_c4.w * r1 + r2;
  467.         r1=_c3.w * r1 - r0.y; // khajiit night vision _c3.w
  468.         r0=_c3.z * r1 + r0.y;
  469.         r1=-r0 + _c5;
  470.        
  471.         _oC0=_c5.w * r1 + r0;
  472.         //_oC0=r0;
  473.     #endif // APPLYGAMECOLORCORRECTION
  474.  
  475.     float4 color=_oC0;     
  476.    
  477.     //HD6 brighten when not using original gamma, so they are at least similiar
  478.     // Bloom is diminshed for some reason, oh well, i dont use this
  479.     #ifndef APPLYGAMECOLORCORRECTION
  480.         color*=1.2;
  481.         color+=0.1;        
  482.     #endif
  483.    
  484.     #ifdef HD6_COLORSAT_DAYNIGHT
  485.         // HeliosDoubleSix code to Desaturate at night 
  486.         // What channels to desaturate by how much, so you could just reduce blue at night and nothing else
  487.         // doesnt seem quite right will tinge things green if you just remove blue :-/ thought perhaps that makes perfect sense :-) *brain hurts*
  488.         // Remember this affects caves, so might be best to remove saturation from nighttime direct and ambient light
  489.         float3 nsatn=lerp(dnsatd,dnsatn,1-cdhnd); // So it has less to different/no effect during day
  490.             //nsatn*=(1-cdhnd); // affect by night time value:
  491.         float3 oldcoln = color.xyz; // store old values
  492.         color.xyz *= nsatn; // adjust saturation   
  493.        
  494.         // spread lost luminace over everything
  495.             //float3 greycn = float3(0.699, 0.887, 0.414); // perception of color luminace
  496.         float3 greycn = float3(0.333,0.333,0.333); // screw perception
  497.             greycn = float3(0.811,0.523,0.996);
  498.         //color.xyz += (oldcoln.x-(oldcoln.x*nsatn.x)) * greycn.x;
  499.         //color.xyz += (oldcoln.y-(oldcoln.y*nsatn.y)) * greycn.y;
  500.         //color.xyz += (oldcoln.z-(oldcoln.z*nsatn.z)) * greycn.z;
  501.     #endif 
  502.    
  503. /*
  504.     #ifndef APPLYGAMECOLORCORRECTION
  505.         //temporary fix for khajiit night vision, but it also degrade colors.
  506.         //  r1=tex2D(_s2, _v0);
  507.         //  r0.y=r1.xy * _c1.y;
  508.         r1=_oC0;
  509.         r1.xyz=r1 * _c1.y;
  510.         r0.x=dot(r1.xyz, _c7.xyz);
  511.         r2=lerp(r0.x, r1, _c3.x);
  512.         r1=r0.x * _c4 - r2;
  513.         r1=_c4.w * r1 + r2;
  514.         r1=_c3.w * r1;// - r0.y;
  515.         r0=_c3.z * r1;// + r0.y;
  516.         r1=-r0 + _c5;
  517.         _oC0=_c5.w * r1 + r0;
  518.     #endif //!APPLYGAMECOLORCORRECTION
  519. */
  520.  
  521.  
  522.  
  523.  
  524.     //adaptation in time
  525.     float4  Adaptation=tex2D(_s4, 0.5);
  526.     float   grayadaptation=max(max(Adaptation.x, Adaptation.y), Adaptation.z);
  527.         //grayadaptation=1.0/grayadaptation;
  528.  
  529.  
  530.     float4  xcolorbloom=tex2D(_s3, _v0.xy); //bloom
  531.    
  532.     #ifdef HD6_BLOOM_NOBLACK
  533.         // Helios code to remove dark/black from bloom, stopping it making dark shapes on light background bleed and smudge black into them like a black glow yuck
  534.         // not really very good, looks like black glow is actually coming from original vanilla game or something, so its toned down for now to 0.05
  535.             // really should make bloom only contain and affect light areas of scene, but this is ok for now.
  536.             //This also has the side effect of lightening those darkest areas
  537.         float lowestvalue=min(min(xcolorbloom.x,xcolorbloom.y),xcolorbloom.z);
  538.             // work out lowest possible value to set RGB without going below 0 and without changing the RGB relative values ie shifting the color in the process
  539.         float3 lowestpossible=xcolorbloom.xyz-lowestvalue;
  540.         xcolorbloom.xyz=max(xcolorbloom.xyz,lowestpossible+(0.22*(1-hnd))); // adds 0.1 during night only
  541.     #endif
  542.    
  543.     //xcolorbloom.xyz=0.2; //HDebug
  544.     //float maxb=max(xcolorbloom.x, max(xcolorbloom.y, xcolorbloom.z));
  545.     //float violetamount=maxb/(maxb+EVioletShiftAmountInv);
  546.     //xcolorbloom.xyz=lerp(xcolorbloom.xyz, xcolorbloom.xyz*EVioletShiftColor, violetamount*violetamount);
  547.  
  548.     #ifdef HD6_BLOOM_DEBLUEIFY
  549.        
  550.         //New saturation to be // 0 being no color
  551.                 //float3 nsat=float3(1,0.74,0.64); // perfect-ish - removes blue and green from fog and outdoors, makes dwarven ruins very white though
  552.                 //float3 nsat=float3(1,0.80,0.74); // Touch greener
  553.                 //float3 nsat=float3(1,0.70,0.65); // Grey, very grey ice gaves almost white, but... foggy days go pink
  554.             //nsat=float3(0.85,0.75,0.7); // More reasnioable, still pink sky and snow in places
  555.             //nsat=float3(0.80,0.75,0.73);
  556.                 //float3 nsat=float3(1,0.64,0.58);
  557.                 //float3 nsat=float3(1,0.74,0.90); 
  558.                 //float3 nsat=float3(0.8,0.56,0.46);
  559.                 //float3 nsat=float3(0.7,0.6,0.4); // desatures everything a bit
  560.                 //float3 nsat=float3(0,0,0); // no color in bloom, makes everything very desaturated, fire looks white almost
  561.  
  562.         // store old values
  563.             float3 oldcol=xcolorbloom.xyz;
  564.            
  565.         // adjust saturation
  566.             xcolorbloom.xyz *= nsat;
  567.            
  568.         // spread lost luminace over everything
  569.                 //float3 greyc = float3(0.299, 0.587, 0.114); // perception of color luminace
  570.             float3 greyc = float3(0.333,0.333,0.333); // screw perception
  571.             xcolorbloom.xyz += (oldcol.x-(oldcol.x*nsat.x)) * greyc.x;
  572.             xcolorbloom.xyz += (oldcol.y-(oldcol.y*nsat.y)) * greyc.y;
  573.             xcolorbloom.xyz += (oldcol.z-(oldcol.z*nsat.z)) * greyc.z;
  574.  
  575.         // equiv to bloom off without destroyng scene luminance-ish
  576.         //xcolorbloom.x=0.3;
  577.         //xcolorbloom.y=0.3;
  578.         //xcolorbloom.z=0.3;
  579.  
  580.         //xcolorbloom.xyz=min(xcolorbloom.xyz,1.2);
  581.     #endif
  582.  
  583.     #ifdef HD6_BLOOM_DEFUZZ
  584.             // Heliosdouble cobbled together bloom defuzzer - increases contrast of bloom / stop it hazing low brightness values
  585.             // what a fudge... but... it works... fancy that
  586.             // modulated by the overall brightness of the screen.
  587.         float mavg=((xcolorbloom.x+xcolorbloom.y+xcolorbloom.z)*0.333);
  588.         xcolorbloom.xyz-=(mavg*0.3);
  589.             //xcolorbloom.xyz=min(xcolorbloom.xyz,0.0);
  590.         xcolorbloom.xyz+=(mavg*0.22);
  591.         xcolorbloom.xyz*(mavg*1.2);
  592.     #endif
  593.  
  594.    
  595.     // Altering color balance is confusing, also Im not entirely sure it works properly :-D
  596.     #ifdef HD6_COLOR_TWEAKS
  597.         float ctbrt1 = lerp(uctbrt1t.x,uctbrt1t.y,hnd); // Brightness Night, Day (Alters before contrast adjustment)
  598.         float ctbrt2 = lerp(uctbrt2t.x,uctbrt2t.y,hnd); // Brightness Night, Day (Alters after contrast adjustment)
  599.         float ctcon = lerp(uctcont.x,uctcont.y,hnd); // Contrast Night, Day
  600.         float ctsat = lerp(uctsatt.x,uctsatt.y,hnd); // Saturation Night, Day
  601.        
  602.         float3 ctLumCoeff = float3(0.2125, 0.7154, 0.0721);            
  603.         float3 ctAvgLumin = float3(0.5, 0.5, 0.5);
  604.         float3 ctbrtColor = color.rgb * ctbrt1;
  605.  
  606.         float3 ctintensity = dot(ctbrtColor, ctLumCoeff);
  607.         float3 ctsatColor = lerp(ctintensity, ctbrtColor, ctsat);
  608.         float3 cconColor = lerp(ctAvgLumin, ctsatColor, ctcon);
  609.        
  610.         color.xyz = cconColor * ctbrt2;
  611.         float3 cbalance = lerp(rgbn,rgbd,hnd);
  612.         color.xyz=cbalance.xyz * color.xyz;
  613.     #endif
  614.    
  615.    
  616.     #ifdef USEBLOOM
  617.         #ifdef HD6_BLOOM_CRISP 
  618.             float3 LumCoeff = float3( 0.2125, 0.7154, 0.0721 );            
  619.             float3 AvgLumin = float3( 5.5, 5.5, 5.5 );
  620.                 //color*=1.06;
  621.                 //color*=1.0; // Brighten it up without loosing contrast
  622.                 //color += lerp(0,1.3,bchnd); // Night, Day, increase kinda lowers contrast, but makes things look more washed out also, this is to lift black areas really
  623.                 //color+=((color/2)*EBloomAmount);
  624.                 xcolorbloom-=0.4;
  625.                 xcolorbloom=max(xcolorbloom,0); // will cause color shift/desaturation also
  626.                 color.xyz+=(color.xyz*(xcolorbloom*EBloomAmount*0.2))+(xcolorbloom/1.5);
  627.                 //color.xyz=(color.xyz*color.xyz)/2;           
  628.                 //color.xyz=(color.xyz*0.5)+((color.xyz*(xcolorbloom*EBloomAmount))*0.5);
  629.                 //color.xyz*=0.8;      
  630.                 //color.xyz*=1.4;
  631.                
  632.             float3 brightbloom = ( xcolorbloom - lerp( 0.18, 0.0, bchnd )); // darkens and thus limits what triggers a bloom, used in part to stop snow at night glowing blue
  633.             brightbloom = max( brightbloom , 0);
  634.            
  635.             float3 superbright = xcolorbloom - 0.7; // crop it to only include superbright elemnts like sky and fire
  636.             superbright = max( superbright , 0 ) ; // crop so dont go any lower than black
  637.                 //superbright = lerp( AvgLumin, superbright, 0.5); // Contrast
  638.             superbright *= 0.6;
  639.            
  640.                
  641.                 //float lowestvaluec=min(min(brightbloom.x,brightbloom.y),brightbloom.z);
  642.                 //float3 lowestpossiblec=brightbloom.xyz-lowestvaluec;
  643.                 //brightbloom=max(brightbloom.xyz,lowestpossiblec);        
  644.            
  645.             // HD6 - Bloom - Brightntess, Contrast, Saturation adjustment 1,1,1 for no change // Remember this is bloom only being altered
  646.                 float brt = lerp( 0.5, 0.5, bchnd ) ; // doesnt work properly, should be done after contrast no?
  647.                 //
  648.                 float con = lerp( 0.5, 0.5, bchnd ); // 1.0, 0.8 // 1.1, 1.1               
  649.                 float sat = lerp( 0.5, 0.5, bchnd ); // 0.5, 0.7 // 0.7, 0.7
  650.                 //
  651.                
  652.                 float3 brtColor = brightbloom * brt;
  653.                 float3 cintensity = dot( brtColor, LumCoeff );
  654.                 float3 satColor = lerp( cintensity, brtColor, sat );
  655.                 float3 conColor = lerp( AvgLumin, satColor, con );
  656.                 conColor -= 0.1;
  657.                 brightbloom = conColor;
  658.                
  659.                
  660.                
  661.                 // These 2 should compensate so when even when no bloom exists it still matches brightness of scene without ENB
  662.             color.xyz += lerp( 0.12, 0.03, bchnd ); color.xyz *= lerp( 1.1, 1.4, bchnd );
  663.            
  664.             // Now Add bloom and compensate for any brightness changes that introduces
  665.            
  666.             color.xyz += (( superbright * hbs ) * lerp( 1, 1, bchnd ));
  667.             brightbloom -= ( superbright * 2 ); // removes superbright from brightbloom so I dont bloom the brightest area twice
  668.             brightbloom = max( brightbloom , 0.0 );
  669.             color.xyz += (( brightbloom * hbs ) * lerp( 1.0, 1.0, bchnd ));
  670.  
  671.                 // Blend in some of the orignal bloom to bring back SOME of the hazy glow of the day, none at night
  672.                 // 1.0, 0.9 - 0.7, 0.6
  673.             color.xyz += (xcolorbloom.xyz * hbs) * lerp( 0.7, 0.6, bchnd );
  674.             color.xyz *= lerp( 0.8, 0.7, bchnd ); // compensate for brightening caused by above bloom
  675.                 // End Blend
  676.            
  677.                 //color.xyz *= 1.0;
  678.                 //color.xyz += (xcolorbloom * 0.3);
  679.                 //color.xyz += 0.25;
  680.                 //float4 debug = color;
  681.                 //debug.xyz = ( superbright * EBloomAmount * 1 );          
  682.            
  683.                 //color.xyz+=((xcolorbloom*EBloomAmount)/1);
  684.                 //color.xyz*=lerp(1.25,0.8,bchnd); // 1.25, 1 // Darkens end result to rematch with how it looks without BLOOM CRISP enabled
  685.            
  686.         #else
  687.             #ifdef HD6_BLOOM_SCREEN
  688.                 // Helios code to restrict bloom to bright areas only, not smudging dark outs around
  689.                 color+=((color/1)*EBloomAmount); // compensate if bloom disabled   
  690.                     //color+=0.1;
  691.                     //xcolorbloom-=0.5;
  692.                 xcolorbloom=max(xcolorbloom,0); // will cause color shift/desaturation also
  693.                     //xcolorbloom+=0.2;
  694.                     // Soft Light: X = (((255-L)*U*L)+ (L*R_s))/255
  695.                     //1 - ((1.0 - base) * (1.0 - blend))
  696.                     //1 - ((255-U)*(255-L))/255
  697.                     //xcolorbloom.xyz*=EBloomAmount;
  698.                 float tmult = 10;
  699.                 color/=tmult; xcolorbloom/=tmult; // Screen mode wont work with floating point numbers / big numbers, so I reduce it first
  700.                
  701.                 color.x = 1.0 - ((1.0 - color.x) * (1.0 - xcolorbloom.x));
  702.                 color.y = 1.0 - ((1.0 - color.y) * (1.0 - xcolorbloom.y));
  703.                 color.z = 1.0 - ((1.0 - color.z) * (1.0 - xcolorbloom.z));
  704.                 color*=tmult;      
  705.             // End helios code
  706.             #else  
  707.                 float tt=1;
  708.                     //float3 tt = float3(1*tempF1.x,1*tempF1.x,1*tempF1.x);
  709.                 color.xyz+=((xcolorbloom.xyz*EBloomAmount)*tt);
  710.             #endif  
  711.         #endif
  712.     #else
  713.         // No bloom
  714.         color+=((color/1)*EBloomAmount); // compensate if bloom disabled
  715.     #endif
  716.        
  717.     //+++++++++++++++++++++++++++++
  718.        
  719.     #ifdef HD6_VIGNETTE    
  720.         // yes this is my own crazy creation after seing how boring the usual linear circle vignettes typically are
  721.         // no doubt I have done it in an overly convoluted way :-)
  722.        
  723.             //float fExposureLevel = 0; // compensate for any change from vignette so center is same brightness
  724.         float2 inTex = _v0;
  725.         float4 voriginal = r1;
  726.         float4 vcolor = voriginal;
  727.         vcolor.xyz=1;
  728.         inTex -= 0.5; // Centers vignette
  729.         inTex.y += 0.0; // Move it off center and up so it obscures sky less
  730.         float vignette = 1.0 - dot( inTex, inTex );
  731.         vcolor *= pow( vignette, vignettepow );
  732.        
  733.        
  734.         // Round Vignette
  735.         float4 rvigtex = vcolor;
  736.         rvigtex.xyz = pow( vcolor, 1 );
  737.         rvigtex.xyz = lerp(float3(0.5, 0.5, 0.5), rvigtex.xyz, 2.0); // Increase Contrast
  738.         rvigtex.xyz = lerp(float3(1,1,1),rvigtex.xyz,rovigpwr); // Set strength of round vignette
  739.        
  740.         // Square Vignette (just top and bottom of screen)
  741.         float4 vigtex = vcolor;
  742.         vcolor.xyz = float3(1,1,1);
  743.         float3 topv = min((inTex.y+0.5)*2,0.5) * 2; // Top vignette
  744.         float3 botv = min(((0-inTex.y)+0.5)*2,0.5) * 2; // Bottom vignette
  745.        
  746.         topv= lerp(float3(1,1,1), topv, sqvigpwr.x);
  747.         botv= lerp(float3(1,1,1), botv, sqvigpwr.y);
  748.         vigtex.xyz = (topv)*(botv);
  749.        
  750.         //vigtex.xyz = lerp(float3(1,1,1),vigtex.xyz,sqvigpwr); // Set strength of square vignette
  751.                
  752.         // Add round and square together
  753.         vigtex.xyz*=rvigtex.xyz;
  754.        
  755.         vigtex.xyz = lerp(vigtex.xyz,float3(1,1,1),(1-vstrengthatnight)*(1-vhnd)); // Alter Strength at night
  756.        
  757.             vigtex.xyz = min(vigtex.xyz,1);
  758.             vigtex.xyz = max(vigtex.xyz,0);
  759.             //vigtex.xyz -= 0.5;
  760.             //(base < 0.5 ? (2.0 * base * blend) : (1.0 - 2.0 * (1.0 - base) * (1.0 - blend)))
  761.             //vigtex.xyz = vigtex.xyz < 0.5 ? (2.0 * color.xyz * vigtex.xyz) : (1 - 2 * (1 - color.xyz) * (1 - vigtex.xyz));
  762.             // Crap I keep forgetting overlay mode doesnt work in floating point/32bit/hdr dur bee durr
  763.                
  764.         // Increase saturation where edges were darkenned
  765.         float3 vtintensity = dot(color.xyz, float3(0.2125, 0.7154, 0.0721));
  766.         color.xyz = lerp(vtintensity, color.xyz, ((((1-(vigtex.xyz*2))+2)-1)*vsatstrength)+1  );
  767.        
  768.             //color.xyz+=0.02;
  769.         color.xyz *= (vigtex.xyz);
  770.             //color.xyz *= fExposureLevel; 
  771.        
  772.     #endif
  773.    
  774.     // HD6 - Warning, Code below appears to reduce 'color.xyz' to 8bit / LDR
  775.        
  776.        
  777.     // HD6 - Eye Adaptation for extreme extreme over bright areas only, such as stupid stupid snow
  778.     // 0.3, 0.9 - affects day time sunny day = bad
  779.     float toobright = max(0,tex2D(_s2, _v0).xyz - 0.5); // 0.5
  780.     color.xyz *= 1-(0.75 * toobright); // 1.3
  781.    
  782.     // <Lazy> HD6 - dopey arse code to alter enbpalette because im too lazy to open photoshop
  783.         // when using your own palette remove this.. ill fix this.. next
  784.         float palmix = 0.8; // 0.4
  785.         color.xyz*=lerp(0.7, 0.80, palmix); // 0.9
  786.     // </Lazy>
  787.        
  788.        
  789.     //+++++++++++++++++++++++++++++
  790.     #if (POSTPROCESS==1)
  791.         grayadaptation=max(grayadaptation, 0.0);
  792.         grayadaptation=min(grayadaptation, 50.0);
  793.         color.xyz=color.xyz/(grayadaptation*EAdaptationMaxV1+EAdaptationMinV1);//*tempF1.x
  794.        
  795.         float cgray=dot(color.xyz, float3(0.27, 0.67, 0.06));
  796.         cgray=pow(cgray, EContrastV1);
  797.         float3 poweredcolor=pow(color.xyz, EColorSaturationV1);
  798.         float newgray=dot(poweredcolor.xyz, float3(0.27, 0.67, 0.06));
  799.         color.xyz=poweredcolor.xyz*cgray/(newgray+0.0001);
  800.  
  801.         float3  luma=color.xyz;
  802.         float   lumamax=300.0;
  803.         color.xyz=(color.xyz * (1.0 + color.xyz/lumamax))/(color.xyz + EToneMappingCurveV1);
  804.     #endif
  805.     //+++++++++++++++++++++++++++++
  806.    
  807.     //+++++++++++++++++++++++++++++
  808.     #if (POSTPROCESS==2)
  809.         grayadaptation=max(grayadaptation, 0.0);
  810.         grayadaptation=min(grayadaptation, 50.0);
  811.         color.xyz=color.xyz/(grayadaptation*EAdaptationMaxV2+EAdaptationMinV2);//*tempF1.x
  812.  
  813.         color.xyz*=EBrightnessV2;
  814.         color.xyz+=0.000001;
  815.         float3 xncol=normalize(color.xyz);
  816.         float3 scl=color.xyz/xncol.xyz;
  817.         scl=pow(scl, EIntensityContrastV2);
  818.         xncol.xyz=pow(xncol.xyz, EColorSaturationV2);
  819.         color.xyz=scl*xncol.xyz;
  820.  
  821.         float   lumamax=EToneMappingOversaturationV2;
  822.         color.xyz=(color.xyz * (1.0 + color.xyz/lumamax))/(color.xyz + EToneMappingCurveV2);
  823.  
  824.        
  825. //MIDHRAS: Mood Colouring
  826. float fRatio = 0.4; // blend ratio (0-1)
  827. //float fRatio = 0.425;
  828. float moodR = 0.735;    // mood color red component
  829. float moodG = 0.62; // mood color green component
  830. float moodB = 0.5;  // mood color blue component
  831.  
  832.  
  833.     float4 colInput = color;
  834.     float4 colMood = 1.0f;
  835.     colMood.r = moodR;
  836.     colMood.g = moodG;
  837.     colMood.b = moodB;
  838.     float fLum = ( colInput.r + colInput.g + colInput.b ) / 3;
  839.  
  840.     colMood = lerp(0, colMood, saturate(fLum * 2.0));
  841.     colMood = lerp(colMood, 1, saturate(fLum - 0.5) * 2.0);
  842.     float4 colOutput = lerp(colInput, colMood, saturate(fLum * fRatio));
  843.     color.rgb=max(0, colOutput);
  844.  
  845. #endif
  846.     //+++++++++++++++++++++++++++++
  847.  
  848.     //+++++++++++++++++++++++++++++ HD6 version based on postprocess 2
  849.     #if (POSTPROCESS==5)
  850.             grayadaptation=max(grayadaptation, 0.0);
  851.             grayadaptation=min(grayadaptation, 50.0);
  852.             //color.xyz=color.xyz/(grayadaptation*EAdaptationMaxV2+EAdaptationMinV2); //*tempF1.x      
  853.         // HD6 - Screw eye adaptation it drives me mad, bright sky causes everything else to darken yuck
  854.         // Human eye adaptation happens instantly or so slowly you dont notice it in reality
  855.         // it would make sense if the game was calibrated for true brightness values of indoors and outdoors being 10000x brighter
  856.         // but it isnt, and thus all the pseudo tone mapping and linear colorspace adaption shenanigans just drives me mad and for little gain
  857.         // So now simple adjust brightness based on time of day
  858.         // with all the other effects turned off this should roughly equal the brightness when ENB is disabled
  859.         //color.xyz*=lerp( 3.1, 1.5, hnd );
  860.         color.xyz*=lerp( hndtweak.x, hndtweak.y, hnd );
  861.  
  862.             //color.xyz*=EBrightnessV2;
  863.             //color.xyz+=0.000001; // HD6 - Why? how curious
  864.         float3 xncol=normalize(color.xyz);
  865.         float3 scl=color.xyz/xncol.xyz;
  866.         scl=pow(scl, EIntensityContrastV2);
  867.         xncol.xyz=pow(xncol.xyz, EColorSaturationV2);
  868.         color.xyz=scl*xncol.xyz;
  869.         color.xyz*=HCompensateSat; // compensate for darkening caused my EcolorSat above
  870.  
  871.             //float lumamax=EToneMappingOversaturationV2;
  872.             //color.xyz=(color.xyz * (1.0 + color.xyz/lumamax))/(color.xyz + EToneMappingCurveV2);
  873.  
  874.         color.xyz=color.xyz/(color.xyz + EToneMappingCurveV2);
  875.             //color.xyz=tex2D(_s0, _v0.xy);
  876.             //color.xyz=color.xyz-0.03;
  877.             //color.xyz/=10;
  878.     #endif
  879.     //+++++++++++++++++++++++++++++
  880.  
  881.     //+++++++++++++++++++++++++++++
  882.     #if (POSTPROCESS==3)
  883.         grayadaptation=max(grayadaptation, 0.0);
  884.         grayadaptation=min(grayadaptation, 50.0);
  885.         color.xyz=color.xyz/(grayadaptation*EAdaptationMaxV3+EAdaptationMinV3); //*tempF1.x
  886.  
  887.         //float3    luma=color.xyz;
  888.         //float lumamax=20.0;
  889.         float   lumamax=EToneMappingOversaturationV3;
  890.         color.xyz=(color.xyz * (1.0 + color.xyz/lumamax))/(color.xyz + EToneMappingCurveV3);
  891.  
  892.        
  893. // /*
  894.  
  895.  
  896. //MIDHRAS: Mood Colouring
  897. float fRatio = 0.75;    // blend ratio (0-1)
  898. //float fRatio = 0.425;
  899. float moodR = 0.735;    // mood color red component
  900. float moodG = 0.620;    // mood color green component
  901. float moodB = 0.500;    // mood color blue component
  902.  
  903.  
  904.     float4 colInput = color;
  905.     float4 colMood = 1.0f;
  906.     colMood.r = moodR;
  907.     colMood.g = moodG;
  908.     colMood.b = moodB;
  909.     float fLum = ( colInput.r + colInput.g + colInput.b ) / 3;
  910.  
  911.     colMood = lerp(0, colMood, saturate(fLum * 2.0));
  912.     colMood = lerp(colMood, 1, saturate(fLum - 0.5) * 1.0);
  913.     float4 colOutput = lerp(colInput, colMood, saturate(fLum * fRatio));
  914.     color.rgb=max(0, colOutput);
  915.    
  916.  
  917. float   Contrast = -0.05;
  918. color.xyz = saturate(color.xyz);
  919.     color.xyz = lerp(color.xyz, 0.5 * (1 + sin((color.xyz - 0.25)*3.1415926)), Contrast);
  920.  
  921. float   Exposure=0.035;
  922. color.rgb *= pow(1.8f, Exposure);
  923.    
  924. // */      
  925.        
  926.     #endif
  927.     //+++++++++++++++++++++++++++++
  928.     //color.xyz=tex2D(_s0, _v0.xy) + xcolorbloom.xyz*float3(0.7, 0.6, 1.0)*0.5;
  929.     //color.xyz=tex2D(_s0, _v0.xy) + xcolorbloom.xyz*float3(0.7, 0.6, 1.0)*0.5;
  930.     //color.xyz*=0.7;
  931.  
  932.     //+++++++++++++++++++++++++++++
  933.     #if (POSTPROCESS==4)
  934.         grayadaptation=max(grayadaptation, 0.0);
  935.         grayadaptation=min(grayadaptation, 50.0);
  936.         color.xyz=color.xyz/(grayadaptation*EAdaptationMaxV4+EAdaptationMinV4);
  937.  
  938.         float Y = dot(color.xyz, float3(0.299, 0.587, 0.114)); //0.299 * R + 0.587 * G + 0.114 * B;
  939.         float U = dot(color.xyz, float3(-0.14713, -0.28886, 0.436)); //-0.14713 * R - 0.28886 * G + 0.436 * B;
  940.         float V = dot(color.xyz, float3(0.615, -0.51499, -0.10001)); //0.615 * R - 0.51499 * G - 0.10001 * B;
  941.        
  942.         Y=pow(Y, EBrightnessCurveV4);
  943.         Y=Y*EBrightnessMultiplierV4;
  944.             //Y=Y/(Y+EBrightnessToneMappingCurveV4);
  945.             //float desaturatefact=saturate(Y*Y*Y*1.7);
  946.             //U=lerp(U, 0.0, desaturatefact);
  947.             //V=lerp(V, 0.0, desaturatefact);
  948.         color.xyz=V * float3(1.13983, -0.58060, 0.0) + U * float3(0.0, -0.39465, 2.03211) + Y;
  949.  
  950.         color.xyz=max(color.xyz, 0.0);
  951.         color.xyz=color.xyz/(color.xyz+EBrightnessToneMappingCurveV4);
  952.     #endif
  953.     //+++++++++++++++++++++++++++++
  954.  
  955.    
  956.    
  957.     //+++++++++++++++++++++++++++++
  958.     //pallete texture (0.082+ version feature)
  959.     #ifdef E_CC_PALETTE
  960.        
  961.        
  962.         color.rgb=saturate(color.rgb);
  963.         float3  brightness=Adaptation.xyz; //tex2D(_s4, 0.5); //adaptation luminance
  964.             //brightness=saturate(brightness); //old version from ldr games
  965.         brightness=(brightness/(brightness+1.0));//new version
  966.         brightness=max(brightness.x, max(brightness.y, brightness.z));//new version
  967.         float3  palette;
  968.         float4  uvsrc=0.0;
  969.         uvsrc.y=brightness.r;
  970.         uvsrc.x=color.r;
  971.         palette.r=tex2Dlod(_s7, uvsrc).r;
  972.         uvsrc.x=color.g;
  973.         uvsrc.y=brightness.g;
  974.         palette.g=tex2Dlod(_s7, uvsrc).g;
  975.         uvsrc.x=color.b;
  976.         uvsrc.y=brightness.b;
  977.         palette.b=tex2Dlod(_s7, uvsrc).b;      
  978.        
  979.         color.rgb=lerp( color.rgb, palette.rgb, palmix );
  980.        
  981.         //color.rgb=toobright;
  982.     #endif //E_CC_PALETTE
  983.     //+++++++++++++++++++++++++++++
  984.  
  985.        
  986.     /*
  987.     // HeliosDoubleSix cobbled code to Cap values above 0, not great as limits how black it can do say if it was pure red?!
  988.     // what is the lowest value out of r,g,b
  989.         float lowestvalue=min(min(color.x,color.y),color.z);
  990.         // work out lowest possible value to set RGB without going below 0 and without changing the RGB relative values ie shifting the color in the process
  991.         float3 lowestpossible=color.xyz-lowestvalue;
  992.         color.xyz=max(color.xyz,lowestpossible);
  993.         //color.r=max(color.r,lowestpossible.x);
  994.         //color.g=max(color.g,lowestpossible.y);
  995.         //color.b=max(color.b,lowestpossible.z);
  996.     */
  997.  
  998.         //color.xyz=saturate(xcolorbloom.xyz);
  999.         //color.xyz-=(pow(color.xyz, 6)/2);
  1000.         //color.xyz=max(0,color.xyz);
  1001.         //color.xyz=debug;
  1002.  
  1003.     /*
  1004.         //temporary testing
  1005.         color.xyz=tex2D(_s0, _v0.xy);
  1006.         //color.xyz=xcolorbloom.xyz*tempF1.x;
  1007.  
  1008.         //color.xyz=pow(color.xyz, 0.5);
  1009.         color.xyz+=(xcolorbloom.xyz-color.xyz)*tempF1.y;
  1010.         //color.xyz=xcolorbloom.xyz*tempF1.y;
  1011.         color.xyz=color.xyz*tempF1.x;
  1012.         //color.xyz=color.xyz/(color.xyz +1.0*tempF1.z);
  1013.         color.xyz=(color.xyz * (1.0 + color.xyz/40))/(color.xyz + EToneMappingCurveV3);
  1014.             Adaptation=tex2D(_s4, 0.5);
  1015.             grayadaptation=max(max(Adaptation.x, Adaptation.y), Adaptation.z);
  1016.             grayadaptation=max(grayadaptation, 0.0);
  1017.             grayadaptation=min(grayadaptation, 50.0);
  1018.         //  color.xyz=Adaptation*2;//*tempF1.x
  1019.  
  1020.         //color.xyz=tex2D(_s0, _v0.xy)*1.3;
  1021.     */
  1022.  
  1023.     //color.xyz=tex2D(_s0, _v0.xy)*pow(tempF1.x,4);
  1024.     //color.xyz=max(xcolorbloom.xyz, tex2D(_s0, _v0.xy).xyz)*pow(tempF1.x,4)*0.7;
  1025.  
  1026.    
  1027.    
  1028.    
  1029.    
  1030.     _oC0.w=1.0;
  1031.     _oC0.xyz=color.xyz;
  1032.     //_oC0.xyz=debug;
  1033.    
  1034.     // HD6 - debug triangle - draws a triangle top left showing the value of night/day for testing
  1035.     //_oC0.xyz = _v0.x+_v0.y < 0.1 ? (hnd) : (_oC0.xyz);
  1036.     float h11 = h1 == 1 ? 0 : 0.4;
  1037.     _oC0.xyz += _v0.x+_v0.y < 0.004 ? (h11) : (0);
  1038.    
  1039.     // Red dot in top left if you adjust daytime
  1040.     float h22 = h2 == 1 ? 0 : 0.4;
  1041.     _oC0.x += _v0.x+_v0.y < 0.004 ? (h22) : (0);
  1042.    
  1043.     return _oC0;
  1044. }
  1045.  
  1046.  
  1047.  
  1048.  
  1049. //switch between vanilla and mine post processing
  1050. #ifndef ENB_FLIPTECHNIQUE
  1051.     technique Shader_D6EC7DD1
  1052. #else
  1053.     technique Shader_ORIGINALPOSTPROCESS
  1054. #endif
  1055. {
  1056.     pass p0
  1057.     {
  1058.         VertexShader = compile vs_3_0 VS_Quad();
  1059.         PixelShader = compile ps_3_0 PS_D6EC7DD1();
  1060.  
  1061.         ColorWriteEnable=ALPHA|RED|GREEN|BLUE;
  1062.         ZEnable=FALSE;
  1063.         ZWriteEnable=FALSE;
  1064.         CullMode=NONE;
  1065.         AlphaTestEnable=FALSE;
  1066.         AlphaBlendEnable=FALSE;
  1067.         SRGBWRITEENABLE=FALSE;
  1068.     }
  1069. }
  1070.  
  1071.  
  1072. // HD6 - below doesnt make any diff??? so I disabled it *shrugs*
  1073. /*
  1074. //original shader of post processing
  1075. #ifndef ENB_FLIPTECHNIQUE
  1076.     technique Shader_ORIGINALPOSTPROCESS
  1077. #else
  1078.     technique Shader_D6EC7DD1
  1079. #endif
  1080. {
  1081.     pass p0
  1082.     {
  1083.         VertexShader  = compile vs_3_0 VS_Quad();
  1084.         PixelShader=
  1085.     asm
  1086.     {
  1087. // Parameters:
  1088. //   sampler2D Avg;
  1089. //   sampler2D Blend;
  1090. //   float4 Cinematic;
  1091. //   float4 ColorRange;
  1092. //   float4 Fade;
  1093. //   sampler2D Image;
  1094. //   float4 Param;
  1095. //   float4 Tint;
  1096.  
  1097.  
  1098. // Registers:
  1099.  
  1100. //   Name         Reg   Size
  1101. //   ------------ ----- ----
  1102. //   ColorRange   c1       1
  1103. //   Param        c2       1
  1104. //   Cinematic    c3       1
  1105. //   Tint         c4       1
  1106. //   Fade         c5       1
  1107. //   Image        s0       1
  1108. //   Blend        s1       1
  1109. //   Avg          s2       1
  1110. //s0 bloom result
  1111. //s1 color
  1112. //s2 is average color
  1113.  
  1114.     ps_3_0
  1115.     def c6, 0, 0, 0, 0
  1116.     //was c0 originally
  1117.     def c7, 0.212500006, 0.715399981, 0.0720999986, 1
  1118.     dcl_texcoord v0.xy
  1119.     dcl_2d s0
  1120.     dcl_2d s1
  1121.     dcl_2d s2
  1122.     rcp r0.x, c2.y
  1123.     texld r1, v0, s2
  1124.     mul r0.yz, r1.xxyw, c1.y
  1125.     rcp r0.w, r0.y
  1126.     mul r0.z, r0.w, r0.z
  1127.     texld r1, v0, s1
  1128.     mul r1.xyz, r1, c1.y
  1129.     dp3 r0.w, c7, r1
  1130.     mul r1.w, r0.w, r0.z
  1131.     mad r0.z, r0.z, r0.w, c7.w
  1132.     rcp r0.z, r0.z
  1133.     mad r0.x, r1.w, r0.x, c7.w
  1134.     mul r0.x, r0.x, r1.w
  1135.     mul r0.x, r0.z, r0.x
  1136.     cmp r0.x, -r0.w, c6.x, r0.x
  1137.     rcp r0.z, r0.w
  1138.     mul r0.z, r0.z, r0.x
  1139.     add_sat r0.x, -r0.x, c2.x
  1140.     texld r2, v0, s0
  1141.     mul r2.xyz, r2, c1.y
  1142.     mul r2.xyz, r0.x, r2
  1143.     mad r1.xyz, r1, r0.z, r2
  1144.     dp3 r0.x, r1, c7
  1145.     mov r1.w, c7.w
  1146.     lrp r2, c3.x, r1, r0.x
  1147.     mad r1, r0.x, c4, -r2
  1148.     mad r1, c4.w, r1, r2
  1149.     mad r1, c3.w, r1, -r0.y
  1150.     mad r0, c3.z, r1, r0.y
  1151.     add r1, -r0, c5
  1152.     mad oC0, c5.w, r1, r0
  1153.  
  1154.     };
  1155.         ColorWriteEnable=ALPHA|RED|GREEN|BLUE;
  1156.         ZEnable=FALSE;
  1157.         ZWriteEnable=FALSE;
  1158.         CullMode=NONE;
  1159.         AlphaTestEnable=FALSE;
  1160.         AlphaBlendEnable=FALSE;
  1161.         SRGBWRITEENABLE=FALSE;
  1162.     }
  1163. }
  1164. */// M I D H R A S T I C   E N B   F O R   F A L L O U T   3
  1165.  
  1166. //++++++++++++++++++++++++++++++++++++++++++++
  1167. // ENBSeries effect file
  1168. // visit http://enbdev.com for updates
  1169. // Copyright (c) 2007-2011 Boris Vorontsov
  1170. //
  1171. // Using decompiled shader of TES Skyrim
  1172. //++++++++++++++++++++++++++++++++++++++++++++
  1173.  
  1174. //++++++++++++++++++++++++++++++++++++++++++++
  1175. // Additions and Tweaking by HD6 (HeliosDoubleSix) v11.3
  1176. // MOD by HD6: http://www.skyrimnexus.com/downloads/file.php?id=4142
  1177. // MOD by ENB: http://www.skyrimnexus.com/downloads/file.php?id=2971
  1178. // these are typically denoted by 'HD6'
  1179. // given I have no shader writing experience,
  1180. // will undoubtedly be retarded to a seasoned professional, I welcome any advice!
  1181. // thanks Boris!
  1182. //++++++++++++++++++++++++++++++++++++++++++++
  1183.  
  1184. // Remove or add '//' infront of '#define' below to disable / enable the various options
  1185.  
  1186. ////
  1187.  
  1188. // ENB - values could be 1, 2, 3 or 4. v4 gives unrealistic, kind of artwork style, v5 is added by HD6
  1189.     #define POSTPROCESS 3
  1190. //
  1191.  
  1192. // ENB - use original game processing first, then mine
  1193.     //#define APPLYGAMECOLORCORRECTION
  1194. //
  1195.  
  1196. // ENB - use original game processing only, with vanilla bloom (basically turns everything off)
  1197.     //#define ENB_FLIPTECHNIQUE
  1198. //
  1199.  
  1200. ////
  1201.  
  1202. // HD6 - Color Balance and Brightness, Contrast adjustment
  1203.     //
  1204.     #define HD6_COLOR_TWEAKS
  1205.     #define HD6_DARKER_NIGHTS
  1206.     // Right now if you do NOT darken the nights, the night sky will be very bright unless changes in enbseries.ini
  1207.     //
  1208.     // Put // or remove the // infront of "#define HD6_DARKER_NIGHTS" above, to darken the nights or not.. // will put nights back to normal
  1209.     //
  1210.     // This is by default and for examples sake set to make the nights even darker
  1211.     // When you decrease brightness you will need to increase contrast or it will look washed out
  1212.     // and if you increrase contrast that naturally increases saturation so you need to reduce saturation
  1213.     // this is just the nature of color correction :-)
  1214.     //
  1215.     // Note nights and days are being desaturated per channel(RGB) using: HD6_COLORSAT_DAYNIGHT elsewhere
  1216.     // Note Bloom is not affected by this and gets its own color/contrast adjustment in HD6_BLOOM_CRISP and HD6_BLOOM_DEBLUEIFY if used
  1217.     //
  1218.     // If the 3 numbers in rgb below do not add up to 3 it will either be darker or lighter than before
  1219.     float3 rgbd     = float3(1, 1, 1 );         // RGB balance day
  1220.     float3 rgbn     = float3( 1.9, 2.1, 2.2 );      // RGB balance night
  1221.     //
  1222.     // First column of the 3 here is for key control only during night
  1223.     // ie you can press number '1' with pageup or pagedown to alter the brightness while playing
  1224.     // As you press pagedown it moves further towards the values in this first column.
  1225.     // As a helpful indicator you can see if you have moved away from default values by
  1226.     // noticing a very small white dot in top left corner of screen.
  1227.     // Adjust with keys till this dot vanishes, then it is back to default
  1228.     // The Keycontrol ONLY affects the night right now. So dont try using it during the day it wont do anything.
  1229.    
  1230.    
  1231.         // Darker Nights ( Night Keypress 1+Pageup/down, Night, Day )
  1232.         // Only uses these values if "#define HD6_DARKER_NIGHTS" does not have '//' infront
  1233.        
  1234.         //      keypress 1,2:     night, day        night, day
  1235.         float4 uctbrt1  = float4( 0.30, 0.30,       0.925, 1.05 );  // Brightness Night, Day (Alters before contrast adjustment)
  1236.         float4 uctbrt2  = float4( 0.30, 0.30,       0.975, 1.10 );  // Brightness Night, Day (Alters after contrast adjustment)
  1237.         float4 uctcon   = float4( 1.05, 1.05,       1.150, 1.25 );  // Contrast Night, Day, v11.2: 1.0, 0.97, 0.85
  1238.         float4 uctsat   = float4( 1.00, 0.8,        1.150, 0.72 );  // Saturation Night, Day (Remember if using HD6_COLORSAT_DAYNIGHT that will also be desaturating the night)
  1239.    
  1240.     #ifdef HD6_DARKER_NIGHTS
  1241.         float4 darkenby1 = float4( 0.30, 0.30,  0.2, 0.40 );
  1242.     #endif
  1243.    
  1244.            
  1245.     //
  1246.     // I have stopped relying on the palette map to darken nights, now I do all darkening here
  1247.     // When reducing brightness it seems increasing saturation is needed to restore color, anda slight increase in contrast to maintain bright spots/flames etc
  1248.     // Remember this is not darkening the bloom, which in itself has as impact on the overall brightness and hazyness of the scene
  1249.     //
  1250.     // Palette map right now is increasing contrast so I have compensated by reducing contrast here (lazy)
  1251. //
  1252. //HD6 - Enable Vignette - darkens and blurs edges of the screen which increasesfocus on center, film/camera type effect/look
  1253.     // didnt bother adding blur, could do without muddying and fuzzing things really
  1254.     // and the effect is only meant to be super subtle not a pin hole camera -_-
  1255.     //
  1256.     //#define HD6_VIGNETTE
  1257.     //
  1258.     // Defaults below, I darken the corners and the bottom only, leaving the top light
  1259.     // darkening all sides feels ike you are trapping/closing in the view too much, so it is not a normal vignette
  1260.     // And it is subtle, till you turn it off I doubt you would ever even notice it
  1261.     // Also is turned off at night
  1262.     //
  1263.     float rovigpwr = 360.0; // For Round vignette // 0.2
  1264.     float2 sqvigpwr = float2( 1.975, 1.975 ); // For square vignette: (top, bottom)
  1265.     //
  1266.     float vsatstrength = 0; // How saturated vignette is
  1267.     float vignettepow = 0; // For Round vignette, higher pushes it to the corners and increases contrast/sharpness
  1268.     //
  1269.     float vstrengthatnight = 360.0; // How strong vignette is as night, 0-1
  1270.  
  1271. // HD6 - Desaturate Nights, can alter saturation seperately from day and night, will affect caves and indoors also for now
  1272.     //
  1273.     #define HD6_COLORSAT_DAYNIGHT
  1274.     //
  1275.     // Nighttime Saturation, Red, Green, Blue
  1276.     float3 dnsatn = float3(1.35, 1.35, 1.35 );
  1277.     //
  1278.     // Daytime Saturation, Red, Green, Blue
  1279.     float3 dnsatd = float3(2.8, 2.75, 2.75);
  1280. //
  1281.  
  1282. // HD6 - removes blue tint from bloom, most apparent in distant fog
  1283.     //
  1284.     #define HD6_BLOOM_DEBLUEIFY
  1285.     //
  1286.     // HeliosDoubleSix cobbled code to deblueify bloom without loosing brightness huzah! - First time writing shader code so be gentle
  1287.     // desaturates bloom, to do this you cant just remove a color or tone it down you need to redistribute it evenly across all channels to make it grey
  1288.     // well evenly would make sense but the eye has different sensetivities to color so its actually RGB (0.3, 0.59, 0.11) to achieve greyscale
  1289.     // Careful as removing too muchblue can send snow and early morning pink   
  1290.     //
  1291.     //float3 nsat=float3(0.6,0.118,0.22);
  1292.     float3 nsat = float3(1.27, 1.33, 1.03);
  1293. //
  1294.  
  1295. // HD6 - Enable Bloom - disable bloom with this if you turn it off in enbseries, compensates for darkening
  1296.     #define USEBLOOM
  1297. //
  1298.  
  1299. //  Pick one or none:
  1300. // HD6 - BLOOM 1 - alternate crisp bloom, no hazey mud
  1301.     //#define HD6_BLOOM_CRISP
  1302. // HD6 - BLOOM 2 - alternate bloom (using screen mode) I have abadoned this code
  1303.     //#define HD6_BLOOM_SCREEN
  1304. //
  1305.  
  1306. // HD6 - old weird serendipitous code to defuzz bloom
  1307.     //#define HD6_BLOOM_DEFUZZ
  1308. //
  1309.  
  1310. // HD6 - remove black from bloom, not working very well
  1311. //  #define HD6_BLOOM_NOBLACK
  1312. //
  1313.  
  1314. // Keyboard controlled temporary variables (in some versions exists in the config file).
  1315. // Press and hold key 1,2,3...8 together with PageUp or PageDown to modify. By default all set to 1.0
  1316.     float4  tempF1; // 0,1,2,3
  1317.     float4  tempF2; // 5,6,7,8
  1318.     float4  tempF3; // 9,0
  1319.  
  1320. // x=generic timer in range 0..1, period of 16777216 ms (4.6 hours), w=frame time elapsed (in seconds)
  1321.     float4  Timer;
  1322. // x=Width, y=1/Width, z=ScreenScaleY, w=1/ScreenScaleY
  1323.     float4  ScreenSize;
  1324. // changes in range 0..1, 0 means that night time, 1 - day time
  1325.     float   ENightDayFactor;
  1326.    
  1327. // enb version of bloom applied, ignored if original post processing used
  1328.     float   EBloomAmount;
  1329.  
  1330. //+++++++++++++++++++++++++++++
  1331. //POSTPROCESS 1
  1332.     float   EAdaptationMinV1 = 0.05;
  1333.     float   EAdaptationMaxV1 = 0.125;
  1334.     float   EContrastV1 = 1.0;
  1335.     float   EColorSaturationV1 = 1.3;
  1336.     float   EToneMappingCurveV1 = 3.0;
  1337. //+++++++++++++++++++++++++++++
  1338.  
  1339. //+++++++++++++++++++++++++++++
  1340. //POSTPROCESS 2
  1341. #if (POSTPROCESS==2)
  1342. float   EBrightnessV2=1.05;
  1343. float   EAdaptationMinV2=0.535;
  1344. float   EAdaptationMaxV2=0.75;
  1345. float   EToneMappingCurveV2=1.05;
  1346. float   EIntensityContrastV2=1.05;
  1347. float   EColorSaturationV2=1.35;
  1348. float   EToneMappingOversaturationV2=75; //250;
  1349. #endif
  1350. //+++++++++++++++++++++++++++++
  1351.  
  1352. //+++++++++++++++++++++++++++++
  1353. //POSTPROCESS 5 by HD6
  1354. #if (POSTPROCESS==5)
  1355.     // HD6 - Adaptation is now ignored by my choice
  1356.     float   EAdaptationMinV2 = 0.28; // 0.28 // lower gets brighter
  1357.    
  1358.     // Increase this to darken days, but darkening them will kill the sky a bit unless you enable the SKY overirde in enberies.ini
  1359.     float   EAdaptationMaxV2 = 0.30; // 0.30 // 0.65 // 0.35 // 0.29
  1360.  
  1361.     // Set ridiculously high, was 8, was in attempt to keep hair colour intact
  1362.     float   EToneMappingCurveV2 = 7; // 130
  1363.  
  1364.     // Adjusting this will throw out all the other values, icreased to high levels to combat how high I increased ToneMappingCurve to bring some contrast back in to daytime
  1365.     float   EIntensityContrastV2 = 1.0; // 3.375 // 4.75 // 3.975
  1366.  
  1367.     // high saturation also helps pop the pink/orange sunsets/mornings at 6.30pm and 7.30am, but also nights then get very blue
  1368.     // Increasing this will darken things in the process
  1369.     // v11.2 = 3.0, 1.0 increased to put even more color into the game
  1370.     float   EColorSaturationV2 = 1.65; // 1.65;
  1371.     float   HCompensateSat = 5; // Compensate for darkening caused by increasing EColorSaturationV2
  1372.  
  1373.     // Not using this now anymore
  1374.     float   EToneMappingOversaturationV2 = 100.0;
  1375. #endif
  1376. //+++++++++++++++++++++++++++++
  1377.  
  1378. //+++++++++++++++++++++++++++++
  1379. //POSTPROCESS 3
  1380. float   EAdaptationMinV3=0.11; //0.535;
  1381. float   EAdaptationMaxV3=0.125; //0.85;
  1382. float   EToneMappingCurveV3=4.0; //0.995;
  1383. float   EToneMappingOversaturationV3=100; //100;
  1384. //+++++++++++++++++++++++++++++
  1385.  
  1386. //+++++++++++++++++++++++++++++
  1387. //POSTPROCESS 4
  1388.     float   EAdaptationMinV4 = 1.1;
  1389.     float   EAdaptationMaxV4 = 1.325;
  1390.     float   EBrightnessCurveV4 = 1.0;
  1391.     float   EBrightnessMultiplierV4 = 0.8;
  1392.     float   EBrightnessToneMappingCurveV4 = 0.4;
  1393. //+++++++++++++++++++++++++++++
  1394.  
  1395. //+++++++++++++++++++++++++++++
  1396. //external parameters, do not modify
  1397. //+++++++++++++++++++++++++++++
  1398.     texture2D texs0; // color
  1399.     texture2D texs1; // bloom skyrim
  1400.     texture2D texs2; // adaptation skyrim
  1401.     texture2D texs3; // bloom enb
  1402.     texture2D texs4; // adaptation enb
  1403.     texture2D texs7; // palette enb
  1404.  
  1405. sampler2D _s0 = sampler_state {
  1406.     Texture   = <texs0>;
  1407.     MinFilter = POINT;
  1408.     MagFilter = POINT;
  1409.     MipFilter = NONE; // LINEAR;
  1410.     AddressU  = Clamp;
  1411.     AddressV  = Clamp;
  1412.     SRGBTexture=FALSE;
  1413.     MaxMipLevel=0;
  1414.     MipMapLodBias=0;
  1415. };
  1416.  
  1417. sampler2D _s1 = sampler_state {
  1418.     Texture   = <texs1>;
  1419.     MinFilter = LINEAR;
  1420.     MagFilter = LINEAR;
  1421.     MipFilter = NONE; // LINEAR;
  1422.     AddressU  = Clamp;
  1423.     AddressV  = Clamp;
  1424.     SRGBTexture=FALSE;
  1425.     MaxMipLevel=0;
  1426.     MipMapLodBias=0;
  1427. };
  1428.  
  1429. sampler2D _s2 = sampler_state {
  1430.     Texture   = <texs2>;
  1431.     MinFilter = LINEAR;
  1432.     MagFilter = LINEAR;
  1433.     MipFilter = NONE; // LINEAR;
  1434.     AddressU  = Clamp;
  1435.     AddressV  = Clamp;
  1436.     SRGBTexture=FALSE;
  1437.     MaxMipLevel=0;
  1438.     MipMapLodBias=0;
  1439. };
  1440.  
  1441. sampler2D _s3 = sampler_state {
  1442.     Texture   = <texs3>;
  1443.     MinFilter = LINEAR;
  1444.     MagFilter = LINEAR;
  1445.     MipFilter = NONE; // LINEAR;
  1446.     AddressU  = Clamp;
  1447.     AddressV  = Clamp;
  1448.     SRGBTexture=FALSE;
  1449.     MaxMipLevel=0;
  1450.     MipMapLodBias=0;
  1451. };
  1452.  
  1453. sampler2D _s4 = sampler_state {
  1454.     Texture   = <texs4>;
  1455.     MinFilter = LINEAR;
  1456.     MagFilter = LINEAR;
  1457.     MipFilter = NONE; // LINEAR;
  1458.     AddressU  = Clamp;
  1459.     AddressV  = Clamp;
  1460.     SRGBTexture=FALSE;
  1461.     MaxMipLevel=0;
  1462.     MipMapLodBias=0;
  1463. };
  1464.  
  1465. sampler2D _s7 = sampler_state {
  1466.     Texture   = <texs7>;
  1467.     MinFilter = LINEAR;
  1468.     MagFilter = LINEAR;
  1469.     MipFilter = NONE;
  1470.     AddressU  = Clamp;
  1471.     AddressV  = Clamp;
  1472.     SRGBTexture=FALSE;
  1473.     MaxMipLevel=0;
  1474.     MipMapLodBias=0;
  1475. };
  1476.  
  1477. struct VS_OUTPUT_POST {
  1478.     float4 vpos     : POSITION;
  1479.     float2 txcoord0 : TEXCOORD0;
  1480. };
  1481.  
  1482. struct VS_INPUT_POST {
  1483.     float3 pos      : POSITION;
  1484.     float2 txcoord0 : TEXCOORD0;
  1485. };
  1486.  
  1487. VS_OUTPUT_POST VS_Quad(VS_INPUT_POST IN){
  1488.     VS_OUTPUT_POST OUT;
  1489.     OUT.vpos=float4(IN.pos.x,IN.pos.y,IN.pos.z,1.0);
  1490.     OUT.txcoord0.xy=IN.txcoord0.xy;
  1491.     return OUT;
  1492. };
  1493.  
  1494. //skyrim shader specific externals, do not modify
  1495.     float4 _c1 : register(c1); float4 _c2 : register(c2); float4 _c3 : register(c3);
  1496.     float4 _c4 : register(c4); float4 _c5 : register(c5);
  1497.  
  1498. float4 PS_D6EC7DD1(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR {
  1499.     float4 _oC0 = 0.0; // output
  1500.     float4 _c6 = float4(0, 0, 0, 0);
  1501.     float4 _c7 = float4(0.212500006, 0.715399981, 0.0720999986, 1.0);
  1502.     float4 r0; float4 r1; float4 r2; float4 r3; float4 r4; float4 r5; float4 r6;
  1503.     float4 r7; float4 r8; float4 r9; float4 r10; float4 r11; float4 _v0=0.0;
  1504.     _v0.xy = IN.txcoord0.xy;
  1505.     r1=tex2D(_s0, _v0.xy); // color
  1506.     r11=r1; // my bypass
  1507.     _oC0.xyz=r1.xyz; // for future use without game color corrections
  1508.    
  1509.     // HD6 - You can play with the night/day value here, not that its advisable to :-D
  1510.     // Visualize this with 'debug triangle' further down
  1511.     float hnd = ENightDayFactor;
  1512.     //hnd-=0.4;
  1513.     //hnd = hnd - (0.5-hnd);
  1514.     //hnd = max(hnd,0);
  1515.     //hnd = min(hnd,1);
  1516.     //hnd=1;
  1517.    
  1518.     float2 hndtweak = float2( 3.1 , 1.5 );
  1519.     float vhnd = hnd; // effects vignette stregth;
  1520.     float bchnd = hnd; // effects hd6 bloom crisp
  1521.     float cdhnd = hnd; // effects hd6 colorsat daynight
  1522.    
  1523.     // Some caves are seen as daytime, so I set key 3 to force nightime
  1524.     // This doesnt work very well >_<
  1525.     hnd = tempF1.z < 1 ? 0 : hnd;
  1526.     hndtweak.x = tempF1.z < 1 ? hndtweak.y : hndtweak.x; // Dont ask, I have no idea why I need this lol
  1527.    
  1528.    
  1529.     // HD6 - Alter Brightness using keyboard during gameplay
  1530.        
  1531.         float4 tuctbrt1 = uctbrt1;
  1532.         float4 tuctbrt2 = uctbrt2;
  1533.         float4 tuctcon  = uctcon;
  1534.         float4 tuctsat  = uctsat;
  1535.        
  1536.         #ifdef HD6_DARKER_NIGHTS
  1537.             tuctbrt1 -= darkenby1;
  1538.         #endif
  1539.                
  1540.         float h1 = lerp(-1,1,tempF1.x); // Increases speed it changes by when pressing key     
  1541.         h1 = lerp( h1, 1, hnd ); // Removes affect during day      
  1542.         h1 = h1 - (h1 % 0.1); // Changes it so incriments are in steps, remove this if you want smooth changes when pressing keys
  1543.         //float hbs = EBloomAmount;
  1544.         float hbs = lerp( EBloomAmount/2, EBloomAmount, h1); // Reduce bloom as it gets darker, otherwise it just gets hazier, higher number reduces bloom more as it gets darker
  1545.        
  1546.         float h2 = lerp(-1,1,tempF1.y); // Increases speed it changes by when pressing key
  1547.         h2 = lerp( 1, h2, hnd ); // Removes affect during night
  1548.         h2 = h2 - (h2 % 0.1); // Changes it so incriments are in steps, remove this if you want smooth changes when pressing keys
  1549.         hbs = lerp( (hbs/2)-1, hbs, h2); // Reduce bloom as it gets darker, otherwise it just gets hazier, higher number reduces bloom more as it gets darker
  1550.         hbs = max(0,hbs);
  1551.         hbs = min(2,hbs); // should be able to go above 1, but not 2
  1552.        
  1553.         vhnd = lerp(-2,hnd,h2);
  1554.         vhnd = max(0,vhnd); // do not go below 0;
  1555.         vhnd = min(1,vhnd); // not above 1, just incase people like surface of sun
  1556.  
  1557.         cdhnd=bchnd=vhnd;
  1558.         //cdhnd=0;
  1559.         //bchnd=0;
  1560.         //vhnd=0;
  1561.        
  1562.         #ifdef HD6_COLOR_TWEAKS
  1563.             //float2 uctbrt1t =     float2( lerp( tuctbrt1.x,   tuctbrt1.y, h1), tuctbrt1.z );
  1564.             //float2 uctbrt2t =     float2( lerp( tuctbrt2.x,   tuctbrt2.y, h1), tuctbrt2.y );         
  1565.             //float2 uctcont  = float2( lerp( tuctcon.x,    tuctcon.y,  h1), tuctcon.z );
  1566.             //float2 uctsatt  = float2( lerp( tuctsat.x,    tuctsat.y,  h1), tuctsat.z );
  1567.             float2 uctbrt1t =   float2( lerp( tuctbrt1.x,   tuctbrt1.z, h1), lerp( tuctbrt1.y,  tuctbrt1.w, h2) );
  1568.             float2 uctbrt2t =   float2( lerp( tuctbrt2.x,   tuctbrt2.z, h1), lerp( tuctbrt2.y,  tuctbrt2.w, h2) );         
  1569.             float2 uctcont  =   float2( lerp( tuctcon.x,    tuctcon.z,  h1), lerp( tuctcon.y,   tuctcon.w, h2) );
  1570.             float2 uctsatt  =   float2( lerp( tuctsat.x,    tuctsat.z,  h1), lerp( tuctsat.y,   tuctsat.w, h2) );
  1571.         #endif
  1572.        
  1573.     ////
  1574.    
  1575.    
  1576.    
  1577.     #ifdef APPLYGAMECOLORCORRECTION
  1578.         //apply original
  1579.         r0.x=1.0/_c2.y;
  1580.         r1=tex2D(_s2, _v0);
  1581.  
  1582.         r1.xyz = lerp( 0.18, 1.1, hnd ); // HD6 - disable vanilla adapation... because it drives me CRAAAZY!!!!! >_<
  1583.         r1.xyz+=1.0;
  1584.         r1.xyz = lerp( min( 0.015, r1.xyz ), 0.007, hnd ); // Ligthen if dark, but do not darken if too light, we do this elsewhere for extreme bright situations
  1585.         // No seriously it screws up when looking at bright lights at night and the sky during day
  1586.        
  1587.        
  1588.        
  1589.         r0.yz=r1.xy * _c1.y;
  1590.         r0.w=1.0/r0.y;
  1591.         r0.z=r0.w * r0.z;
  1592.         r1=tex2D(_s0, _v0);
  1593.         r1.xyz=r1 * _c1.y;
  1594.         r0.w=dot(_c7.xyz, r1.xyz);
  1595.         r1.w=r0.w * r0.z;
  1596.         r0.z=r0.z * r0.w + _c7.w;
  1597.         r0.z=1.0/r0.z;
  1598.         r0.x=r1.w * r0.x + _c7.w;
  1599.         r0.x=r0.x * r1.w;
  1600.         r0.x=r0.z * r0.x;
  1601.         if (r0.w<0) r0.x=_c6.x;
  1602.         r0.z=1.0/r0.w;
  1603.         r0.z=r0.z * r0.x;
  1604.         r0.x=saturate(-r0.x + _c2.x);
  1605.  
  1606.         //r2=tex2D(_s3, _v0); // enb bloom
  1607.         r2=tex2D(_s1, _v0);//skyrim bloom
  1608.        
  1609.         #ifdef USEBLOOM
  1610.             r2.xyz=min(r2,0.5); // HD6 code to stop bloom causing glitches, inverting
  1611.             r2.xyz=max(r2,0.1);
  1612.         #else
  1613.             r2.xyz=0.0; // compensate for lack of bloom
  1614.         #endif
  1615.         r2.xyz=0.00; // Screw it bloom should not happen here at all so just set to 0
  1616.         r2+=0.000; // HD6 - I add 0.1 to lighten it a bit, probably not great place to do it now
  1617.  
  1618.             //r2=tex2D(_s1, _v0); // skyrim bloom
  1619.         r2.xyz=r2 * _c1.y;
  1620.         r2.xyz=r0.x * r2;
  1621.                
  1622.         r1.xyz=r1 * r0.z + r2;
  1623.         r0.x=dot(r1.xyz, _c7.xyz);
  1624.         r1.w=_c7.w;
  1625.        
  1626.         r2=lerp(r0.x, r1, _c3.x);
  1627.            
  1628.         r1=r0.x * _c4 - r2;
  1629.         r1=_c4.w * r1 + r2;
  1630.         r1=_c3.w * r1 - r0.y; // khajiit night vision _c3.w
  1631.         r0=_c3.z * r1 + r0.y;
  1632.         r1=-r0 + _c5;
  1633.        
  1634.         _oC0=_c5.w * r1 + r0;
  1635.         //_oC0=r0;
  1636.     #endif // APPLYGAMECOLORCORRECTION
  1637.  
  1638.     float4 color=_oC0;     
  1639.    
  1640.     //HD6 brighten when not using original gamma, so they are at least similiar
  1641.     // Bloom is diminshed for some reason, oh well, i dont use this
  1642.     #ifndef APPLYGAMECOLORCORRECTION
  1643.         color*=1.2;
  1644.         color+=0.1;        
  1645.     #endif
  1646.    
  1647.     #ifdef HD6_COLORSAT_DAYNIGHT
  1648.         // HeliosDoubleSix code to Desaturate at night 
  1649.         // What channels to desaturate by how much, so you could just reduce blue at night and nothing else
  1650.         // doesnt seem quite right will tinge things green if you just remove blue :-/ thought perhaps that makes perfect sense :-) *brain hurts*
  1651.         // Remember this affects caves, so might be best to remove saturation from nighttime direct and ambient light
  1652.         float3 nsatn=lerp(dnsatd,dnsatn,1-cdhnd); // So it has less to different/no effect during day
  1653.             //nsatn*=(1-cdhnd); // affect by night time value:
  1654.         float3 oldcoln = color.xyz; // store old values
  1655.         color.xyz *= nsatn; // adjust saturation   
  1656.        
  1657.         // spread lost luminace over everything
  1658.             //float3 greycn = float3(0.699, 0.887, 0.414); // perception of color luminace
  1659.         float3 greycn = float3(0.333,0.333,0.333); // screw perception
  1660.             greycn = float3(0.811,0.523,0.996);
  1661.         //color.xyz += (oldcoln.x-(oldcoln.x*nsatn.x)) * greycn.x;
  1662.         //color.xyz += (oldcoln.y-(oldcoln.y*nsatn.y)) * greycn.y;
  1663.         //color.xyz += (oldcoln.z-(oldcoln.z*nsatn.z)) * greycn.z;
  1664.     #endif 
  1665.    
  1666. /*
  1667.     #ifndef APPLYGAMECOLORCORRECTION
  1668.         //temporary fix for khajiit night vision, but it also degrade colors.
  1669.         //  r1=tex2D(_s2, _v0);
  1670.         //  r0.y=r1.xy * _c1.y;
  1671.         r1=_oC0;
  1672.         r1.xyz=r1 * _c1.y;
  1673.         r0.x=dot(r1.xyz, _c7.xyz);
  1674.         r2=lerp(r0.x, r1, _c3.x);
  1675.         r1=r0.x * _c4 - r2;
  1676.         r1=_c4.w * r1 + r2;
  1677.         r1=_c3.w * r1;// - r0.y;
  1678.         r0=_c3.z * r1;// + r0.y;
  1679.         r1=-r0 + _c5;
  1680.         _oC0=_c5.w * r1 + r0;
  1681.     #endif //!APPLYGAMECOLORCORRECTION
  1682. */
  1683.  
  1684.  
  1685.  
  1686.  
  1687.     //adaptation in time
  1688.     float4  Adaptation=tex2D(_s4, 0.5);
  1689.     float   grayadaptation=max(max(Adaptation.x, Adaptation.y), Adaptation.z);
  1690.         //grayadaptation=1.0/grayadaptation;
  1691.  
  1692.  
  1693.     float4  xcolorbloom=tex2D(_s3, _v0.xy); //bloom
  1694.    
  1695.     #ifdef HD6_BLOOM_NOBLACK
  1696.         // Helios code to remove dark/black from bloom, stopping it making dark shapes on light background bleed and smudge black into them like a black glow yuck
  1697.         // not really very good, looks like black glow is actually coming from original vanilla game or something, so its toned down for now to 0.05
  1698.             // really should make bloom only contain and affect light areas of scene, but this is ok for now.
  1699.             //This also has the side effect of lightening those darkest areas
  1700.         float lowestvalue=min(min(xcolorbloom.x,xcolorbloom.y),xcolorbloom.z);
  1701.             // work out lowest possible value to set RGB without going below 0 and without changing the RGB relative values ie shifting the color in the process
  1702.         float3 lowestpossible=xcolorbloom.xyz-lowestvalue;
  1703.         xcolorbloom.xyz=max(xcolorbloom.xyz,lowestpossible+(0.22*(1-hnd))); // adds 0.1 during night only
  1704.     #endif
  1705.    
  1706.     //xcolorbloom.xyz=0.2; //HDebug
  1707.     //float maxb=max(xcolorbloom.x, max(xcolorbloom.y, xcolorbloom.z));
  1708.     //float violetamount=maxb/(maxb+EVioletShiftAmountInv);
  1709.     //xcolorbloom.xyz=lerp(xcolorbloom.xyz, xcolorbloom.xyz*EVioletShiftColor, violetamount*violetamount);
  1710.  
  1711.     #ifdef HD6_BLOOM_DEBLUEIFY
  1712.        
  1713.         //New saturation to be // 0 being no color
  1714.                 //float3 nsat=float3(1,0.74,0.64); // perfect-ish - removes blue and green from fog and outdoors, makes dwarven ruins very white though
  1715.                 //float3 nsat=float3(1,0.80,0.74); // Touch greener
  1716.                 //float3 nsat=float3(1,0.70,0.65); // Grey, very grey ice gaves almost white, but... foggy days go pink
  1717.             //nsat=float3(0.85,0.75,0.7); // More reasnioable, still pink sky and snow in places
  1718.             //nsat=float3(0.80,0.75,0.73);
  1719.                 //float3 nsat=float3(1,0.64,0.58);
  1720.                 //float3 nsat=float3(1,0.74,0.90); 
  1721.                 //float3 nsat=float3(0.8,0.56,0.46);
  1722.                 //float3 nsat=float3(0.7,0.6,0.4); // desatures everything a bit
  1723.                 //float3 nsat=float3(0,0,0); // no color in bloom, makes everything very desaturated, fire looks white almost
  1724.  
  1725.         // store old values
  1726.             float3 oldcol=xcolorbloom.xyz;
  1727.            
  1728.         // adjust saturation
  1729.             xcolorbloom.xyz *= nsat;
  1730.            
  1731.         // spread lost luminace over everything
  1732.                 //float3 greyc = float3(0.299, 0.587, 0.114); // perception of color luminace
  1733.             float3 greyc = float3(0.333,0.333,0.333); // screw perception
  1734.             xcolorbloom.xyz += (oldcol.x-(oldcol.x*nsat.x)) * greyc.x;
  1735.             xcolorbloom.xyz += (oldcol.y-(oldcol.y*nsat.y)) * greyc.y;
  1736.             xcolorbloom.xyz += (oldcol.z-(oldcol.z*nsat.z)) * greyc.z;
  1737.  
  1738.         // equiv to bloom off without destroyng scene luminance-ish
  1739.         //xcolorbloom.x=0.3;
  1740.         //xcolorbloom.y=0.3;
  1741.         //xcolorbloom.z=0.3;
  1742.  
  1743.         //xcolorbloom.xyz=min(xcolorbloom.xyz,1.2);
  1744.     #endif
  1745.  
  1746.     #ifdef HD6_BLOOM_DEFUZZ
  1747.             // Heliosdouble cobbled together bloom defuzzer - increases contrast of bloom / stop it hazing low brightness values
  1748.             // what a fudge... but... it works... fancy that
  1749.             // modulated by the overall brightness of the screen.
  1750.         float mavg=((xcolorbloom.x+xcolorbloom.y+xcolorbloom.z)*0.333);
  1751.         xcolorbloom.xyz-=(mavg*0.3);
  1752.             //xcolorbloom.xyz=min(xcolorbloom.xyz,0.0);
  1753.         xcolorbloom.xyz+=(mavg*0.22);
  1754.         xcolorbloom.xyz*(mavg*1.2);
  1755.     #endif
  1756.  
  1757.    
  1758.     // Altering color balance is confusing, also Im not entirely sure it works properly :-D
  1759.     #ifdef HD6_COLOR_TWEAKS
  1760.         float ctbrt1 = lerp(uctbrt1t.x,uctbrt1t.y,hnd); // Brightness Night, Day (Alters before contrast adjustment)
  1761.         float ctbrt2 = lerp(uctbrt2t.x,uctbrt2t.y,hnd); // Brightness Night, Day (Alters after contrast adjustment)
  1762.         float ctcon = lerp(uctcont.x,uctcont.y,hnd); // Contrast Night, Day
  1763.         float ctsat = lerp(uctsatt.x,uctsatt.y,hnd); // Saturation Night, Day
  1764.        
  1765.         float3 ctLumCoeff = float3(0.2125, 0.7154, 0.0721);            
  1766.         float3 ctAvgLumin = float3(0.5, 0.5, 0.5);
  1767.         float3 ctbrtColor = color.rgb * ctbrt1;
  1768.  
  1769.         float3 ctintensity = dot(ctbrtColor, ctLumCoeff);
  1770.         float3 ctsatColor = lerp(ctintensity, ctbrtColor, ctsat);
  1771.         float3 cconColor = lerp(ctAvgLumin, ctsatColor, ctcon);
  1772.        
  1773.         color.xyz = cconColor * ctbrt2;
  1774.         float3 cbalance = lerp(rgbn,rgbd,hnd);
  1775.         color.xyz=cbalance.xyz * color.xyz;
  1776.     #endif
  1777.    
  1778.    
  1779.     #ifdef USEBLOOM
  1780.         #ifdef HD6_BLOOM_CRISP 
  1781.             float3 LumCoeff = float3( 0.2125, 0.7154, 0.0721 );            
  1782.             float3 AvgLumin = float3( 5.5, 5.5, 5.5 );
  1783.                 //color*=1.06;
  1784.                 //color*=1.0; // Brighten it up without loosing contrast
  1785.                 //color += lerp(0,1.3,bchnd); // Night, Day, increase kinda lowers contrast, but makes things look more washed out also, this is to lift black areas really
  1786.                 //color+=((color/2)*EBloomAmount);
  1787.                 xcolorbloom-=0.4;
  1788.                 xcolorbloom=max(xcolorbloom,0); // will cause color shift/desaturation also
  1789.                 color.xyz+=(color.xyz*(xcolorbloom*EBloomAmount*0.2))+(xcolorbloom/1.5);
  1790.                 //color.xyz=(color.xyz*color.xyz)/2;           
  1791.                 //color.xyz=(color.xyz*0.5)+((color.xyz*(xcolorbloom*EBloomAmount))*0.5);
  1792.                 //color.xyz*=0.8;      
  1793.                 //color.xyz*=1.4;
  1794.                
  1795.             float3 brightbloom = ( xcolorbloom - lerp( 0.18, 0.0, bchnd )); // darkens and thus limits what triggers a bloom, used in part to stop snow at night glowing blue
  1796.             brightbloom = max( brightbloom , 0);
  1797.            
  1798.             float3 superbright = xcolorbloom - 0.7; // crop it to only include superbright elemnts like sky and fire
  1799.             superbright = max( superbright , 0 ) ; // crop so dont go any lower than black
  1800.                 //superbright = lerp( AvgLumin, superbright, 0.5); // Contrast
  1801.             superbright *= 0.6;
  1802.            
  1803.                
  1804.                 //float lowestvaluec=min(min(brightbloom.x,brightbloom.y),brightbloom.z);
  1805.                 //float3 lowestpossiblec=brightbloom.xyz-lowestvaluec;
  1806.                 //brightbloom=max(brightbloom.xyz,lowestpossiblec);        
  1807.            
  1808.             // HD6 - Bloom - Brightntess, Contrast, Saturation adjustment 1,1,1 for no change // Remember this is bloom only being altered
  1809.                 float brt = lerp( 0.5, 0.5, bchnd ) ; // doesnt work properly, should be done after contrast no?
  1810.                 //
  1811.                 float con = lerp( 0.5, 0.5, bchnd ); // 1.0, 0.8 // 1.1, 1.1               
  1812.                 float sat = lerp( 0.5, 0.5, bchnd ); // 0.5, 0.7 // 0.7, 0.7
  1813.                 //
  1814.                
  1815.                 float3 brtColor = brightbloom * brt;
  1816.                 float3 cintensity = dot( brtColor, LumCoeff );
  1817.                 float3 satColor = lerp( cintensity, brtColor, sat );
  1818.                 float3 conColor = lerp( AvgLumin, satColor, con );
  1819.                 conColor -= 0.1;
  1820.                 brightbloom = conColor;
  1821.                
  1822.                
  1823.                
  1824.                 // These 2 should compensate so when even when no bloom exists it still matches brightness of scene without ENB
  1825.             color.xyz += lerp( 0.12, 0.03, bchnd ); color.xyz *= lerp( 1.1, 1.4, bchnd );
  1826.            
  1827.             // Now Add bloom and compensate for any brightness changes that introduces
  1828.            
  1829.             color.xyz += (( superbright * hbs ) * lerp( 1, 1, bchnd ));
  1830.             brightbloom -= ( superbright * 2 ); // removes superbright from brightbloom so I dont bloom the brightest area twice
  1831.             brightbloom = max( brightbloom , 0.0 );
  1832.             color.xyz += (( brightbloom * hbs ) * lerp( 1.0, 1.0, bchnd ));
  1833.  
  1834.                 // Blend in some of the orignal bloom to bring back SOME of the hazy glow of the day, none at night
  1835.                 // 1.0, 0.9 - 0.7, 0.6
  1836.             color.xyz += (xcolorbloom.xyz * hbs) * lerp( 0.7, 0.6, bchnd );
  1837.             color.xyz *= lerp( 0.8, 0.7, bchnd ); // compensate for brightening caused by above bloom
  1838.                 // End Blend
  1839.            
  1840.                 //color.xyz *= 1.0;
  1841.                 //color.xyz += (xcolorbloom * 0.3);
  1842.                 //color.xyz += 0.25;
  1843.                 //float4 debug = color;
  1844.                 //debug.xyz = ( superbright * EBloomAmount * 1 );          
  1845.            
  1846.                 //color.xyz+=((xcolorbloom*EBloomAmount)/1);
  1847.                 //color.xyz*=lerp(1.25,0.8,bchnd); // 1.25, 1 // Darkens end result to rematch with how it looks without BLOOM CRISP enabled
  1848.            
  1849.         #else
  1850.             #ifdef HD6_BLOOM_SCREEN
  1851.                 // Helios code to restrict bloom to bright areas only, not smudging dark outs around
  1852.                 color+=((color/1)*EBloomAmount); // compensate if bloom disabled   
  1853.                     //color+=0.1;
  1854.                     //xcolorbloom-=0.5;
  1855.                 xcolorbloom=max(xcolorbloom,0); // will cause color shift/desaturation also
  1856.                     //xcolorbloom+=0.2;
  1857.                     // Soft Light: X = (((255-L)*U*L)+ (L*R_s))/255
  1858.                     //1 - ((1.0 - base) * (1.0 - blend))
  1859.                     //1 - ((255-U)*(255-L))/255
  1860.                     //xcolorbloom.xyz*=EBloomAmount;
  1861.                 float tmult = 10;
  1862.                 color/=tmult; xcolorbloom/=tmult; // Screen mode wont work with floating point numbers / big numbers, so I reduce it first
  1863.                
  1864.                 color.x = 1.0 - ((1.0 - color.x) * (1.0 - xcolorbloom.x));
  1865.                 color.y = 1.0 - ((1.0 - color.y) * (1.0 - xcolorbloom.y));
  1866.                 color.z = 1.0 - ((1.0 - color.z) * (1.0 - xcolorbloom.z));
  1867.                 color*=tmult;      
  1868.             // End helios code
  1869.             #else  
  1870.                 float tt=1;
  1871.                     //float3 tt = float3(1*tempF1.x,1*tempF1.x,1*tempF1.x);
  1872.                 color.xyz+=((xcolorbloom.xyz*EBloomAmount)*tt);
  1873.             #endif  
  1874.         #endif
  1875.     #else
  1876.         // No bloom
  1877.         color+=((color/1)*EBloomAmount); // compensate if bloom disabled
  1878.     #endif
  1879.        
  1880.     //+++++++++++++++++++++++++++++
  1881.        
  1882.     #ifdef HD6_VIGNETTE    
  1883.         // yes this is my own crazy creation after seing how boring the usual linear circle vignettes typically are
  1884.         // no doubt I have done it in an overly convoluted way :-)
  1885.        
  1886.             //float fExposureLevel = 0; // compensate for any change from vignette so center is same brightness
  1887.         float2 inTex = _v0;
  1888.         float4 voriginal = r1;
  1889.         float4 vcolor = voriginal;
  1890.         vcolor.xyz=1;
  1891.         inTex -= 0.5; // Centers vignette
  1892.         inTex.y += 0.0; // Move it off center and up so it obscures sky less
  1893.         float vignette = 1.0 - dot( inTex, inTex );
  1894.         vcolor *= pow( vignette, vignettepow );
  1895.        
  1896.        
  1897.         // Round Vignette
  1898.         float4 rvigtex = vcolor;
  1899.         rvigtex.xyz = pow( vcolor, 1 );
  1900.         rvigtex.xyz = lerp(float3(0.5, 0.5, 0.5), rvigtex.xyz, 2.0); // Increase Contrast
  1901.         rvigtex.xyz = lerp(float3(1,1,1),rvigtex.xyz,rovigpwr); // Set strength of round vignette
  1902.        
  1903.         // Square Vignette (just top and bottom of screen)
  1904.         float4 vigtex = vcolor;
  1905.         vcolor.xyz = float3(1,1,1);
  1906.         float3 topv = min((inTex.y+0.5)*2,0.5) * 2; // Top vignette
  1907.         float3 botv = min(((0-inTex.y)+0.5)*2,0.5) * 2; // Bottom vignette
  1908.        
  1909.         topv= lerp(float3(1,1,1), topv, sqvigpwr.x);
  1910.         botv= lerp(float3(1,1,1), botv, sqvigpwr.y);
  1911.         vigtex.xyz = (topv)*(botv);
  1912.        
  1913.         //vigtex.xyz = lerp(float3(1,1,1),vigtex.xyz,sqvigpwr); // Set strength of square vignette
  1914.                
  1915.         // Add round and square together
  1916.         vigtex.xyz*=rvigtex.xyz;
  1917.        
  1918.         vigtex.xyz = lerp(vigtex.xyz,float3(1,1,1),(1-vstrengthatnight)*(1-vhnd)); // Alter Strength at night
  1919.        
  1920.             vigtex.xyz = min(vigtex.xyz,1);
  1921.             vigtex.xyz = max(vigtex.xyz,0);
  1922.             //vigtex.xyz -= 0.5;
  1923.             //(base < 0.5 ? (2.0 * base * blend) : (1.0 - 2.0 * (1.0 - base) * (1.0 - blend)))
  1924.             //vigtex.xyz = vigtex.xyz < 0.5 ? (2.0 * color.xyz * vigtex.xyz) : (1 - 2 * (1 - color.xyz) * (1 - vigtex.xyz));
  1925.             // Crap I keep forgetting overlay mode doesnt work in floating point/32bit/hdr dur bee durr
  1926.                
  1927.         // Increase saturation where edges were darkenned
  1928.         float3 vtintensity = dot(color.xyz, float3(0.2125, 0.7154, 0.0721));
  1929.         color.xyz = lerp(vtintensity, color.xyz, ((((1-(vigtex.xyz*2))+2)-1)*vsatstrength)+1  );
  1930.        
  1931.             //color.xyz+=0.02;
  1932.         color.xyz *= (vigtex.xyz);
  1933.             //color.xyz *= fExposureLevel; 
  1934.        
  1935.     #endif
  1936.    
  1937.     // HD6 - Warning, Code below appears to reduce 'color.xyz' to 8bit / LDR
  1938.        
  1939.        
  1940.     // HD6 - Eye Adaptation for extreme extreme over bright areas only, such as stupid stupid snow
  1941.     // 0.3, 0.9 - affects day time sunny day = bad
  1942.     float toobright = max(0,tex2D(_s2, _v0).xyz - 0.5); // 0.5
  1943.     color.xyz *= 1-(0.75 * toobright); // 1.3
  1944.    
  1945.     // <Lazy> HD6 - dopey arse code to alter enbpalette because im too lazy to open photoshop
  1946.         // when using your own palette remove this.. ill fix this.. next
  1947.         float palmix = 0.8; // 0.4
  1948.         color.xyz*=lerp(0.7, 0.80, palmix); // 0.9
  1949.     // </Lazy>
  1950.        
  1951.        
  1952.     //+++++++++++++++++++++++++++++
  1953.     #if (POSTPROCESS==1)
  1954.         grayadaptation=max(grayadaptation, 0.0);
  1955.         grayadaptation=min(grayadaptation, 50.0);
  1956.         color.xyz=color.xyz/(grayadaptation*EAdaptationMaxV1+EAdaptationMinV1);//*tempF1.x
  1957.        
  1958.         float cgray=dot(color.xyz, float3(0.27, 0.67, 0.06));
  1959.         cgray=pow(cgray, EContrastV1);
  1960.         float3 poweredcolor=pow(color.xyz, EColorSaturationV1);
  1961.         float newgray=dot(poweredcolor.xyz, float3(0.27, 0.67, 0.06));
  1962.         color.xyz=poweredcolor.xyz*cgray/(newgray+0.0001);
  1963.  
  1964.         float3  luma=color.xyz;
  1965.         float   lumamax=300.0;
  1966.         color.xyz=(color.xyz * (1.0 + color.xyz/lumamax))/(color.xyz + EToneMappingCurveV1);
  1967.     #endif
  1968.     //+++++++++++++++++++++++++++++
  1969.    
  1970.     //+++++++++++++++++++++++++++++
  1971.     #if (POSTPROCESS==2)
  1972.         grayadaptation=max(grayadaptation, 0.0);
  1973.         grayadaptation=min(grayadaptation, 50.0);
  1974.         color.xyz=color.xyz/(grayadaptation*EAdaptationMaxV2+EAdaptationMinV2);//*tempF1.x
  1975.  
  1976.         color.xyz*=EBrightnessV2;
  1977.         color.xyz+=0.000001;
  1978.         float3 xncol=normalize(color.xyz);
  1979.         float3 scl=color.xyz/xncol.xyz;
  1980.         scl=pow(scl, EIntensityContrastV2);
  1981.         xncol.xyz=pow(xncol.xyz, EColorSaturationV2);
  1982.         color.xyz=scl*xncol.xyz;
  1983.  
  1984.         float   lumamax=EToneMappingOversaturationV2;
  1985.         color.xyz=(color.xyz * (1.0 + color.xyz/lumamax))/(color.xyz + EToneMappingCurveV2);
  1986.  
  1987.        
  1988. //MIDHRAS: Mood Colouring
  1989. float fRatio = 0.4; // blend ratio (0-1)
  1990. //float fRatio = 0.425;
  1991. float moodR = 0.735;    // mood color red component
  1992. float moodG = 0.62; // mood color green component
  1993. float moodB = 0.5;  // mood color blue component
  1994.  
  1995.  
  1996.     float4 colInput = color;
  1997.     float4 colMood = 1.0f;
  1998.     colMood.r = moodR;
  1999.     colMood.g = moodG;
  2000.     colMood.b = moodB;
  2001.     float fLum = ( colInput.r + colInput.g + colInput.b ) / 3;
  2002.  
  2003.     colMood = lerp(0, colMood, saturate(fLum * 2.0));
  2004.     colMood = lerp(colMood, 1, saturate(fLum - 0.5) * 2.0);
  2005.     float4 colOutput = lerp(colInput, colMood, saturate(fLum * fRatio));
  2006.     color.rgb=max(0, colOutput);
  2007.  
  2008. #endif
  2009.     //+++++++++++++++++++++++++++++
  2010.  
  2011.     //+++++++++++++++++++++++++++++ HD6 version based on postprocess 2
  2012.     #if (POSTPROCESS==5)
  2013.             grayadaptation=max(grayadaptation, 0.0);
  2014.             grayadaptation=min(grayadaptation, 50.0);
  2015.             //color.xyz=color.xyz/(grayadaptation*EAdaptationMaxV2+EAdaptationMinV2); //*tempF1.x      
  2016.         // HD6 - Screw eye adaptation it drives me mad, bright sky causes everything else to darken yuck
  2017.         // Human eye adaptation happens instantly or so slowly you dont notice it in reality
  2018.         // it would make sense if the game was calibrated for true brightness values of indoors and outdoors being 10000x brighter
  2019.         // but it isnt, and thus all the pseudo tone mapping and linear colorspace adaption shenanigans just drives me mad and for little gain
  2020.         // So now simple adjust brightness based on time of day
  2021.         // with all the other effects turned off this should roughly equal the brightness when ENB is disabled
  2022.         //color.xyz*=lerp( 3.1, 1.5, hnd );
  2023.         color.xyz*=lerp( hndtweak.x, hndtweak.y, hnd );
  2024.  
  2025.             //color.xyz*=EBrightnessV2;
  2026.             //color.xyz+=0.000001; // HD6 - Why? how curious
  2027.         float3 xncol=normalize(color.xyz);
  2028.         float3 scl=color.xyz/xncol.xyz;
  2029.         scl=pow(scl, EIntensityContrastV2);
  2030.         xncol.xyz=pow(xncol.xyz, EColorSaturationV2);
  2031.         color.xyz=scl*xncol.xyz;
  2032.         color.xyz*=HCompensateSat; // compensate for darkening caused my EcolorSat above
  2033.  
  2034.             //float lumamax=EToneMappingOversaturationV2;
  2035.             //color.xyz=(color.xyz * (1.0 + color.xyz/lumamax))/(color.xyz + EToneMappingCurveV2);
  2036.  
  2037.         color.xyz=color.xyz/(color.xyz + EToneMappingCurveV2);
  2038.             //color.xyz=tex2D(_s0, _v0.xy);
  2039.             //color.xyz=color.xyz-0.03;
  2040.             //color.xyz/=10;
  2041.     #endif
  2042.     //+++++++++++++++++++++++++++++
  2043.  
  2044.     //+++++++++++++++++++++++++++++
  2045.     #if (POSTPROCESS==3)
  2046.         grayadaptation=max(grayadaptation, 0.0);
  2047.         grayadaptation=min(grayadaptation, 50.0);
  2048.         color.xyz=color.xyz/(grayadaptation*EAdaptationMaxV3+EAdaptationMinV3); //*tempF1.x
  2049.  
  2050.         //float3    luma=color.xyz;
  2051.         //float lumamax=20.0;
  2052.         float   lumamax=EToneMappingOversaturationV3;
  2053.         color.xyz=(color.xyz * (1.0 + color.xyz/lumamax))/(color.xyz + EToneMappingCurveV3);
  2054.  
  2055.        
  2056. // /*
  2057.  
  2058.  
  2059. //MIDHRAS: Mood Colouring
  2060. float fRatio = 0.75;    // blend ratio (0-1)
  2061. //float fRatio = 0.425;
  2062. float moodR = 0.735;    // mood color red component
  2063. float moodG = 0.620;    // mood color green component
  2064. float moodB = 0.500;    // mood color blue component
  2065.  
  2066.  
  2067.     float4 colInput = color;
  2068.     float4 colMood = 1.0f;
  2069.     colMood.r = moodR;
  2070.     colMood.g = moodG;
  2071.     colMood.b = moodB;
  2072.     float fLum = ( colInput.r + colInput.g + colInput.b ) / 3;
  2073.  
  2074.     colMood = lerp(0, colMood, saturate(fLum * 2.0));
  2075.     colMood = lerp(colMood, 1, saturate(fLum - 0.5) * 1.0);
  2076.     float4 colOutput = lerp(colInput, colMood, saturate(fLum * fRatio));
  2077.     color.rgb=max(0, colOutput);
  2078.    
  2079.  
  2080. float   Contrast = -0.05;
  2081. color.xyz = saturate(color.xyz);
  2082.     color.xyz = lerp(color.xyz, 0.5 * (1 + sin((color.xyz - 0.25)*3.1415926)), Contrast);
  2083.  
  2084. float   Exposure=0.035;
  2085. color.rgb *= pow(1.8f, Exposure);
  2086.    
  2087. // */      
  2088.        
  2089.     #endif
  2090.     //+++++++++++++++++++++++++++++
  2091.     //color.xyz=tex2D(_s0, _v0.xy) + xcolorbloom.xyz*float3(0.7, 0.6, 1.0)*0.5;
  2092.     //color.xyz=tex2D(_s0, _v0.xy) + xcolorbloom.xyz*float3(0.7, 0.6, 1.0)*0.5;
  2093.     //color.xyz*=0.7;
  2094.  
  2095.     //+++++++++++++++++++++++++++++
  2096.     #if (POSTPROCESS==4)
  2097.         grayadaptation=max(grayadaptation, 0.0);
  2098.         grayadaptation=min(grayadaptation, 50.0);
  2099.         color.xyz=color.xyz/(grayadaptation*EAdaptationMaxV4+EAdaptationMinV4);
  2100.  
  2101.         float Y = dot(color.xyz, float3(0.299, 0.587, 0.114)); //0.299 * R + 0.587 * G + 0.114 * B;
  2102.         float U = dot(color.xyz, float3(-0.14713, -0.28886, 0.436)); //-0.14713 * R - 0.28886 * G + 0.436 * B;
  2103.         float V = dot(color.xyz, float3(0.615, -0.51499, -0.10001)); //0.615 * R - 0.51499 * G - 0.10001 * B;
  2104.        
  2105.         Y=pow(Y, EBrightnessCurveV4);
  2106.         Y=Y*EBrightnessMultiplierV4;
  2107.             //Y=Y/(Y+EBrightnessToneMappingCurveV4);
  2108.             //float desaturatefact=saturate(Y*Y*Y*1.7);
  2109.             //U=lerp(U, 0.0, desaturatefact);
  2110.             //V=lerp(V, 0.0, desaturatefact);
  2111.         color.xyz=V * float3(1.13983, -0.58060, 0.0) + U * float3(0.0, -0.39465, 2.03211) + Y;
  2112.  
  2113.         color.xyz=max(color.xyz, 0.0);
  2114.         color.xyz=color.xyz/(color.xyz+EBrightnessToneMappingCurveV4);
  2115.     #endif
  2116.     //+++++++++++++++++++++++++++++
  2117.  
  2118.    
  2119.    
  2120.     //+++++++++++++++++++++++++++++
  2121.     //pallete texture (0.082+ version feature)
  2122.     #ifdef E_CC_PALETTE
  2123.        
  2124.        
  2125.         color.rgb=saturate(color.rgb);
  2126.         float3  brightness=Adaptation.xyz; //tex2D(_s4, 0.5); //adaptation luminance
  2127.             //brightness=saturate(brightness); //old version from ldr games
  2128.         brightness=(brightness/(brightness+1.0));//new version
  2129.         brightness=max(brightness.x, max(brightness.y, brightness.z));//new version
  2130.         float3  palette;
  2131.         float4  uvsrc=0.0;
  2132.         uvsrc.y=brightness.r;
  2133.         uvsrc.x=color.r;
  2134.         palette.r=tex2Dlod(_s7, uvsrc).r;
  2135.         uvsrc.x=color.g;
  2136.         uvsrc.y=brightness.g;
  2137.         palette.g=tex2Dlod(_s7, uvsrc).g;
  2138.         uvsrc.x=color.b;
  2139.         uvsrc.y=brightness.b;
  2140.         palette.b=tex2Dlod(_s7, uvsrc).b;      
  2141.        
  2142.         color.rgb=lerp( color.rgb, palette.rgb, palmix );
  2143.        
  2144.         //color.rgb=toobright;
  2145.     #endif //E_CC_PALETTE
  2146.     //+++++++++++++++++++++++++++++
  2147.  
  2148.        
  2149.     /*
  2150.     // HeliosDoubleSix cobbled code to Cap values above 0, not great as limits how black it can do say if it was pure red?!
  2151.     // what is the lowest value out of r,g,b
  2152.         float lowestvalue=min(min(color.x,color.y),color.z);
  2153.         // work out lowest possible value to set RGB without going below 0 and without changing the RGB relative values ie shifting the color in the process
  2154.         float3 lowestpossible=color.xyz-lowestvalue;
  2155.         color.xyz=max(color.xyz,lowestpossible);
  2156.         //color.r=max(color.r,lowestpossible.x);
  2157.         //color.g=max(color.g,lowestpossible.y);
  2158.         //color.b=max(color.b,lowestpossible.z);
  2159.     */
  2160.  
  2161.         //color.xyz=saturate(xcolorbloom.xyz);
  2162.         //color.xyz-=(pow(color.xyz, 6)/2);
  2163.         //color.xyz=max(0,color.xyz);
  2164.         //color.xyz=debug;
  2165.  
  2166.     /*
  2167.         //temporary testing
  2168.         color.xyz=tex2D(_s0, _v0.xy);
  2169.         //color.xyz=xcolorbloom.xyz*tempF1.x;
  2170.  
  2171.         //color.xyz=pow(color.xyz, 0.5);
  2172.         color.xyz+=(xcolorbloom.xyz-color.xyz)*tempF1.y;
  2173.         //color.xyz=xcolorbloom.xyz*tempF1.y;
  2174.         color.xyz=color.xyz*tempF1.x;
  2175.         //color.xyz=color.xyz/(color.xyz +1.0*tempF1.z);
  2176.         color.xyz=(color.xyz * (1.0 + color.xyz/40))/(color.xyz + EToneMappingCurveV3);
  2177.             Adaptation=tex2D(_s4, 0.5);
  2178.             grayadaptation=max(max(Adaptation.x, Adaptation.y), Adaptation.z);
  2179.             grayadaptation=max(grayadaptation, 0.0);
  2180.             grayadaptation=min(grayadaptation, 50.0);
  2181.         //  color.xyz=Adaptation*2;//*tempF1.x
  2182.  
  2183.         //color.xyz=tex2D(_s0, _v0.xy)*1.3;
  2184.     */
  2185.  
  2186.     //color.xyz=tex2D(_s0, _v0.xy)*pow(tempF1.x,4);
  2187.     //color.xyz=max(xcolorbloom.xyz, tex2D(_s0, _v0.xy).xyz)*pow(tempF1.x,4)*0.7;
  2188.  
  2189.    
  2190.    
  2191.    
  2192.    
  2193.     _oC0.w=1.0;
  2194.     _oC0.xyz=color.xyz;
  2195.     //_oC0.xyz=debug;
  2196.    
  2197.     // HD6 - debug triangle - draws a triangle top left showing the value of night/day for testing
  2198.     //_oC0.xyz = _v0.x+_v0.y < 0.1 ? (hnd) : (_oC0.xyz);
  2199.     float h11 = h1 == 1 ? 0 : 0.4;
  2200.     _oC0.xyz += _v0.x+_v0.y < 0.004 ? (h11) : (0);
  2201.    
  2202.     // Red dot in top left if you adjust daytime
  2203.     float h22 = h2 == 1 ? 0 : 0.4;
  2204.     _oC0.x += _v0.x+_v0.y < 0.004 ? (h22) : (0);
  2205.    
  2206.     return _oC0;
  2207. }
  2208.  
  2209.  
  2210.  
  2211.  
  2212. //switch between vanilla and mine post processing
  2213. #ifndef ENB_FLIPTECHNIQUE
  2214.     technique Shader_D6EC7DD1
  2215. #else
  2216.     technique Shader_ORIGINALPOSTPROCESS
  2217. #endif
  2218. {
  2219.     pass p0
  2220.     {
  2221.         VertexShader = compile vs_3_0 VS_Quad();
  2222.         PixelShader = compile ps_3_0 PS_D6EC7DD1();
  2223.  
  2224.         ColorWriteEnable=ALPHA|RED|GREEN|BLUE;
  2225.         ZEnable=FALSE;
  2226.         ZWriteEnable=FALSE;
  2227.         CullMode=NONE;
  2228.         AlphaTestEnable=FALSE;
  2229.         AlphaBlendEnable=FALSE;
  2230.         SRGBWRITEENABLE=FALSE;
  2231.     }
  2232. }
  2233.  
  2234.  
  2235. // HD6 - below doesnt make any diff??? so I disabled it *shrugs*
  2236. /*
  2237. //original shader of post processing
  2238. #ifndef ENB_FLIPTECHNIQUE
  2239.     technique Shader_ORIGINALPOSTPROCESS
  2240. #else
  2241.     technique Shader_D6EC7DD1
  2242. #endif
  2243. {
  2244.     pass p0
  2245.     {
  2246.         VertexShader  = compile vs_3_0 VS_Quad();
  2247.         PixelShader=
  2248.     asm
  2249.     {
  2250. // Parameters:
  2251. //   sampler2D Avg;
  2252. //   sampler2D Blend;
  2253. //   float4 Cinematic;
  2254. //   float4 ColorRange;
  2255. //   float4 Fade;
  2256. //   sampler2D Image;
  2257. //   float4 Param;
  2258. //   float4 Tint;
  2259.  
  2260.  
  2261. // Registers:
  2262.  
  2263. //   Name         Reg   Size
  2264. //   ------------ ----- ----
  2265. //   ColorRange   c1       1
  2266. //   Param        c2       1
  2267. //   Cinematic    c3       1
  2268. //   Tint         c4       1
  2269. //   Fade         c5       1
  2270. //   Image        s0       1
  2271. //   Blend        s1       1
  2272. //   Avg          s2       1
  2273. //s0 bloom result
  2274. //s1 color
  2275. //s2 is average color
  2276.  
  2277.     ps_3_0
  2278.     def c6, 0, 0, 0, 0
  2279.     //was c0 originally
  2280.     def c7, 0.212500006, 0.715399981, 0.0720999986, 1
  2281.     dcl_texcoord v0.xy
  2282.     dcl_2d s0
  2283.     dcl_2d s1
  2284.     dcl_2d s2
  2285.     rcp r0.x, c2.y
  2286.     texld r1, v0, s2
  2287.     mul r0.yz, r1.xxyw, c1.y
  2288.     rcp r0.w, r0.y
  2289.     mul r0.z, r0.w, r0.z
  2290.     texld r1, v0, s1
  2291.     mul r1.xyz, r1, c1.y
  2292.     dp3 r0.w, c7, r1
  2293.     mul r1.w, r0.w, r0.z
  2294.     mad r0.z, r0.z, r0.w, c7.w
  2295.     rcp r0.z, r0.z
  2296.     mad r0.x, r1.w, r0.x, c7.w
  2297.     mul r0.x, r0.x, r1.w
  2298.     mul r0.x, r0.z, r0.x
  2299.     cmp r0.x, -r0.w, c6.x, r0.x
  2300.     rcp r0.z, r0.w
  2301.     mul r0.z, r0.z, r0.x
  2302.     add_sat r0.x, -r0.x, c2.x
  2303.     texld r2, v0, s0
  2304.     mul r2.xyz, r2, c1.y
  2305.     mul r2.xyz, r0.x, r2
  2306.     mad r1.xyz, r1, r0.z, r2
  2307.     dp3 r0.x, r1, c7
  2308.     mov r1.w, c7.w
  2309.     lrp r2, c3.x, r1, r0.x
  2310.     mad r1, r0.x, c4, -r2
  2311.     mad r1, c4.w, r1, r2
  2312.     mad r1, c3.w, r1, -r0.y
  2313.     mad r0, c3.z, r1, r0.y
  2314.     add r1, -r0, c5
  2315.     mad oC0, c5.w, r1, r0
  2316.  
  2317.     };
  2318.         ColorWriteEnable=ALPHA|RED|GREEN|BLUE;
  2319.         ZEnable=FALSE;
  2320.         ZWriteEnable=FALSE;
  2321.         CullMode=NONE;
  2322.         AlphaTestEnable=FALSE;
  2323.         AlphaBlendEnable=FALSE;
  2324.         SRGBWRITEENABLE=FALSE;
  2325.     }
  2326. }
  2327. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement