Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.38 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; float4 ScreenSize; float ENightDayFactor; float EInteriorFactor;
  30. float4 WeatherAndTime; float4 Timer; float FieldOfView; float GameTime; float4 SunDirection;
  31. float4 CustomShaderConstants1[8]; float4 MatrixVP[4]; float4 MatrixInverseVP[4]; float4 MatrixVPRotation[4];
  32. float4 MatrixInverseVPRotation[4]; float4 MatrixView[4]; float4 MatrixInverseView[4]; float4 CameraPosition;
  33. float4x4 MatrixWVP; float4x4 MatrixWVPInverse; float4x4 MatrixWorld; float4x4 MatrixProj; float4 diffColor;
  34. float4 specColor; float4 ambColor; float4 FogParam; float4 FogFarColor; float4 lightDiffuse[8]; float4 lightSpecular[8];
  35. float4 lightDirection[8]; float4 VehicleParameters1;
  36.  
  37. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
  38. //Textures
  39. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
  40.  
  41. texture2D texOriginal;
  42. texture2D texRefl;
  43. texture2D texEnv;
  44. texture2D texNoise < string ResourceName = "NoiseCar.png"; >;
  45. sampler2D SamplerOriginal = sampler_state { Texture = <texOriginal>; };
  46. textureCUBE texColeso < string ResourceName = "SkyCar.dds"; string ResourceType = "CUBE"; >;
  47.  
  48. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
  49. //Sampler Inputs
  50. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
  51.  
  52. sampler2D SamplerRefl = sampler_state
  53. {
  54. Texture = <texRefl>;
  55. MinFilter = LINEAR;
  56. MagFilter = LINEAR;
  57. MipFilter = LINEAR;
  58. AddressU = Clamp;
  59. AddressV = Clamp;
  60. SRGBTexture=FALSE;
  61. MaxMipLevel=0;
  62. MipMapLodBias=0;
  63. };
  64.  
  65. sampler2D SamplerEnv = sampler_state
  66. {
  67. Texture = <texEnv>;
  68. MinFilter = LINEAR;
  69. MagFilter = LINEAR;
  70. MipFilter = LINEAR;
  71. AddressU = Mirror;
  72. AddressV = Mirror;
  73. SRGBTexture=FALSE;
  74. MaxMipLevel=0;
  75. MipMapLodBias=0;
  76. };
  77.  
  78. samplerCUBE SamplerCube = sampler_state
  79. {
  80. Texture = <texColeso>;
  81. MinFilter = LINEAR;
  82. MagFilter = LINEAR;
  83. MipFilter = LINEAR;
  84. AddressU = Wrap;
  85. AddressV = Wrap;
  86. SRGBTexture=TRUE;
  87. MaxMipLevel=0;
  88. MipMapLodBias=0;
  89. };
  90.  
  91. sampler2D NoiseSampler = sampler_state
  92. {
  93. Texture = <texNoise>;
  94. MinFilter = LINEAR;
  95. MagFilter = LINEAR;
  96. MipFilter = LINEAR;
  97. AddressU = Wrap;
  98. AddressV = Wrap;
  99. AddressW = Wrap;
  100. SRGBTexture=TRUE;
  101. MaxMipLevel=2;
  102. MipMapLodBias=2;
  103. };
  104.  
  105. struct PS_OUTPUT3
  106. {
  107. float4 Color[3] : COLOR0;
  108. };
  109.  
  110. struct VS_INPUT_N
  111. {
  112. float3 pos : POSITION;
  113. float3 normal : NORMAL;
  114. float2 txcoord0 : TEXCOORD0;
  115. };
  116.  
  117. struct VS_OUTPUT
  118. {
  119. float4 pos : POSITION;
  120. float2 txcoord0 : TEXCOORD0;
  121. float3 viewnormal : TEXCOORD3;
  122. float3 eyedir : TEXCOORD4;
  123. float3 wnormal : TEXCOORD5;
  124. float4 vposition : TEXCOORD6;
  125. float3 normal : TEXCOORD7;
  126. };
  127.  
  128. ////////////////////////////////////////////////////////////////////////////////////
  129. /////////////////////////////////////SA_DirectX/////////////////////////////////////
  130. ////////////////////////////////////////////////////////////////////////////////////
  131. VS_OUTPUT VS_Draw(VS_INPUT_N IN)
  132. {
  133. VS_OUTPUT OUT;
  134. float4 pos;
  135. pos.xyz=IN.pos.xyz;
  136. pos.w=1.0;
  137. float4 tpos;
  138. tpos=mul(pos, MatrixWVP);
  139. OUT.pos=tpos;
  140. OUT.vposition=tpos;
  141. OUT.txcoord0=IN.txcoord0;
  142. float3 wnormal=normalize(mul(IN.normal.xyz, MatrixWorld));
  143. float3 normal;
  144. normal.x=dot(wnormal.xyz, MatrixView[0]);
  145. normal.y=dot(wnormal.xyz, MatrixView[1]);
  146. normal.z=dot(wnormal.xyz, MatrixView[2]);
  147. OUT.viewnormal=normalize(normal.xyz);
  148. OUT.normal=normalize(mul(IN.normal.xyz, MatrixWVP));
  149. OUT.wnormal=wnormal;
  150. float3 campos=CameraPosition;
  151. OUT.eyedir=(mul(pos, MatrixWorld) - campos);
  152. return OUT;
  153. }
  154.  
  155. ////////////////////////////////////////////////////////////////////////////////////
  156. /////////////////////////////////////SA_DirectX/////////////////////////////////////
  157. ////////////////////////////////////////////////////////////////////////////////////
  158.  
  159. float ReflContrast
  160. <
  161. string UIName="Reflection - Contrast";
  162. string UIWidget="Spinner";
  163. float UIMin=0.0;
  164. float UIMax=4.0;
  165. > = {2.0};
  166.  
  167. float ReflContrast2
  168. <
  169. string UIName="Reflection - Contrast(Night)";
  170. string UIWidget="Spinner";
  171. float UIMin=0.0;
  172. float UIMax=4.0;
  173. > = {1.5};
  174.  
  175. float ReflSaturate
  176. <
  177. string UIName="Reflection - Saturate";
  178. string UIWidget="Spinner";
  179. float UIMin=0.0;
  180. float UIMax=4.0;
  181. > = {0.65};
  182.  
  183. float refd
  184. <
  185. string UIName="Reflection - Day";
  186. string UIWidget="Spinner";
  187. float UIMin=0.0;
  188. float UIMax=5.0;
  189. > = {1.0};
  190.  
  191. float refn
  192. <
  193. string UIName="Reflection - Night";
  194. string UIWidget="Spinner";
  195. float UIMin=0.0;
  196. float UIMax=5.0;
  197. > = {1.0};
  198.  
  199. float refw
  200. <
  201. string UIName="Reflection - Weather";
  202. string UIWidget="Spinner";
  203. float UIMin=0.0;
  204. float UIMax=5.0;
  205. > = {1.0};
  206.  
  207. float skyref
  208. <
  209. string UIName="Sky - Brightness";
  210. string UIWidget="Spinner";
  211. float UIMin=0.0;
  212. float UIMax=3.0;
  213. > = {1.4};
  214.  
  215. float refglass
  216. <
  217. string UIName="Glass - Reflection";
  218. string UIWidget="Spinner";
  219. float UIMin=0.0;
  220. float UIMax=4.0;
  221. > = {1.0};
  222.  
  223. float carglass
  224. <
  225. string UIName="Glass - Tinting";
  226. string UIWidget="Spinner";
  227. float UIMin=0.0;
  228. float UIMax=1.0;
  229. > = {1.0};
  230.  
  231. bool EReflEnable
  232. <
  233. string UIName="SreenSpaceRefl: Enable";
  234. > = {true};
  235.  
  236. bool cre
  237. <
  238. string UIName="Chrome: Enable";
  239. > = {true};
  240.  
  241. float carchrome
  242. <
  243. string UIName="Chrome - Brightness";
  244. string UIWidget="Spinner";
  245. float UIMin=0.0;
  246. float UIMax=5.0;
  247. > = {1.0};
  248.  
  249. float EFresnelFactor
  250. <
  251. string UIName="Vehicle: FresnelFactor";
  252. string UIWidget="Spinner";
  253. float UIMin=0.0;
  254. float UIMax=1.0;
  255. > = {0.84};
  256.  
  257. float EF1
  258. <
  259. string UIName="Fresnel: coverage1";
  260. string UIWidget="Spinner";
  261. float UIMin=0.0;
  262. float UIMax=3.0;
  263. > = {0.4};
  264.  
  265. float EF2
  266. <
  267. string UIName="Fresnel: coverage2";
  268. string UIWidget="Spinner";
  269. float UIMin=0.0;
  270. float UIMax=3.0;
  271. > = {0.55};
  272.  
  273. float CarContrast
  274. <
  275. string UIName="Vehicle: Contrast";
  276. string UIWidget="Spinner";
  277. float UIMin=0.0;
  278. float UIMax=10000.0;
  279. > = {1.0};
  280.  
  281. float CarSaturate
  282. <
  283. string UIName="Vehicle: Saturate";
  284. string UIWidget="Spinner";
  285. float UIMin=0.0;
  286. float UIMax=10000.0;
  287. > = {1.0};
  288.  
  289. float wLhights
  290. <
  291. string UIName="wheels and interior";
  292. string UIWidget="Spinner";
  293. float UIMin=0.0;
  294. float UIMax=5.0;
  295. > = {1.5};
  296.  
  297. float ftColor3
  298. <
  299. string UIName="Car - Brightness";
  300. string UIWidget="Spinner";
  301. float UIMin=0.0;
  302. float UIMax=2.0;
  303. > = {0.14};
  304.  
  305. float flighting
  306. <
  307. string UIName="Lighting - Brightness";
  308. string UIWidget="Spinner";
  309. float UIMin=0.0;
  310. float UIMax=10.0;
  311. > = {1.0};
  312.  
  313. float LightingContrast
  314. <
  315. string UIName="Lighting - Contrast";
  316. string UIWidget="Spinner";
  317. float UIMin=0.0;
  318. float UIMax=10000.0;
  319. > = {1.0};
  320.  
  321. float LightingSaturate
  322. <
  323. string UIName="Lighting - Saturate";
  324. string UIWidget="Spinner";
  325. float UIMin=0.0;
  326. float UIMax=10000.0;
  327. > = {1.0};
  328.  
  329.  
  330. float L1
  331. <
  332. string UIName="Lighting - L1";
  333. string UIWidget="Spinner";
  334. float UIMin=0.0;
  335. float UIMax=10.0;
  336. > = {1.0};
  337.  
  338.  
  339. float L2
  340. <
  341. string UIName="Lighting - L2";
  342. string UIWidget="Spinner";
  343. float UIMin=0.0;
  344. float UIMax=20.0;
  345. > = {1.0};
  346.  
  347. float L3
  348. <
  349. string UIName="Lighting - L2(weather)";
  350. string UIWidget="Spinner";
  351. float UIMin=0.0;
  352. float UIMax=20.0;
  353. > = {1.0};
  354.  
  355. float RefSize
  356. <
  357. string UIName="RefSize";
  358. string UIWidget="Spinner";
  359. float UIMin=0.0;
  360. float UIMax=10.0;
  361. > = {1.0};
  362.  
  363.  
  364. ////////////////////////////////////////////////////////////////////////////////////
  365. /////////////////////////////////////SA_DirectX/////////////////////////////////////
  366. ////////////////////////////////////////////////////////////////////////////////////
  367.  
  368. float4 wpd1(float2 cd, float d)
  369. {
  370. float4 tv;
  371. tv.xy = cd.xy*2.0-1.0;
  372. tv.y = -tv.y;
  373. tv.z = d;
  374. tv.w = 1.0;
  375. float4 wp;
  376. wp.x = dot(tv,MatrixInverseVPRotation[0]);
  377. wp.y = dot(tv,MatrixInverseVPRotation[1]);
  378. wp.z = dot(tv,MatrixInverseVPRotation[2]);
  379. wp.w = dot(tv,MatrixInverseVPRotation[3]);
  380. wp.xyz/= wp.w;
  381. return wp;
  382. }
  383.  
  384. float2 wpd2(float3 cd)
  385. {
  386. float4 tv = float4(cd.xyz, 1.0);
  387. float4 wp = 0.0;
  388. wp.x = dot(tv,MatrixVPRotation[0]);
  389. wp.y = dot(tv,MatrixVPRotation[1]);
  390. wp.z = dot(tv,MatrixVPRotation[2]);
  391. wp.w = dot(tv,MatrixVPRotation[3]);
  392. wp.xyz/= wp.w;
  393. wp.y = -wp.y;
  394. wp.xy = wp.xy*0.5+0.5;
  395. return wp.xy;
  396. }
  397.  
  398. float4 reflection(float3 n, float2 cd, float d)
  399. {
  400. float3 wpos = wpd1(cd.xy, d);
  401. float3 v = {0.35, 0.35, 1.15};
  402. n = normalize(n.xyz*v);
  403. float3 n0 = reflect(wpos.xyz, n.xyz);
  404. float3 n1 = ((1000.0/0.01)*n0)/1000.0;
  405. float3 r0 = (wpos+n1);
  406. float2 r1 = wpd2(r0.xyz);
  407. float4 r2 = tex2Dlod(SamplerRefl, float4(r1.xy, 0.0, RefSize));
  408. r2.xyz+=0.000001;
  409. float3 st0 = normalize(r2.xyz);
  410. float3 ct0 = r2.xyz/st0.xyz;
  411. ct0=pow(ct0, 0.70);
  412. st0.xyz = pow(st0.xyz, 0.95);
  413. r2.xyz = ct0*st0.xyz;
  414. r2.w = r1.y<0.0||r1.y>1.0 ? 0.0:1.0;
  415. r2.w*= r1.x<0.0||r1.x>1.0 ? 0.0:1.0;
  416. return r2;
  417. }
  418.  
  419. ////////////////////////////////////////////////////////////////////////////////////
  420. /////////////////////////////////////SA_DirectX/////////////////////////////////////
  421. ////////////////////////////////////////////////////////////////////////////////////
  422.  
  423. PS_OUTPUT3 PS_Draw(VS_OUTPUT IN, in float2 vpos : VPOS)
  424. {
  425. float4 cd;
  426. float2 cd0 = IN.txcoord0.xy;
  427. float4 wx = WeatherAndTime;
  428. float3 n0 = normalize(IN.normal.xyz);
  429. float3 wn = normalize(IN.wnormal.xyz);
  430. float3 ed = normalize(-IN.vposition.xyz);
  431. float3 wed = normalize(-IN.eyedir.xyz);
  432. float4 tex = tex2D(SamplerOriginal, cd0);
  433. float4 r0;
  434. float4 rfl;
  435. float2 rfl0;
  436.  
  437. float4 fp1;
  438. fp1.xyz = diffColor*specColor*specColor.w*0.085;
  439. fp1.w = min(fp1.x, min(fp1.y, fp1.z));
  440. fp1.w = saturate(1.0-fp1.w);
  441. fp1.w*= fp1.w;
  442. cd.zw = 0.0;
  443. cd.w = fp1.w*4.0;
  444.  
  445. float t0 = GameTime;
  446. float x1 = smoothstep(0.0, 4.0, t0);
  447. float x2 = smoothstep(4.0, 5.0, t0);
  448. float x3 = smoothstep(5.0, 6.0, t0);
  449. float x4 = smoothstep(6.0, 7.0, t0);
  450. float xE = smoothstep(8.0, 11.0, t0);
  451. float x5 = smoothstep(16.0, 17.0, t0);
  452. float x6 = smoothstep(18.0, 19.0, t0);
  453. float x7 = smoothstep(19.0, 20.0, t0);
  454. float xG = smoothstep(20.0, 21.0, t0);
  455. float xZ = smoothstep(21.0, 22.0, t0);
  456. float x8 = smoothstep(22.0, 23.0, t0);
  457. float x9 = smoothstep(23.0, 24.0, t0);
  458.  
  459. float3 rv1 = {-0.2, -1.1, 1.0};
  460.  
  461. float opacity = saturate(tex.a*diffColor.a);
  462. float3 refl = reflect(ed, n0);
  463. rfl0.xy = (IN.vposition.xy /IN.vposition.w)*float2(0.5, -0.5) + 0.5;
  464. rfl0.xy+= (refl.xy*float2(-1.0, 1.0)*0.5);
  465. cd.xy = rfl0;
  466. float smix;
  467. smix = saturate(wn.z)*saturate(-n0.z);
  468. smix*= smix;
  469. //-------------------------------------
  470. //-------------------------------------
  471. cd.y = 1.0-((wn.z*0.5)+0.5);
  472. cd.x = 0.5;
  473.  
  474. float3 wp = reflect(wed, wn);
  475. float4 tcube = texCUBE(SamplerCube, -wp.xzy);
  476. float2 txcoord1;
  477. txcoord1.xy = (IN.vposition.xy /IN.vposition.w)*float2(0.5, -0.5) + 0.5;
  478. txcoord1.xy+= 0.5*float2(ScreenSize.y, ScreenSize.y*ScreenSize.z);
  479.  
  480. float4 b0 = 1.0;
  481. float3 nont01 = b0.xyz*0.0;
  482. nont01.xyz = min(nont01, b0);
  483. float3 tr2 = b0.xyz*10.0/saturate(opacity + 0.02 + VehicleParameters1.y);
  484. b0.xyz = lerp(tr2, nont01, saturate(opacity+VehicleParameters1.y));
  485. float mask8 = max(b0.x, max(b0.y, b0.z));
  486. mask8 = saturate(mask8*0.3)*1.0;
  487.  
  488. float4 noise = tex2Dlod(NoiseSampler, float4(txcoord1.xy*4.0, 0.0, 0.0));
  489. noise = lerp(noise, 0.0, mask8);
  490. float d = (IN.vposition.z/IN.vposition.w);
  491. rfl = reflection(normalize(wn), txcoord1+(0.010*noise), d);
  492. float4 sky = tex2D(SamplerEnv, rv1+cd.xy+(0.005*noise));
  493. float3 tc0 = lerp(0.01, 0.1, x1);
  494. tc0 = lerp(tc0, 0.3, x2);
  495. tc0 = lerp(tc0, 1.0, x3);
  496. tc0 = lerp(tc0, 1.0, x4);
  497. tc0 = lerp(tc0, 1.0, xE);
  498. tc0 = lerp(tc0, 1.0, x5);
  499. tc0 = lerp(tc0, 1.0, x6);
  500. tc0 = lerp(tc0, 0.8, x7);
  501. tc0 = lerp(tc0, 0.6, xG);
  502. tc0 = lerp(tc0, 0.3, xZ);
  503. tc0 = lerp(tc0, 0.2, x8);
  504. tc0 = lerp(tc0, 0.01, x9);
  505.  
  506. float4 sc = tcube*sky;
  507. float sc0 = saturate(tcube)*tc0;
  508.  
  509. float4 cubeC;
  510. float4 cubeN;
  511. if (wx.x==0,1) cubeC = sc;
  512. if (wx.y==0,1) cubeN = sc;
  513. if (wx.x==4) cubeC = sc0;
  514. if (wx.x==7) cubeC = sc0;
  515. if (wx.x==8) cubeC = sc0;
  516. if (wx.x==9) cubeC = sc0;
  517. if (wx.x==12) cubeC = sc0;
  518. if (wx.x==15) cubeC = sc0;
  519. if (wx.x==16) cubeC = sc0;
  520. if (wx.y==4) cubeN = sc0;
  521. if (wx.y==7) cubeN = sc0;
  522. if (wx.y==8) cubeN = sc0;
  523. if (wx.y==9) cubeN = sc0;
  524. if (wx.y==12) cubeN = sc0;
  525. if (wx.y==15) cubeN = sc0;
  526. if (wx.y==16) cubeN = sc0;
  527. float4 wmix0 = lerp(cubeC, cubeN, wx.z);
  528. float4 skymix = wmix0;
  529.  
  530. float3 st0 = normalize(rfl.xyz);
  531. float3 ct0=rfl.xyz/st0.xyz;
  532. ct0=pow(ct0, 1.10);
  533. st0.xyz = pow(st0.xyz, 1.15);
  534. rfl.xyz = ct0*st0.xyz;
  535.  
  536. float3 st1 = normalize(skymix.xyz);
  537. float3 ct1=skymix.xyz/st1.xyz;
  538. ct1=pow(ct1, 0.5);
  539. st1.xyz = pow(st1.xyz, 0.5);
  540. skymix.xyz = ct1*st1.xyz;
  541. skymix.xyz*= skyref;
  542.  
  543. float3 wpos = wpd1(txcoord1.xy, d);
  544. float3 v = {0.35, 0.35, 1.15};
  545. float3 n1 = normalize(wn*v);
  546. float3 n2 = reflect(wpos.xyz, n1.xyz);
  547. float3 rw = ((1000.0/0.01)*n2)/1000.0;
  548. float3 ref = (wpos+rw);
  549. float2 rd = wpd2(ref.xyz);
  550.  
  551. float nf02 = saturate(8.0*(rd.y));
  552. nf02*= saturate(8.0*(rd.x));
  553. nf02 = pow(nf02, 1.0);
  554. float nf03 = saturate(8.0+rd.y*(-8.0));
  555. nf03*= saturate(8.0+rd.x*(-8.0));
  556. nf03 = pow(nf03, 1.0);
  557.  
  558. float4 rfl1 = skymix;
  559. rfl.xyz = lerp(rfl1, rfl, pow(0.01*0.5, smix));
  560.  
  561. float nf = saturate(1.0+smix*0.3 -abs(n0.z));
  562. float ff = pow(nf, 2.5);
  563.  
  564. rfl.xyz = lerp(rfl, rfl1, pow(0.01*0.01, ff));
  565. if (EReflEnable==true) rfl1 = lerp(rfl1, rfl, rfl.w*nf02*nf03);
  566.  
  567. float3 st3 = normalize(rfl1.xyz);
  568. float3 ct3 = rfl1.xyz/st3.xyz;
  569. float tc1 = lerp(ReflContrast2, ReflContrast2, x1);
  570. tc1 = lerp(tc1, ReflContrast, x2);
  571. tc1 = lerp(tc1, ReflContrast, x3);
  572. tc1 = lerp(tc1, ReflContrast, x4);
  573. tc1 = lerp(tc1, ReflContrast, xE);
  574. tc1 = lerp(tc1, ReflContrast, x5);
  575. tc1 = lerp(tc1, ReflContrast, x6);
  576. tc1 = lerp(tc1, ReflContrast, x7);
  577. tc1 = lerp(tc1, ReflContrast, xG);
  578. tc1 = lerp(tc1, ReflContrast, xZ);
  579. tc1 = lerp(tc1, ReflContrast, x8);
  580. tc1 = lerp(tc1, ReflContrast2, x9);
  581. ct3 = pow(ct3, tc1);
  582. st3.xyz = pow(st3.xyz, ReflSaturate);
  583. rfl1.xyz = ct3*st3.xyz;
  584. //-------------------------------------
  585. //-------------------------------------
  586. float3 sv0 = SunDirection.xyz;
  587. float3 sv1 = normalize(float3(0.0, 0.0, 0.0));
  588.  
  589. float yy1 = smoothstep(0.0, 1.0, t0);
  590. float yy2 = smoothstep(1.0, 23.0, t0);
  591. float yy3 = smoothstep(23.0, 24.0, t0);
  592.  
  593. float3 sv = lerp(sv1, sv0, yy1);
  594. sv = lerp(sv, sv0, yy2);
  595. sv = lerp(sv, sv1, yy3);
  596.  
  597. float3 hv = normalize(sv.xyz+wed.xyz);
  598. float gf = saturate((0.01*0.001) + dot(hv, wn.xyz));
  599. gf = pow(gf, 1500.0 * 5.0);
  600. float gm = (gf*gf);
  601. float gl = (gm/0.01)* 0.2;
  602. //-------------------------------------
  603. //-------------------------------------
  604. float distfade = saturate(IN.vposition.z * 0.014);
  605. rfl1.xyz = lerp(rfl1, skymix, smix);
  606. rfl1.xyz*= 1.0-distfade*distfade;
  607.  
  608. float4 dc = diffColor;
  609. float4 tc = tex;
  610. float4 tc2 = tex;
  611. float4 gl0 = 1.0;
  612. float4 gl1 = 1.0;
  613. float3 st4 = normalize(dc.xyz);
  614. float3 ct4=dc.xyz/st4.xyz;
  615. ct4=pow(ct4, CarContrast);
  616. st4.xyz = pow(st4.xyz, CarSaturate);
  617. dc.xyz = ct4*st4.xyz;
  618.  
  619. float Headlights = 0.25;
  620. float3 lf = lerp(Headlights*7.0, Headlights*7.0, x1);
  621. lf = lerp(lf, Headlights*6.0, x2);
  622. lf = lerp(lf, Headlights, x3);
  623. lf = lerp(lf, Headlights, x4);
  624. lf = lerp(lf, Headlights, xE);
  625. lf = lerp(lf, Headlights, x5);
  626. lf = lerp(lf, Headlights, x6);
  627. lf = lerp(lf, Headlights, x7);
  628. lf = lerp(lf, Headlights, xG);
  629. lf = lerp(lf, Headlights, xZ);
  630. lf = lerp(lf, Headlights*5.0, x8);
  631. lf = lerp(lf, Headlights*6.5, x9);
  632.  
  633. float3 lighting = 1.53*(dc+(ambColor*lf))*tex;
  634.  
  635. float3 st5 = normalize(tc.xyz);
  636. float3 ct5 = tc.xyz/st5.xyz;
  637. ct5 = pow(ct5, 9.0);
  638. st5.xyz = pow(st5.xyz, -5.9);
  639. tc.xyz = ct5*st5.xyz;
  640.  
  641. float3 st6 = normalize(tc2.xyz);
  642. float3 ct6 = tc2.xyz/st6.xyz;
  643. ct6 = pow(ct6, 8.0);
  644. st6.xyz = pow(st6.xyz, 4.0);
  645. tc2.xyz = ct6*st6.xyz;
  646.  
  647. float3 nt = gl0.xyz*0.6;
  648. nt.xyz = min(nt, gl0);
  649. float3 tr = gl0.xyz*(-3.0)/saturate(opacity + 0.02 + VehicleParameters1.y);
  650. gl0.xyz = lerp(tr, nt, saturate(opacity+VehicleParameters1.y));
  651. float3 nt0 = gl1.xyz*0.0;
  652. nt0.xyz = min(nt0, gl1);
  653. float3 tr0 = gl1.xyz*10.0/saturate(opacity + 0.02 + VehicleParameters1.y);
  654. gl1.xyz = lerp(tr0, nt0, saturate(opacity+VehicleParameters1.y));
  655.  
  656. float4 sc1 = specColor*1000.0;
  657. float4 sc2 = tex;
  658. float3 g2 = normalize(sc1.xyz);
  659. float3 g4 = normalize(sc2.xyz);
  660. float3 s2 = sc1.xyz/g2.xyz;
  661. float3 s4 = sc2.xyz/g4.xyz;
  662. s2 = pow(s2, -15.0);
  663. s4 = pow(s4, -34.0);
  664. g4.xyz = pow(g4.xyz, 3.0);
  665. sc2.xyz = s4*g4.xyz;
  666.  
  667. float mask0 = max(specColor.x, max(specColor.y, specColor.z));
  668. mask0 = saturate(mask0*1000.0);
  669. float mask1 = max(s2.x, max(s2.y, s2.z));
  670. mask1 = saturate(mask1);
  671. float mask2 = max(sc2.x, max(sc2.y, sc2.z));
  672. mask2 = saturate(mask2);
  673. float mask3 = max(tc.x, max(tc.y, tc.z));
  674. mask3 = saturate(mask3);
  675. float mask4 = max(tc2.x, max(tc2.y, tc2.z));
  676. mask4 = saturate(mask4);
  677. float mask5 = max(gl0.x, max(gl0.y, gl0.z));
  678. mask5 = saturate(mask5);
  679. float mask6 = max(gl1.x, max(gl1.y, gl1.z));
  680. mask6 = saturate(mask6*0.3)*1.0;
  681.  
  682. float3 sv3 = normalize(float3(0.0, 0.0, 1.0)+wed.xyz);
  683. float3 sv2 = normalize(sv.xyz+wed.xyz);
  684. float3 sv4 = normalize(sv.xyz);
  685. float3 ScCurrent;
  686. float3 ScNext;
  687. if (wx.x==0,1) ScCurrent = sv2;
  688. if (wx.y==0,1) ScNext = sv2;
  689. if (wx.x==4) ScCurrent = sv3;
  690. if (wx.x==7) ScCurrent = sv3;
  691. if (wx.x==8) ScCurrent = sv3;
  692. if (wx.x==9) ScCurrent = sv3;
  693. if (wx.x==12) ScCurrent = sv3;
  694. if (wx.x==15) ScCurrent = sv3;
  695. if (wx.x==16) ScCurrent = sv3;
  696. if (wx.y==4) ScNext = sv3;
  697. if (wx.y==7) ScNext = sv3;
  698. if (wx.y==8) ScNext = sv3;
  699. if (wx.y==9) ScNext = sv3;
  700. if (wx.y==12) ScNext = sv3;
  701. if (wx.y==15) ScNext = sv3;
  702. if (wx.y==16) ScNext = sv3;
  703.  
  704. float3 svmix = lerp(ScCurrent, ScNext, wx.z);
  705. float3 ScCurrent2;
  706. float3 ScNext2;
  707. if (wx.x==0,1) ScCurrent2 = sv4;
  708. if (wx.y==0,1) ScNext2 = sv4;
  709. if (wx.x==4) ScCurrent2 = sv3;
  710. if (wx.x==7) ScCurrent2 = sv3;
  711. if (wx.x==8) ScCurrent2 = sv3;
  712. if (wx.x==9) ScCurrent2 = sv3;
  713. if (wx.x==12) ScCurrent2 = sv3;
  714. if (wx.x==15) ScCurrent2 = sv3;
  715. if (wx.x==16) ScCurrent2 = sv3;
  716. if (wx.y==4) ScNext2 = sv3;
  717. if (wx.y==7) ScNext2 = sv3;
  718. if (wx.y==8) ScNext2 = sv3;
  719. if (wx.y==9) ScNext2 = sv3;
  720. if (wx.y==12) ScNext2 = sv3;
  721. if (wx.y==15) ScNext2 = sv3;
  722. if (wx.y==16) ScNext2 = sv3;
  723.  
  724. float re4 = L3;
  725. float gc5;
  726. float gn5;
  727. if (wx.x==0,1) gc5 = L2;
  728. if (wx.y==0,1) gn5 = L2;
  729. if (wx.x==4) gc5 = re4;
  730. if (wx.x==7) gc5 = re4;
  731. if (wx.x==8) gc5 = re4;
  732. if (wx.x==9) gc5 = re4;
  733. if (wx.x==12) gc5 = re4;
  734. if (wx.x==15) gc5 = re4;
  735. if (wx.x==16) gc5 = re4;
  736. if (wx.y==4) gn5 = re4;
  737. if (wx.y==7) gn5 = re4;
  738. if (wx.y==8) gn5 = re4;
  739. if (wx.y==9) gn5 = re4;
  740. if (wx.y==12) gn5 = re4;
  741. if (wx.y==15) gn5 = re4;
  742. if (wx.y==16) gn5 = re4;
  743.  
  744. float svmix5 = lerp(gc5, gn5, wx.z);
  745. float3 svmix2 = lerp(ScCurrent2, ScNext2, wx.z);
  746. float3 np = normalize(wn.xyz);
  747. float factor = 0.18*svmix5 - dot(-svmix, np);
  748. factor = pow(factor, 12.0*L1);
  749. float factor2 = 0.85*svmix5 - dot(-svmix2, np);
  750. factor2 = pow(factor2, 2.0*L1);
  751. float factor3 = 0.08 - dot(-svmix, np);
  752. factor3 = pow(factor3, 25.0);
  753. float factor0 = EF2 - dot(-wed, np);
  754. factor0 = pow(factor0, EF1);
  755. float fr0 = (factor0*factor0);
  756. fr0/= 2.5;
  757. float fr = (factor*factor);
  758. fr/= 2.5;
  759. float fr2 = (factor2*factor2);
  760. fr2/= 2.5;
  761. float fr3 = (factor3*factor3);
  762. fr3/= 2.5;
  763.  
  764. float re2 = ftColor3*0.4;
  765. float gc2;
  766. float gn2;
  767. if (wx.x==0,1) gc2 = ftColor3;
  768. if (wx.y==0,1) gn2 = ftColor3;
  769. if (wx.x==4) gc2 = re2;
  770. if (wx.x==7) gc2 = re2;
  771. if (wx.x==8) gc2 = re2;
  772. if (wx.x==9) gc2 = re2;
  773. if (wx.x==12) gc2 = re2;
  774. if (wx.x==15) gc2 = re2;
  775. if (wx.x==16) gc2 = re2;
  776. if (wx.y==4) gn2 = re2;
  777. if (wx.y==7) gn2 = re2;
  778. if (wx.y==8) gn2 = re2;
  779. if (wx.y==9) gn2 = re2;
  780. if (wx.y==12) gn2 = re2;
  781. if (wx.y==15) gn2 = re2;
  782. if (wx.y==16) gn2 = re2;
  783.  
  784. float wmix3 = lerp(gc2, gn2, wx.z);
  785.  
  786. float3 tl = lerp(0.06, 0.10, x1);
  787. tl = lerp(tl, 0.10, x2);
  788. tl = lerp(tl, wmix3*0.8, x3);
  789. tl = lerp(tl, wmix3*0.8, x4);
  790. tl = lerp(tl, wmix3*0.8, xE);
  791. tl = lerp(tl, wmix3*0.8, x5);
  792. tl = lerp(tl, wmix3*0.8, x6);
  793. tl = lerp(tl, 0.20, x7);
  794. tl = lerp(tl, 0.10, xG);
  795. tl = lerp(tl, 0.08, xZ);
  796. tl = lerp(tl, 0.06, x8);
  797. tl = lerp(tl, 0.06, x9);
  798.  
  799. r0.xyz = (saturate(tl*lighting)*2.0);
  800.  
  801. float3 tl0 = lerp(2.8, 2.0, x1);
  802. tl0 = lerp(tl0, 2.0, x2);
  803. tl0 = lerp(tl0, 1.2, x3);
  804. tl0 = lerp(tl0, 1.2, x4);
  805. tl0 = lerp(tl0, 1.2, xE);
  806. tl0 = lerp(tl0, 1.2, x5);
  807. tl0 = lerp(tl0, 1.2, x6);
  808. tl0 = lerp(tl0, 1.2, x7);
  809. tl0 = lerp(tl0, 1.2, xG);
  810. tl0 = lerp(tl0, 1.2, xZ);
  811. tl0 = lerp(tl0, 2.0, x8);
  812. tl0 = lerp(tl0, 2.8, x9);
  813.  
  814. float3 ge0 = 0.0;
  815. float3 gc6;
  816. float3 gn6;
  817. if (wx.x==0,1) gc6 = float3(0.235, 0.157, 0.0);
  818. if (wx.y==0,1) gn6 = float3(0.235, 0.157, 0.0);
  819. if (wx.x==4) gc6 = ge0;
  820. if (wx.x==7) gc6 = ge0;
  821. if (wx.x==8) gc6 = ge0;
  822. if (wx.x==9) gc6 = ge0;
  823. if (wx.x==12) gc6 = ge0;
  824. if (wx.x==15) gc6 = ge0;
  825. if (wx.x==16) gc6 = ge0;
  826. if (wx.y==4) gn6 = ge0;
  827. if (wx.y==7) gn6 = ge0;
  828. if (wx.y==8) gn6 = ge0;
  829. if (wx.y==9) gn6 = ge0;
  830. if (wx.y==12) gn6 = ge0;
  831. if (wx.y==15) gn6 = ge0;
  832. if (wx.y==16) gn6 = ge0;
  833.  
  834. float3 wmix6 = lerp(gc6, gn6, wx.z);
  835. float srs = saturate(dc);
  836. float3 cdl = lerp(float3(0.392, 0.392, 0.392), wmix6, pow(srs, 0.05));
  837.  
  838. float re3 = flighting*1.4;
  839. float gc3;
  840. float gn3;
  841. if (wx.x==0,1) gc3 = flighting;
  842. if (wx.y==0,1) gn3 = flighting;
  843. if (wx.x==4) gc3 = re3;
  844. if (wx.x==7) gc3 = re3;
  845. if (wx.x==8) gc3 = re3;
  846. if (wx.x==9) gc3 = re3;
  847. if (wx.x==12) gc3 = re3;
  848. if (wx.x==15) gc3 = re3;
  849. if (wx.x==16) gc3 = re3;
  850. if (wx.y==4) gn3 = re3;
  851. if (wx.y==7) gn3 = re3;
  852. if (wx.y==8) gn3 = re3;
  853. if (wx.y==9) gn3 = re3;
  854. if (wx.y==12) gn3 = re3;
  855. if (wx.y==15) gn3 = re3;
  856. if (wx.y==16) gn3 = re3;
  857.  
  858. float wmix4 = lerp(gc3, gn3, wx.z);
  859.  
  860. float ecd3 = 0.12*wmix4;
  861. float3 cc = lerp(0.0, 0.00, x1);
  862. cc = lerp(cc, cdl*ecd3*0.2, x2);
  863. cc = lerp(cc, cdl*ecd3*0.6, x3);
  864. cc = lerp(cc, cdl*ecd3*0.9, x4);
  865. cc = lerp(cc, cdl*ecd3, xE);
  866. cc = lerp(cc, cdl*ecd3, x5);
  867. cc = lerp(cc, cdl*ecd3*0.5, x6);
  868. cc = lerp(cc, 0.00, x7);
  869. cc = lerp(cc, 0.00, xG);
  870. cc = lerp(cc, 0.00, xZ);
  871. cc = lerp(cc, 0.00, x8);
  872. cc*= 1.0;
  873.  
  874.  
  875.  
  876. float3 fday = 6.5*refd;
  877. float3 fnight = 6.0*refn;
  878. float3 sl = lerp(fnight, fday, yy1);
  879. sl = lerp(sl, fday, yy2);
  880. sl = lerp(sl, fnight, yy3);
  881.  
  882. float ecd2 = 0.32*wmix4;
  883. float3 cc2 = lerp(0.0, 0.00, x1);
  884. cc2 = lerp(cc2, float3(0.627, 0.627, 0.627)*ecd2*0.4, x2);
  885. cc2 = lerp(cc2, float3(0.627, 0.627, 0.627)*ecd2*0.4, x3);
  886. cc2 = lerp(cc2, float3(0.667, 0.667, 0.667)*ecd2*0.8, x4);
  887. cc2 = lerp(cc2, ecd2, xE);
  888. cc2 = lerp(cc2, ecd2, x5);
  889. cc2 = lerp(cc2, float3(0.667, 0.667, 0.667)*ecd2*0.5, x6);
  890. cc2 = lerp(cc2, 0.0, x7);
  891. cc2 = lerp(cc2, 0.0, xG);
  892. cc2 = lerp(cc2, 0.0, xZ);
  893. cc2 = lerp(cc2, 0.0, x8);
  894. cc2*= 1.0;
  895.  
  896. float ecd = 0.05*wmix4;
  897. float3 cc1 = lerp(0.0, 0.00, x1);
  898. cc1 = lerp(cc1, float3(0.627, 0.627, 0.627)*ecd*0.4, x2);
  899. cc1 = lerp(cc1, float3(0.627, 0.627, 0.627)*ecd*5.4, x3);
  900. cc1 = lerp(cc1, float3(0.667, 0.667, 0.667)*ecd*3.4, x4);
  901. cc1 = lerp(cc1, ecd*3.4, xE);
  902. cc1 = lerp(cc1, ecd*3.4, x5);
  903. cc1 = lerp(cc1, float3(0.667, 0.667, 0.667)*ecd*0.5, x6);
  904. cc1 = lerp(cc1, 0.00, x7);
  905. cc1 = lerp(cc1, 0.00, xG);
  906. cc1 = lerp(cc1, 0.00, xZ);
  907. cc1 = lerp(cc1, 0.00, x8);
  908. cc1*= 1.0;
  909.  
  910. float cc0 = lerp(2.0, 2.0, x1);
  911. cc0 = lerp(cc0, 3.0, x2);
  912. cc0 = lerp(cc0, 3.0, x3);
  913. cc0 = lerp(cc0, 3.0, x4);
  914. cc0 = lerp(cc0, 3.0, xE);
  915. cc0 = lerp(cc0, 3.0, x5);
  916. cc0 = lerp(cc0, 3.0, x6);
  917. cc0 = lerp(cc0, 3.0, x7);
  918. cc0 = lerp(cc0, 3.0, xG);
  919. cc0 = lerp(cc0, 3.0, xZ);
  920. cc0 = lerp(cc0, 2.0, x8);
  921.  
  922. float xt = saturate(fr0*tex*cc0);
  923.  
  924. float3 re0 = 15.0*refw;
  925. float3 gc;
  926. float3 gn;
  927. if (wx.x==0,1) gc = sl;
  928. if (wx.y==0,1) gn = sl;
  929. if (wx.x==4) gc = re0;
  930. if (wx.x==7) gc = re0;
  931. if (wx.x==8) gc = re0;
  932. if (wx.x==9) gc = re0;
  933. if (wx.x==12) gc = re0;
  934. if (wx.x==15) gc = re0;
  935. if (wx.x==16) gc = re0;
  936. if (wx.y==4) gn = re0;
  937. if (wx.y==7) gn = re0;
  938. if (wx.y==8) gn = re0;
  939. if (wx.y==9) gn = re0;
  940. if (wx.y==12) gn = re0;
  941. if (wx.y==15) gn = re0;
  942. if (wx.y==16) gn = re0;
  943.  
  944. float3 wmix1 = lerp(gc, gn, wx.z);
  945.  
  946. float re1 = refglass*1.3;
  947. float gc1;
  948. float gn1;
  949. if (wx.x==0,1) gc1 = refglass;
  950. if (wx.y==0,1) gn1 = refglass;
  951. if (wx.x==4) gc1 = re1;
  952. if (wx.x==7) gc1 = re1;
  953. if (wx.x==8) gc1 = re1;
  954. if (wx.x==9) gc1 = re1;
  955. if (wx.x==12) gc1 = re1;
  956. if (wx.x==15) gc1 = re1;
  957. if (wx.x==16) gc1 = re1;
  958. if (wx.y==4) gn1 = re1;
  959. if (wx.y==7) gn1 = re1;
  960. if (wx.y==8) gn1 = re1;
  961. if (wx.y==9) gn1 = re1;
  962. if (wx.y==12) gn1 = re1;
  963. if (wx.y==15) gn1 = re1;
  964. if (wx.y==16) gn1 = re1;
  965.  
  966. float wmix2 = lerp(gc1, gn1, wx.z);
  967.  
  968.  
  969.  
  970. float3 specular=0.0;
  971. for (int li=0; li<8; li++)
  972. {
  973. float3 sv5 = normalize(lightDirection[li].xyz);
  974. float specfact = saturate(dot(sv5, wn.xyz));
  975. specfact = pow(specfact, 10.0);
  976. specular+= saturate(lightDiffuse[li]-lightSpecular[li]) * specfact;
  977. }
  978.  
  979. float cc3 = lerp(0.0, 0.0, x1);
  980. cc3 = lerp(cc3, 0.3, x2);
  981. cc3 = lerp(cc3, 1.0, x3);
  982. cc3 = lerp(cc3, 1.0, x4);
  983. cc3 = lerp(cc3, 1.0, xE);
  984. cc3 = lerp(cc3, 1.0, x5);
  985. cc3 = lerp(cc3, 1.0, x6);
  986. cc3 = lerp(cc3, 0.0, x7);
  987. cc3 = lerp(cc3, 0.0, xG);
  988. cc3 = lerp(cc3, 0.0, xZ);
  989. cc3 = lerp(cc3, 0.0, x8);
  990.  
  991.  
  992. float4 dc1 = diffColor;
  993. float3 st8 = normalize(dc1.xyz);
  994. float3 ct8=dc1.xyz/st8.xyz;
  995. ct8=pow(ct8, LightingContrast);
  996. st8.xyz = pow(st8.xyz, LightingSaturate);
  997. dc1.xyz = ct8*st8.xyz;
  998.  
  999. r0.xyz+= dc1*specular*tex*6.0; // Ночное Освещение 1
  1000. r0.xyz+= specular*tex*0.1; // Ночное Освещение 2
  1001. r0.xyz+= (float3(0.902, 1.0, 1.0)*fr3*tex*cc);
  1002. r0.xyz+= saturate(fr2*dc1*tex*cc2)*2.2;
  1003. r0.xyz+= saturate(fr*dc1*tex*cc1)*2.2;
  1004.  
  1005. float ch1 = 2.5*carchrome;
  1006. float ch2 = 1.5*carchrome;
  1007. float gc4;
  1008. float gn4;
  1009. if (wx.x==0,1) gc4 = ch2;
  1010. if (wx.y==0,1) gn4 = ch2;
  1011. if (wx.x==4) gc4 = ch1;
  1012. if (wx.x==7) gc4 = ch1;
  1013. if (wx.x==8) gc4 = ch1;
  1014. if (wx.x==9) gc4 = ch1;
  1015. if (wx.x==12) gc4 = ch1;
  1016. if (wx.x==15) gc4 = ch1;
  1017. if (wx.x==16) gc4 = ch1;
  1018. if (wx.y==4) gn4 = ch1;
  1019. if (wx.y==7) gn4 = ch1;
  1020. if (wx.y==8) gn4 = ch1;
  1021. if (wx.y==9) gn4 = ch1;
  1022. if (wx.y==12) gn4 = ch1;
  1023. if (wx.y==15) gn4 = ch1;
  1024. if (wx.y==16) gn4 = ch1;
  1025.  
  1026. float wmix5 = lerp(gc4, gn4, wx.z);
  1027. float gg = saturate(1.1*mask0*mask3*mask2*mask5)*1.0;
  1028.  
  1029. if (cre==true) r0.xyz = lerp(r0, saturate(0.06*rfl1)*11.9*wmix5, gg);
  1030. //r0.xyz = lerp(r0, lerp(r0+wmix1*tl0*saturate(0.06*rfl1)*1.7, r0, xt*EFresnelFactor), 1.0*mask0*mask4*mask5); // Отражения на тачке
  1031. r0.xyz = lerp(r0, lerp(wmix1*tl0*saturate(0.06*rfl1)*1.7, r0, xt*EFresnelFactor), 1.0*mask0*mask4*mask5); // Отражения на тачке
  1032. r0.xyz = lerp(r0, r0+(saturate(0.08*rfl1)*3.5)*wmix2, 1.0*mask6); // Отражения на стеклах
  1033.  
  1034. float3 d1 = r0;
  1035. r0.xyz+= saturate(mask0*gl*0.95*cc3)*4.0;
  1036. float3 d0 = r0;
  1037. float3 dcurrent;
  1038. float3 dnext;
  1039. if (wx.x==0,1) dcurrent = d0;
  1040. if (wx.y==0,1) dnext = d0;
  1041. if (wx.x==4) dcurrent = d1;
  1042. if (wx.x==7) dcurrent = d1;
  1043. if (wx.x==8) dcurrent = d1;
  1044. if (wx.x==9) dcurrent = d1;
  1045. if (wx.x==12) dcurrent = d1;
  1046. if (wx.x==15) dcurrent = d1;
  1047. if (wx.x==16) dcurrent = d1;
  1048. if (wx.y==4) dnext = d1;
  1049. if (wx.y==7) dnext = d1;
  1050. if (wx.y==8) dnext = d1;
  1051. if (wx.y==9) dnext = d1;
  1052. if (wx.y==12) dnext = d1;
  1053. if (wx.y==15) dnext = d1;
  1054. if (wx.y==16) dnext = d1;
  1055.  
  1056. r0.xyz = lerp(dcurrent, dnext, wx.z);
  1057. float4 r3 = r0;
  1058. float3 st7 = normalize(r3.xyz);
  1059. float3 ct7=r3.xyz/st7.xyz;
  1060. ct7=pow(ct7, 1.0);
  1061. st7.xyz = pow(st7.xyz, 1.0);
  1062. r3.xyz = ct7*st7.xyz;
  1063.  
  1064. r0.xyz = lerp(r0, r0+wLhights*r3*(-0.4), 1.0*mask2*mask5);
  1065. r0.xyz = lerp(r0, r0+mask2*mask5*tcube, 0.02);
  1066. r0.w = lerp(1.0, opacity, carglass);
  1067. float fadefact = (FogParam.w - IN.vposition.z) / (FogParam.w - FogParam.z);
  1068. r0.xyz = lerp(FogFarColor.xyz, r0.xyz, saturate(fadefact));
  1069.  
  1070. float nonlineardepth = (IN.vposition.z/IN.vposition.w);
  1071. float3 ssnormal = normalize(IN.viewnormal);
  1072. ssnormal.yz = -ssnormal.yz;
  1073. float4 r1;
  1074. r1.xyz = ssnormal*0.5+0.5;
  1075. r1.w = 251.0/255.0;
  1076.  
  1077. float4 r2;
  1078. r2 = nonlineardepth;
  1079. r2.w = 1.0;
  1080. PS_OUTPUT3 OUT;
  1081. OUT.Color[0]=r0;
  1082. OUT.Color[1]=r1;
  1083. OUT.Color[2]=r2;
  1084. return OUT;
  1085. }
  1086.  
  1087. ////////////////////////////////////////////////////////////////////////////////////
  1088. /////////////////////////////////////SA_DirectX/////////////////////////////////////
  1089. ////////////////////////////////////////////////////////////////////////////////////
  1090.  
  1091. technique Draw
  1092. {
  1093. pass p0
  1094. {
  1095. VertexShader = compile vs_3_0 VS_Draw();
  1096. PixelShader = compile ps_3_0 PS_Draw();
  1097. }
  1098. }
  1099.  
  1100. technique DrawTransparent
  1101. {
  1102. pass p0
  1103. {
  1104. VertexShader = compile vs_3_0 VS_Draw();
  1105. PixelShader = compile ps_3_0 PS_Draw();
  1106. }
  1107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement