Advertisement
Guest User

TEST

a guest
Apr 28th, 2021
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.57 KB | None | 0 0
  1. //++++++++++++++++++++++++++++++++++++++++++++
  2. // ENBSeries effect file
  3. // visit http://enbdev.com for updates
  4. // Copyright (c) 2007-2013 Boris Vorontsov
  5. //++++++++++++++++++++++++++++++++++++++++++++
  6.  
  7.  
  8. // 3D ENABLER TRUE OR FALSE
  9. bool 3dlut <
  10. string UIName="Enable LUT";
  11. string UIWidget="Toggle";
  12. > = true;
  13.  
  14. //post processing mode. Change value (could be 1, 2, 3, 4). Every mode have own internal parameters, look below
  15. #ifndef POSTPROCESS
  16. #define POSTPROCESS 2
  17. #endif
  18.  
  19. //use original game processing first, then mine
  20. //#define APPLYGAMECOLORCORRECTION
  21.  
  22.  
  23.  
  24. //+++++++++++++++++++++++++++++
  25. //internal parameters, can be modified
  26. //+++++++++++++++++++++++++++++
  27. //modify these values to tweak various color processing
  28.  
  29.  
  30. //POSTPROCESS 2
  31. //float EBrightnessV2=2.5;
  32. float EBrightnessV2Day
  33. <
  34. string UIName="Brightness Day";
  35. string UIWidget="Spinner";
  36. float UIMin=0.0;
  37. float UIMax=1.0;
  38. > = {1.0};
  39.  
  40. float EBrightnessV2Night
  41. <
  42. string UIName="Brightness Night";
  43. string UIWidget="Spinner";
  44. float UIMin=0.0;
  45. float UIMax=1.0;
  46. > = {1.0};
  47.  
  48. float EBrightnessV2Interior
  49. <
  50. string UIName="Brightness Interior";
  51. string UIWidget="Spinner";
  52. float UIMin=0.0;
  53. float UIMax=1.0;
  54. > = {1.0};
  55.  
  56. float EAdaptationMinV2Day
  57. <
  58. string UIName="Adaptation Day Min";
  59. string UIWidget="Spinner";
  60. float UIMin=0.0;
  61. float UIMax=1.0;
  62. > = {0.08};
  63.  
  64. float EAdaptationMinV2Night
  65. <
  66. string UIName="Adaptation Night Min";
  67. string UIWidget="Spinner";
  68. float UIMin=0.0;
  69. float UIMax=1.0;
  70. > = {0.08};
  71.  
  72. float EAdaptationMinV2Interior
  73. <
  74. string UIName="Adaptation Interior Min";
  75. string UIWidget="Spinner";
  76. float UIMin=0.0;
  77. float UIMax=1.0;
  78. > = {0.08};
  79.  
  80.  
  81. float EAdaptationMaxV2Day
  82. <
  83. string UIName="Adaptation Day Max";
  84. string UIWidget="Spinner";
  85. float UIMin=0.0;
  86. float UIMax=1.0;
  87. > = {0.13};
  88.  
  89. float EAdaptationMaxV2Night
  90. <
  91. string UIName="Adaptation Night Max";
  92. string UIWidget="Spinner";
  93. float UIMin=0.0;
  94. float UIMax=1.0;
  95. > = {0.13};
  96.  
  97. float EAdaptationMaxV2Interior
  98. <
  99. string UIName="Adaptation Interior Max";
  100. string UIWidget="Spinner";
  101. float UIMin=0.0;
  102. float UIMax=1.0;
  103. > = {0.13};
  104.  
  105. float EToneMappingCurveV2Day
  106. <
  107. string UIName="ToneMapping Curve Day";
  108. string UIWidget="Spinner";
  109. float UIMin=0.0;
  110. float UIMax=100.0;
  111. > = {7.5};
  112.  
  113. float EToneMappingCurveV2Night
  114. <
  115. string UIName="ToneMapping Curve Night";
  116. string UIWidget="Spinner";
  117. float UIMin=0.0;
  118. float UIMax=100.0;
  119. > = {10.0};
  120.  
  121. float EToneMappingCurveV2Interior
  122. <
  123. string UIName="ToneMapping Curve Interior";
  124. string UIWidget="Spinner";
  125. float UIMin=0.0;
  126. float UIMax=100.0;
  127. > = {8.5};
  128.  
  129.  
  130. float EIntensityContrastV2Day
  131. <
  132. string UIName="Contrast Day";
  133. string UIWidget="Spinner";
  134. float UIMin=0.0;
  135. float UIMax=10.0;
  136. > = {1.35};
  137.  
  138. float EIntensityContrastV2Night
  139. <
  140. string UIName="Contrast Night";
  141. string UIWidget="Spinner";
  142. float UIMin=0.0;
  143. float UIMax=10.0;
  144. > = {1.25};
  145.  
  146. float EIntensityContrastV2Interior
  147. <
  148. string UIName="Contrast Interior";
  149. string UIWidget="Spinner";
  150. float UIMin=0.0;
  151. float UIMax=10.0;
  152. > = {1.3};
  153.  
  154. float EColorSaturationV2Day
  155. <
  156. string UIName="Saturation Day";
  157. string UIWidget="Spinner";
  158. float UIMin=0.0;
  159. float UIMax=10.0;
  160. > = {1.25};
  161.  
  162. float EColorSaturationV2Night
  163. <
  164. string UIName="Saturation Night";
  165. string UIWidget="Spinner";
  166. float UIMin=0.0;
  167. float UIMax=10.0;
  168. > = {0.9};
  169.  
  170. float EColorSaturationV2Interior
  171. <
  172. string UIName="Saturation Interior";
  173. string UIWidget="Spinner";
  174. float UIMin=0.0;
  175. float UIMax=10.0;
  176. > = {1.0};
  177.  
  178. float EToneMappingOversaturationV2Day
  179. <
  180. string UIName="Overbright Dampening Day";
  181. string UIWidget="Spinner";
  182. float UIMin=0.0;
  183. float UIMax=100.0;
  184. > = {75.0};
  185.  
  186. float EToneMappingOversaturationV2Night
  187. <
  188. string UIName="Overbright Dampening Night";
  189. string UIWidget="Spinner";
  190. float UIMin=0.0;
  191. float UIMax=100.0;
  192. > = {50.0};
  193.  
  194. float EToneMappingOversaturationV2Interior
  195. <
  196. string UIName="Overbright Dampening Interior";
  197. string UIWidget="Spinner";
  198. float UIMin=0.0;
  199. float UIMax=100.0;
  200. > = {30.0};
  201.  
  202. //parameters for ldr color correction, if enabled
  203. float ECCGamma
  204. <
  205. string UIName="CC: Gamma";
  206. string UIWidget="Spinner";
  207. float UIMin=0.2;//not zero!!!
  208. float UIMax=5.0;
  209. > = {1.0};
  210.  
  211. float ECCInBlack
  212. <
  213. string UIName="CC: In black";
  214. string UIWidget="Spinner";
  215. float UIMin=0.0;
  216. float UIMax=1.0;
  217. > = {0.0};
  218.  
  219. float ECCInWhite
  220. <
  221. string UIName="CC: In white";
  222. string UIWidget="Spinner";
  223. float UIMin=0.0;
  224. float UIMax=1.0;
  225. > = {1.0};
  226.  
  227. float ECCOutBlack
  228. <
  229. string UIName="CC: Out black";
  230. string UIWidget="Spinner";
  231. float UIMin=0.0;
  232. float UIMax=1.0;
  233. > = {0.0};
  234.  
  235. float ECCOutWhite
  236. <
  237. string UIName="CC: Out white";
  238. string UIWidget="Spinner";
  239. float UIMin=0.0;
  240. float UIMax=1.0;
  241. > = {1.0};
  242.  
  243. float ECCBrightness
  244. <
  245. string UIName="CC: Brightness";
  246. string UIWidget="Spinner";
  247. float UIMin=0.0;
  248. float UIMax=10.0;
  249. > = {1.0};
  250.  
  251. float ECCContrastGrayLevel
  252. <
  253. string UIName="CC: Contrast gray level";
  254. string UIWidget="Spinner";
  255. float UIMin=0.01;
  256. float UIMax=0.99;
  257. > = {0.5};
  258.  
  259. float ECCContrast
  260. <
  261. string UIName="CC: Contrast";
  262. string UIWidget="Spinner";
  263. float UIMin=0.0;
  264. float UIMax=10.0;
  265. > = {1.0};
  266.  
  267. float ECCSaturation
  268. <
  269. string UIName="CC: Saturation";
  270. string UIWidget="Spinner";
  271. float UIMin=0.0;
  272. float UIMax=10.0;
  273. > = {1.0};
  274.  
  275. float ECCDesaturateShadows
  276. <
  277. string UIName="CC: Desaturate shadows";
  278. string UIWidget="Spinner";
  279. float UIMin=0.0;
  280. float UIMax=1.0;
  281. > = {0.0};
  282.  
  283. float3 ECCColorBalanceShadows <
  284. string UIName="CC: Color balance shadows";
  285. string UIWidget="Color";
  286. > = {0.5, 0.5, 0.5};
  287.  
  288. float3 ECCColorBalanceHighlights <
  289. string UIName="CC: Color balance highlights";
  290. string UIWidget="Color";
  291. > = {0.5, 0.5, 0.5};
  292.  
  293. float3 ECCChannelMixerR <
  294. string UIName="CC: Channel mixer R";
  295. string UIWidget="Color";
  296. > = {1.0, 0.0, 0.0};
  297.  
  298. float3 ECCChannelMixerG <
  299. string UIName="CC: Channel mixer G";
  300. string UIWidget="Color";
  301. > = {0.0, 1.0, 0.0};
  302.  
  303. float3 ECCChannelMixerB <
  304. string UIName="CC: Channel mixer B";
  305. string UIWidget="Color";
  306. > = {0.0, 0.0, 1.0};
  307.  
  308.  
  309.  
  310. //+++++++++++++++++++++++++++++
  311. //external parameters, do not modify
  312. //+++++++++++++++++++++++++++++
  313. //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
  314. float4 tempF1; //0,1,2,3
  315. float4 tempF2; //5,6,7,8
  316. float4 tempF3; //9,0
  317. //x=generic timer in range 0..1, period of 16777216 ms (4.6 hours), w=frame time elapsed (in seconds)
  318. float4 Timer;
  319. //x=Width, y=1/Width, z=ScreenScaleY, w=1/ScreenScaleY
  320. float4 ScreenSize;
  321. //changes in range 0..1, 0 means that night time, 1 - day time
  322. float ENightDayFactor;
  323. //changes 0 or 1. 0 means that exterior, 1 - interior
  324. float EInteriorFactor;
  325. //enb version of bloom applied, ignored if original post processing used
  326. float EBloomAmount;
  327.  
  328.  
  329. //+++++++++++++++++++++++++++++
  330. // LUT texture helper
  331. //+++++++++++++++++++++++++++++
  332.  
  333.  
  334. #define LOAD_TEXTURE( Name, Path, sampler, UV ) \
  335. texture2D tex##Name <string ResourceName= #Path ; >; \
  336. sampler2D Sampler##Name = sampler_state { \
  337. Texture = < tex##Name >; SRGBTexture=FALSE; \
  338. MinFilter = sampler; MagFilter = sampler; MipFilter = NONE; \
  339. AddressU = UV; AddressV = UV; }
  340.  
  341. LOAD_TEXTURE( LUT, LUT.png, LINEAR, CLAMP );
  342.  
  343.  
  344. //+++++++++++++++++++++++++++++
  345. //
  346. //+++++++++++++++++++++++++++++
  347.  
  348.  
  349. texture2D texs0;//color falloutnv
  350. texture2D texs1;//bloom falloutnv
  351. texture2D texs3;//bloom enb
  352. texture2D texs4;//adaptation enb
  353. texture2D texs7;//palette enb
  354.  
  355. sampler2D _s0 = sampler_state
  356. {
  357. Texture = <texs0>;
  358. MinFilter = POINT;//
  359. MagFilter = POINT;//
  360. MipFilter = NONE;//LINEAR;
  361. AddressU = Clamp;
  362. AddressV = Clamp;
  363. SRGBTexture=FALSE;
  364. MaxMipLevel=0;
  365. MipMapLodBias=0;
  366. };
  367.  
  368. sampler2D _s1 = sampler_state
  369. {
  370. Texture = <texs1>;
  371. MinFilter = LINEAR;//
  372. MagFilter = LINEAR;//
  373. MipFilter = NONE;//LINEAR;
  374. AddressU = Clamp;
  375. AddressV = Clamp;
  376. SRGBTexture=FALSE;
  377. MaxMipLevel=0;
  378. MipMapLodBias=0;
  379. };
  380.  
  381. sampler2D _s3 = sampler_state
  382. {
  383. Texture = <texs3>;
  384. MinFilter = LINEAR;//
  385. MagFilter = LINEAR;//
  386. MipFilter = NONE;//LINEAR;
  387. AddressU = Clamp;
  388. AddressV = Clamp;
  389. SRGBTexture=FALSE;
  390. MaxMipLevel=0;
  391. MipMapLodBias=0;
  392. };
  393.  
  394. sampler2D _s4 = sampler_state
  395. {
  396. Texture = <texs4>;
  397. MinFilter = LINEAR;//
  398. MagFilter = LINEAR;//
  399. MipFilter = NONE;//LINEAR;
  400. AddressU = Clamp;
  401. AddressV = Clamp;
  402. SRGBTexture=FALSE;
  403. MaxMipLevel=0;
  404. MipMapLodBias=0;
  405. };
  406.  
  407. sampler2D _s7 = sampler_state
  408. {
  409. Texture = <texs7>;
  410. MinFilter = LINEAR;
  411. MagFilter = LINEAR;
  412. MipFilter = NONE;
  413. AddressU = Clamp;
  414. AddressV = Clamp;
  415. SRGBTexture=FALSE;
  416. MaxMipLevel=0;
  417. MipMapLodBias=0;
  418. };
  419.  
  420. struct VS_OUTPUT_POST
  421. {
  422. float4 vpos : POSITION;
  423. float2 txcoord0 : TEXCOORD0;
  424. };
  425. struct VS_INPUT_POST
  426. {
  427. float3 pos : POSITION;
  428. float2 txcoord0 : TEXCOORD0;
  429. };
  430.  
  431.  
  432.  
  433. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  434. //
  435. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  436. VS_OUTPUT_POST VS_Quad(VS_INPUT_POST IN)
  437. {
  438. VS_OUTPUT_POST OUT;
  439.  
  440. OUT.vpos=float4(IN.pos.x,IN.pos.y,IN.pos.z,1.0);
  441.  
  442. OUT.txcoord0.xy=IN.txcoord0.xy;
  443.  
  444. return OUT;
  445. }
  446.  
  447.  
  448. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  449. // LUT Function
  450. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  451.  
  452.  
  453. static const float2 CLut_Size = float2(1024.0, 32.0);
  454.  
  455. float3 CLutFunc( float3 colorIN, sampler2D LutSampler ) {
  456. float2 CLut_pSize = 1.0 / CLut_Size;
  457. float4 CLut_UV;
  458. colorIN = saturate(colorIN) * ( CLut_Size.y - 1.0);
  459. CLut_UV.w = floor(colorIN.b);
  460. CLut_UV.xy = (colorIN.rg + 0.5) * CLut_pSize;
  461. CLut_UV.x += CLut_UV.w * CLut_pSize.y;
  462. CLut_UV.z = CLut_UV.x + CLut_pSize.y;
  463. return lerp( tex2Dlod(LutSampler, CLut_UV.xyzz).rgb,
  464. tex2Dlod(LutSampler, CLut_UV.zyzz).rgb, colorIN.b - CLut_UV.w);
  465. }
  466.  
  467. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  468. //
  469. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  470.  
  471.  
  472. //falloutnv shader specific externals, do not modify
  473. float4 _c1 : register(c1);
  474. float4 _c2 : register(c2);
  475. float4 _c19 : register(c19);
  476. float4 _c20 : register(c20);
  477. float4 _c22 : register(c22);
  478.  
  479. float4 PS_C1DAE3F7(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
  480. {
  481. float4 _oC0=0.0; //output
  482.  
  483. float4 r0;
  484. float4 r1;
  485. float4 r2;
  486. float4 r3;
  487. float4 r4;
  488. float4 r5;
  489. float4 r6;
  490. float4 r7;
  491. float4 r8;
  492. float4 r9;
  493. float4 r10;
  494. float4 r11;
  495.  
  496.  
  497. float4 _v0=0.0;
  498.  
  499. _v0.xy=IN.txcoord0.xy;
  500. r1=tex2D(_s0, _v0.xy); //color
  501.  
  502. //apply bloom
  503. float4 xcolorbloom=tex2D(_s3, _v0.xy);
  504.  
  505. xcolorbloom.xyz=xcolorbloom-r1;
  506. xcolorbloom.xyz=max(xcolorbloom, 0.0);
  507. r1.xyz+=xcolorbloom*EBloomAmount;
  508.  
  509. r11=r1; //my bypass
  510. _oC0.xyz=r1.xyz; //for future use without game color corrections
  511.  
  512.  
  513. #ifdef APPLYGAMECOLORCORRECTION
  514. //apply original
  515.  
  516. // float3 BlurScale;
  517. // float4 Cinematic;
  518. // sampler2D DestBlend;
  519. // float4 Fade;
  520. // float4 HDRParam;
  521. // sampler2D Src0;
  522. // float4 Tint;
  523. // Registers:
  524. // Name Reg Size
  525. // ------------ ----- ----
  526. // HDRParam c1 1
  527. // BlurScale c2 1
  528. // Cinematic c19 1
  529. // Tint c20 1
  530. // Fade c22 1
  531. // Src0 s0 1
  532. // DestBlend s1 1
  533. //todo apply uv offsets to coordinates
  534. r0=tex2D(_s0, IN.txcoord0.xy);//r0=tex2D(_s0, IN.txcoord1.xy);
  535. r1=tex2D(_s1, IN.txcoord0.xy);
  536. r0.w=max(r1.w, _c1.x);
  537. r0.w=1.0/r0.w;
  538. r1.w=r0.w * 0.5;
  539. r0.w=r0.w * _c1.x;
  540. r1.xyz=r1 * r1.w;
  541. r2.xyz=max(r1, 0.0);
  542. r0.xyz=r0.w * r0 + r2.xyz;
  543. r0.w=dot(r0.xyz, float3(0.298999995, 0.587000012, 0.114));
  544. r1.xyz=lerp(r0.w, r0, _c19.x);
  545. r0.xyz=_c20 * r0.w - r1;
  546. r0.xyz=_c20.w * r0 + r1;
  547. r0.xyz=_c19.w * r0 - _c19.y;
  548. r0.xyz=_c19.z * r0 + _c19.y;
  549. r1.xyz=lerp(r0, _c22, _c22.w);
  550. r1.w=_c2.z;
  551. _oC0=r1;
  552.  
  553. #endif //APPLYGAMECOLORCORRECTION
  554.  
  555.  
  556.  
  557. float4 color=_oC0;
  558. color.xyz = _c19.w * color.xyz;
  559.  
  560. //adaptation in time
  561. float4 Adaptation=tex2D(_s4, 0.5);
  562. float grayadaptation=max(max(Adaptation.x, Adaptation.y), Adaptation.z);
  563.  
  564. #if (POSTPROCESS==1)
  565.  
  566. grayadaptation=max(grayadaptation, 0.0);
  567. grayadaptation=min(grayadaptation, 50.0);
  568. color.xyz=color.xyz/(grayadaptation*EAdaptationMaxV1+EAdaptationMinV1);//*tempF1.x
  569.  
  570. float cgray=dot(color.xyz, float3(0.27, 0.67, 0.06));
  571. cgray=pow(cgray, EContrastV1);
  572. float3 poweredcolor=pow(color.xyz, EColorSaturationV1);
  573. float newgray=dot(poweredcolor.xyz, float3(0.27, 0.67, 0.06));
  574. color.xyz=poweredcolor.xyz*cgray/(newgray+0.0001);
  575.  
  576. float3 luma=color.xyz;
  577. float lumamax=300.0;
  578. color.xyz=(color.xyz * (1.0 + color.xyz/lumamax))/(color.xyz + EToneMappingCurveV1);
  579.  
  580. #endif
  581.  
  582.  
  583.  
  584. #if (POSTPROCESS==2)
  585.  
  586. float newEAdaptationMax=lerp( lerp(EAdaptationMaxV2Night, EAdaptationMaxV2Day, ENightDayFactor), EAdaptationMaxV2Interior, EInteriorFactor );
  587. float newEAdaptationMin=lerp( lerp(EAdaptationMinV2Night, EAdaptationMinV2Day, ENightDayFactor), EAdaptationMinV2Interior, EInteriorFactor );
  588. float newEBrightnessV2=lerp( lerp(EBrightnessV2Night, EBrightnessV2Day, ENightDayFactor), EBrightnessV2Interior, EInteriorFactor );
  589. float newEToneMappingCurve=lerp( lerp(EToneMappingCurveV2Night, EToneMappingCurveV2Day, ENightDayFactor), EToneMappingCurveV2Interior, EInteriorFactor );
  590. float newEIntensityContrastV2=lerp( lerp(EIntensityContrastV2Night, EIntensityContrastV2Day, ENightDayFactor), EIntensityContrastV2Interior, EInteriorFactor );
  591. float newEColorSaturationV2=lerp( lerp(EColorSaturationV2Night, EColorSaturationV2Day, ENightDayFactor), EColorSaturationV2Interior, EInteriorFactor );
  592. float newEToneMappingOversaturationV2=lerp( lerp(EToneMappingOversaturationV2Night, EToneMappingOversaturationV2Day, ENightDayFactor), EToneMappingOversaturationV2Interior, EInteriorFactor );
  593.  
  594.  
  595. grayadaptation=max(grayadaptation, 0.0);
  596. grayadaptation=min(grayadaptation, 50.0);
  597. color.xyz=color.xyz/(grayadaptation*newEAdaptationMax+newEAdaptationMin);//*tempF1.x
  598.  
  599. color.xyz*=(newEBrightnessV2);
  600. color.xyz+=0.000001;
  601. float3 xncol=normalize(color.xyz);
  602. float3 scl=color.xyz/xncol.xyz;
  603. scl=pow(scl, newEIntensityContrastV2);
  604. xncol.xyz=pow(xncol.xyz, newEColorSaturationV2);
  605. color.xyz=scl*xncol.xyz;
  606.  
  607. float lumamax=newEToneMappingOversaturationV2;
  608. color.xyz=(color.xyz * (1.0 + color.xyz/lumamax))/(color.xyz + newEToneMappingCurve);
  609.  
  610. #endif
  611.  
  612.  
  613. #if (POSTPROCESS==3)
  614.  
  615. grayadaptation=max(grayadaptation, 0.0);
  616. grayadaptation=min(grayadaptation, 50.0);
  617. color.xyz=color.xyz/(grayadaptation*EAdaptationMaxV3+EAdaptationMinV3);//*tempF1.x
  618.  
  619. float lumamax=EToneMappingOversaturationV3;
  620. color.xyz=(color.xyz * (1.0 + color.xyz/lumamax))/(color.xyz + EToneMappingCurveV3);
  621.  
  622. #endif
  623.  
  624. //color.xyz=tex2D(_s0, _v0.xy) + xcolorbloom.xyz*float3(0.7, 0.6, 1.0)*0.5;
  625. //color.xyz=tex2D(_s0, _v0.xy) + xcolorbloom.xyz*float3(0.7, 0.6, 1.0)*0.5;
  626. //color.xyz*=0.7;
  627.  
  628.  
  629. #if (POSTPROCESS==4)
  630.  
  631. grayadaptation=max(grayadaptation, 0.0);
  632. grayadaptation=min(grayadaptation, 50.0);
  633. color.xyz=color.xyz/(grayadaptation*EAdaptationMaxV4+EAdaptationMinV4);
  634.  
  635. float Y = dot(color.xyz, float3(0.299, 0.587, 0.114)); //0.299 * R + 0.587 * G + 0.114 * B;
  636. float U = dot(color.xyz, float3(-0.14713, -0.28886, 0.436)); //-0.14713 * R - 0.28886 * G + 0.436 * B;
  637. float V = dot(color.xyz, float3(0.615, -0.51499, -0.10001)); //0.615 * R - 0.51499 * G - 0.10001 * B;
  638. Y=pow(Y, EBrightnessCurveV4);
  639. Y=Y*EBrightnessMultiplierV4;
  640. // Y=Y/(Y+EBrightnessToneMappingCurveV4);
  641. // float desaturatefact=saturate(Y*Y*Y*1.7);
  642. // U=lerp(U, 0.0, desaturatefact);
  643. // V=lerp(V, 0.0, desaturatefact);
  644. color.xyz=V * float3(1.13983, -0.58060, 0.0) + U * float3(0.0, -0.39465, 2.03211) + Y;
  645.  
  646. color.xyz=max(color.xyz, 0.0);
  647. color.xyz=color.xyz/(color.xyz+EBrightnessToneMappingCurveV4);
  648.  
  649. #endif
  650.  
  651.  
  652.  
  653. //pallete texture (0.082+ version feature)
  654. #ifdef E_CC_PALETTE
  655. color.rgb=saturate(color.rgb);
  656. float3 brightness=Adaptation.xyz;//tex2D(_s4, 0.5);//adaptation luminance
  657. // brightness=saturate(brightness);//old version from ldr games
  658. brightness=(brightness/(brightness+1.0));//new version
  659. brightness=max(brightness.x, max(brightness.y, brightness.z));//new version
  660. float3 palette;
  661. float4 uvsrc=0.0;
  662. uvsrc.y=brightness.r;
  663. uvsrc.x=color.r;
  664. palette.r=tex2Dlod(_s7, uvsrc).r;
  665. uvsrc.x=color.g;
  666. uvsrc.y=brightness.g;
  667. palette.g=tex2Dlod(_s7, uvsrc).g;
  668. uvsrc.x=color.b;
  669. uvsrc.y=brightness.b;
  670. palette.b=tex2Dlod(_s7, uvsrc).b;
  671. color.rgb=palette.rgb;
  672. #endif //E_CC_PALETTE
  673.  
  674.  
  675.  
  676. #ifdef E_CC_PROCEDURAL
  677. float tempgray;
  678. float4 tempvar;
  679. float3 tempcolor;
  680. /*
  681. //these replaced by "levels"
  682. //+++ gamma
  683. if (ECCGamma!=1.0)
  684. color=pow(color, 1.0/ECCGamma);
  685.  
  686. //+++ brightness like in photoshop
  687. color=color+ECCAditiveBrightness;
  688.  
  689. //+++ lightness
  690. tempvar.x=saturate(ELightness);
  691. tempvar.y=saturate(1.0+ECCLightness);
  692. color=tempvar.x*(1.0-color) + (tempvar.y*color);
  693. */
  694. //+++ levels like in photoshop, including gamma, lightness, additive brightness
  695. color=max(color-ECCInBlack, 0.0) / max(ECCInWhite-ECCInBlack, 0.0001);
  696. if (ECCGamma!=1.0) color=pow(color, ECCGamma);
  697. color=color*(ECCOutWhite-ECCOutBlack) + ECCOutBlack;
  698.  
  699. //+++ brightness
  700. color=color*ECCBrightness;
  701.  
  702. //+++ contrast
  703. color=(color-ECCContrastGrayLevel) * ECCContrast + ECCContrastGrayLevel;
  704.  
  705. //+++ saturation
  706. tempgray=dot(color, 0.3333);
  707. color=lerp(tempgray, color, ECCSaturation);
  708.  
  709. //+++ desaturate shadows
  710. tempgray=dot(color, 0.3333);
  711. tempvar.x=saturate(1.0-tempgray);
  712. tempvar.x*=tempvar.x;
  713. tempvar.x*=tempvar.x;
  714. color=lerp(color, tempgray, ECCDesaturateShadows*tempvar.x);
  715.  
  716. //+++ color balance
  717. color=saturate(color);
  718. tempgray=dot(color, 0.3333);
  719. float2 shadow_highlight=float2(1.0-tempgray, tempgray);
  720. shadow_highlight*=shadow_highlight;
  721. color.rgb+=(ECCColorBalanceHighlights*2.0-1.0)*color * shadow_highlight.x;
  722. color.rgb+=(ECCColorBalanceShadows*2.0-1.0)*(1.0-color) * shadow_highlight.y;
  723.  
  724. //+++ channel mixer
  725. tempcolor=color;
  726. color.r=dot(tempcolor, ECCChannelMixerR);
  727. color.g=dot(tempcolor, ECCChannelMixerG);
  728. color.b=dot(tempcolor, ECCChannelMixerB);
  729. #endif //E_CC_PROCEDURAL
  730.  
  731. if(3dlut){
  732. color.xyz = ClutFunc(color.rgb, SamplerLUT);
  733. }
  734. else{
  735. color.xyz = color.xyz;
  736. }
  737.  
  738. _oC0.w=1.0;
  739. _oC0.xyz=color.xyz;
  740. return _oC0;
  741. }
  742.  
  743.  
  744.  
  745. //switch between vanilla and mine post processing
  746. technique Shader_C1DAE3F7 <string UIName="ENBSeries";>
  747. {
  748. pass p0
  749. {
  750. VertexShader = compile vs_3_0 VS_Quad();
  751. PixelShader = compile ps_3_0 PS_C1DAE3F7();
  752.  
  753. ColorWriteEnable=ALPHA|RED|GREEN|BLUE;
  754. ZEnable=FALSE;
  755. ZWriteEnable=FALSE;
  756. CullMode=NONE;
  757. AlphaTestEnable=FALSE;
  758. AlphaBlendEnable=FALSE;
  759. SRGBWRITEENABLE=FALSE;
  760. }
  761. }
  762.  
  763.  
  764.  
  765. //original shader of post processing
  766. technique Shader_ORIGINALPOSTPROCESS <string UIName="Vanilla";>
  767. {
  768. pass p0
  769. {
  770. //VertexShader = compile vs_3_0 VS_Quad();
  771. VertexShader=
  772. asm
  773. {
  774. // Parameters:
  775. // float4 geometryOffset;
  776. // float4 texOffset0;
  777. // float4 texOffset1;
  778. // Registers:
  779. // Name Reg Size
  780. // -------------- ----- ----
  781. // geometryOffset c0 1
  782. // texOffset0 c1 1
  783. // texOffset1 c2 1
  784. //
  785. vs_1_1
  786. def c3, 2, -2, 0, 0
  787. dcl_position v0
  788. dcl_texcoord v1
  789. mov r0.xy, c0
  790. mad oPos.xy, r0, -c3, v0
  791. add oT0.xy, v1, c1
  792. add oT1.xy, v1, c2
  793. mov oPos.zw, v0
  794. };
  795. PixelShader=
  796. asm
  797. {
  798. // Parameters:
  799. // float3 BlurScale;
  800. // float4 Cinematic;
  801. // sampler2D DestBlend;
  802. // float4 Fade;
  803. // float4 HDRParam;
  804. // sampler2D Src0;
  805. // float4 Tint;
  806. // Registers:
  807. // Name Reg Size
  808. // ------------ ----- ----
  809. // HDRParam c1 1
  810. // BlurScale c2 1
  811. // Cinematic c19 1
  812. // Tint c20 1
  813. // Fade c22 1
  814. // Src0 s0 1
  815. // DestBlend s1 1
  816. //
  817. ps_2_x
  818. def c0, 0.5, 0, 0, 0
  819. def c3, 0.298999995, 0.587000012, 0.114, 0
  820. dcl t0.xy
  821. dcl t1.xy
  822. dcl_2d s0
  823. dcl_2d s1
  824. texld r0, t1, s1
  825. texld r1, t0, s0
  826. max r0.w, r1.w, c1.x
  827. rcp r0.w, r0.w
  828. mul r1.w, r0.w, c0.x
  829. mul r0.w, r0.w, c1.x
  830. mul r1.xyz, r1, r1.w
  831. max r2.xyz, r1, c0.y
  832. mad r0.xyz, r0.w, r0, r2
  833. dp3 r0.w, r0, c3
  834. lrp r1.xyz, c19.x, r0, r0.w
  835. mad r0.xyz, r0.w, c20, -r1
  836. mad r0.xyz, c20.w, r0, r1
  837. mad r0.xyz, c19.w, r0, -c19.y
  838. mad r0.xyz, c19.z, r0, c19.y
  839. lrp r1.xyz, c22.w, c22, r0
  840. mov r1.w, c2.z
  841. mov oC0, r1
  842. };
  843. ColorWriteEnable=ALPHA|RED|GREEN|BLUE;
  844. ZEnable=FALSE;
  845. ZWriteEnable=FALSE;
  846. CullMode=NONE;
  847. AlphaTestEnable=FALSE;
  848. AlphaBlendEnable=FALSE;
  849. SRGBWRITEENABLE=FALSE;
  850. }
  851. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement