SHARE
TWEET

Oblivion - NLA enbeffect v5

a guest Apr 11th, 2017 106 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //++++++++++++++++++++++++++++++++++++++++++++
  2. // ENBSeries effect file
  3. // visit http://enbdev.com for updates
  4. // Copyright (c) 2007-2012 Boris Vorontsov
  5. //++++++++++++++++++++++++++++++++++++++++++++
  6.  
  7. #ifndef POSTPROCESS
  8.  #define POSTPROCESS    3
  9. #endif
  10.  
  11. //+++++++++++++++++++++++++++++
  12. //internal parameters, can be modified
  13. //+++++++++++++++++++++++++++++
  14. //float3    EColorFilter=float3(1.0, 0.9, 0.9);
  15.  
  16. //modify these values to tweak various color processing
  17.  
  18. //POSTPROCESS 3
  19. float   EAdaptationMinV3=0.05;
  20. float   EAdaptationMaxV3=0.05;
  21. float   EToneMappingCurveV3=1.0;
  22. float   EToneMappingOversaturationV3=10.0;
  23.  
  24. //begin NLA Adaptation
  25. float   AdaptationMinInterior = 0.003;
  26.  
  27. float   AdaptationMaxInterior = 0.004;
  28.  
  29. float   AdaptationMinDay = 0.015;
  30.  
  31. float   AdaptationMaxDay = 0.015;
  32.  
  33. float   AdaptationMinNight = 0.0;
  34.  
  35. float   AdaptationMaxNight = 0.03;
  36. //End
  37.  
  38. //begin NLA Palette
  39. float   PaletteDay = 1.475;
  40.  
  41. float   PaletteNight = 1.05;
  42.  
  43. float   PaletteInterior = 1.0;
  44.  
  45. float   PaletteBrightnessDay = 1.0;
  46.  
  47. float   PaletteBrightnessNight = 3.0;
  48.  
  49. float   PaletteBrightnessInterior = 3.0;
  50. //End
  51.  
  52. //begin NLA Color
  53. float   GammaDay = 1.2;
  54.  
  55. float   GammaNight = 1.0;
  56.  
  57. float   GammaInterior = 1.0;
  58.  
  59. float   DesatRDay = 1.0;
  60.  
  61. float   DesatRNight = 1.0;
  62.  
  63. float   DesatRInterior = 1.0;
  64.  
  65. float   DesatGDay = 1.0;
  66.  
  67. float   DesatGNight = 1.0;
  68.  
  69. float   DesatGInterior = 1.0;
  70.  
  71. float   DesatBDay = 0.9;
  72.  
  73. float   DesatBNight = 1.0;
  74.  
  75. float   DesatBInterior = 1.0;
  76. //End
  77.  
  78. //begin NLA Tonemapping
  79.  
  80. float   IntensityContrastDay = 1.5;
  81.  
  82. float   IntensityContrastNight = 1.3;
  83.  
  84. float   IntensityContrastInterior = 1.3;
  85.  
  86. float   SaturationDay = 1.0;
  87.  
  88. float   SaturationNight = 1.0;
  89.  
  90. float   SaturationInterior = 1.0;
  91.  
  92. float   ToneMappingCurveDay = 2.0;
  93.  
  94. float   ToneMappingCurveNight = 2.0;
  95.  
  96. float   ToneMappingCurveInterior = 1.8;
  97.  
  98. float   ToneMappingOversaturationDay = 40.0;
  99.  
  100. float   ToneMappingOversaturationNight = 12.0;
  101.  
  102. float   ToneMappingOversaturationInterior = 20.0;
  103.  
  104. //End
  105.  
  106. //begin NLA Brightness
  107.  
  108. float   BrightnessDay = 0.22;
  109.  
  110. float   BrightnessNight = 0.15;
  111.  
  112. float   BrightnessInterior = 0.22;
  113.  
  114. float   BrightnessCurveDay = 1.05;
  115.  
  116. float   BrightnessCurveNight = 1.28;
  117.  
  118. float   BrightnessCurveInterior = 0.98;
  119.  
  120. float   BrightnessMultiplierDay = 0.9;
  121.  
  122. float   BrightnessMultiplierNight = 0.9;
  123.  
  124. float   BrightnessMultiplierInterior = 0.15;
  125.  
  126. float   BrightnessToneMappingCurveDay = 0.7;
  127.  
  128. float   BrightnessToneMappingCurveNight = 0.5;
  129.  
  130. float   BrightnessToneMappingCurveInterior = 0.15;
  131.  
  132. //end NLA Brightness
  133.  
  134.  
  135.  
  136. //+++++++++++++++++++++++++++++
  137. //external parameters, do not modify
  138. //+++++++++++++++++++++++++++++
  139. //keyboard controlled temporary variables (in some versions exists in the config file). Press and hold key 1,2,3...8 together with PageUp or PageDown to modify. By default all set to 1.0
  140. float4  tempF1; //0,1,2,3
  141. float4  tempF2; //5,6,7,8
  142. float4  tempF3; //9,0
  143. //x=generic timer in range 0..1, period of 16777216 ms (4.6 hours), w=frame time elapsed (in seconds)
  144. float4  Timer;
  145. //x=Width, y=1/Width, z=ScreenScaleY, w=1/ScreenScaleY
  146. float4  ScreenSize;
  147. //changes in range 0..1, 0 means that night time, 1 - day time
  148. float   ENightDayFactor;
  149. //changes 0 or 1. 0 means that exterior, 1 - interior
  150. float   EInteriorFactor;
  151. //enb version of bloom applied, ignored if original post processing used
  152. float   EBloomAmount;
  153.  
  154.  
  155.  
  156. texture2D texs0;//color oblivion
  157. texture2D texs1;//bloom oblivion
  158. texture2D texs2;//adaptaion oblivion
  159. texture2D texs3;//bloom enb
  160. texture2D texs4;//adaptation enb
  161. texture2D texs7;//palette enb
  162.  
  163. sampler2D _s0 = sampler_state
  164. {
  165.     Texture   = <texs0>;
  166.     MinFilter = POINT;//
  167.     MagFilter = POINT;//
  168.     MipFilter = NONE;//LINEAR;
  169.     AddressU  = Clamp;
  170.     AddressV  = Clamp;
  171.     SRGBTexture=FALSE;
  172.     MaxMipLevel=0;
  173.     MipMapLodBias=0;
  174. };
  175.  
  176. sampler2D _s1 = sampler_state
  177. {
  178.     Texture   = <texs1>;
  179.     MinFilter = LINEAR;//
  180.     MagFilter = LINEAR;//
  181.     MipFilter = NONE;//LINEAR;
  182.     AddressU  = Clamp;
  183.     AddressV  = Clamp;
  184.     SRGBTexture=FALSE;
  185.     MaxMipLevel=0;
  186.     MipMapLodBias=0;
  187. };
  188.  
  189. sampler2D _s2 = sampler_state
  190. {
  191.     Texture   = <texs2>;
  192.     MinFilter = LINEAR;//
  193.     MagFilter = LINEAR;//
  194.     MipFilter = NONE;//LINEAR;
  195.     AddressU  = Clamp;
  196.     AddressV  = Clamp;
  197.     SRGBTexture=FALSE;
  198.     MaxMipLevel=0;
  199.     MipMapLodBias=0;
  200. };
  201.  
  202. sampler2D _s3 = sampler_state
  203. {
  204.     Texture   = <texs3>;
  205.     MinFilter = LINEAR;//
  206.     MagFilter = LINEAR;//
  207.     MipFilter = NONE;//LINEAR;
  208.     AddressU  = Clamp;
  209.     AddressV  = Clamp;
  210.     SRGBTexture=FALSE;
  211.     MaxMipLevel=0;
  212.     MipMapLodBias=0;
  213. };
  214.  
  215. sampler2D _s4 = sampler_state
  216. {
  217.     Texture   = <texs4>;
  218.     MinFilter = LINEAR;//
  219.     MagFilter = LINEAR;//
  220.     MipFilter = NONE;//LINEAR;
  221.     AddressU  = Clamp;
  222.     AddressV  = Clamp;
  223.     SRGBTexture=FALSE;
  224.     MaxMipLevel=0;
  225.     MipMapLodBias=0;
  226. };
  227.  
  228. sampler2D _s7 = sampler_state
  229. {
  230.     Texture   = <texs7>;
  231.     MinFilter = LINEAR;
  232.     MagFilter = LINEAR;
  233.     MipFilter = NONE;
  234.     AddressU  = Clamp;
  235.     AddressV  = Clamp;
  236.     SRGBTexture=FALSE;
  237.     MaxMipLevel=0;
  238.     MipMapLodBias=0;
  239. };
  240.  
  241. struct VS_OUTPUT_POST
  242. {
  243.     float4 vpos  : POSITION;
  244.     float2 txcoord0 : TEXCOORD0;
  245. };
  246. struct VS_INPUT_POST
  247. {
  248.     float3 pos  : POSITION;
  249.     float2 txcoord0 : TEXCOORD0;
  250. };
  251.  
  252.  
  253.  
  254. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  255. //
  256. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  257. VS_OUTPUT_POST VS_Quad(VS_INPUT_POST IN)
  258. {
  259.     VS_OUTPUT_POST OUT;
  260.  
  261.     OUT.vpos=float4(IN.pos.x,IN.pos.y,IN.pos.z,1.0);
  262.  
  263.     OUT.txcoord0.xy=IN.txcoord0.xy;
  264.  
  265.     return OUT;
  266. }
  267.  
  268.  
  269.  
  270. //oblivion shader specific externals, do not modify
  271. float4  _c1 : register(c1);
  272.  
  273. float4 PS_B8104A59(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
  274. {
  275.     float4 _oC0=0.0; //output
  276.  
  277.     float4 r0;
  278.     float4 r1;
  279.     float4 r2;
  280.     float4 r3;
  281.     float4 r4;
  282.     float4 r5;
  283.     float4 r6;
  284.     float4 r7;
  285.     float4 r8;
  286.     float4 r9;
  287.     float4 r10;
  288.     float4 r11;
  289.  
  290.  
  291.     float4 _v0=0.0;
  292.  
  293.     _v0.xy=IN.txcoord0.xy;
  294.     r1=tex2D(_s0, _v0.xy); //color
  295.  
  296.     //apply bloom
  297.     float4  xcolorbloom=tex2D(_s3, _v0.xy);
  298.  
  299.     xcolorbloom.xyz=xcolorbloom-r1;
  300.     xcolorbloom.xyz=max(xcolorbloom, 0.0);
  301.     r1.xyz+=xcolorbloom*EBloomAmount;
  302.  
  303.     r11=r1; //my bypass
  304.     _oC0.xyz=r1.xyz; //for future use without game color corrections
  305.  
  306.  
  307. #ifdef APPLYGAMECOLORCORRECTION
  308.     //apply original
  309. //   HDRParam     c1       1
  310. //   Src0         s0       1
  311. //   DestBlend    s1       1
  312. //   AvgLum       s2       1
  313. //s1 - bloom
  314. //s0 - color
  315.     r2=tex2D(_s2, IN.txcoord0.xy);
  316.     r1=tex2D(_s1, IN.txcoord0.xy);
  317.     r0=tex2D(_s0, IN.txcoord0.xy);
  318.     r2.x=dot(r2.xyz, 1.0);
  319.     r0.w=max(r2.x, _c1.x);
  320.     r0.w=1.0/r0.w;
  321.     r1.w=r0.w * 0.5;
  322.     r2.xyz=r1.xyz * r1.w;
  323.     r0.w=r0.w * _c1.x;
  324.     r1.xyz=max(r2.xyz, 0.0);
  325.     r0.xyz=r0.w * r0.xyz + r1.xyz;
  326.     r0.w=1.0;
  327.     _oC0=r0;
  328.  
  329. #endif //APPLYGAMECOLORCORRECTION
  330.  
  331.  
  332.  
  333.     float4 color=_oC0;
  334.  
  335.  
  336.     //adaptation in time
  337.     float4  Adaptation=tex2D(_s4, 0.5);
  338.     float   grayadaptation=max(max(Adaptation.x, Adaptation.y), Adaptation.z);
  339.    
  340.    
  341.         //begin Paste01
  342.     float fGamma = lerp(GammaNight, GammaDay, ENightDayFactor);
  343.     fGamma = lerp(fGamma, GammaInterior, EInteriorFactor);
  344.    
  345.     float DesatR = lerp(DesatRNight, DesatRDay, ENightDayFactor);
  346.     DesatR = lerp(DesatR, DesatRInterior, EInteriorFactor);
  347.    
  348.     float DesatG = lerp(DesatGNight, DesatGDay, ENightDayFactor);
  349.     DesatG = lerp(DesatG, DesatGInterior, EInteriorFactor);
  350.    
  351.     float DesatB = lerp(DesatBNight, DesatBDay, ENightDayFactor);
  352.     DesatB = lerp(DesatB, DesatBInterior, EInteriorFactor);
  353.    
  354.    
  355.     float AdaptationMin = lerp(AdaptationMinNight, AdaptationMinDay, ENightDayFactor);
  356.     AdaptationMin = lerp(AdaptationMin, AdaptationMinInterior, EInteriorFactor);
  357.    
  358.     float AdaptationMax = lerp(AdaptationMaxNight, AdaptationMaxDay, ENightDayFactor);
  359.     AdaptationMax = lerp(AdaptationMax, AdaptationMaxInterior, EInteriorFactor);
  360.    
  361.    
  362.     float Saturation = lerp(SaturationNight, SaturationDay, ENightDayFactor);
  363.     Saturation = lerp(Saturation, SaturationInterior, EInteriorFactor);
  364.    
  365.    
  366.     float ToneMappingCurve = lerp(ToneMappingCurveNight, ToneMappingCurveDay, ENightDayFactor);
  367.     ToneMappingCurve = lerp(ToneMappingCurve, ToneMappingCurveInterior, EInteriorFactor);
  368.    
  369.     float ToneMappingOversaturation = lerp(ToneMappingOversaturationNight, ToneMappingOversaturationDay, ENightDayFactor);
  370.     ToneMappingOversaturation = lerp(ToneMappingOversaturation, ToneMappingOversaturationInterior, EInteriorFactor);
  371.    
  372.    
  373.     float IntensityContrast = lerp(IntensityContrastNight, IntensityContrastDay, ENightDayFactor);
  374.     IntensityContrast = lerp(IntensityContrast, IntensityContrastInterior, EInteriorFactor);
  375.    
  376.    
  377.     float Brightness = lerp(BrightnessNight, BrightnessDay, ENightDayFactor);
  378.     Brightness = lerp(Brightness, BrightnessInterior, EInteriorFactor);
  379.    
  380.     float BrightnessCurve = lerp(BrightnessCurveNight, BrightnessCurveDay, ENightDayFactor);
  381.     BrightnessCurve=lerp(BrightnessCurve, BrightnessCurveInterior, EInteriorFactor);
  382.    
  383.     float BrightnessMultiplier = lerp(BrightnessMultiplierNight, BrightnessMultiplierDay, ENightDayFactor);
  384.     BrightnessMultiplier = lerp(BrightnessMultiplier, BrightnessMultiplierInterior, EInteriorFactor);
  385.    
  386.     float BrightnessToneMappingCurve = lerp(BrightnessToneMappingCurveNight, BrightnessToneMappingCurveDay, ENightDayFactor);
  387.     BrightnessToneMappingCurve = lerp(BrightnessToneMappingCurve, BrightnessToneMappingCurveInterior, EInteriorFactor);
  388.    
  389.    
  390.     float greyscale = dot(color.xyz, float3(0.3, 0.59, 0.11));
  391.     color.r = lerp(greyscale, color.r, DesatR);
  392.     color.g = lerp(greyscale, color.g, DesatG);
  393.     color.b = lerp(greyscale, color.b, DesatB);
  394.  
  395.    
  396.     color.xyz = pow(color, fGamma);
  397.    
  398.    
  399.     //end Paste01
  400.  
  401.  
  402.  
  403. #if (POSTPROCESS==3)
  404.  
  405.     grayadaptation = max(grayadaptation, 0.0);
  406.     grayadaptation = min(grayadaptation, 50.0);
  407.     color.xyz = color.xyz / (grayadaptation * AdaptationMax + AdaptationMin);//*tempF1.x
  408.    
  409.    
  410.     //begin Paste02
  411.  
  412.     color.xyz *= Brightness;
  413.     color.xyz += 0.000001;
  414.     float3 xncol = normalize(color.xyz);
  415.     float3 scl = color.xyz / xncol.xyz;
  416.     scl = pow(scl, IntensityContrast);
  417.     xncol.xyz = pow(xncol.xyz, Saturation);
  418.     color.xyz = scl * xncol.xyz;
  419.    
  420.     float lumamax = ToneMappingOversaturation;
  421.     color.xyz = (color.xyz * (1.0 + color.xyz / lumamax)) / (color.xyz + ToneMappingCurve);
  422.    
  423.     float Y = dot(color.xyz, float3(0.299, 0.587, 0.114)); //0.299 * R + 0.587 * G + 0.114 * B;
  424.     float U = dot(color.xyz, float3(-0.14713, -0.28886, 0.436)); //-0.14713 * R - 0.28886 * G + 0.436 * B;
  425.     float V = dot(color.xyz, float3(0.615, -0.51499, -0.10001)); //0.615 * R - 0.51499 * G - 0.10001 * B;  
  426.    
  427.     Y = pow(Y, BrightnessCurve);
  428.     Y = Y * BrightnessMultiplier;
  429.     Y = Y / (Y + BrightnessToneMappingCurve);
  430.     float desaturatefact = saturate(Y * Y * Y *1.7);
  431.     U = lerp(U, 0.0, desaturatefact);
  432.     V = lerp(V, 0.0, desaturatefact);
  433.     color.xyz = V * float3(1.13983, -0.58060, 0.0) + U * float3(0.0, -0.39465, 2.03211) + Y;
  434.     //end Paste02
  435.    
  436.    
  437.     lumamax = EToneMappingOversaturationV3;
  438.     color.xyz = (color.xyz * (1.0 + color.xyz / lumamax)) / (color.xyz + EToneMappingCurveV3);
  439.  
  440. #endif
  441.  
  442. //color.xyz=tex2D(_s0, _v0.xy) + xcolorbloom.xyz*float3(0.7, 0.6, 1.0)*0.5;
  443. //color.xyz=tex2D(_s0, _v0.xy) + xcolorbloom.xyz*float3(0.7, 0.6, 1.0)*0.5;
  444. //color.xyz*=0.7;
  445.  
  446.  
  447.  
  448.     //pallete texture (0.082+ version feature)
  449. #ifdef E_CC_PALETTE
  450.  
  451.     //begin Paste03
  452.    
  453.     float fPalette = lerp(PaletteNight, PaletteDay, ENightDayFactor);
  454.     fPalette = lerp(fPalette, PaletteInterior, EInteriorFactor);
  455.    
  456.     float PaletteBrightness = lerp(PaletteBrightnessNight, PaletteBrightnessDay, ENightDayFactor);
  457.     PaletteBrightness = lerp(PaletteBrightness, PaletteBrightnessInterior, EInteriorFactor);
  458.    
  459.     color.rgb = saturate(color.rgb);
  460.     float3 brightness = Adaptation.xyz;//tex2D(_s4, 0.5);//adaptation luminance
  461.     brightness = (brightness / (brightness + PaletteBrightness));//new version
  462.    
  463.     brightness = max(brightness.x, max(brightness.y, brightness.z));//new version
  464.     float3  palette;
  465.     float4  uvsrc=0.0;
  466.     uvsrc.y = brightness.r;
  467.     uvsrc.x = color.r;
  468.     palette.r = tex2Dlod(_s7, uvsrc).r;
  469.     uvsrc.x = color.g;
  470.     uvsrc.y = brightness.g;
  471.     palette.g = tex2Dlod(_s7, uvsrc).g;
  472.     uvsrc.x = color.b;
  473.     uvsrc.y = brightness.b;
  474.     palette.b = tex2Dlod(_s7, uvsrc).b;
  475.    
  476.     color.rgb = palette.rgb * fPalette;
  477.     //end Paste03
  478. #endif //E_CC_PALETTE
  479.  
  480.  
  481.     _oC0.w=1.0;
  482.     _oC0.xyz=color.xyz;
  483.     return _oC0;
  484. }
  485.  
  486.  
  487.  
  488. //switch between vanilla and mine post processing
  489. #ifndef ENB_FLIPTECHNIQUE
  490. technique Shader_B8104A59
  491. #else
  492. technique Shader_ORIGINALPOSTPROCESS
  493. #endif
  494. {
  495.     pass p0
  496.     {
  497.         VertexShader  = compile vs_3_0 VS_Quad();
  498.         PixelShader  = compile ps_3_0 PS_B8104A59();
  499.  
  500.         ColorWriteEnable=ALPHA|RED|GREEN|BLUE;
  501.         ZEnable=FALSE;
  502.         ZWriteEnable=FALSE;
  503.         CullMode=NONE;
  504.         AlphaTestEnable=FALSE;
  505.         AlphaBlendEnable=FALSE;
  506.         SRGBWRITEENABLE=FALSE;
  507.     }
  508. }
  509.  
  510.  
  511.  
  512. //original shader of post processing
  513. #ifndef ENB_FLIPTECHNIQUE
  514. technique Shader_ORIGINALPOSTPROCESS
  515. #else
  516. technique Shader_B8104A59
  517. #endif
  518. {
  519.     pass p0
  520.     {
  521.         //VertexShader  = compile vs_3_0 VS_Quad();
  522.         VertexShader=
  523.     asm
  524.     {
  525. //   float4 texRatio0;
  526. //   float4 texRatio1;
  527. //
  528. //
  529. // Registers:
  530. //
  531. //   Name         Reg   Size
  532. //   ------------ ----- ----
  533. //   texRatio0    c6       1
  534. //   texRatio1    c7       1
  535.  
  536.     vs_1_1
  537.     dcl_position v0
  538.     dcl_texcoord v1
  539. //    mad oT0.xy, v1, c6, c6.zwzw
  540. //    mad oT1.xy, v1, c7, c7.zwzw
  541.     mov oT0.xy, v1
  542.     mov oT1.xy, v1
  543.     mov oPos, v0
  544.     };
  545.         PixelShader=
  546.     asm
  547.     {
  548. //   sampler2D AvgLum;
  549. //   sampler2D DestBlend;
  550. //   float4 HDRParam;
  551. //   sampler2D Src0;
  552. //
  553. //
  554. // Registers:
  555. //
  556. //   Name         Reg   Size
  557. //   ------------ ----- ----
  558. //   HDRParam     c1       1
  559. //   Src0         s0       1
  560. //   DestBlend    s1       1
  561. //   AvgLum       s2       1
  562. //s0 - bloom
  563. //s1 - color
  564.     ps_2_x
  565.     def c0, 1, 0.5, 0, 0
  566.     dcl t0.xy
  567.     dcl t1.xy
  568.     dcl_2d s0
  569.     dcl_2d s1
  570.     dcl_2d s2
  571.     texld r2, t0, s2
  572.     texld r1, t0, s0
  573.     texld r0, t1, s1
  574.     dp3 r2.x, r2, c0.x
  575.     max r0.w, r2.x, c1.x
  576.     rcp r0.w, r0.w
  577.     mul r1.w, r0.w, c0.y
  578.     mul r2.xyz, r1, r1.w
  579.     mul r0.w, r0.w, c1.x
  580.     max r1.xyz, r2, c0.z
  581.     mad r0.xyz, r0.w, r0, r1
  582.     mov r0.w, c0.x
  583.     mov oC0, r0
  584.     };
  585.         ColorWriteEnable=ALPHA|RED|GREEN|BLUE;
  586.         ZEnable=FALSE;
  587.         ZWriteEnable=FALSE;
  588.         CullMode=NONE;
  589.         AlphaTestEnable=FALSE;
  590.         AlphaBlendEnable=FALSE;
  591.         SRGBWRITEENABLE=FALSE;
  592.     }
  593. }
RAW Paste Data
Top