Advertisement
Plr5000

Untitled

May 23rd, 2021
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.03 KB | None | 0 0
  1. //++++++++++++++++++++++++++++++++++++++++++++++++
  2. // Clouds from SA_DirectX 2.0
  3. // Copyright Boris Vorontsov / Maxim Dubinov (Makarus)
  4. // Editing and cloud settings by AP84
  5. //++++++++++++++++++++++++++++++++++++++++++++++++
  6.  
  7. float4 tempF1; float4 tempF2; float4 tempF3;
  8. float4 ScreenSize; float4 Timer;float ENightDayFactor;
  9. float4 SunDirection; float EInteriorFactor; float FadeFactor; float FieldOfView;
  10. float4 MatrixVP[4]; float4 MatrixInverseVP[4]; float4 MatrixVPRotation[4]; float4 MatrixInverseVPRotation[4];
  11. float4 MatrixView[4];float4 MatrixInverseView[4];float4 CameraPosition;float GameTime;float4 CustomShaderConstants1[8];
  12. float4 WeatherAndTime;float4x4 MatrixWVP;float4x4 MatrixWVPInverse;float4x4 MatrixWorld; float4x4 MatrixProj;float4 FogParam;float4 FogFarColor;
  13.  
  14. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
  15. //Textures
  16. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
  17.  
  18. texture2D texEnv;
  19. texture2D texOriginal;
  20. texture2D texColor;
  21. texture2D texDepth;
  22. texture2D texNoise;
  23. texture2D texNormal;
  24. texture2D texNs < string ResourceName="Noise.png"; >;
  25. texture2D texNs2 < string ResourceName="NoiseCd.png";>;
  26.  
  27. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
  28. //Sampler Inputs
  29. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
  30.  
  31. sampler2D SamplerEnv = sampler_state
  32. {
  33. Texture = <texEnv>;
  34. MinFilter = LINEAR;
  35. MagFilter = LINEAR;
  36. MipFilter = LINEAR;
  37. AddressU = Mirror;
  38. AddressV = Mirror;
  39. SRGBTexture=FALSE;
  40. MaxMipLevel=0;
  41. MipMapLodBias=0;
  42. };
  43.  
  44. sampler2D SamplerOriginal = sampler_state
  45. {
  46. Texture = <texOriginal>;
  47. MinFilter = LINEAR;
  48. MagFilter = LINEAR;
  49. MipFilter = LINEAR;//NONE;
  50. AddressU = Clamp;
  51. AddressV = Clamp;
  52. SRGBTexture=FALSE;
  53. MaxMipLevel=0;
  54. MipMapLodBias=0;
  55. };
  56.  
  57. sampler2D SamplerNormal = sampler_state
  58. {
  59. Texture = <texNormal>;
  60. MinFilter = Anisotropic;
  61. MagFilter = Anisotropic;
  62. MipFilter = LINEAR;
  63. AddressU = Wrap;
  64. AddressV = Wrap;
  65. SRGBTexture=FALSE;
  66. MaxMipLevel=0;
  67. MipMapLodBias=0;
  68. };
  69.  
  70. sampler2D SamplerColor = sampler_state
  71. {
  72. Texture = <texColor>;
  73. MinFilter = LINEAR;
  74. MagFilter = LINEAR;
  75. MipFilter = NONE;
  76. AddressU = Clamp;
  77. AddressV = Clamp;
  78. SRGBTexture=TRUE;
  79. MaxMipLevel=2;
  80. MipMapLodBias=0;
  81. };
  82.  
  83. sampler2D SamplerDepth = sampler_state
  84. {
  85. Texture = <texDepth>;
  86. MinFilter = LINEAR;
  87. MagFilter = LINEAR;
  88. MipFilter = LINEAR;
  89. AddressU = Wrap;
  90. AddressV = Wrap;
  91. AddressW = Wrap;
  92. SRGBTexture=TRUE;
  93. MaxMipLevel=1;
  94. MipMapLodBias=0;
  95. };
  96.  
  97. sampler2D SamplerNoise = sampler_state
  98. {
  99. Texture = <texNoise>;
  100. MinFilter = POINT;
  101. MagFilter = POINT;
  102. MipFilter = NONE;
  103. AddressU = Wrap;
  104. AddressV = Wrap;
  105. SRGBTexture=FALSE;
  106. MaxMipLevel=2;
  107. MipMapLodBias=0;
  108. };
  109.  
  110.  
  111. sampler2D SamplerNs = sampler_state
  112. {
  113. Texture = <texNs>;
  114. MinFilter = LINEAR;
  115. MagFilter = LINEAR;
  116. MipFilter = LINEAR;
  117. AddressU = Wrap;
  118. AddressV = Wrap;
  119. AddressW = Wrap;
  120. SRGBTexture=FALSE;
  121. MaxMipLevel=0;
  122. MipMapLodBias=0;
  123. };
  124.  
  125. sampler2D SamplerNs2 = sampler_state
  126. {
  127. Texture = <texNs2>;
  128. MinFilter = LINEAR;
  129. MagFilter = LINEAR;
  130. MipFilter = LINEAR;
  131. AddressU = Wrap;
  132. AddressV = Wrap;
  133. AddressW = Wrap;
  134. SRGBTexture=FALSE;
  135. MaxMipLevel=0;
  136. MipMapLodBias=0;
  137. };
  138.  
  139.  
  140. struct VS_OUTPUT_POST
  141. {
  142. float4 vpos : POSITION;
  143. float2 txcoord : TEXCOORD0;
  144. };
  145.  
  146. struct VS_INPUT_POST
  147. {
  148. float3 pos : POSITION;
  149. float2 txcoord : TEXCOORD0;
  150. };
  151.  
  152. ////////////////////////////////////////////////////////////////
  153. VS_OUTPUT_POST VS_PostProcess(VS_INPUT_POST IN)
  154. {
  155. VS_OUTPUT_POST OUT;
  156. float4 pos=float4(IN.pos.x,IN.pos.y,IN.pos.z,1.0);
  157. OUT.vpos=pos;
  158. OUT.txcoord.xy=IN.txcoord.xy;
  159. return OUT;
  160. }
  161.  
  162. ////////////////////////////////////////////////////////////////////////////////////
  163. /////////////////////////////////////SA_DirectX/////////////////////////////////////
  164. ////////////////////////////////////////////////////////////////////////////////////
  165.  
  166. float4 WorldPos(in float2 coord)
  167. {
  168. float d0 = tex2D(SamplerDepth, coord.xy).x;
  169. float4 tvec;
  170. tvec.xy = coord.xy*2.0-1.0;
  171. tvec.y = -tvec.y;
  172. tvec.z = d0;
  173. tvec.w = 1.0;
  174. float4 wpos;
  175. wpos.x = dot(tvec, MatrixInverseVPRotation[0]);
  176. wpos.y = dot(tvec, MatrixInverseVPRotation[1]);
  177. wpos.z = dot(tvec, MatrixInverseVPRotation[2]);
  178. wpos.w = dot(tvec, MatrixInverseVPRotation[3]);
  179. wpos.xyz/= wpos.w;
  180. return wpos;
  181. }
  182.  
  183. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  184.  
  185. float CalculateGameTime0(in float t)
  186. {
  187. float x1 = smoothstep(0.0, 4.0, t);
  188. float x2 = smoothstep(4.0, 5.0, t);
  189. float x3 = smoothstep(5.0, 6.0, t);
  190. float x4 = smoothstep(6.0, 7.0, t);
  191. float xE = smoothstep(8.0, 11.0, t);
  192. float x5 = smoothstep(16.0, 17.0, t);
  193. float x6 = smoothstep(18.0, 19.0, t);
  194. float x7 = smoothstep(19.0, 20.0, t);
  195. float xG = smoothstep(20.0, 21.0, t);
  196. float xZ = smoothstep(21.0, 22.0, t);
  197. float x8 = smoothstep(22.0, 23.0, t);
  198. float x9 = smoothstep(23.0, 24.0, t);
  199.  
  200. float3 t0 = lerp(0.0, 0.1, x1);
  201. t0 = lerp(t0, 0.2, x2);
  202. t0 = lerp(t0, 0.8, x3);
  203. t0 = lerp(t0, 0.9, x4);
  204. t0 = lerp(t0, 1.0, xE);
  205. t0 = lerp(t0, 1.0, x5);
  206. t0 = lerp(t0, 0.9, x6);
  207. t0 = lerp(t0, 0.5, x7);
  208. t0 = lerp(t0, 0.4, xG);
  209. t0 = lerp(t0, 0.3, xZ);
  210. t0 = lerp(t0, 0.2, x8);
  211. t0 = lerp(t0, 0.0, x9);
  212. return t0;
  213. }
  214.  
  215. float CalculateGameTime(in float t)
  216. {
  217. float x1 = smoothstep(0.0, 4.0, t);
  218. float x2 = smoothstep(4.0, 5.0, t);
  219. float x3 = smoothstep(5.0, 6.0, t);
  220. float x4 = smoothstep(6.0, 7.0, t);
  221. float xE = smoothstep(8.0, 11.0, t);
  222. float x5 = smoothstep(16.0, 17.0, t);
  223. float x6 = smoothstep(18.0, 19.0, t);
  224. float x7 = smoothstep(19.0, 20.0, t);
  225. float xG = smoothstep(20.0, 21.0, t);
  226. float xZ = smoothstep(21.0, 22.0, t);
  227. float x8 = smoothstep(22.0, 23.0, t);
  228. float x9 = smoothstep(23.0, 24.0, t);
  229.  
  230. float3 t0 = lerp(0.0, 0.1, x1);
  231. t0 = lerp(t0, 0.7, x2);
  232. t0 = lerp(t0, 1.0, x3);
  233. t0 = lerp(t0, 1.0, x4);
  234. t0 = lerp(t0, 1.0, xE);
  235. t0 = lerp(t0, 1.0, x5);
  236. t0 = lerp(t0, 0.9, x6);
  237. t0 = lerp(t0, 0.8, x7);
  238. t0 = lerp(t0, 0.6, xG);
  239. t0 = lerp(t0, 0.4, xZ);
  240. t0 = lerp(t0, 0.2, x8);
  241. t0 = lerp(t0, 0.0, x9);
  242. return t0;
  243. }
  244.  
  245. float Noise1(in float3 p)
  246. {
  247. float t = (Timer.x * 5.0) * 20.0;
  248. p.z += 0.5 * t;
  249. p.xyz += 1.0 * t;
  250. float2 uv = (p * float2(17.2, 17.2));
  251. float2 c = (uv + 0.5) / 20.0;
  252. float r0 = tex2Dlod(SamplerNs, float4(c*0.04, 0.0, 0.0)).x;
  253. return r0;
  254. }
  255.  
  256. float Noise2(in float3 p)
  257. {
  258. float t = (Timer.x * 20.0) * 20.0;
  259. p.z += 0.5 * t;
  260. p.xyz += 1.0 * t;
  261. float2 uv = (p * float2(17.2, 17.2));
  262. float2 c = (uv + 0.5) / 20.0;
  263. float r0 = tex2Dlod(SamplerNs2, float4(c*0.04, 0.0, 0.0)).x;
  264. return r0;
  265. }
  266.  
  267. float4 GWP(in float2 c, in float d)
  268. {
  269. float4 t;
  270. float4 w;
  271. t.xy=c.xy*2.0-1.0;
  272. t.y=-t.y;
  273. t.z=d;
  274. t.w=1.0;
  275. w.x=dot(t, MatrixInverseVPRotation[0]);
  276. w.y=dot(t, MatrixInverseVPRotation[1]);
  277. w.z=dot(t, MatrixInverseVPRotation[2]);
  278. w.w=dot(t, MatrixInverseVPRotation[3]);
  279. w.xyz/=w.w;
  280. //w.xyz+=CameraPosition;
  281. return w;
  282. }
  283.  
  284. float SunLight(in float2 c, in float d)
  285. {
  286. float3 v0=SunDirection.xyz;
  287. float3 v2=normalize(float3(-0.09, -0.94, 0.31));
  288. float t0 = GameTime;
  289. float x1 = smoothstep(0.0, 4.0, t0);
  290. float x2 = smoothstep(4.0, 23.0, t0);
  291. float x3 = smoothstep(23.0, 24.0, t0);
  292. float3 sv = lerp(v2, v0, x1);
  293. sv = lerp(sv, v0, x2);
  294. sv = lerp(sv, v2, x3);
  295. float4 WorldP = GWP(c, d);
  296. float c0 = 6.07;
  297. float3 np = normalize(WorldP.xyz);
  298. float f0 = 0.95 - dot(-sv, np);
  299. f0 = pow(f0, c0);
  300. float r0 = (f0*f0);
  301. return r0/40000.0;
  302. }
  303.  
  304. float Coverage(in float v, in float d, in float c)
  305. {
  306. c = clamp(c - (1.0 - v), 0.0, 1.0 - d)/(1.0 - d);
  307. c = max(0.0, c * 1.1 - 0.1);
  308. c = c = c * c * (3.0 - 2.0 * c);
  309. return c;
  310. }
  311.  
  312. float fcc
  313. <
  314. string UIName="Clouds - Coverage";
  315. string UIWidget="Spinner";
  316. float UIMin=0.0;
  317. float UIMax=0.55;
  318. > = {0.5};
  319.  
  320. float4 GenerateClouds(float4 worldpos, in float3 sunlight)
  321. {
  322. float t = (Timer.x * 1000.0)*20.0;
  323. float3 vecm = normalize(float3(-0.09, -0.94, 0.31));
  324. float3 sv0=-SunDirection.xyz;
  325. float3 sv2=-vecm;
  326.  
  327. float t0 = GameTime;
  328. float x1 = smoothstep(0.0, 4.0, t0);
  329. float x2 = smoothstep(4.0, 5.0, t0);
  330. float x3 = smoothstep(5.0, 6.0, t0);
  331. float x4 = smoothstep(6.0, 7.0, t0);
  332. float xE = smoothstep(8.0, 11.0, t0);
  333. float x5 = smoothstep(16.0, 17.0, t0);
  334. float x6 = smoothstep(18.0, 19.0, t0);
  335. float x7 = smoothstep(19.0, 20.0, t0);
  336. float xG = smoothstep(20.0, 21.0, t0);
  337. float xZ = smoothstep(21.0, 22.0, t0);
  338. float x8 = smoothstep(22.0, 23.0, t0);
  339. float x9 = smoothstep(23.0, 24.0, t0);
  340. float x10 = smoothstep(4.0, 23.0, t0);
  341. float x11 = smoothstep(23.0, 24.0, t0);
  342.  
  343. float3 sv = lerp(sv2, sv0, x1);
  344. sv = lerp(sv, sv0, x10);
  345. sv = lerp(sv, sv2, x11);
  346.  
  347. float3 wp = worldpos/1.5;
  348. wp.x *= 0.04;
  349. wp.y *= 0.10;
  350. wp.y -= t * 0.01;
  351. float3 wp1 = wp * float3(1.0, 0.5, 1.0) + float3(0.0, t * 0.01, 0.0);
  352.  
  353. float noise = Noise2(wp * float3(1.0, 0.5, 1.0) + float3(0.0, t * 0.01, 0.0));
  354. wp *= 3.0;
  355. wp.xy -= t * 0.04;
  356. wp.x += 2.0;
  357. float3 wp2 = wp;
  358.  
  359. noise += (2.0 - abs(Noise2(wp) * 0.8)) * 0.25;
  360. wp *= 10.0;
  361. wp.xy -= t * 0.035;
  362. float3 wp3 = wp;
  363.  
  364. noise += (2.0 - abs(Noise1(wp) * 1.0)) * 0.03;
  365. noise /= 0.80;
  366.  
  367. float4 wx = WeatherAndTime;
  368. float CovCurrent;
  369. float CovNext;
  370. if (wx.x==0,1) CovCurrent = fcc;
  371. if (wx.y==0,1) CovNext = fcc;
  372.  
  373. if (wx.x==0) CovCurrent = 0.00;
  374. if (wx.x==2) CovCurrent = 0.00;
  375. if (wx.x==6) CovCurrent = 0.00;
  376. if (wx.x==11) CovCurrent = 0.00;
  377. if (wx.x==13) CovCurrent = 0.00;
  378. if (wx.x==17) CovCurrent = 0.00;
  379.  
  380. if (wx.x==4) CovCurrent = 1.70;
  381. if (wx.x==7) CovCurrent = 1.70;
  382. if (wx.x==8) CovCurrent = 1.70;
  383. if (wx.x==9) CovCurrent = 1.70;
  384. if (wx.x==12) CovCurrent = 1.70;
  385. if (wx.x==15) CovCurrent = 1.70;
  386. if (wx.x==16) CovCurrent = 1.70;
  387.  
  388. if (wx.y==0) CovNext = 0.00;
  389. if (wx.y==2) CovNext = 0.00;
  390. if (wx.y==6) CovNext = 0.00;
  391. if (wx.y==11) CovNext = 0.00;
  392. if (wx.y==13) CovNext = 0.00;
  393. if (wx.y==17) CovNext = 0.00;
  394.  
  395. if (wx.y==4) CovNext = 1.70;
  396. if (wx.y==7) CovNext = 1.70;
  397. if (wx.y==8) CovNext = 1.70;
  398. if (wx.y==9) CovNext = 1.70;
  399. if (wx.y==12) CovNext = 1.70;
  400. if (wx.y==15) CovNext = 1.70;
  401. if (wx.y==16) CovNext = 1.70;
  402.  
  403. float3 wmix0 = lerp(CovCurrent, CovNext, pow(wx.z, 0.9));
  404.  
  405. float coverage = wmix0;
  406. float dn = 0.1 - 0.3 * 0.3;
  407. noise = Coverage(coverage, dn, noise);
  408.  
  409. float d0 = Noise2(wp1 + sv.xyz * 0.70 / 2.3);
  410. d0 += (2.0 - abs(Noise2(wp2 + sv.xyz * 0.70 / 2.3) * 0.8)) * 0.25;
  411. d0 += (2.0 - abs(Noise1(wp3 + sv.xyz * 0.70 / 2.3) * 1.0)) * 0.03;
  412. d0 = Coverage(0.84, dn, d0);
  413.  
  414. float bf = lerp(clamp(pow(noise, 0.5) * 0.5, 0.0, 1.0), 0.5, pow(sunlight, 1.0));
  415. d0 *= bf;
  416.  
  417. float3 lt = lerp(float3(0.0275, 0.0353, 0.0471), 0.01, x1);
  418. lt = lerp(lt, float3(1.0, 0.627, 0.235)*0.6, x2);
  419. lt = lerp(lt, float3(1.0, 0.627, 0.235), x3);
  420. lt = lerp(lt, float3(1.0, 0.627, 0.235), x4);
  421. lt = lerp(lt, float3(1.0, 1.0, 1.0), xE);
  422. lt = lerp(lt, float3(1.0, 1.0, 1.0), x5);
  423. lt = lerp(lt, float3(1.0, 0.627, 0.235), x6);
  424. lt = lerp(lt, float3(1.0, 0.627, 0.235), x7);
  425. lt = lerp(lt, 0.5, xG);
  426. lt = lerp(lt, 0.3, xZ);
  427. lt = lerp(lt, 0.1, x8);
  428. lt = lerp(lt, float3(0.0275, 0.0353, 0.0471), x9);
  429.  
  430. float3 sh = lerp(float3(0.051, 0.0784, 0.118)*0.05, float3(0.03, 0.04, 0.05)*0.2, x1);
  431. sh = lerp(sh, float3(0.157, 0.165, 0.216)*0.6, x2);
  432. sh = lerp(sh, float3(0.157, 0.165, 0.216), x3);
  433. sh = lerp(sh, float3(0.157, 0.165, 0.216), x4);
  434. sh = lerp(sh, float3(0.392, 0.392, 0.392), xE);
  435. sh = lerp(sh, float3(0.392, 0.392, 0.392), x5);
  436. sh = lerp(sh, float3(0.157, 0.165, 0.216), x6);
  437. sh = lerp(sh, float3(0.157, 0.165, 0.216), x7);
  438. sh = lerp(sh, float3(0.157, 0.165, 0.216), xG);
  439. sh = lerp(sh, float3(0.157, 0.165, 0.216)*0.6, xZ);
  440. sh = lerp(sh, float3(0.157, 0.165, 0.216)*0.4, x8);
  441. sh = lerp(sh, float3(0.051, 0.0784, 0.118)*0.05, x9);
  442.  
  443. float3 fmix = lerp(0.02, 0.1, x1);
  444. fmix = lerp(fmix, 0.1, x2);
  445. fmix = lerp(fmix, 0.2, x3);
  446. fmix = lerp(fmix, 0.5, x4);
  447. fmix = lerp(fmix, 0.5, xE);
  448. fmix = lerp(fmix, 0.5, x5);
  449. fmix = lerp(fmix, 0.3, x6);
  450. fmix = lerp(fmix, 0.2, x7);
  451. fmix = lerp(fmix, 0.1, xG);
  452. fmix = lerp(fmix, 0.05, xZ);
  453. fmix = lerp(fmix, 0.03, x8);
  454. fmix = lerp(fmix, 0.02, x9);
  455.  
  456. float3 fmix2 = lerp(0.01, 0.1, x1);
  457. fmix2 = lerp(fmix2, 0.05, x2);
  458. fmix2 = lerp(fmix2, 0.1, x3);
  459. fmix2 = lerp(fmix2, 0.2, x4);
  460. fmix2 = lerp(fmix2, 0.2, xE);
  461. fmix2 = lerp(fmix2, 0.2, x5);
  462. fmix2 = lerp(fmix2, 0.1, x6);
  463. fmix2 = lerp(fmix2, 0.08, x7);
  464. fmix2 = lerp(fmix2, 0.05, xG);
  465. fmix2 = lerp(fmix2, 0.03, xZ);
  466. fmix2 = lerp(fmix2, 0.02, x8);
  467. fmix2 = lerp(fmix2, 0.01, x9);
  468.  
  469. float3 ColorSun = lerp(float3(0.0392, 0.0588, 0.0784)*0.2, float3(0.05, 0.04, 0.02)*0.0, x1);
  470. ColorSun = lerp(ColorSun, float3(0.40, 0.08, 0.0)*0.8, x2);
  471. ColorSun = lerp(ColorSun, float3(0.45, 0.07, 0.0), x3);
  472. ColorSun = lerp(ColorSun, float3(0.392, 0.118, 0.0588), x4);
  473. ColorSun = lerp(ColorSun, float3(0.392, 0.275, 0.118), xE);
  474. ColorSun = lerp(ColorSun, float3(0.392, 0.275, 0.118), x5);
  475. ColorSun = lerp(ColorSun, float3(0.392, 0.08, 0.0), x6);
  476. ColorSun = lerp(ColorSun, float3(0.392, 0.08, 0.0), x7);
  477. ColorSun = lerp(ColorSun, float3(0.392, 0.118, 0.0588), xG);
  478. ColorSun = lerp(ColorSun, float3(0.392, 0.118, 0.0588)*0.4, xZ);
  479. ColorSun = lerp(ColorSun, float3(0.392, 0.118, 0.0588)*0.2, x8);
  480. ColorSun = lerp(ColorSun, float3(0.0392, 0.0588, 0.0784)*0.2, x9);
  481.  
  482. float3 SunCurrent;
  483. float3 SunNext;
  484.  
  485. float3 m0 = float3(min(1.0, d0), min(1.0, d0), min(1.0, d0));
  486. float3 color = lerp((pow(sunlight, 0.5)*ColorSun*50.0)+lt, sh, m0);
  487. float3 colorPasm = lerp(fmix, fmix2, m0);
  488.  
  489. if (wx.x==0,1) SunCurrent = color;
  490. if (wx.y==0,1) SunNext = color;
  491.  
  492. if (wx.x==4) SunCurrent = colorPasm;
  493. if (wx.x==7) SunCurrent = colorPasm;
  494. if (wx.x==8) SunCurrent = colorPasm;
  495. if (wx.x==9) SunCurrent = colorPasm;
  496. if (wx.x==12) SunCurrent = colorPasm;
  497. if (wx.x==15) SunCurrent = colorPasm;
  498. if (wx.x==16) SunCurrent = colorPasm;
  499.  
  500. if (wx.y==4) SunNext = colorPasm;
  501. if (wx.y==7) SunNext = colorPasm;
  502. if (wx.y==8) SunNext = colorPasm;
  503. if (wx.y==9) SunNext = colorPasm;
  504. if (wx.y==12) SunNext = colorPasm;
  505. if (wx.y==15) SunNext = colorPasm;
  506. if (wx.y==16) SunNext = colorPasm;
  507.  
  508. float3 wmix = lerp(SunCurrent, SunNext, wx.z);
  509.  
  510. float4 r0 = float4(wmix.rgb, (noise*noise*noise));
  511. return r0;
  512. }
  513.  
  514. float IntersectPlane(float3 pos, float3 dir)
  515. {
  516. return -pos.z/dir.z;
  517. }
  518.  
  519. ////////////////////////////////////////////////////////////////////////////////////
  520. /////////////////////////////////////SA_DirectX/////////////////////////////////////
  521. ////////////////////////////////////////////////////////////////////////////////////
  522. float4 PS_DX1(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
  523. {
  524. float t = GameTime;
  525. float tf = CalculateGameTime(t);
  526. float tf2 = CalculateGameTime0(t);
  527.  
  528. float2 coord = IN.txcoord.xy;
  529. float4 r0 = tex2D(SamplerColor, coord.xy);
  530. float d0 = tex2D(SamplerDepth, coord.xy).x;
  531. float4 wpos = WorldPos(coord);
  532. //Sky------------------------------------------------------------------------------
  533. float4 w0 = wpos+CameraPosition;
  534. float4 cam = CameraPosition;
  535. float4 np0 = float4(normalize(wpos.xyz), 1.0);
  536. np0.xyz = normalize(w0.xyz-float3(cam.xy, 0.0));
  537. float3 vec = normalize(float3(0.0, 0.0, 1.0));
  538. float3 hv = normalize(-vec+np0);
  539. float np4 = (np0.z * (2.0)) + 0.40;
  540. np4 *= lerp(0.0, 1.0, tf2);
  541. float3 a2 = np4;
  542. float3 sc = 1.0;
  543. float3 sn = 1.0;
  544.  
  545. float4 wx = WeatherAndTime;
  546. float3 wmix0 = lerp(sc, sn, wx.z);
  547. float4 worldpos = GWP(coord, d0);
  548. float L = worldpos.xyz;
  549. //Clouds---------------------------------------------------------------------------
  550. float d3 = pow(tex2D(SamplerDepth, coord).x, 17000.0);
  551. float3 sc0 = SunLight(coord, d3);
  552. float3 w1 = float3(1.0, 1.0, 3.33);
  553. float4 ns = float4(normalize(worldpos.xyz), 1.0);
  554. float ip = IntersectPlane(w1, ns.xyz);
  555. float4 r1 = r0;
  556. if (ip <= 1.0)
  557. if( 10000.0 < L || d0 == 1)
  558. {
  559. float4 c0 = GenerateClouds(float4((ns.xyz*ip*15.0), 1.0), sc0);
  560. c0.a = min(1.0, c0.a);
  561. r1.xyz = lerp(r0, c0.rgb*1.75, c0.a);
  562. }
  563. r0.xyz = lerp(r0, r1, smoothstep(0.0, 0.1, pow(ns.z, 0.66)));
  564. //---------------------------------------------------------------------------------
  565. return r0;
  566. }
  567.  
  568. ////////////////////////////////////////////////////////////////////////////////////
  569. /////////////////////////////////////SA_DirectX/////////////////////////////////////
  570. ////////////////////////////////////////////////////////////////////////////////////
  571.  
  572. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  573.  
  574. technique PostProcess
  575. {
  576. pass P0
  577. {
  578. VertexShader = compile vs_3_0 VS_PostProcess();
  579. PixelShader = compile ps_3_0 PS_DX1();
  580. }
  581. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement