Advertisement
Guest User

Untitled

a guest
Oct 25th, 2017
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.35 KB | None | 0 0
  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. GammaDay = tempF1.x;
  341. GammaNight = tempF1.y;
  342. AdaptionMinDay = tempF1.z;
  343. AdaptionMinNight = tempF1.w;
  344. SaturationDay = tempF2.x;
  345. SaturationNight = tempF2.y;
  346. ToneMappingCurveDay = tempF2.z;
  347. ToneMappingCurveNight = tempF2.w;
  348. ToneMappingOversaturationDay = tempF3.x;
  349. ToneMappingOversaturationNight = tempF3.y;
  350.  
  351. //begin Paste01
  352. float fGamma = lerp(GammaNight, GammaDay, ENightDayFactor);
  353. fGamma = lerp(fGamma, GammaInterior, EInteriorFactor);
  354.  
  355. float DesatR = lerp(DesatRNight, DesatRDay, ENightDayFactor);
  356. DesatR = lerp(DesatR, DesatRInterior, EInteriorFactor);
  357.  
  358. float DesatG = lerp(DesatGNight, DesatGDay, ENightDayFactor);
  359. DesatG = lerp(DesatG, DesatGInterior, EInteriorFactor);
  360.  
  361. float DesatB = lerp(DesatBNight, DesatBDay, ENightDayFactor);
  362. DesatB = lerp(DesatB, DesatBInterior, EInteriorFactor);
  363.  
  364.  
  365. float AdaptationMin = lerp(AdaptationMinNight, AdaptationMinDay, ENightDayFactor);
  366. AdaptationMin = lerp(AdaptationMin, AdaptationMinInterior, EInteriorFactor);
  367.  
  368. float AdaptationMax = lerp(AdaptationMaxNight, AdaptationMaxDay, ENightDayFactor);
  369. AdaptationMax = lerp(AdaptationMax, AdaptationMaxInterior, EInteriorFactor);
  370.  
  371.  
  372. float Saturation = lerp(SaturationNight, SaturationDay, ENightDayFactor);
  373. Saturation = lerp(Saturation, SaturationInterior, EInteriorFactor);
  374.  
  375.  
  376. float ToneMappingCurve = lerp(ToneMappingCurveNight, ToneMappingCurveDay, ENightDayFactor);
  377. ToneMappingCurve = lerp(ToneMappingCurve, ToneMappingCurveInterior, EInteriorFactor);
  378.  
  379. float ToneMappingOversaturation = lerp(ToneMappingOversaturationNight, ToneMappingOversaturationDay, ENightDayFactor);
  380. ToneMappingOversaturation = lerp(ToneMappingOversaturation, ToneMappingOversaturationInterior, EInteriorFactor);
  381.  
  382.  
  383. float IntensityContrast = lerp(IntensityContrastNight, IntensityContrastDay, ENightDayFactor);
  384. IntensityContrast = lerp(IntensityContrast, IntensityContrastInterior, EInteriorFactor);
  385.  
  386.  
  387. float Brightness = lerp(BrightnessNight, BrightnessDay, ENightDayFactor);
  388. Brightness = lerp(Brightness, BrightnessInterior, EInteriorFactor);
  389.  
  390. float BrightnessCurve = lerp(BrightnessCurveNight, BrightnessCurveDay, ENightDayFactor);
  391. BrightnessCurve=lerp(BrightnessCurve, BrightnessCurveInterior, EInteriorFactor);
  392.  
  393. float BrightnessMultiplier = lerp(BrightnessMultiplierNight, BrightnessMultiplierDay, ENightDayFactor);
  394. BrightnessMultiplier = lerp(BrightnessMultiplier, BrightnessMultiplierInterior, EInteriorFactor);
  395.  
  396. float BrightnessToneMappingCurve = lerp(BrightnessToneMappingCurveNight, BrightnessToneMappingCurveDay, ENightDayFactor);
  397. BrightnessToneMappingCurve = lerp(BrightnessToneMappingCurve, BrightnessToneMappingCurveInterior, EInteriorFactor);
  398.  
  399.  
  400. float greyscale = dot(color.xyz, float3(0.3, 0.59, 0.11));
  401. color.r = lerp(greyscale, color.r, DesatR);
  402. color.g = lerp(greyscale, color.g, DesatG);
  403. color.b = lerp(greyscale, color.b, DesatB);
  404.  
  405.  
  406. color.xyz = pow(color, fGamma);
  407.  
  408.  
  409. //end Paste01
  410.  
  411.  
  412.  
  413. #if (POSTPROCESS==3)
  414.  
  415. grayadaptation = max(grayadaptation, 0.0);
  416. grayadaptation = min(grayadaptation, 50.0);
  417. color.xyz = color.xyz / (grayadaptation * AdaptationMax + AdaptationMin);//*tempF1.x
  418.  
  419.  
  420. //begin Paste02
  421.  
  422. color.xyz *= Brightness;
  423. color.xyz += 0.000001;
  424. float3 xncol = normalize(color.xyz);
  425. float3 scl = color.xyz / xncol.xyz;
  426. scl = pow(scl, IntensityContrast);
  427. xncol.xyz = pow(xncol.xyz, Saturation);
  428. color.xyz = scl * xncol.xyz;
  429.  
  430. float lumamax = ToneMappingOversaturation;
  431. color.xyz = (color.xyz * (1.0 + color.xyz / lumamax)) / (color.xyz + ToneMappingCurve);
  432.  
  433. float Y = dot(color.xyz, float3(0.299, 0.587, 0.114)); //0.299 * R + 0.587 * G + 0.114 * B;
  434. float U = dot(color.xyz, float3(-0.14713, -0.28886, 0.436)); //-0.14713 * R - 0.28886 * G + 0.436 * B;
  435. float V = dot(color.xyz, float3(0.615, -0.51499, -0.10001)); //0.615 * R - 0.51499 * G - 0.10001 * B;
  436.  
  437. Y = pow(Y, BrightnessCurve);
  438. Y = Y * BrightnessMultiplier;
  439. Y = Y / (Y + BrightnessToneMappingCurve);
  440. float desaturatefact = saturate(Y * Y * Y *1.7);
  441. U = lerp(U, 0.0, desaturatefact);
  442. V = lerp(V, 0.0, desaturatefact);
  443. color.xyz = V * float3(1.13983, -0.58060, 0.0) + U * float3(0.0, -0.39465, 2.03211) + Y;
  444. //end Paste02
  445.  
  446.  
  447. lumamax = EToneMappingOversaturationV3;
  448. color.xyz = (color.xyz * (1.0 + color.xyz / lumamax)) / (color.xyz + EToneMappingCurveV3);
  449.  
  450. #endif
  451.  
  452. //color.xyz=tex2D(_s0, _v0.xy) + xcolorbloom.xyz*float3(0.7, 0.6, 1.0)*0.5;
  453. //color.xyz=tex2D(_s0, _v0.xy) + xcolorbloom.xyz*float3(0.7, 0.6, 1.0)*0.5;
  454. //color.xyz*=0.7;
  455.  
  456.  
  457.  
  458. //pallete texture (0.082+ version feature)
  459. #ifdef E_CC_PALETTE
  460.  
  461. //begin Paste03
  462.  
  463. float fPalette = lerp(PaletteNight, PaletteDay, ENightDayFactor);
  464. fPalette = lerp(fPalette, PaletteInterior, EInteriorFactor);
  465.  
  466. float PaletteBrightness = lerp(PaletteBrightnessNight, PaletteBrightnessDay, ENightDayFactor);
  467. PaletteBrightness = lerp(PaletteBrightness, PaletteBrightnessInterior, EInteriorFactor);
  468.  
  469. color.rgb = saturate(color.rgb);
  470. float3 brightness = Adaptation.xyz;//tex2D(_s4, 0.5);//adaptation luminance
  471. brightness = (brightness / (brightness + PaletteBrightness));//new version
  472.  
  473. brightness = max(brightness.x, max(brightness.y, brightness.z));//new version
  474. float3 palette;
  475. float4 uvsrc=0.0;
  476. uvsrc.y = brightness.r;
  477. uvsrc.x = color.r;
  478. palette.r = tex2Dlod(_s7, uvsrc).r;
  479. uvsrc.x = color.g;
  480. uvsrc.y = brightness.g;
  481. palette.g = tex2Dlod(_s7, uvsrc).g;
  482. uvsrc.x = color.b;
  483. uvsrc.y = brightness.b;
  484. palette.b = tex2Dlod(_s7, uvsrc).b;
  485.  
  486. color.rgb = palette.rgb * fPalette;
  487. //end Paste03
  488. #endif //E_CC_PALETTE
  489.  
  490.  
  491. _oC0.w=1.0;
  492. _oC0.xyz=color.xyz;
  493. return _oC0;
  494. }
  495.  
  496.  
  497.  
  498. //switch between vanilla and mine post processing
  499. #ifndef ENB_FLIPTECHNIQUE
  500. technique Shader_B8104A59
  501. #else
  502. technique Shader_ORIGINALPOSTPROCESS
  503. #endif
  504. {
  505. pass p0
  506. {
  507. VertexShader = compile vs_3_0 VS_Quad();
  508. PixelShader = compile ps_3_0 PS_B8104A59();
  509.  
  510. ColorWriteEnable=ALPHA|RED|GREEN|BLUE;
  511. ZEnable=FALSE;
  512. ZWriteEnable=FALSE;
  513. CullMode=NONE;
  514. AlphaTestEnable=FALSE;
  515. AlphaBlendEnable=FALSE;
  516. SRGBWRITEENABLE=FALSE;
  517. }
  518. }
  519.  
  520.  
  521.  
  522. //original shader of post processing
  523. #ifndef ENB_FLIPTECHNIQUE
  524. technique Shader_ORIGINALPOSTPROCESS
  525. #else
  526. technique Shader_B8104A59
  527. #endif
  528. {
  529. pass p0
  530. {
  531. //VertexShader = compile vs_3_0 VS_Quad();
  532. VertexShader=
  533. asm
  534. {
  535. // float4 texRatio0;
  536. // float4 texRatio1;
  537. //
  538. //
  539. // Registers:
  540. //
  541. // Name Reg Size
  542. // ------------ ----- ----
  543. // texRatio0 c6 1
  544. // texRatio1 c7 1
  545.  
  546. vs_1_1
  547. dcl_position v0
  548. dcl_texcoord v1
  549. // mad oT0.xy, v1, c6, c6.zwzw
  550. // mad oT1.xy, v1, c7, c7.zwzw
  551. mov oT0.xy, v1
  552. mov oT1.xy, v1
  553. mov oPos, v0
  554. };
  555. PixelShader=
  556. asm
  557. {
  558. // sampler2D AvgLum;
  559. // sampler2D DestBlend;
  560. // float4 HDRParam;
  561. // sampler2D Src0;
  562. //
  563. //
  564. // Registers:
  565. //
  566. // Name Reg Size
  567. // ------------ ----- ----
  568. // HDRParam c1 1
  569. // Src0 s0 1
  570. // DestBlend s1 1
  571. // AvgLum s2 1
  572. //s0 - bloom
  573. //s1 - color
  574. ps_2_x
  575. def c0, 1, 0.5, 0, 0
  576. dcl t0.xy
  577. dcl t1.xy
  578. dcl_2d s0
  579. dcl_2d s1
  580. dcl_2d s2
  581. texld r2, t0, s2
  582. texld r1, t0, s0
  583. texld r0, t1, s1
  584. dp3 r2.x, r2, c0.x
  585. max r0.w, r2.x, c1.x
  586. rcp r0.w, r0.w
  587. mul r1.w, r0.w, c0.y
  588. mul r2.xyz, r1, r1.w
  589. mul r0.w, r0.w, c1.x
  590. max r1.xyz, r2, c0.z
  591. mad r0.xyz, r0.w, r0, r1
  592. mov r0.w, c0.x
  593. mov oC0, r0
  594. };
  595. ColorWriteEnable=ALPHA|RED|GREEN|BLUE;
  596. ZEnable=FALSE;
  597. ZWriteEnable=FALSE;
  598. CullMode=NONE;
  599. AlphaTestEnable=FALSE;
  600. AlphaBlendEnable=FALSE;
  601. SRGBWRITEENABLE=FALSE;
  602. }
  603. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement