Advertisement
XShadXow

Untitled

Aug 22nd, 2019
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 66.36 KB | None | 0 0
  1.  
  2. /* VERSION 2.0 */
  3.  
  4. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
  5. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
  6. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
  7. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
  8. // /XXXXXXX\ __ |HHHHHHHHH\ \HH\ /HH/ //
  9. // |XX| |XX| XX |HH| \HHH\ /\ \HH\ /HH/ //
  10. // |XX| |X| /XX\ |HH| \HH\ \/ \HH\ /HH/ //
  11. // \XX\ /XXXX\ |HH| |HH| __ __ __ ___ ___ __ \HHHHH/ //
  12. // \XX\ /XX/\XX\ |HH| |HH| || || /__\ /___\ /___\ __||__ \HHH/ //
  13. // _ \XX\ /XX/ \XX\ |HH| |HH| || ||// \\ // \\ // \\ |== ==| /HHH\ //
  14. // |X| \XX\ /XXXXXXXXXX\ |HH| |HH| || ||/ ||===|| || - || /HHHHH\ //
  15. // \XX\ |XX| /XX/ \XX\ |HH| /HH/ || || || || || /HH/ \HH\ //
  16. // \XX\ /XX/ /XX/ \XX\ ________ |HH| /HHH/ || || \\ _ \\ _ || _ /HH/ \HH\ //
  17. // \XXXXXXX/ /XX/ \XX\|________||HHHHHHHHH/ || || \===// \===// \\=// /HH/ \HH\ //
  18. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
  19.  
  20. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
  21. //++++++++++++++++++++++++++++++++++ ENBSeries effect file ++++++++++++++++++++++++++++++++++//
  22. //++++++++++++++++++++++++++++++++++ SA_DirectX by Maxim Dubinov(Makarus) ++++++++++++++++++++++++++++++++++//
  23. //++++++++++++++++++++++++++++++++++ Visit http://www.facebook.com/sadirectx ++++++++++++++++++++++++++++++++++//
  24. //+++++++++++++++++++++++++ https://www.youtube.com/channel/UCrASy-x5DgwHpYiDv41RL2Q ++++++++++++++++++++++++++//
  25. //++++++++++++++++++++++++++++++++++ Visit http://enbdev.com ++++++++++++++++++++++++++++++++++//
  26. //++++++++++++++++++++++++++++++++++ Copyright (c) 2007-2018 Boris Vorontsov ++++++++++++++++++++++++++++++++++//
  27. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
  28.  
  29. float4 tempF1; float4 tempF2; float4 tempF3;
  30. float4 ScreenSize; float4 Timer;float ENightDayFactor;
  31. float4 SunDirection; float EInteriorFactor; float FadeFactor; float FieldOfView;
  32. float4 MatrixVP[4]; float4 MatrixInverseVP[4]; float4 MatrixVPRotation[4]; float4 MatrixInverseVPRotation[4];
  33. float4 MatrixView[4];float4 MatrixInverseView[4];float4 CameraPosition;float GameTime;float4 CustomShaderConstants1[8];
  34. float4 WeatherAndTime; float4 FogFarColor;
  35.  
  36. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
  37. //Textures
  38. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
  39.  
  40. texture2D texEnv;
  41. texture2D texOriginal;
  42. texture2D texColor;
  43. texture2D texDepth;
  44. texture2D texNoise;
  45. texture2D texShadow;
  46. texture2D texPalette;
  47. texture2D texFocus;
  48. texture2D texCurr;
  49. texture2D texPrev;
  50. texture2D texNormal;
  51. texture2D texStars < string ResourceName="stars.png"; >;
  52. texture2D texRain < string ResourceName="Rain.png"; >;
  53. texture2D texRain2 < string ResourceName="Rain2.png"; >;
  54. texture2D texMoon < string ResourceName="Moon.png"; >;
  55. texture2D texNs < string ResourceName="Noise.png"; >;
  56. texture2D texNs2 < string ResourceName="Noise2.png";>;
  57. texture2D texPd < string ResourceName="NoisePd.png"; >;
  58. texture2D texRipples < string ResourceName="Ripples.png"; >;
  59. texture2D texAlpha < string ResourceName="RipplesAlpha.png"; >;
  60. texture2D texAlpha2 < string ResourceName="RipplesAlpha2.png"; >;
  61. texture2D texwrl < string ResourceName="PuddlesRelief.png"; >;
  62. texture2D texltn < string ResourceName="lightning.png"; >;
  63. texture2D texltn2 < string ResourceName="lightning2.png"; >;
  64. textureCUBE texCube < string ResourceName = "SkyLight.dds"; string ResourceType = "CUBE"; >;
  65.  
  66. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
  67. //Sampler Inputs
  68. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
  69. sampler2D SamplerLightning2 = sampler_state
  70. {
  71. Texture = <texltn2>;
  72. MinFilter = LINEAR;
  73. MagFilter = LINEAR;
  74. MipFilter = LINEAR;
  75. AddressU = Clamp;
  76. AddressV = Clamp;
  77. SRGBTexture=FALSE;
  78. MaxMipLevel=0;
  79. MipMapLodBias=0;
  80. };
  81.  
  82.  
  83. sampler2D SamplerLightning = sampler_state
  84. {
  85. Texture = <texltn>;
  86. MinFilter = LINEAR;
  87. MagFilter = LINEAR;
  88. MipFilter = LINEAR;
  89. AddressU = Clamp;
  90. AddressV = Clamp;
  91. SRGBTexture=FALSE;
  92. MaxMipLevel=0;
  93. MipMapLodBias=0;
  94. };
  95.  
  96. sampler2D SamplerEnv = sampler_state
  97. {
  98. Texture = <texEnv>;
  99. MinFilter = LINEAR;
  100. MagFilter = LINEAR;
  101. MipFilter = LINEAR;
  102. AddressU = Mirror;
  103. AddressV = Mirror;
  104. SRGBTexture=FALSE;
  105. MaxMipLevel=0;
  106. MipMapLodBias=0;
  107. };
  108.  
  109. sampler2D SamplerOriginal = sampler_state
  110. {
  111. Texture = <texOriginal>;
  112. MinFilter = LINEAR;
  113. MagFilter = LINEAR;
  114. MipFilter = LINEAR;//NONE;
  115. AddressU = Clamp;
  116. AddressV = Clamp;
  117. SRGBTexture=FALSE;
  118. MaxMipLevel=0;
  119. MipMapLodBias=0;
  120. };
  121.  
  122. sampler2D SamplerWrl = sampler_state
  123. {
  124. Texture = <texwrl>;
  125. MinFilter = LINEAR;
  126. MagFilter = LINEAR;
  127. MipFilter = LINEAR;
  128. AddressU = Wrap;
  129. AddressV = Wrap;
  130. AddressW = Wrap;
  131. SRGBTexture=TRUE;
  132. MaxMipLevel=1;
  133. MipMapLodBias=0;
  134. };
  135.  
  136. sampler2D SamplerWrp = sampler_state
  137. {
  138. Texture = <texRipples>;
  139. MinFilter = LINEAR;
  140. MagFilter = LINEAR;
  141. MipFilter = LINEAR;
  142. AddressU = Wrap;
  143. AddressV = Wrap;
  144. AddressW = Wrap;
  145. SRGBTexture=TRUE;
  146. MaxMipLevel=1;
  147. MipMapLodBias=0;
  148. };
  149.  
  150. sampler2D SamplerAlpha = sampler_state
  151. {
  152. Texture = <texAlpha>;
  153. MinFilter = LINEAR;
  154. MagFilter = LINEAR;
  155. MipFilter = LINEAR;
  156. AddressU = Wrap;
  157. AddressV = Wrap;
  158. AddressW = Wrap;
  159. SRGBTexture=TRUE;
  160. MaxMipLevel=1;
  161. MipMapLodBias=0;
  162. };
  163.  
  164. sampler2D SamplerAlpha2 = sampler_state
  165. {
  166. Texture = <texAlpha2>;
  167. MinFilter = LINEAR;
  168. MagFilter = LINEAR;
  169. MipFilter = LINEAR;
  170. AddressU = Wrap;
  171. AddressV = Wrap;
  172. AddressW = Wrap;
  173. SRGBTexture=TRUE;
  174. MaxMipLevel=1;
  175. MipMapLodBias=0;
  176. };
  177.  
  178. samplerCUBE SamplerCM = sampler_state
  179. {
  180. Texture = <texCube>;
  181. MinFilter = LINEAR;
  182. MagFilter = LINEAR;
  183. MipFilter = LINEAR;
  184. AddressU = Wrap;
  185. AddressV = Wrap;
  186. AddressW = Wrap;
  187. SRGBTexture=FALSE;
  188. MaxMipLevel=0;
  189. MipMapLodBias=0;
  190. };
  191.  
  192. sampler2D SamplerNormal = sampler_state
  193. {
  194. Texture = <texNormal>;
  195. MinFilter = Anisotropic;
  196. MagFilter = Anisotropic;
  197. MipFilter = LINEAR;
  198. AddressU = Wrap;
  199. AddressV = Wrap;
  200. SRGBTexture=FALSE;
  201. MaxMipLevel=0;
  202. MipMapLodBias=0;
  203. };
  204.  
  205. sampler2D SamplerColor = sampler_state
  206. {
  207. Texture = <texColor>;
  208. MinFilter = LINEAR;
  209. MagFilter = LINEAR;
  210. MipFilter = NONE;
  211. AddressU = Clamp;
  212. AddressV = Clamp;
  213. SRGBTexture=TRUE;
  214. MaxMipLevel=2;
  215. MipMapLodBias=0;
  216. };
  217.  
  218. sampler2D SamplerDepth = sampler_state
  219. {
  220. Texture = <texDepth>;
  221. MinFilter = LINEAR;
  222. MagFilter = LINEAR;
  223. MipFilter = LINEAR;
  224. AddressU = Wrap;
  225. AddressV = Wrap;
  226. AddressW = Wrap;
  227. SRGBTexture=TRUE;
  228. MaxMipLevel=1;
  229. MipMapLodBias=0;
  230. };
  231.  
  232. sampler2D SamplerNoise = sampler_state
  233. {
  234. Texture = <texNoise>;
  235. MinFilter = POINT;
  236. MagFilter = POINT;
  237. MipFilter = NONE;
  238. AddressU = Wrap;
  239. AddressV = Wrap;
  240. SRGBTexture=FALSE;
  241. MaxMipLevel=2;
  242. MipMapLodBias=0;
  243. };
  244.  
  245. sampler2D SamplerPalette = sampler_state
  246. {
  247. Texture = <texPalette>;
  248. MinFilter = LINEAR;
  249. MagFilter = LINEAR;
  250. MipFilter = NONE;
  251. AddressU = Clamp;
  252. AddressV = Clamp;
  253. SRGBTexture=FALSE;
  254. MaxMipLevel=0;
  255. MipMapLodBias=0;
  256. };
  257.  
  258.  
  259. sampler2D SamplerCurr = sampler_state
  260. {
  261. Texture = <texCurr>;
  262. MinFilter = LINEAR;
  263. MagFilter = LINEAR;
  264. MipFilter = LINEAR;//NONE;
  265. AddressU = Clamp;
  266. AddressV = Clamp;
  267. SRGBTexture=FALSE;
  268. MaxMipLevel=0;
  269. MipMapLodBias=0;
  270. };
  271.  
  272.  
  273. sampler2D SamplerPrev = sampler_state
  274. {
  275. Texture = <texPrev>;
  276. MinFilter = LINEAR;
  277. MagFilter = LINEAR;
  278. MipFilter = NONE;
  279. AddressU = Clamp;
  280. AddressV = Clamp;
  281. SRGBTexture=FALSE;
  282. MaxMipLevel=0;
  283. MipMapLodBias=0;
  284. };
  285.  
  286. sampler2D SamplerFocus = sampler_state
  287. {
  288. Texture = <texFocus>;
  289. MinFilter = LINEAR;
  290. MagFilter = LINEAR;
  291. MipFilter = NONE;
  292. AddressU = Clamp;
  293. AddressV = Clamp;
  294. SRGBTexture=FALSE;
  295. MaxMipLevel=0;
  296. MipMapLodBias=0;
  297. };
  298.  
  299. sampler2D SamplerStars = sampler_state
  300. {
  301. Texture = <texStars>;
  302. MinFilter = LINEAR;
  303. MagFilter = LINEAR;
  304. MipFilter = NONE;
  305. AddressU = WRAP;
  306. AddressV = WRAP;
  307. SRGBTexture=FALSE;
  308. MaxMipLevel=0;
  309. MipMapLodBias=0;
  310. };
  311.  
  312. sampler2D SamplerRain = sampler_state
  313. {
  314. Texture = <texRain>;
  315. MinFilter = LINEAR;
  316. MagFilter = LINEAR;
  317. MipFilter = LINEAR;
  318. AddressU = Wrap;
  319. AddressV = Wrap;
  320. AddressW = Wrap;
  321. SRGBTexture=TRUE;
  322. MaxMipLevel=0;
  323. MipMapLodBias=0;
  324. };
  325.  
  326. sampler2D SamplerRain2 = sampler_state
  327. {
  328. Texture = <texRain2>;
  329. MinFilter = LINEAR;
  330. MagFilter = LINEAR;
  331. MipFilter = LINEAR;
  332. AddressU = Wrap;
  333. AddressV = Wrap;
  334. AddressW = Wrap;
  335. SRGBTexture=TRUE;
  336. MaxMipLevel=0;
  337. MipMapLodBias=0;
  338. };
  339.  
  340. sampler2D SamplerMoon = sampler_state
  341. {
  342. Texture = <texMoon>;
  343. MinFilter = LINEAR;
  344. MagFilter = LINEAR;
  345. MipFilter = NONE;
  346. AddressU = Clamp;
  347. AddressV = Clamp;
  348. SRGBTexture=FALSE;
  349. MaxMipLevel=0;
  350. MipMapLodBias=0;
  351. };
  352.  
  353. sampler2D SamplerNs = sampler_state
  354. {
  355. Texture = <texNs>;
  356. MinFilter = LINEAR;
  357. MagFilter = LINEAR;
  358. MipFilter = LINEAR;
  359. AddressU = Wrap;
  360. AddressV = Wrap;
  361. AddressW = Wrap;
  362. SRGBTexture=FALSE;
  363. MaxMipLevel=0;
  364. MipMapLodBias=0;
  365. };
  366.  
  367. sampler2D SamplerNs2 = sampler_state
  368. {
  369. Texture = <texNs2>;
  370. MinFilter = LINEAR;
  371. MagFilter = LINEAR;
  372. MipFilter = LINEAR;
  373. AddressU = Wrap;
  374. AddressV = Wrap;
  375. AddressW = Wrap;
  376. SRGBTexture=FALSE;
  377. MaxMipLevel=0;
  378. MipMapLodBias=0;
  379. };
  380.  
  381. sampler2D SamplerPuddle = sampler_state
  382. {
  383. Texture = <texPd>;
  384. MinFilter = LINEAR;
  385. MagFilter = LINEAR;
  386. MipFilter = LINEAR;
  387. AddressU = Wrap;
  388. AddressV = Wrap;
  389. AddressW = Wrap;
  390. SRGBTexture=FALSE;
  391. MaxMipLevel=0;
  392. MipMapLodBias=0;
  393. };
  394.  
  395. sampler2D SamplerShadow = sampler_state
  396. {
  397. Texture = <texShadow>;
  398. MinFilter = LINEAR;
  399. MagFilter = LINEAR;
  400. MipFilter = NONE;
  401. AddressU = Clamp;
  402. AddressV = Clamp;
  403. SRGBTexture=FALSE;
  404. MaxMipLevel=0;
  405. MipMapLodBias=0;
  406. };
  407.  
  408. struct VS_OUTPUT_POST
  409. {
  410. float4 vpos : POSITION;
  411. float2 txcoord : TEXCOORD0;
  412. };
  413.  
  414. struct VS_INPUT_POST
  415. {
  416. float3 pos : POSITION;
  417. float2 txcoord : TEXCOORD0;
  418. };
  419.  
  420. ////////////////////////////////////////////////////////////////////////////////////
  421. /////////////////////////////////////SA_DirectX/////////////////////////////////////
  422. ////////////////////////////////////////////////////////////////////////////////////
  423. VS_OUTPUT_POST VS_PostProcess(VS_INPUT_POST IN)
  424. {
  425. VS_OUTPUT_POST OUT;
  426. float4 pos=float4(IN.pos.x,IN.pos.y,IN.pos.z,1.0);
  427. OUT.vpos=pos;
  428. OUT.txcoord.xy=IN.txcoord.xy;
  429. return OUT;
  430. }
  431.  
  432. float linearlizeDepth(float nonlinearDepth)
  433. {
  434. float2 dofProj = float2(0.0509804, 3098.0392);
  435. float2 dofDist = float2(0.0, 0.0509804);
  436. float4 depth = nonlinearDepth;
  437. depth.y = -dofProj.x + dofProj.y;
  438. depth.y = 1.0/depth.y;
  439. depth.z = depth.y * dofProj.y;
  440. depth.z = depth.z * -dofProj.x;
  441. depth.x = dofProj.y * -depth.y + depth.x;
  442. depth.x = 1.0/depth.x;
  443. depth.y = depth.z * depth.x;
  444. depth.x = depth.z * depth.x - dofDist.y;
  445. depth.x+= dofDist.x * -0.5;
  446. depth.x = max(depth.x, 0.0);
  447. return depth.x;
  448. }
  449.  
  450. float CL(in float3 c)
  451. {
  452. return (c.r * 0.2126 + c.g * 0.7152 + c.b * 0.0722)*1.0;
  453. }
  454.  
  455. float4 wpd0(in float2 cd, in float d)
  456. {
  457. float4 tv;
  458. tv.xy = cd.xy*2.0-1.0;
  459. tv.y = -tv.y;
  460. tv.z = d;
  461. tv.w = 1.0;
  462. float4 wp;
  463. wp.x = dot(tv, MatrixInverseVPRotation[0]);
  464. wp.y = dot(tv, MatrixInverseVPRotation[1]);
  465. wp.z = dot(tv, MatrixInverseVPRotation[2]);
  466. wp.w = dot(tv, MatrixInverseVPRotation[3]);
  467. wp.xyz/= wp.w;
  468. wp.xyz+= CameraPosition;
  469. return wp;
  470. }
  471.  
  472. float4 wpd1(float2 cd)
  473. {
  474. float4 tv;
  475. tv.xy = cd.xy*2.0-1.0;
  476. tv.y =-tv.y;
  477. tv.z = tex2Dlod(SamplerDepth, float4(cd.xy,0,0)).x;
  478. tv.w = 1.0;
  479. float4 wp;
  480. wp.x = dot(tv,MatrixInverseVPRotation[0]);
  481. wp.y = dot(tv,MatrixInverseVPRotation[1]);
  482. wp.z = dot(tv,MatrixInverseVPRotation[2]);
  483. wp.w = dot(tv,MatrixInverseVPRotation[3]);
  484. wp.xyz/= wp.w;
  485. return wp;
  486. }
  487.  
  488. float2 wpd2(float3 cd)
  489. {
  490. float4 tv = float4(cd.xyz, 1.0);
  491. float4 wp = 0.0;
  492. wp.x = dot(tv,MatrixVPRotation[0]);
  493. wp.y = dot(tv,MatrixVPRotation[1]);
  494. wp.z = dot(tv,MatrixVPRotation[2]);
  495. wp.w = dot(tv,MatrixVPRotation[3]);
  496. wp.xyz/= wp.w;
  497. wp.y = -wp.y;
  498. wp.xy = wp.xy*0.5+0.5;
  499. return wp.xy;
  500. }
  501.  
  502. ////////////////////////////////////////////////////////////////////////////////////
  503. /////////////////////////////////////SA_DirectX/////////////////////////////////////
  504. ////////////////////////////////////////////////////////////////////////////////////
  505. float3 fs0(float2 cd)
  506. {
  507. float3 wpos = wpd1(cd.xy);
  508. float2 fscreen = float2(ScreenSize.y,ScreenSize.y*ScreenSize.z);
  509. float3 y = wpd1(cd.xy+float2(fscreen.x, 0.0)) - wpos;
  510. float3 f = wpd1(cd.xy+float2(0.0, fscreen.y)) - wpos;
  511. float3 n = cross(f,y);
  512. return normalize(n);
  513. }
  514.  
  515. float4 reflection(float3 n, float2 cd)
  516. {
  517. float3 wpos = wpd1(cd.xy);
  518. float3 v = float3(0.353, 0.353, 1.0);
  519. n = (normalize(n.xyz*v)*0.98);
  520. float3 n0 = reflect(wpos.xyz, n.xyz);
  521. float3 n1 = ((1000.0/0.01)*n0)/1000.0;
  522. float3 r0 = (wpos+n1);
  523. float2 r1 = wpd2(r0.xyz);
  524. float4 r2 = tex2Dlod(SamplerColor, float4(r1.xy, 0.0, 6.0));
  525. r2.w = r1.y<0.0||r1.y>1.0 ? 0.0:1.0;
  526. return r2;
  527. }
  528.  
  529. float Lighting_Brightness
  530. <
  531. string UIName="Lighting - Brightness";
  532. string UIWidget="Spinner";
  533. float UIMin=0.0;
  534. float UIMax=6.0;
  535. > = {1.20};
  536.  
  537. float Lighting_Saturate
  538. <
  539. string UIName="Lighting - Saturate";
  540. string UIWidget="Spinner";
  541. float UIMin=0.0;
  542. float UIMax=5.0;
  543. > = {1.20};
  544.  
  545. float Lighting_Contrast
  546. <
  547. string UIName="Lighting - Contrast";
  548. string UIWidget="Spinner";
  549. float UIMin=0.0;
  550. float UIMax=5.0;
  551. > = {1.30};
  552.  
  553. float Shadow_Brightness
  554. <
  555. string UIName="Shadow - Brightness";
  556. string UIWidget="Spinner";
  557. float UIMin=0.0;
  558. float UIMax=2.0;
  559. > = {0.65};
  560.  
  561. float Shadow_Saturate
  562. <
  563. string UIName="Shadow - Saturate";
  564. string UIWidget="Spinner";
  565. float UIMin=0.0;
  566. float UIMax=5.0;
  567. > = {0.80};
  568.  
  569. float Shadow_Contrast
  570. <
  571. string UIName="Shadow - Contrast";
  572. string UIWidget="Spinner";
  573. float UIMin=0.0;
  574. float UIMax=5.0;
  575. > = {1.80};
  576.  
  577. float Peds_SideLighting
  578. <
  579. string UIName="Peds - Fresnel Lighting";
  580. string UIWidget="Spinner";
  581. float UIMin=0.0;
  582. float UIMax=10.0;
  583. > = {2.00};
  584.  
  585.  
  586. float Lighting_Level
  587. <
  588. string UIName="Cars - Shadow";
  589. string UIWidget="Spinner";
  590. float UIMin=0.0;
  591. float UIMax=10.0;
  592. > = {0.60};
  593.  
  594. ////////////////////////////////////////////////////////////////////////////////////
  595. /////////////////////////////////////SA_DirectX/////////////////////////////////////
  596. ////////////////////////////////////////////////////////////////////////////////////
  597. float4 PS_DX0(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
  598. {
  599. //=============================================================
  600. float4 tv0;
  601. float4 tv1;
  602. float4 wpos;
  603. float4 npos;
  604. float2 cd = IN.txcoord.xy;
  605. float4 r0 = tex2D(SamplerColor, cd);
  606. r0.a = min(1.0, r0.a);
  607. float4 r1 = tex2D(SamplerColor, cd);
  608. float4 r2 = r1;
  609. float4 r3 = r1;
  610. float4 r4 = r1;
  611. r4.xyz+=0.000001;
  612. float4 r5 = tex2D(SamplerOriginal, cd);
  613. float4 shadow = tex2D(SamplerShadow, cd);
  614. float3 normal = tex2D(SamplerNormal, IN.txcoord.xy)*2.0-1.0;
  615. float d0 = tex2D(SamplerDepth, cd).x;
  616. float d1 = linearlizeDepth(tex2D(SamplerDepth, cd).x)*1.0;
  617. //=============================================================
  618. float t0 = GameTime;
  619. float3 sv0 = SunDirection.xyz;
  620. float3 sv1 = normalize(float3(0.0, 0.0, 0.0));
  621. float s1 = smoothstep(0.0, 1.0, t0);
  622. float s2 = smoothstep(1.0, 23.0, t0);
  623. float s3 = smoothstep(23.0, 24.0, t0);
  624. float3 sunvec = lerp(sv1, sv0, s1);
  625. sunvec = lerp(sunvec, sv0, s2);
  626. sunvec = lerp(sunvec, sv1, s3);
  627. //=============================================================
  628. float x1 = smoothstep(0.0, 4.0, t0);
  629. float x2 = smoothstep(4.0, 5.0, t0);
  630. float x3 = smoothstep(5.0, 6.0, t0);
  631. float x4 = smoothstep(6.0, 7.0, t0);
  632. float xE = smoothstep(8.0, 11.0, t0);
  633. float x5 = smoothstep(16.0, 17.0, t0);
  634. float x6 = smoothstep(18.0, 19.0, t0);
  635. float x7 = smoothstep(19.0, 20.0, t0);
  636. float xG = smoothstep(20.0, 21.0, t0);
  637. float xZ = smoothstep(21.0, 22.0, t0);
  638. float x8 = smoothstep(22.0, 23.0, t0);
  639. float x9 = smoothstep(23.0, 24.0, t0);
  640. //=============================================================
  641. tv1.xy = IN.txcoord.xy*2.0-1.0;
  642. tv1.y = -tv1.y;
  643. tv1.z = d0;
  644. tv1.w = 1.0;
  645. wpos.x = dot(tv1, MatrixInverseVPRotation[0]);
  646. wpos.y = dot(tv1, MatrixInverseVPRotation[1]);
  647. wpos.z = dot(tv1, MatrixInverseVPRotation[2]);
  648. wpos.w = dot(tv1, MatrixInverseVPRotation[3]);
  649. wpos.xyz/= wpos.w;
  650. //=============================================================
  651. tv0.xy = normal.xy;
  652. tv0.x = -tv0.x;
  653. tv0.z = normal.z;
  654. npos.x = dot(tv0.xyz, MatrixInverseView[0])*1.0;
  655. npos.y = dot(tv0.xyz, MatrixInverseView[1])*1.0;
  656. npos.z = dot(tv0.xyz, MatrixInverseView[2])*1.0;
  657. float3 n2 = normalize(npos.xyz);
  658. float3 n3 = normalize(wpos.xyz);
  659. //=============================================================
  660. float4 wpos0 = float4(normalize(wpos.xyz), 1.0);
  661. float3 c1 = normalize(n3.xyz-sunvec);
  662. c1*= smoothstep(16.0, 0.0, normalize(-wpos0.z-sunvec));
  663. c1*= saturate(1.0 - dot(r0.xyz, 0.0));
  664. //=============================================================
  665. float d11 = dot(n2, sunvec);
  666. d11 = d11 * 1.0 + 0.0;
  667. float d12 = pow(d11 * 0.5 + 0.5, Lighting_Level);
  668.  
  669. float d5 = dot(n2.xzy, normalize(float3(0.0, -1.0, 0.0)));
  670. d5 = d5 * 1.0 + 0.0;
  671. float d5s = dot(n2.xzy, normalize(float3(0.0, 1.0, 0.0)));
  672. d5s = d5s * 1.0 + 0.0;
  673. float mix3 = pow(d5 * 0.5 + 0.5, 1.5);
  674. float mix3s = pow(d5s * 0.5 + 0.5, 1.5);
  675. float4 sl = mix3*4.0; sl.a = min(1.0, sl.a);
  676. float4 sl2 = mix3s*4.0; sl2.a = min(1.0, sl2.a);
  677. //=============================================================
  678. float3 timelt = lerp(0.0, 0.00, x1);
  679. timelt = lerp(timelt, float3(0.686, 0.392, 0.235)*float3(0.745, 0.588, 0.157)*7.0*0.3, x2);
  680. timelt = lerp(timelt, float3(0.686, 0.392, 0.235)*float3(0.745, 0.588, 0.157)*7.0, x3);
  681. timelt = lerp(timelt, 4.1*float3(1.0, 0.745, 0.51), x4);
  682. timelt = lerp(timelt, 4.1*float3(1.0, 0.98, 0.745)*0.90, xE);
  683. timelt = lerp(timelt, 4.1*float3(1.0, 0.98, 0.745)*0.90, x5);
  684. timelt = lerp(timelt, float3(0.686, 0.392, 0.235)*float3(0.745, 0.588, 0.157)*7.0, x6);
  685. timelt = lerp(timelt, 0.0, x7);
  686. timelt = lerp(timelt, 0.00, xG);
  687. timelt = lerp(timelt, 0.00, xZ);
  688. timelt = lerp(timelt, 0.00, x8);
  689. timelt*= 1.0;
  690. float3 timesh = lerp(0.0, 0.00, x1);
  691. timesh = lerp(timesh, 0.10, x2);
  692. timesh = lerp(timesh, 0.10, x3);
  693. timesh = lerp(timesh, 0.20, x4);
  694. timesh = lerp(timesh, 0.2, xE);
  695. timesh = lerp(timesh, 0.2, x5);
  696. timesh = lerp(timesh, 0.40, x6);
  697. timesh = lerp(timesh, 0.10, x7);
  698. timesh = lerp(timesh, 0.10, xG);
  699. timesh = lerp(timesh, 0.10, xZ);
  700. timesh = lerp(timesh, 0.10, x8);
  701. timesh = lerp(timesh, 0.0, x9);
  702. //=============================================================
  703. float4 sh0 = shadow;
  704. float4 sh1 = shadow;
  705. float4 sh2 = shadow;
  706. sh0*= saturate(0.0-(d11) * 2.0);
  707. sh0.xyz = lerp(1.0, sh0, timesh);
  708. sh1*= saturate(0.0-(d11) * 2.0);
  709. sh1.xyz = lerp(1.0, sh1, timesh*Lighting_Level);
  710. sh2*= saturate(-d11);
  711. float3 albedo = r0;
  712. albedo = clamp(albedo, 0.001, 1.0);
  713. albedo.xyz = albedo.xyz/(0.5+dot(albedo.xyz, 0.35));
  714.  
  715. float3 st0 = normalize(albedo.xyz);
  716. float3 cs0=albedo.xyz/st0.xyz;
  717. cs0=pow(cs0, Shadow_Contrast);
  718. st0.xyz = pow(st0.xyz, Shadow_Saturate);
  719. albedo.xyz = cs0*st0.xyz;
  720. //=============================================================
  721. float4 mask0 = tex2D(SamplerNormal, cd).w;
  722. if (mask0.w<0.99) mask0 = 0.0;
  723. float4 mask1 = tex2D(SamplerNormal, cd).w;
  724. if (mask1.w<0.99) mask1 = 50.0*1.9;
  725. mask1*= 0.01;
  726. float4 mask2 = tex2D(SamplerNormal, cd).w;
  727. if (mask2.w<0.0) mask2 = 0.0;
  728. float4 mask3 = tex2D(SamplerNormal, cd).w;
  729. if (mask3.w==254/255.0) mask3 = 0.0;
  730. float4 mask4 = tex2D(SamplerNormal, cd).w;
  731. if (mask4.w==254/255.0) mask4 = 50.0*1.9;
  732. mask4*= 0.01;
  733. float4 mask5 = tex2D(SamplerNormal, cd).w;
  734. if (mask5.w==253/255.0) mask5 = 5.0*100.0;
  735. mask5*= 0.001;
  736. float4 mask6 = r5;
  737. mask6.xyz+= 0.000001;
  738. float3 st1 = normalize(mask6.xyz);
  739. float3 cs1 = mask6.xyz/st1.xyz;
  740. cs1 = pow(cs1, 1.0);
  741. st1.xyz = pow(st1.xyz, 1.0);
  742. mask6.xyz = cs1*st1.xyz;
  743. float4 mask7 = r5;
  744. mask7.xyz+= 0.000001;
  745. float3 st2 = normalize(mask7.xyz);
  746. float3 cs2 = mask7.xyz/st2.xyz;
  747. cs2 = pow(cs2, 2.0);
  748. st2.xyz = pow(st2.xyz, 0.1);
  749. mask7.xyz = cs2*st2.xyz;
  750. float graymask0 = saturate(mask6);
  751. float graymask1 = saturate(mask7);
  752. //=============================================================
  753. float3 timesk = lerp(float3(0.843, 0.784, 0.667)*0.03, float3(0.843, 0.784, 0.667)*0.03, x1);
  754. timesk = lerp(timesk, float3(0.843, 0.784, 0.667)*0.6, x2);
  755. timesk = lerp(timesk, float3(0.843, 0.784, 0.667), x3);
  756. timesk = lerp(timesk, float3(0.843, 0.784, 0.667), x4);
  757. timesk = lerp(timesk, float3(0.843, 0.784, 0.667)*1.2, xE);
  758. timesk = lerp(timesk, float3(0.843, 0.784, 0.667)*1.2, x5);
  759. timesk = lerp(timesk, float3(0.843, 0.784, 0.667), x6);
  760. timesk = lerp(timesk, float3(0.843, 0.784, 0.667)*0.1, x7);
  761. timesk = lerp(timesk, float3(0.843, 0.784, 0.667)*0.05, xG);
  762. timesk = lerp(timesk, float3(0.843, 0.784, 0.667)*0.05, xZ);
  763. timesk = lerp(timesk, float3(0.843, 0.784, 0.667)*0.03, x8);
  764. float3 timesk2 = lerp(float3(0.314, 0.431, 0.588)*1.0, float3(0.314, 0.431, 0.588)*1.0, x1);
  765. timesk2 = lerp(timesk2, float3(0.314, 0.431, 0.588)*0.6, x2);
  766. timesk2 = lerp(timesk2, float3(0.314, 0.431, 0.588), x3);
  767. timesk2 = lerp(timesk2, float3(0.314, 0.431, 0.588), x4);
  768. timesk2 = lerp(timesk2, float3(0.314, 0.431, 0.588), xE);
  769. timesk2 = lerp(timesk2, float3(0.314, 0.431, 0.588), x5);
  770. timesk2 = lerp(timesk2, float3(0.314, 0.431, 0.588), x6);
  771. timesk2 = lerp(timesk2, float3(0.314, 0.431, 0.588)*0.6, x7);
  772. timesk2 = lerp(timesk2, float3(0.314, 0.431, 0.588)*0.6, xG);
  773. timesk2 = lerp(timesk2, float3(0.314, 0.431, 0.588)*0.7, xZ);
  774. timesk2 = lerp(timesk2, float3(0.314, 0.431, 0.588)*0.7, x8);
  775. timesk2 = lerp(timesk2, float3(0.314, 0.431, 0.588)*1.0, x8);
  776. //=============================================================
  777. float4 wx = WeatherAndTime;
  778. float4 lc;
  779. float4 ln;
  780. float3 slc;
  781. float3 sln;
  782.  
  783. float4 mask0z = tex2D(SamplerNormal, cd).w;
  784. if (mask0z.w<0.50) mask0z = 0.0;
  785. float4 mask1z = tex2D(SamplerNormal, cd).w;
  786. if (mask1z.w<0.99) mask1z = 50.0*40.0;
  787. mask1z*= 0.001;
  788. float mask2z = lerp(1.0, 0.0, mask1z);
  789. mask2z = saturate(mask2z);
  790. float mask1x = saturate(mask1z*mask0z)*1.0;
  791.  
  792. if (wx.x==0,1) slc = lerp(((timesk2*sl)+(sl2*timesk))*1.0, 1.0, mask1x);
  793. if (wx.y==0,1) sln = lerp(((timesk2*sl)+(sl2*timesk))*1.0, 1.0, mask1x);
  794. if (wx.x==4) slc = 1.0;
  795. if (wx.x==7) slc = 1.0;
  796. if (wx.x==8) slc = 1.0;
  797. if (wx.x==9) slc = 1.0;
  798. if (wx.x==12) slc = 1.0;
  799. if (wx.x==15) slc = 1.0;
  800. if (wx.x==16) slc = 1.0;
  801. if (wx.y==4) sln = 1.0;
  802. if (wx.y==7) sln = 1.0;
  803. if (wx.y==8) sln = 1.0;
  804. if (wx.y==9) sln = 1.0;
  805. if (wx.y==12) sln = 1.0;
  806. if (wx.y==15) sln = 1.0;
  807. if (wx.y==16) sln = 1.0;
  808. float3 wmix = lerp(slc, sln, pow(wx.z,5.0));
  809.  
  810.  
  811.  
  812.  
  813.  
  814. if(d1 < 3000)r0.xyz*= wmix*sh0*albedo*Shadow_Brightness;
  815. if(d1 < 3000)r0.xyz = lerp(r1, r0, mask0z);
  816. if(d1 < 3000)r0.xyz = lerp(r1, r0, mask2z);
  817. if(d1 < 3000)r1.xyz*= wmix*sh1*Shadow_Brightness;
  818. if(d1 < 3000)r0.xyz = lerp(r0.xyz, r1.xyz, mask1x);
  819. if(d1 < 3000)r0.xyz = lerp(r2.xyz, r0.xyz, mask2);
  820.  
  821. float3 st3 = normalize(r2.xyz);
  822. float3 cs3=r2.xyz/st3.xyz;
  823. cs3=pow(cs3, Lighting_Contrast);
  824. st3.xyz = pow(st3.xyz, Lighting_Saturate);
  825. r2.xyz = cs3*st3.xyz;
  826.  
  827. float cz = 100.0*0.05;
  828. float f0 = pow(dot(c1.z, n2.z), 0.15);
  829. f0 = pow(f0, cz);
  830. float f1 = (f0*f0);
  831. f1/= 2.5;
  832.  
  833. float3 timebl = lerp(0.0, 0.00, x1);
  834. timebl = lerp(timebl, float3(0.667, 0.51, 0.392)*float3(0.706, 0.51, 0.157)*7.0, x2);
  835. timebl = lerp(timebl, float3(0.667, 0.51, 0.392)*float3(0.706, 0.51, 0.157)*7.0*8.0, x3);
  836. timebl = lerp(timebl, 4.1*float3(1.0, 0.745, 0.51)*2.0, x4);
  837. timebl = lerp(timebl, 4.1*float3(1.0, 0.98, 0.745)*0.30, xE);
  838. timebl = lerp(timebl, 4.1*float3(1.0, 0.98, 0.745)*0.30, x5);
  839. timebl = lerp(timebl, float3(0.667, 0.51, 0.392)*float3(0.706, 0.51, 0.157)*7.0*8.0, x6);
  840. timebl = lerp(timebl, 0.0, x7);
  841. timebl = lerp(timebl, 0.00, xG);
  842. timebl = lerp(timebl, 0.00, xZ);
  843. timebl = lerp(timebl, 0.00, x8);
  844. timebl*= 1.0;
  845.  
  846. if(d1 < 3000)r0.xyz+= lerp(r2*sh2*graymask0*timelt*(mask3*mask0)*Lighting_Brightness, graymask1*10.0*f1*timebl*Lighting_Brightness*0.80, f1*graymask0*sh2*mask2z);
  847. if(d1 < 3000)r0.xyz+= r3*sh2*(timelt*0.0)*(mask1+mask4)*Lighting_Brightness;
  848. if(d1 < 3000)r0.xyz = lerp(r3, r0, mask0z);
  849. //=============================================================
  850. float3 wp = reflect(n3.xyz, n2.xyz);
  851. float4 pr = texCUBE(SamplerCM, wp.xzy);
  852. float4 n0 = tex2D(SamplerNormal, cd);
  853. float smix;
  854. smix=saturate(npos.z)*saturate(-n0.z);
  855. smix*=smix;
  856. float nf1 = saturate(1.65+smix*0.3 -abs(n0.z));
  857. nf1 = pow(nf1, 10.0);
  858. r0.xyz = lerp(r0, r0+pr*Peds_SideLighting, r2*nf1*mask5);
  859. //=============================================================
  860. float3 st4 = normalize(r4.xyz);
  861. float3 cs4=r4.xyz/st4.xyz;
  862. cs4=pow(cs4, 2.1);
  863. st4.xyz = pow(st4.xyz, 1.6);
  864. r4.xyz = lerp(r4*0.6, cs4*st4.xyz, mask0*mask3);
  865. float4 t2;
  866. t2 = lerp(r4*1.5, r4*1.5, x1);
  867. t2 = lerp(t2, r0, x2);
  868. t2 = lerp(t2, r0, x3);
  869. t2 = lerp(t2, r0, x4);
  870. t2 = lerp(t2, r0, xE);
  871. t2 = lerp(t2, r0, x5);
  872. t2 = lerp(t2, r0, x6);
  873. t2 = lerp(t2, r0, x7);
  874. t2 = lerp(t2, r4*1.5, x8);
  875. if (wx.x==0,1) lc = t2;
  876. if (wx.y==0,1) ln = t2;
  877. if (wx.x==4) lc = r4;
  878. if (wx.x==7) lc = r4;
  879. if (wx.x==8) lc = r4;
  880. if (wx.x==9) lc = r4;
  881. if (wx.x==12) lc = r4;
  882. if (wx.x==15) lc = r4;
  883. if (wx.x==16) lc = r4;
  884. if (wx.y==4) ln = r4;
  885. if (wx.y==7) ln = r4;
  886. if (wx.y==8) ln = r4;
  887. if (wx.y==9) ln = r4;
  888. if (wx.y==12) ln = r4;
  889. if (wx.y==15) ln = r4;
  890. if (wx.y==16) ln = r4;
  891. float4 wmix0 = lerp(lc, ln, pow(wx.z, 5.0));
  892. //=============================================================
  893. //r0.xyz = mask2;
  894. //return r0;
  895. return wmix0;
  896.  
  897. }
  898.  
  899. ////////////////////////////////////////////////////////////////////////////////////
  900. /////////////////////////////////////SA_DirectX/////////////////////////////////////
  901. ////////////////////////////////////////////////////////////////////////////////////
  902.  
  903. float4 WorldPos(in float2 coord)
  904. {
  905. float d0 = tex2D(SamplerDepth, coord.xy).x;
  906. float4 tvec;
  907. tvec.xy = coord.xy*2.0-1.0;
  908. tvec.y = -tvec.y;
  909. tvec.z = d0;
  910. tvec.w = 1.0;
  911. float4 wpos;
  912. wpos.x = dot(tvec, MatrixInverseVPRotation[0]);
  913. wpos.y = dot(tvec, MatrixInverseVPRotation[1]);
  914. wpos.z = dot(tvec, MatrixInverseVPRotation[2]);
  915. wpos.w = dot(tvec, MatrixInverseVPRotation[3]);
  916. wpos.xyz/= wpos.w;
  917. return wpos;
  918. }
  919.  
  920. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  921. // etc
  922. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  923.  
  924. float Sky_Saturate
  925. <
  926. string UIName="Sky - Saturate";
  927. string UIWidget="Spinner";
  928. float UIMin=0.0;
  929. float UIMax=6.0;
  930. > = {1.30};
  931.  
  932. float Sky_Contrast
  933. <
  934. string UIName="Sky - Contrast";
  935. string UIWidget="Spinner";
  936. float UIMin=0.0;
  937. float UIMax=6.0;
  938. > = {1.35};
  939.  
  940. float Sky_Brightness
  941. <
  942. string UIName="Sky - Brightness";
  943. string UIWidget="Spinner";
  944. float UIMin=0.0;
  945. float UIMax=6.0;
  946. > = {1.00};
  947.  
  948.  
  949. float3 CalculateSun(in float2 coord)
  950. {
  951. float3 sv = SunDirection.xyz;
  952. float3 sv2 = normalize(float3(-0.0833, -0.946, 0.317));
  953.  
  954. float t = GameTime;
  955.  
  956. float x1 = smoothstep(0.0, 4.0, t);
  957. float x2 = smoothstep(4.0, 5.0, t);
  958. float x3 = smoothstep(5.0, 6.0, t);
  959. float x4 = smoothstep(6.0, 7.0, t);
  960. float xE = smoothstep(8.0, 11.0, t);
  961. float x5 = smoothstep(16.0, 17.0, t);
  962. float x6 = smoothstep(18.0, 19.0, t);
  963. float x7 = smoothstep(19.0, 20.0, t);
  964. float xG = smoothstep(20.0, 21.0, t);
  965. float xZ = smoothstep(21.0, 22.0, t);
  966. float x8 = smoothstep(22.0, 23.0, t);
  967. float x9 = smoothstep(23.0, 24.0, t);
  968.  
  969. float3 t0 = lerp(0.0, 0.0, x1);
  970. t0 = lerp(t0, float3(1.0, 0.549, 0.0784)*2.0, x2);
  971. t0 = lerp(t0, float3(1.0, 0.549, 0.0784)*2.7, x3);
  972. t0 = lerp(t0, float3(1.0, 0.51, 0.235)*2.0, x4);
  973. t0 = lerp(t0, float3(1.0, 0.863, 0.549), xE);
  974. t0 = lerp(t0, float3(1.0, 0.863, 0.549), x5);
  975. t0 = lerp(t0, float3(1.0, 0.549, 0.0784)*2.0, x6);
  976. t0 = lerp(t0, float3(1.0, 0.549, 0.0784)*0.8, x7);
  977. t0 = lerp(t0, float3(1.0, 0.549, 0.0784)*0.6, xG);
  978. t0 = lerp(t0, float3(1.0, 0.549, 0.0784)*0.4, xZ);
  979. t0 = lerp(t0, float3(1.0, 0.549, 0.0784)*0.2, x8);
  980. t0 = lerp(t0, 0.0, x9);
  981.  
  982. float3 t3 = lerp(0.0, 0.0, x1);
  983. t3 = lerp(t3, float3(1.0, 0.447, 0.0)*2.0, x2);
  984. t3 = lerp(t3, float3(1.0, 0.447, 0.0)*2.7, x3);
  985. t3 = lerp(t3, float3(1.0, 0.784, 0.392)*2.0, x4);
  986. t3 = lerp(t3, float3(1.0, 1.0, 1.0)*2.0, xE);
  987. t3 = lerp(t3, float3(1.0, 1.0, 1.0)*2.0, x5);
  988. t3 = lerp(t3, float3(1.0, 0.447, 0.0)*2.0, x6);
  989. t3 = lerp(t3, float3(1.0, 0.447, 0.0)*0.8, x7);
  990. t3 = lerp(t3, float3(1.0, 0.447, 0.0)*0.6, xG);
  991. t3 = lerp(t3, float3(1.0, 0.447, 0.0)*0.4, xZ);
  992. t3 = lerp(t3, float3(1.0, 0.447, 0.0)*0.2, x8);
  993. t3 = lerp(t3, 0.0, x9);
  994.  
  995. float4 wp = WorldPos(coord);
  996. float c0 = 475.0 * 25.0;
  997. float c1 = 18.0;
  998. float c2 = 1.35;
  999.  
  1000. float3 np0 = normalize(wp.xyz);
  1001. float factor = (0.01/12.0) - dot(-sv, np0);
  1002. factor = pow(factor, c0);
  1003. float factor1 = 0.04 - dot(-sv, np0);
  1004. factor1 = pow(factor1, c1);
  1005. float factor2 = 0.6 - dot(-sv, np0);
  1006. factor2 = pow(factor2, c2);
  1007.  
  1008. float factor3 = 0.04 - dot(-sv2, np0);
  1009. factor3 = pow(factor3, c1);
  1010. float factor4 = 0.6 - dot(-sv2, np0);
  1011. factor4 = pow(factor4, c2);
  1012.  
  1013. float3 f0 = factor/12.0;
  1014. float3 f1 = (factor1*factor1)/5.0;
  1015. float3 f2 = (factor2*factor2)/10.0;
  1016.  
  1017. float3 f1x = (factor3*factor3)/5.0;
  1018. float3 f2x = (factor4*factor4)/10.0;
  1019. float3 fnight = (f1x*float3(0.0863, 0.137, 0.176))+(f2x*float3(0.0, 0.0, 0.0));
  1020. fnight*= smoothstep(0.0, 0.3, -np0.y);
  1021.  
  1022. float y1 = smoothstep(0.0, 2.0, t);
  1023. float yZ = smoothstep(2.0, 3.0, t);
  1024. float y2 = smoothstep(4.0, 23.0, t);
  1025. float y3 = smoothstep(23.0, 24.0, t);
  1026.  
  1027. float3 t4 = lerp(0.0, 0.0, y1);
  1028. t4 = lerp(t4, float3(0.0392, 0.0235, 0.0118), yZ);
  1029. t4 = lerp(t4, float3(0.0392, 0.0235, 0.0118), y2);
  1030. t4 = lerp(t4, 0.0, y3);
  1031.  
  1032. float3 t5 = lerp(1.0, 0.5, y1);
  1033. t5 = lerp(t5, 0.0, yZ);
  1034. t5 = lerp(t5, 0.0, y2);
  1035. t5 = lerp(t5, 1.0, y3);
  1036.  
  1037. float3 wp0 = wp + CameraPosition;
  1038. float3 np1 = normalize(wp0.xyz);
  1039. float3 f3 = lerp(0.0, (f0*t4), smoothstep(0.0, 0.005, np1.z)) +(f1*t0)+(f2*t3)+(fnight*t5);
  1040.  
  1041. float3 SunCurrent;
  1042. float3 SunNext;
  1043. float4 wx = WeatherAndTime;
  1044.  
  1045. if (wx.x==0,1) SunCurrent = f3;
  1046. if (wx.y==0,1) SunNext = f3;
  1047.  
  1048. if (wx.x==4) SunCurrent = 0.0;
  1049. if (wx.x==7) SunCurrent = 0.0;
  1050. if (wx.x==8) SunCurrent = 0.0;
  1051. if (wx.x==9) SunCurrent = 0.0;
  1052. if (wx.x==12) SunCurrent = 0.0;
  1053. if (wx.x==15) SunCurrent = 0.0;
  1054. if (wx.x==16) SunCurrent = 0.0;
  1055.  
  1056. if (wx.y==4) SunNext = 0.0;
  1057. if (wx.y==7) SunNext = 0.0;
  1058. if (wx.y==8) SunNext = 0.0;
  1059. if (wx.y==9) SunNext = 0.0;
  1060. if (wx.y==12) SunNext = 0.0;
  1061. if (wx.y==15) SunNext = 0.0;
  1062. if (wx.y==16) SunNext = 0.0;
  1063.  
  1064. float3 wmix = lerp(SunCurrent, SunNext, wx.z);
  1065.  
  1066. return wmix;
  1067. }
  1068.  
  1069. float CalculateGameTime0(in float t)
  1070. {
  1071. float x1 = smoothstep(0.0, 4.0, t);
  1072. float x2 = smoothstep(4.0, 5.0, t);
  1073. float x3 = smoothstep(5.0, 6.0, t);
  1074. float x4 = smoothstep(6.0, 7.0, t);
  1075. float xE = smoothstep(8.0, 11.0, t);
  1076. float x5 = smoothstep(16.0, 17.0, t);
  1077. float x6 = smoothstep(18.0, 19.0, t);
  1078. float x7 = smoothstep(19.0, 20.0, t);
  1079. float xG = smoothstep(20.0, 21.0, t);
  1080. float xZ = smoothstep(21.0, 22.0, t);
  1081. float x8 = smoothstep(22.0, 23.0, t);
  1082. float x9 = smoothstep(23.0, 24.0, t);
  1083.  
  1084. float3 t0 = lerp(0.0, 0.1, x1);
  1085. t0 = lerp(t0, 0.2, x2);
  1086. t0 = lerp(t0, 0.8, x3);
  1087. t0 = lerp(t0, 0.9, x4);
  1088. t0 = lerp(t0, 1.0, xE);
  1089. t0 = lerp(t0, 1.0, x5);
  1090. t0 = lerp(t0, 0.9, x6);
  1091. t0 = lerp(t0, 0.5, x7);
  1092. t0 = lerp(t0, 0.4, xG);
  1093. t0 = lerp(t0, 0.3, xZ);
  1094. t0 = lerp(t0, 0.2, x8);
  1095. t0 = lerp(t0, 0.0, x9);
  1096. return t0;
  1097. }
  1098.  
  1099. float CalculateGameTime(in float t)
  1100. {
  1101. float x1 = smoothstep(0.0, 4.0, t);
  1102. float x2 = smoothstep(4.0, 5.0, t);
  1103. float x3 = smoothstep(5.0, 6.0, t);
  1104. float x4 = smoothstep(6.0, 7.0, t);
  1105. float xE = smoothstep(8.0, 11.0, t);
  1106. float x5 = smoothstep(16.0, 17.0, t);
  1107. float x6 = smoothstep(18.0, 19.0, t);
  1108. float x7 = smoothstep(19.0, 20.0, t);
  1109. float xG = smoothstep(20.0, 21.0, t);
  1110. float xZ = smoothstep(21.0, 22.0, t);
  1111. float x8 = smoothstep(22.0, 23.0, t);
  1112. float x9 = smoothstep(23.0, 24.0, t);
  1113.  
  1114. float3 t0 = lerp(0.0, 0.1, x1);
  1115. t0 = lerp(t0, 0.7, x2);
  1116. t0 = lerp(t0, 1.0, x3);
  1117. t0 = lerp(t0, 1.0, x4);
  1118. t0 = lerp(t0, 1.0, xE);
  1119. t0 = lerp(t0, 1.0, x5);
  1120. t0 = lerp(t0, 0.9, x6);
  1121. t0 = lerp(t0, 0.8, x7);
  1122. t0 = lerp(t0, 0.6, xG);
  1123. t0 = lerp(t0, 0.4, xZ);
  1124. t0 = lerp(t0, 0.2, x8);
  1125. t0 = lerp(t0, 0.0, x9);
  1126. return t0;
  1127. }
  1128.  
  1129. float CalculateGameTime2(in float t)
  1130. {
  1131. float x1 = smoothstep(0.0, 4.0, t);
  1132. float x2 = smoothstep(4.0, 5.0, t);
  1133. float x3 = smoothstep(5.0, 6.0, t);
  1134. float x4 = smoothstep(6.0, 7.0, t);
  1135. float xE = smoothstep(8.0, 11.0, t);
  1136. float x5 = smoothstep(16.0, 17.0, t);
  1137. float x6 = smoothstep(18.0, 19.0, t);
  1138. float x7 = smoothstep(19.0, 20.0, t);
  1139. float xG = smoothstep(20.0, 21.0, t);
  1140. float xZ = smoothstep(21.0, 22.0, t);
  1141. float x8 = smoothstep(22.0, 23.0, t);
  1142. float x9 = smoothstep(23.0, 24.0, t);
  1143.  
  1144. float3 t0 = lerp(0.0, 0.0, x1);
  1145. t0 = lerp(t0, 0.7, x2);
  1146. t0 = lerp(t0, 0.9, x3);
  1147. t0 = lerp(t0, 1.0, x4);
  1148. t0 = lerp(t0, 1.0, xE);
  1149. t0 = lerp(t0, 0.5, x5);
  1150. t0 = lerp(t0, 0.5, x6);
  1151. t0 = lerp(t0, 1.0, x7);
  1152. t0 = lerp(t0, 1.0, xG);
  1153. t0 = lerp(t0, 1.0, xZ);
  1154. t0 = lerp(t0, 0.0, x8);
  1155. t0 = lerp(t0, 0.0, x9);
  1156. return t0;
  1157. }
  1158.  
  1159. float3 ColorHorizon(float3 r0, float f)
  1160. {
  1161. float t = GameTime;
  1162. float tf = CalculateGameTime2(t);
  1163. float df = pow(saturate(SunDirection.z * tf), 1.0);
  1164. float3 sg = lerp(1.0, float3(0.902, 0.784, 0.882), pow(r0.y, 2.2));
  1165. float3 sg2 = lerp(1.0, float3(1.0, 1.0, 0.529), pow(r0.y, 1.15));
  1166. float3 sd = lerp(1.0, float3(1.0, 1.0, 0.804), pow(r0.y, 2.15));
  1167. float3 sd2 = lerp(1.0, float3(1.0, 1.0, 1.0), pow(r0.y, 1.15));
  1168. float3 a = lerp(sg, 1.0, f);
  1169. float3 a2 = lerp(sg2, 1.0, f);
  1170. float3 ad = lerp(sd, 1.0, f);
  1171. float3 ad2 = lerp(sd2, 1.0, f);
  1172. r0 *= lerp(a, 1.0, df);
  1173. r0 *= lerp(a2, 1.0, df);
  1174. float3 d1 = lerp(1.0, ad, df);
  1175. float3 d2 = lerp(1.0, ad2, df);
  1176. r0 *= d1*d2;
  1177. return r0;
  1178. }
  1179.  
  1180. float3 ColorTop()
  1181. {
  1182. float3 cc = float3(1.0, 1.0, 1.0);
  1183. float3 cn = float3(1.0, 1.0, 1.0);
  1184.  
  1185. float x1 = smoothstep(1.0, 2.0, WeatherAndTime);
  1186.  
  1187. float4 wx = WeatherAndTime;
  1188.  
  1189. if (wx.x==0,1) cc = float3(0.251, 0.51, 1.0);
  1190. if (wx.y==0,1) cn = float3(0.251, 0.51, 1.0);
  1191.  
  1192. float3 skyW = float3(0.259, 0.259, 0.259);
  1193.  
  1194. if (wx.x==4) cc = skyW;
  1195. if (wx.x==7) cc = skyW;
  1196. if (wx.x==8) cc = skyW;
  1197. if (wx.x==9) cc = skyW;
  1198. if (wx.x==12) cc = skyW;
  1199. if (wx.x==15) cc = skyW;
  1200. if (wx.x==16) cc = skyW;
  1201.  
  1202. if (wx.y==4) cn = skyW;
  1203. if (wx.y==7) cn = skyW;
  1204. if (wx.y==8) cn = skyW;
  1205. if (wx.y==9) cn = skyW;
  1206. if (wx.y==12) cn = skyW;
  1207. if (wx.y==15) cn = skyW;
  1208. if (wx.y==16) cn = skyW;
  1209.  
  1210. float3 wmix0 = lerp(cc, cn, wx.z);
  1211.  
  1212. return wmix0;
  1213. }
  1214.  
  1215. float Noise1(in float3 p)
  1216. {
  1217. float t = (Timer.x * 5.0) * 30.0;
  1218. p.z += 0.5 * t;
  1219. p.xyz += 1.0 * t;
  1220. float2 uv = (p * float2(17.2, 17.2));
  1221. float2 c = (uv + 0.5) / 20.0;
  1222. float r0 = tex2Dlod(SamplerNs, float4(c*0.04, 0.0, 0.0)).x;
  1223. return r0;
  1224. }
  1225.  
  1226. float Noise2(in float3 p)
  1227. {
  1228. float t = (Timer.x * 30.0) * 30.0;
  1229. p.z += 0.5 * t;
  1230. p.xyz += 1.0 * t;
  1231. float2 uv = (p * float2(17.2, 17.2));
  1232. float2 c = (uv + 0.5) / 20.0;
  1233. float r0 = tex2Dlod(SamplerNs2, float4(c*0.04, 0.0, 0.0)).x;
  1234. return r0;
  1235. }
  1236.  
  1237. float4 GWP(in float2 c, in float d)
  1238. {
  1239. float4 t;
  1240. float4 w;
  1241. t.xy=c.xy*2.0-1.0;
  1242. t.y=-t.y;
  1243. t.z=d;
  1244. t.w=1.0;
  1245. w.x=dot(t, MatrixInverseVPRotation[0]);
  1246. w.y=dot(t, MatrixInverseVPRotation[1]);
  1247. w.z=dot(t, MatrixInverseVPRotation[2]);
  1248. w.w=dot(t, MatrixInverseVPRotation[3]);
  1249. w.xyz/=w.w;
  1250. //w.xyz+=CameraPosition;
  1251. return w;
  1252. }
  1253.  
  1254. float SunLight(in float2 c, in float d)
  1255. {
  1256. float3 v0=SunDirection.xyz;
  1257. float3 v2=normalize(float3(-0.09, -0.94, 0.31));
  1258. float t0 = GameTime;
  1259. float x1 = smoothstep(0.0, 4.0, t0);
  1260. float x2 = smoothstep(4.0, 23.0, t0);
  1261. float x3 = smoothstep(23.0, 24.0, t0);
  1262. float3 sv = lerp(v2, v0, x1);
  1263. sv = lerp(sv, v0, x2);
  1264. sv = lerp(sv, v2, x3);
  1265. float4 WorldP = GWP(c, d);
  1266. float c0 = 6.07;
  1267. float3 np = normalize(WorldP.xyz);
  1268. float f0 = 0.95 - dot(-sv, np);
  1269. f0 = pow(f0, c0);
  1270. float r0 = (f0*f0);
  1271. return r0/40000.0;
  1272. }
  1273.  
  1274. float Coverage(in float v, in float d, in float c)
  1275. {
  1276. c = clamp(c - (1.0 - v), 0.0, 1.0 - d)/(1.0 - d);
  1277. c = max(0.0, c * 1.1 - 0.1);
  1278. c = c = c * c * (3.0 - 2.0 * c);
  1279. return c;
  1280. }
  1281.  
  1282. float fcc
  1283. <
  1284. string UIName="Clouds - Coverage";
  1285. string UIWidget="Spinner";
  1286. float UIMin=0.0;
  1287. float UIMax=0.50;
  1288. > = {0.40};
  1289.  
  1290. float4 GenerateClouds(float4 worldpos, in float3 sunlight)
  1291. {
  1292. float t = (Timer.x * 1000.0)*30.0;
  1293. float3 vecm = normalize(float3(-0.09, -0.94, 0.31));
  1294. float3 sv0=-SunDirection.xyz;
  1295. float3 sv2=-vecm;
  1296.  
  1297. float t0 = GameTime;
  1298. float x1 = smoothstep(0.0, 4.0, t0);
  1299. float x2 = smoothstep(4.0, 5.0, t0);
  1300. float x3 = smoothstep(5.0, 6.0, t0);
  1301. float x4 = smoothstep(6.0, 7.0, t0);
  1302. float xE = smoothstep(8.0, 11.0, t0);
  1303. float x5 = smoothstep(16.0, 17.0, t0);
  1304. float x6 = smoothstep(18.0, 19.0, t0);
  1305. float x7 = smoothstep(19.0, 20.0, t0);
  1306. float xG = smoothstep(20.0, 21.0, t0);
  1307. float xZ = smoothstep(21.0, 22.0, t0);
  1308. float x8 = smoothstep(22.0, 23.0, t0);
  1309. float x9 = smoothstep(23.0, 24.0, t0);
  1310. float x10 = smoothstep(4.0, 23.0, t0);
  1311. float x11 = smoothstep(23.0, 24.0, t0);
  1312.  
  1313. float3 sv = lerp(sv2, sv0, x1);
  1314. sv = lerp(sv, sv0, x10);
  1315. sv = lerp(sv, sv2, x11);
  1316.  
  1317. float3 wp = worldpos/1.5;
  1318. wp.x *= 0.04;
  1319. wp.y *= 0.10;
  1320. wp.y -= t * 0.01;
  1321. float3 wp1 = wp * float3(1.0, 0.5, 1.0) + float3(0.0, t * 0.01, 0.0);
  1322.  
  1323. float noise = Noise2(wp * float3(1.0, 0.5, 1.0) + float3(0.0, t * 0.01, 0.0));
  1324. wp *= 3.0;
  1325. wp.xy -= t * 0.04;
  1326. wp.x += 2.0;
  1327. float3 wp2 = wp;
  1328.  
  1329. noise += (2.0 - abs(Noise2(wp) * 0.8)) * 0.25;
  1330. wp *= 10.0;
  1331. wp.xy -= t * 0.035;
  1332. float3 wp3 = wp;
  1333.  
  1334. noise += (2.0 - abs(Noise1(wp) * 1.0)) * 0.03;
  1335. noise /= 0.80;
  1336.  
  1337. float4 wx = WeatherAndTime;
  1338. float CovCurrent;
  1339. float CovNext;
  1340. if (wx.x==0,1) CovCurrent = fcc;
  1341. if (wx.y==0,1) CovNext = fcc;
  1342.  
  1343. if (wx.x==0) CovCurrent = 0.00;
  1344. if (wx.x==2) CovCurrent = 0.00;
  1345. if (wx.x==6) CovCurrent = 0.00;
  1346. if (wx.x==11) CovCurrent = 0.00;
  1347. if (wx.x==13) CovCurrent = 0.00;
  1348. if (wx.x==17) CovCurrent = 0.00;
  1349.  
  1350. if (wx.x==4) CovCurrent = 1.70;
  1351. if (wx.x==7) CovCurrent = 1.70;
  1352. if (wx.x==8) CovCurrent = 1.70;
  1353. if (wx.x==9) CovCurrent = 1.70;
  1354. if (wx.x==12) CovCurrent = 1.70;
  1355. if (wx.x==15) CovCurrent = 1.70;
  1356. if (wx.x==16) CovCurrent = 1.70;
  1357.  
  1358. if (wx.y==0) CovNext = 0.00;
  1359. if (wx.y==2) CovNext = 0.00;
  1360. if (wx.y==6) CovNext = 0.00;
  1361. if (wx.y==11) CovNext = 0.00;
  1362. if (wx.y==13) CovNext = 0.00;
  1363. if (wx.y==17) CovNext = 0.00;
  1364.  
  1365. if (wx.y==4) CovNext = 1.70;
  1366. if (wx.y==7) CovNext = 1.70;
  1367. if (wx.y==8) CovNext = 1.70;
  1368. if (wx.y==9) CovNext = 1.70;
  1369. if (wx.y==12) CovNext = 1.70;
  1370. if (wx.y==15) CovNext = 1.70;
  1371. if (wx.y==16) CovNext = 1.70;
  1372.  
  1373. float3 wmix0 = lerp(CovCurrent, CovNext, pow(wx.z, 0.9));
  1374.  
  1375. float coverage = wmix0;
  1376. float dn = 0.1 - 0.3 * 0.3;
  1377. noise = Coverage(coverage, dn, noise);
  1378.  
  1379. float d0 = Noise2(wp1 + sv.xyz * 0.70 / 2.3);
  1380. d0 += (2.0 - abs(Noise2(wp2 + sv.xyz * 0.70 / 2.3) * 0.8)) * 0.25;
  1381. d0 += (2.0 - abs(Noise1(wp3 + sv.xyz * 0.70 / 2.3) * 1.0)) * 0.03;
  1382. d0 = Coverage(0.84, dn, d0);
  1383.  
  1384. float bf = lerp(clamp(pow(noise, 0.5) * 1.0, 0.0, 1.0), 0.5, pow(sunlight, 1.0));
  1385. d0 *= bf;
  1386.  
  1387. float3 lt = lerp(float3(0.0275, 0.0353, 0.0471), 0.01, x1);
  1388. lt = lerp(lt, float3(1.0, 0.627, 0.235)*0.6, x2);
  1389. lt = lerp(lt, float3(1.0, 0.627, 0.235), x3);
  1390. lt = lerp(lt, float3(1.0, 0.627, 0.235), x4);
  1391. lt = lerp(lt, float3(1.0, 1.0, 1.0), xE);
  1392. lt = lerp(lt, float3(1.0, 1.0, 1.0), x5);
  1393. lt = lerp(lt, float3(1.0, 0.627, 0.235), x6);
  1394. lt = lerp(lt, float3(1.0, 0.627, 0.235), x7);
  1395. lt = lerp(lt, 0.5, xG);
  1396. lt = lerp(lt, 0.3, xZ);
  1397. lt = lerp(lt, 0.1, x8);
  1398. lt = lerp(lt, float3(0.0275, 0.0353, 0.0471), x9);
  1399.  
  1400. float3 sh = lerp(float3(0.051, 0.0784, 0.118)*0.05, float3(0.03, 0.04, 0.05)*0.2, x1);
  1401. sh = lerp(sh, float3(0.157, 0.165, 0.216)*0.6, x2);
  1402. sh = lerp(sh, float3(0.157, 0.165, 0.216), x3);
  1403. sh = lerp(sh, float3(0.157, 0.165, 0.216), x4);
  1404. sh = lerp(sh, float3(0.392, 0.392, 0.392), xE);
  1405. sh = lerp(sh, float3(0.392, 0.392, 0.392), x5);
  1406. sh = lerp(sh, float3(0.157, 0.165, 0.216), x6);
  1407. sh = lerp(sh, float3(0.157, 0.165, 0.216), x7);
  1408. sh = lerp(sh, float3(0.157, 0.165, 0.216), xG);
  1409. sh = lerp(sh, float3(0.157, 0.165, 0.216)*0.6, xZ);
  1410. sh = lerp(sh, float3(0.157, 0.165, 0.216)*0.4, x8);
  1411. sh = lerp(sh, float3(0.051, 0.0784, 0.118)*0.05, x9);
  1412.  
  1413. float3 fmix = lerp(0.02, 0.1, x1);
  1414. fmix = lerp(fmix, 0.1, x2);
  1415. fmix = lerp(fmix, 0.2, x3);
  1416. fmix = lerp(fmix, 0.5, x4);
  1417. fmix = lerp(fmix, 0.5, xE);
  1418. fmix = lerp(fmix, 0.5, x5);
  1419. fmix = lerp(fmix, 0.3, x6);
  1420. fmix = lerp(fmix, 0.2, x7);
  1421. fmix = lerp(fmix, 0.1, xG);
  1422. fmix = lerp(fmix, 0.05, xZ);
  1423. fmix = lerp(fmix, 0.03, x8);
  1424. fmix = lerp(fmix, 0.02, x9);
  1425.  
  1426. float3 fmix2 = lerp(0.01, 0.1, x1);
  1427. fmix2 = lerp(fmix2, 0.05, x2);
  1428. fmix2 = lerp(fmix2, 0.1, x3);
  1429. fmix2 = lerp(fmix2, 0.2, x4);
  1430. fmix2 = lerp(fmix2, 0.2, xE);
  1431. fmix2 = lerp(fmix2, 0.2, x5);
  1432. fmix2 = lerp(fmix2, 0.1, x6);
  1433. fmix2 = lerp(fmix2, 0.08, x7);
  1434. fmix2 = lerp(fmix2, 0.05, xG);
  1435. fmix2 = lerp(fmix2, 0.03, xZ);
  1436. fmix2 = lerp(fmix2, 0.02, x8);
  1437. fmix2 = lerp(fmix2, 0.01, x9);
  1438.  
  1439. float3 ColorSun = lerp(float3(0.0392, 0.0588, 0.0784)*0.2, float3(0.05, 0.04, 0.02)*0.0, x1);
  1440. ColorSun = lerp(ColorSun, float3(0.40, 0.08, 0.0)*0.8, x2);
  1441. ColorSun = lerp(ColorSun, float3(0.45, 0.07, 0.0), x3);
  1442. ColorSun = lerp(ColorSun, float3(0.392, 0.118, 0.0588), x4);
  1443. ColorSun = lerp(ColorSun, float3(0.392, 0.275, 0.118), xE);
  1444. ColorSun = lerp(ColorSun, float3(0.392, 0.275, 0.118), x5);
  1445. ColorSun = lerp(ColorSun, float3(0.392, 0.08, 0.0), x6);
  1446. ColorSun = lerp(ColorSun, float3(0.392, 0.08, 0.0), x7);
  1447. ColorSun = lerp(ColorSun, float3(0.392, 0.118, 0.0588), xG);
  1448. ColorSun = lerp(ColorSun, float3(0.392, 0.118, 0.0588)*0.4, xZ);
  1449. ColorSun = lerp(ColorSun, float3(0.392, 0.118, 0.0588)*0.2, x8);
  1450. ColorSun = lerp(ColorSun, float3(0.0392, 0.0588, 0.0784)*0.2, x9);
  1451.  
  1452. float3 SunCurrent;
  1453. float3 SunNext;
  1454.  
  1455. float3 m0 = float3(min(1.0, d0), min(1.0, d0), min(1.0, d0));
  1456. float3 color = lerp((pow(sunlight, 0.3)*ColorSun*50.0)+lt*2.0, sh, m0);
  1457. float3 colorPasm = lerp(fmix, fmix2, m0);
  1458.  
  1459. if (wx.x==0,1) SunCurrent = color;
  1460. if (wx.y==0,1) SunNext = color;
  1461.  
  1462. if (wx.x==4) SunCurrent = colorPasm;
  1463. if (wx.x==7) SunCurrent = colorPasm;
  1464. if (wx.x==8) SunCurrent = colorPasm;
  1465. if (wx.x==9) SunCurrent = colorPasm;
  1466. if (wx.x==12) SunCurrent = colorPasm;
  1467. if (wx.x==15) SunCurrent = colorPasm;
  1468. if (wx.x==16) SunCurrent = colorPasm;
  1469.  
  1470. if (wx.y==4) SunNext = colorPasm;
  1471. if (wx.y==7) SunNext = colorPasm;
  1472. if (wx.y==8) SunNext = colorPasm;
  1473. if (wx.y==9) SunNext = colorPasm;
  1474. if (wx.y==12) SunNext = colorPasm;
  1475. if (wx.y==15) SunNext = colorPasm;
  1476. if (wx.y==16) SunNext = colorPasm;
  1477.  
  1478. float3 wmix = lerp(SunCurrent, SunNext, wx.z);
  1479.  
  1480. float4 r0 = float4(wmix.rgb, (noise*noise*noise));
  1481. return r0;
  1482. }
  1483.  
  1484. float IntersectPlane(float3 pos, float3 dir)
  1485. {
  1486. return -pos.z/dir.z;
  1487. }
  1488.  
  1489. float Stars_Brightness
  1490. <
  1491. string UIName="Stars - Brightness";
  1492. string UIWidget="Spinner";
  1493. float UIMin=0.0;
  1494. float UIMax=5.0;
  1495. > = {1.00};
  1496.  
  1497. float starscover
  1498. <
  1499. string UIName="Stars - Size";
  1500. string UIWidget="Spinner";
  1501. float UIMin=0.0;
  1502. float UIMax=0.20;
  1503. > = {0.05};
  1504.  
  1505. float Stars(in float2 coord)
  1506. {
  1507. //float t = (Timer.x * 10.0) * 0.25;
  1508. float2 uv = coord.xy;
  1509. float2 p = (uv) / (starscover*2.0);
  1510. float fstars = tex2Dlod(SamplerStars, float4(p, 0.0, 0.0));
  1511. return fstars;
  1512. }
  1513.  
  1514. float Moon(in float2 coord)
  1515. {
  1516. float2 uv = coord.xy + 0.1 * 1.5;
  1517. float2 p = (uv + 0.5) / (-3.25*2.0);
  1518. float fmoon = tex2Dlod(SamplerMoon, float4(p, 0.0, 0.0));
  1519. return fmoon*1.5;
  1520. }
  1521.  
  1522.  
  1523. ////////////////////////////////////////////////////////////////////////////////////
  1524. /////////////////////////////////////SA_DirectX/////////////////////////////////////
  1525. ////////////////////////////////////////////////////////////////////////////////////
  1526. float4 PS_DX1(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
  1527. {
  1528. float t = GameTime;
  1529. float tf = CalculateGameTime(t);
  1530. float tf2 = CalculateGameTime0(t);
  1531.  
  1532. float2 coord = IN.txcoord.xy;
  1533. float4 r0 = tex2D(SamplerColor, coord.xy);
  1534. float d0 = tex2D(SamplerDepth, coord.xy).x;
  1535. float4 wpos = WorldPos(coord);
  1536. float3 colorS = ColorTop();
  1537. //Sky------------------------------------------------------------------------------
  1538. float4 w0 = wpos+CameraPosition;
  1539. float4 cam = CameraPosition;
  1540. float p2 = length(wpos.xyz);
  1541. float3 dp = -1.0/exp(length(0.0-p2)/250.0);
  1542. float fog = pow(tex2D(SamplerDepth, coord).x, 117000.0);
  1543. fog = lerp(1.0, fog, dp);
  1544. float4 f0 = pow(fog.x, -1000.0);
  1545. f0.a = min(1.0, f0.a);
  1546. float4 np0 = float4(normalize(wpos.xyz), 1.0);
  1547. np0.xyz = normalize(w0.xyz-float3(cam.xy, 0.0));
  1548.  
  1549. float3 vec = normalize(float3(0.0, 0.0, 1.0));
  1550. float3 hv = normalize(-vec+np0);
  1551. float sgf = dot(hv, np0);
  1552.  
  1553. if (dot(hv, np0) > 0.75*0.95)
  1554. sgf = (1.5*0.95) - sgf;
  1555. float curve = 8.0*0.85;
  1556. sgf = pow(sgf, curve);
  1557.  
  1558. float3 d1 = float3(1.0, 1.0, 1.0);
  1559. d1 = CL(d1) * colorS;
  1560. d1 *= (sgf * (20.0*1.4)) + 0.85;
  1561.  
  1562. float3 sun = CalculateSun(coord);
  1563. float3 d2 = ColorHorizon(d1, sgf);
  1564.  
  1565. d1 = d2;
  1566. d1*= lerp(0.0, 1.0, tf);
  1567. d1.xyz+=0.000001;
  1568. float3 n0 = normalize(d1.xyz);
  1569. float3 ct0=d1.xyz/n0.xyz;
  1570. ct0=pow(ct0, Sky_Contrast);
  1571. n0.xyz = pow(n0.xyz, Sky_Saturate);
  1572. d1.xyz = ct0*n0.xyz;
  1573. d1.xyz*= Sky_Brightness;
  1574.  
  1575. float np4 = (np0.z * (2.0)) + 0.40;
  1576. np4 *= lerp(0.0, 1.0, tf2);
  1577. float3 a = d1+sun;
  1578. float3 a2 = np4;
  1579. float3 sc = 1.0;
  1580. float3 sn = 1.0;
  1581. float4 wx = WeatherAndTime;
  1582. if (wx.x==0,1) sc = a;
  1583. if (wx.y==0,1) sn = a;
  1584. if (wx.x==4) sc = a2;
  1585. if (wx.x==7) sc = a2;
  1586. if (wx.x==8) sc = a2;
  1587. if (wx.x==9) sc = a2;
  1588. if (wx.x==12) sc = a2;
  1589. if (wx.x==15) sc = a2;
  1590. if (wx.x==16) sc = a2;
  1591. if (wx.y==4) sn = a2;
  1592. if (wx.y==7) sn = a2;
  1593. if (wx.y==8) sn = a2;
  1594. if (wx.y==9) sn = a2;
  1595. if (wx.y==12) sn = a2;
  1596. if (wx.y==15) sn = a2;
  1597. if (wx.y==16) sn = a2;
  1598. float3 wmix0 = lerp(sc, sn, wx.z);
  1599. r0.xyz = lerp(r0, wmix0, f0);
  1600. float4 worldpos = GWP(coord, d0);
  1601. float L = worldpos.xyz;
  1602. //NightSky-------------------------------------------------------------------------
  1603. float sm1 = smoothstep(0.0, 4.0, t),
  1604. sm2 = smoothstep(4.0, 5.0, t),
  1605. sm3 = smoothstep(5.0, 6.0, t),
  1606. sm4 = smoothstep(6.0, 23.0, t),
  1607. sm5 = smoothstep(23.0, 24.0, t);
  1608. float3 ti = lerp(1.0, 1.0, sm1);
  1609. ti = lerp(ti, 0.3, sm2);
  1610. ti = lerp(ti, 0.0, sm3);
  1611. ti = lerp(ti, 0.0, sm4);
  1612. ti = lerp(ti, 1.0, sm5);
  1613. float3 p0 = (MatrixInverseVP[3].xyz/MatrixInverseVP[3].w);
  1614. float3 ns0 = normalize(worldpos.xzy);
  1615. float3 ns1 = normalize(worldpos.xyz);
  1616. ns1.z = abs(ns1.z)*1.40;
  1617. float3x3 vec0 = float3x3(1, 0, 0, 0, cos(2.91), sin(2.91), 0, -sin(2.91), cos(2.91));
  1618. ns0 = mul(ns0, vec0);
  1619. float3 np1 = normalize(ns0);
  1620. float3 np2 = normalize(-p0+ns1);
  1621. float4 np3 = float4(normalize(worldpos.xyz), 1.0);
  1622. if( 10000 < L || d0 == 1)
  1623. {
  1624. float4 s0 = Stars(np2 * 0.5 + 0.5)*3.2*Stars_Brightness;
  1625. s0*= step(0.3, s0);
  1626. s0*= smoothstep(0.0, 0.3, np3.z);
  1627. s0*= saturate(1.0 - dot(r0.xyz, 4.0));
  1628. s0.a = min(1.0, ti*s0.a);
  1629. r0.xyz = lerp(r0, s0.xyz, s0.a);
  1630. }
  1631. if( 6000 < L || d0 == 1)
  1632. {
  1633. float4 m0 = Moon(np1*47.5)*0.78;
  1634. m0*= smoothstep(0.0, 0.3, -np3.y);
  1635. m0.a = min(1.0, ti*m0.a);
  1636. r0.xyz = lerp(r0, 1.5*m0.xyz, m0.a);
  1637. }
  1638. //Clouds---------------------------------------------------------------------------
  1639. float d3 = pow(tex2D(SamplerDepth, coord).x, 17000.0);
  1640. float3 sc0 = SunLight(coord, d3);
  1641. float3 w1 = float3(1.0, 1.0, 10.0);
  1642. float4 ns = float4(normalize(worldpos.xyz), 1.0);
  1643. float ip = IntersectPlane(w1, ns.xyz);
  1644. float4 r1 = r0;
  1645. if (ip <= 1.0)
  1646. if( 10000.0 < L || d0 == 1)
  1647. {
  1648. float4 c0 = GenerateClouds(float4((ns.xyz*ip*5.0), 1.0), sc0);
  1649. c0.a = min(1.0, c0.a);
  1650. r1.xyz = lerp(r0, c0.rgb*3.0, c0.a);
  1651. }
  1652. r0.xyz = lerp(r0, r1, smoothstep(0.0, 0.10, pow(ns.z, 1.85)));
  1653. //---------------------------------------------------------------------------------
  1654. return r0;
  1655. }
  1656.  
  1657. ////////////////////////////////////////////////////////////////////////////////////
  1658. /////////////////////////////////////SA_DirectX/////////////////////////////////////
  1659. ////////////////////////////////////////////////////////////////////////////////////
  1660.  
  1661. float Rain0(in float2 cd)
  1662. {
  1663. float2 uv = cd.yx;
  1664. float2 p = uv/40.0;
  1665. float r = tex2Dlod(SamplerRain2, float4(p*float2(10.0, 2.0), 0.0, 0.0)).y;
  1666. return r;
  1667. }
  1668.  
  1669. float Rain1(in float2 cd)
  1670. {
  1671. float2 uv = cd.yx;
  1672. float2 p = uv/1.2;
  1673. float r = tex2Dlod(SamplerRain, float4(p*float2(3.5, 0.3), 0.0, 0.0)).y;
  1674. return r;
  1675. }
  1676.  
  1677. float Rain2(in float2 cd)
  1678. {
  1679. float2 uv = cd.yx;
  1680. float2 p = uv/0.5;
  1681. float r = tex2Dlod(SamplerRain, float4(p*float2(3.0, 0.5), 0.0, 0.0)).y;
  1682. float r2 = tex2Dlod(SamplerRain2, float4(p*float2(2.0, 0.5), 0.0, 0.0)).y;
  1683. float j = (r+r2);
  1684. return j;
  1685. }
  1686.  
  1687. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1688. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1689.  
  1690. float3 ComputeRipple(float2 uv, float CurrentTime, float Weight)
  1691. {
  1692. //https://seblagarde.wordpress.com/2013/01/03/water-drop-2b-dynamic-rain-and-its-effects/
  1693. float4 rp = tex2Dlod(SamplerWrp, float4(uv, 0.0, 0.0))*1.4;
  1694. rp.yz = rp.yz * 2.0-1.0;
  1695. float a0 = tex2Dlod(SamplerAlpha, float4(uv, 0.0, 0.0))*1.4;
  1696. float a1 = tex2Dlod(SamplerAlpha2, float4(uv, 0.0, 0.0))*1.4;
  1697.  
  1698. float4 rp3 = lerp(0.0, rp, a0);
  1699.  
  1700. float4 wx = WeatherAndTime;
  1701. float wc;
  1702. float wn;
  1703. if (wx.x==0,1) wc = 0.0;
  1704. if (wx.y==0,1) wn = 0.0;
  1705. if (wx.x==8) wc = 2.0;
  1706. if (wx.x==16) wc = 2.0;
  1707. if (wx.y==8) wn = 2.0;
  1708. if (wx.y==16) wn = 2.0;
  1709. float rp0 = lerp(wc, wn, pow(wx.z, 0.5));
  1710. float DropFrac = frac(rp3.w+CurrentTime);
  1711. float TimeFrac = DropFrac - 1.0 + rp3.x;
  1712. float DropFactor = saturate(0.20 + Weight * 0.80 - DropFrac);
  1713. float PI = 3.14159265359;
  1714. float FF = DropFactor*rp3.x * sin(clamp(TimeFrac * 12.0, 0.0, 5.0) * PI);
  1715.  
  1716. float3 cpl = lerp(0.0, float3(rp3.yz*FF*rp0, 1.0), a1);
  1717. return cpl;
  1718. }
  1719.  
  1720. float3 CR(float3 n, float3 uv)
  1721. {
  1722. float Tr = Timer.x * 14000.0;
  1723. float4 TimeMul = float4(0.6, 0.7, 0.8, 1.0);
  1724. float4 TimeAdd = float4(0.22, 0.44, 0.66, 0.9);
  1725. float4 Times = (Tr * TimeMul + TimeAdd) * 2.4;
  1726. Times = frac(Times);
  1727. float4 Weights = 1.0 - float4(0, 0.25, 0.5, 0.75);
  1728. Weights = saturate(Weights * 4.0);
  1729. float3 Ripple1 = ComputeRipple(uv * 0.18 + float2(0.25, 0.0), Times.x, Weights.x);
  1730. float3 Ripple2 = ComputeRipple(uv * 0.25 + float2(-0.55, 0.3), Times.y, Weights.y);
  1731. float3 Ripple3 = ComputeRipple(uv * 0.28 + float2(0.6, 0.85), Times.z, Weights.z);
  1732. float3 Ripple4 = ComputeRipple(uv * 0.30 + float2(0.5, -0.75), Times.w, Weights.w);
  1733. float3 Ripple5 = ComputeRipple(uv * 0.32 + float2(0.3, -0.42), Times.w, Weights.w);
  1734. float3 Ripple6 = ComputeRipple(uv * 0.20 + float2(0.35, 0.1), Times.x, Weights.x);
  1735. n=normalize(float3(n.xy+Ripple1.xy,n.z));
  1736. n=normalize(float3(n.xy+Ripple2.xy,n.z));
  1737. n=normalize(float3(n.xy+Ripple3.xy,n.z));
  1738. n=normalize(float3(n.xy+Ripple4.xy,n.z));
  1739. n=normalize(float3(n.xy+Ripple5.xy,n.z));
  1740. n=normalize(float3(n.xy+Ripple6.xy,n.z));
  1741. return n;
  1742. }
  1743.  
  1744. float3 ComputeRelief(float2 uv, float CurrentTime, float3 Weight)
  1745. {
  1746. float tx = (Timer.x * 1000.0) * 1.05;
  1747. float4 rf = tex2Dlod(SamplerWrl, float4(uv.xy + float2(0.5, 0.5*tx), 0.0, 0.0));
  1748. rf.yz = rf.yz * 2.0-1.0;
  1749. float RelfSt = step(0.2, rf.a);
  1750. float DropFrac = frac(rf.w+CurrentTime);
  1751. float3 DropFactor = saturate(0.2 + Weight * 0.8 - DropFrac);
  1752. float3 FF = DropFactor * rf.x*RelfSt;
  1753. return float3(rf.yz*FF, 1.0);
  1754. }
  1755.  
  1756. float3 PR(float3 n, float3 uv)
  1757. {
  1758. float4 t = 1.99;
  1759. float3 w = float3(1.2, 1.2, 1.2);
  1760. float tx = (Timer.x * 1000.0) * 1.05;
  1761. float3 Relief1 = ComputeRelief(uv * 0.05 + float2(0.55, 0.89), t.x, w);
  1762. float3 Relief2 = ComputeRelief(uv * 0.25 + float2(0.22, 0.33)*tx, t.x, w);
  1763. n=normalize(float3(n.xy+Relief1.xy,n.z));
  1764. n=normalize(float3(n.xy+Relief2.xy,n.z));
  1765. return n;
  1766. }
  1767.  
  1768. bool Puddles_alltime
  1769. <
  1770. string UIName="Puddles_alltime";
  1771. > = {true};
  1772.  
  1773. float Puddles_alltime_coverage
  1774. <
  1775. string UIName="Puddles_alltime - coverage";
  1776. string UIWidget="Spinner";
  1777. float UIMin=0.0;
  1778. float UIMax=2.0;
  1779. > = {0.65};
  1780.  
  1781. ////////////////////////////////////////////////////////////////////////////////////
  1782. /////////////////////////////////////SA_DirectX/////////////////////////////////////
  1783. ////////////////////////////////////////////////////////////////////////////////////
  1784.  
  1785. float Lightning(in float2 coord)
  1786. {
  1787. float2 uv = coord.xy + 0.1 * 1.5;
  1788. float2 p = (uv + 0.5) / (-3.25*2.0);
  1789. float fl0 = tex2Dlod(SamplerLightning, float4(p, 0.0, 0.0));
  1790. float fl1 = tex2Dlod(SamplerLightning2, float4(p, 0.0, 0.0));
  1791. float ti = max(sin(Timer.x*100000.0*2.0),0);
  1792. float mix = lerp(fl0, fl1, ti);
  1793. return mix*1.5;
  1794. }
  1795.  
  1796. float Lightning2(in float2 coord, float v1, float v2)
  1797. {
  1798. float2 uv = coord.xy + 0.1 * 1.5;
  1799. float2 p = (float2(v1, v2)+ uv + 0.5) / (-3.25*2.0);
  1800. float fl0 = tex2Dlod(SamplerLightning, float4(p, 0.0, 0.0));
  1801. float fl1 = tex2Dlod(SamplerLightning2, float4(p, 0.0, 0.0));
  1802. float ti = max(sin(Timer.x*100000.0*2.0),0);
  1803. float mix = lerp(fl0, fl1, ti);
  1804. return mix*1.5;
  1805. }
  1806.  
  1807. float4 PS_DX2(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
  1808. {
  1809. float4 r0 = tex2D(SamplerColor, IN.txcoord.xy);
  1810. float4 r1 = r0;
  1811. float2 cd = IN.txcoord.xy;
  1812. float d0 = tex2D(SamplerDepth, IN.txcoord.xy).x;
  1813. float d1 = linearlizeDepth(tex2D(SamplerDepth, IN.txcoord.xy).x)*1.0;
  1814. float4 tv0;
  1815. float4 wpos;
  1816. tv0.xy = IN.txcoord.xy*2.0-1.0;
  1817. tv0.y =-tv0.y;
  1818. tv0.z = d0;
  1819. tv0.w = 1.0;
  1820. wpos.x = dot(tv0, MatrixInverseVPRotation[0]);
  1821. wpos.y = dot(tv0, MatrixInverseVPRotation[1]);
  1822. wpos.z = dot(tv0, MatrixInverseVPRotation[2]);
  1823. wpos.w = dot(tv0, MatrixInverseVPRotation[3]);
  1824. wpos.xyz/= wpos.w;
  1825. float4 npos;
  1826. float4 n0 = tex2D(SamplerNormal, IN.txcoord.xy)*2.0-1.0;
  1827. float4 tv1;
  1828. tv1.xy = n0.xy;
  1829. tv1.x = -tv1.x;
  1830. tv1.z = n0.z;
  1831. npos.x = dot(tv1.xyz, MatrixInverseView[0]);
  1832. npos.y = dot(tv1.xyz, MatrixInverseView[1]);
  1833. npos.z = dot(tv1.xyz, MatrixInverseView[2]);
  1834. float3 n2 = normalize(npos.xyz);
  1835. n2 = CR(n2.xyz, wpos+CameraPosition);
  1836. n2 = PR(n2.xyz, wpos+CameraPosition);
  1837. float3 vp = float3(0.0, 0.0, 1.03);
  1838. float4 wc = wpd0(cd, d0);
  1839. float rx = tex2Dlod(SamplerPuddle, float4(wc.xy*0.012, 0.0, 0.0));
  1840. float t = GameTime;
  1841. float x1 = smoothstep(0.0, 4.0, t);
  1842. float x2 = smoothstep(4.0, 5.0, t);
  1843. float x3 = smoothstep(5.0, 6.0, t);
  1844. float x4 = smoothstep(6.0, 7.0, t);
  1845. float xE = smoothstep(8.0, 11.0, t);
  1846. float x5 = smoothstep(16.0, 17.0, t);
  1847. float x6 = smoothstep(18.0, 19.0, t);
  1848. float x7 = smoothstep(19.0, 20.0, t);
  1849. float xG = smoothstep(20.0, 21.0, t);
  1850. float xZ = smoothstep(21.0, 22.0, t);
  1851. float x8 = smoothstep(22.0, 23.0, t);
  1852. float x9 = smoothstep(23.0, 24.0, t);
  1853. float rc;
  1854. float rn;
  1855. float4 Wx = WeatherAndTime;
  1856. if (Wx.x==0,1) rc = 2.0;
  1857. if (Wx.y==0,1) rn = 2.0;
  1858. if (Wx.x==8) rc = 0.2;
  1859. if (Wx.y==8) rn = 0.2;
  1860. if (Wx.x==16) rc = 0.2;
  1861. if (Wx.y==16) rn = 0.2;
  1862. float wmix1 = lerp(rc, rn, pow(Wx.z, 8.5));
  1863. float coverage = lerp(wmix1, Puddles_alltime_coverage, Puddles_alltime);
  1864. coverage = lerp(coverage, 0.87, 2.0);
  1865. float density = 0.1 - 2.0 * 0.3;
  1866. rx = Coverage(coverage, density, rx);
  1867. float rh = smoothstep(0.999, 1.0, dot(-vp, -fs0(cd)));
  1868. float4 rx2 = rx;
  1869. rx2.a = min(1.0, rx2.a);
  1870. float4 skyenv=tex2D(SamplerEnv, cd);
  1871. float3 ssr = skyenv;
  1872. float4 rfl = reflection(n2.xyz, IN.txcoord.xy);
  1873. rfl = (rfl * 1.05);
  1874. float3 wp0 = wpd1(cd.xy);
  1875. float3 p3 = float3(0.353, 0.353, 1.0);
  1876. n2 = (normalize(n2.xyz*p3)*0.98);
  1877. float3 nz = reflect(wp0.xyz, n2.xyz);
  1878. float3 rw = ((1000.0/0.01)*nz)/1000.0;
  1879. float3 ref11 = (wp0+rw);
  1880. float2 rd = wpd2(ref11.xyz);
  1881. float nf0 = saturate(8.0*(rd.y));
  1882. nf0 = pow(nf0, 1.5);
  1883. ssr=lerp(ssr, rfl.xyz, rfl.w*nf0);
  1884. float4 n1 = tex2D(SamplerNormal, IN.txcoord.xy);
  1885. float rmix;
  1886. rmix=saturate(n1.z)*saturate(n1.z);
  1887. rmix*=rmix;
  1888. ssr.xyz=lerp(ssr, skyenv, rmix);
  1889. ssr.xyz=lerp(ssr, r0*0.15, pow(rmix, 1.2));
  1890. float wcr;
  1891. float wnr;
  1892. if (Wx.x==0,1) wcr = 0.0;
  1893. if (Wx.y==0,1) wnr = 0.0;
  1894. if (Wx.x==8) wcr = 1.0;
  1895. if (Wx.x==16) wcr = 1.0;
  1896. if (Wx.y==8) wnr = 1.0;
  1897. if (Wx.y==16) wnr = 1.0;
  1898. float wmix = lerp(wcr, wnr, pow(Wx.z, 0.07));
  1899. float4 nw = tex2D(SamplerNormal, IN.txcoord.xy).w;
  1900. if (nw.w<1.0) nw = 0.0;
  1901.  
  1902. float3 n3 = CR(float3(0.0, 1.0, 1.0), wpos+CameraPosition);
  1903. float3 sv = normalize(float3(0.0, 0.0, 1.0));
  1904. float t1 = lerp(0.04, 0.04, x1);
  1905. t1 = lerp(t1, 0.04, x2);
  1906. t1 = lerp(t1, 0.09, x3);
  1907. t1 = lerp(t1, 0.09, x4);
  1908. t1 = lerp(t1, 0.09, xE);
  1909. t1 = lerp(t1, 0.09, x5);
  1910. t1 = lerp(t1, 0.09, x6);
  1911. t1 = lerp(t1, 0.08, x7);
  1912. t1 = lerp(t1, 0.07, xG);
  1913. t1 = lerp(t1, 0.06, xZ);
  1914. t1 = lerp(t1, 0.05, x8);
  1915. t1 = lerp(t1, 0.04, x9);
  1916. t1*= 1.1;
  1917. float factor = t1 - dot(sv, n2);
  1918. factor = pow(factor, 12.0);
  1919. float fr = (factor*factor);
  1920. fr/= 4.5;
  1921. float n6 = saturate(n3);
  1922. float lp = lerp(0.0, fr, n6);
  1923.  
  1924. if(d1 < 3000)r0.xyz = lerp(r0, 0.75*ssr+lp, nw*rh*rx2*1.0);
  1925. float4 rp = float4(normalize(wpos.xyz), 1.0);
  1926. float3 rpos = normalize(rp.xyz)*1.0;
  1927. float3x3 vec = float3x3(1,0,0,0,cos(0.25),sin(0.25),0,-sin(0.25),cos(0.25));
  1928. rpos = mul(rpos, vec);
  1929. float2 f0=float2(acos(rpos.z),atan(rpos.x/rpos.y));
  1930. float2 RainTimer = float2(Timer.x*31000.0, 0.0);
  1931. float4 raindx2 = Rain2(-f0.xy+RainTimer*0.7);
  1932. float4 raindx1 = Rain1(-f0.xy+RainTimer*1.0);
  1933. float4 raindx0 = Rain0(-f0.xy+RainTimer*2.9);
  1934. float a0 = smoothstep(1.0, 0.90, abs(rpos.z));
  1935. float pow2 = length(wpos.xyz);
  1936. float distance = 0.0;
  1937. float3 rd0 = 1.0-1.0/exp(length(distance-pow2)/0.1);
  1938. float3 rd1 = 1.0-1.0/exp(length(distance-pow2)/8.0);
  1939. float3 rd2 = 1.0-1.0/exp(length(distance-pow2)/95.0);
  1940. float3 dr0 = step(0.15, rd0*raindx0);
  1941. float3 dr1 = step(0.1, rd1*raindx1);
  1942. float3 dr2 = step(0.1, rd2*raindx2);
  1943. float4 rn0 = tex2Dlod(SamplerColor, float4(IN.txcoord.xy+raindx2*float2(0.0, -0.10), 0.0, 4.0));
  1944. rn0*= 0.63;
  1945. float4 rn1 = tex2Dlod(SamplerColor, float4(IN.txcoord.xy+raindx1*float2(0.0, -0.13), 0.0, 4.0));
  1946. rn1*= 0.63;
  1947. float4 rn2 = tex2Dlod(SamplerColor, float4(IN.txcoord.xy+raindx0*float2(0.0, -0.15), 0.0, 4.0));
  1948. rn2*= 0.63;
  1949. rn0.a = min(0.9, rn0.a);
  1950. rn1.a = min(0.9, rn1.a);
  1951. rn2.a = min(0.9, rn2.a);
  1952. float t2 = lerp(0.0, 0.0, x1);
  1953. t2 = lerp(t2, 0.10, x2);
  1954. t2 = lerp(t2, 0.20, x3);
  1955. t2 = lerp(t2, 0.25, x4);
  1956. t2 = lerp(t2, 0.25, xE);
  1957. t2 = lerp(t2, 0.25, x5);
  1958. t2 = lerp(t2, 0.25, x6);
  1959. t2 = lerp(t2, 0.15, x7);
  1960. t2 = lerp(t2, 0.12, xG);
  1961. t2 = lerp(t2, 0.10, xZ);
  1962. t2 = lerp(t2, 0.10, x8);
  1963. t2 = lerp(t2, 0.07, x9);
  1964. r0.xyz = lerp(r0, 1.05*rn0+t2, wmix*dr2*a0*rn0.a);
  1965. r0.xyz = lerp(r0, 1.07*rn1+t2, wmix*dr1*a0*rn1.a);
  1966. r0.xyz = lerp(r0, 1.09*rn2+t2, wmix*dr0*a0*rn2.a);
  1967. float wc1;
  1968. float wn1;
  1969. if (Wx.x==0,1) wc1 = 0.0;
  1970. if (Wx.y==0,1) wn1 = 0.0;
  1971. if (Wx.x==8) wc1 = 1.0;
  1972. if (Wx.y==8) wn1 = 1.0;
  1973. if (Wx.x==16) wc1 = 1.0;
  1974. if (Wx.y==16) wn1 = 1.0;
  1975. float wmix2 = lerp(wc1, wn1, Wx.z);
  1976. float3 fx0 = FogFarColor;
  1977. float3 st3 = normalize(fx0.xyz);
  1978. float3 cs3=fx0.xyz/st3.xyz;
  1979. cs3=pow(cs3, 6.0);
  1980. fx0.xyz = cs3;
  1981. float fx = saturate(fx0);
  1982. float3 npos0 = normalize(wpos.xyz);
  1983.  
  1984. float vecx2 = 5.45;
  1985. float vecx3 = 3.85;
  1986. float vecx4 = 1.65;
  1987. float3 ns0 = normalize(wpos.xzy);
  1988. float3x3 vec0 = float3x3(1, 0, 0,
  1989. 0, cos(vecx2), sin(vecx2),
  1990. 0, -sin(vecx2), cos(vecx2));
  1991. ns0 = mul(ns0, vec0);
  1992. float3 np1 = normalize(ns0);
  1993.  
  1994. float3 ns1 = normalize(wpos.xyz);
  1995. float3 ns2 = normalize(wpos.xzy);
  1996. float3x3 vec1 = float3x3(1, 0, 0,
  1997. 0, cos(vecx3), sin(vecx3),
  1998. 0, -sin(vecx3), cos(vecx3));
  1999.  
  2000. float3x3 vec2 = float3x3(0, 0, 1,
  2001. cos(vecx4), sin(vecx4), 0,
  2002. -sin(vecx4), cos(vecx4), 0);
  2003. ns1 = mul(ns1, vec1);
  2004. ns2 = mul(ns2, vec2);
  2005.  
  2006. float3 np2 = normalize(ns1.xyz);
  2007. float3 np3 = normalize(ns2.xyz);
  2008. float4 fx2 = Lightning(np1*10.0)*3.0;
  2009. fx2*= smoothstep(0.0, 0.3, npos0.z);
  2010. float4 fx3 = Lightning(np2*10.0)*3.0;
  2011. fx3*= smoothstep(0.0, 0.3, npos0.z);
  2012. float4 fx4 = Lightning2(np3*10.0, -7.9, -7.3)*3.0;
  2013. float4 fx5 = Lightning2(np3*10.0, 1.0, -6.4)*3.0;
  2014.  
  2015. r0.xyz*= lerp(1.0, 1.8, wmix2*fx);
  2016. float L = wpos.xyz;
  2017.  
  2018. float ti = max(sin(Timer.x*100000.0*0.5),0);
  2019. float ti2 = max(sin(Timer.x*100000.0*1.0),0);
  2020. float3 mix0 = lerp(fx2, fx3, ti);
  2021. float3 mix1 = lerp(fx4, fx5, ti);
  2022.  
  2023. float3 mix2 = lerp(mix0, mix1, ti2);
  2024.  
  2025. if( 6000 < L || d0 == 1)
  2026. {
  2027. r0.xyz =lerp(r0, r0+mix2, wmix2*fx);
  2028. }
  2029.  
  2030. return r0;
  2031. }
  2032.  
  2033. ////////////////////////////////////////////////////////////////////////////////////
  2034. /////////////////////////////////////SA_DirectX/////////////////////////////////////
  2035. ////////////////////////////////////////////////////////////////////////////////////
  2036.  
  2037. technique PostProcess
  2038. {
  2039. pass P0
  2040. {
  2041. VertexShader = compile vs_3_0 VS_PostProcess();
  2042. PixelShader = compile ps_3_0 PS_DX0();
  2043. }
  2044. }
  2045.  
  2046. technique PostProcess2
  2047. {
  2048. pass P0
  2049. {
  2050. VertexShader = compile vs_3_0 VS_PostProcess();
  2051. PixelShader = compile ps_3_0 PS_DX1();
  2052. }
  2053. }
  2054.  
  2055. technique PostProcess3
  2056. {
  2057. pass P0
  2058. {
  2059. VertexShader = compile vs_3_0 VS_PostProcess();
  2060. PixelShader = compile ps_3_0 PS_DX2();
  2061. }
  2062. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement