Advertisement
Guest User

Untitled

a guest
Jul 16th, 2011
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.88 KB | None | 0 0
  1. // TEST TEST TEST TEST
  2.  
  3. // Copyright : DKT70&GP65CJ04&ICELAGLACE
  4.  
  5. // ASK PERMISSIONS IF YOU WANT IT
  6.  
  7. // MAIL ME AT [email protected]
  8. // PM ME ON GTAFORUMS
  9. // YOUTUBE ACCOUNT : AIMEDEHAIRE
  10.  
  11. // I LIKE BIG BUTTS AND I CANNOT LIE
  12.  
  13.  
  14. float4 BloomParameters;
  15. float4 TempParameters;
  16. float4 ScreenSize;
  17. float Nintendo = 64;
  18. float WhatIfYouGet2N64 = 128;
  19. float Stealers = 0.0;
  20.  
  21.  
  22. //quad
  23. struct VS_OUTPUT_POST
  24. {
  25. float4 vpos : POSITION;
  26. float2 txcoord0 : TEXCOORD0;
  27. };
  28. struct VS_INPUT_POST
  29. {
  30. float3 pos : POSITION;
  31. float2 txcoord0 : TEXCOORD0;
  32. };
  33.  
  34.  
  35.  
  36. texture2D texBloom1;
  37. texture2D texBloom2;
  38. texture2D texBloom3;
  39. texture2D texBloom4;
  40. texture2D texBloom5;
  41.  
  42. sampler2D SamplerBloom1 = sampler_state
  43. {
  44. Texture = <texBloom1>;
  45. MinFilter = LINEAR;
  46. MagFilter = LINEAR;
  47. MipFilter = NONE;//NONE;
  48. AddressU = Clamp;
  49. AddressV = Clamp;
  50. SRGBTexture=FALSE;
  51. MaxMipLevel=0;
  52. MipMapLodBias=0;
  53. };
  54.  
  55. sampler2D SamplerBloom2 = sampler_state
  56. {
  57. Texture = <texBloom2>;
  58. MinFilter = LINEAR;
  59. MagFilter = LINEAR;
  60. MipFilter = NONE;//NONE;
  61. AddressU = Clamp;
  62. AddressV = Clamp;
  63. SRGBTexture=FALSE;
  64. MaxMipLevel=0;
  65. MipMapLodBias=0;
  66. };
  67.  
  68. sampler2D SamplerBloom3 = sampler_state
  69. {
  70. Texture = <texBloom3>;
  71. MinFilter = LINEAR;
  72. MagFilter = LINEAR;
  73. MipFilter = NONE;//NONE;
  74. AddressU = Clamp;
  75. AddressV = Clamp;
  76. SRGBTexture=FALSE;
  77. MaxMipLevel=0;
  78. MipMapLodBias=0;
  79. };
  80.  
  81. sampler2D SamplerBloom4 = sampler_state
  82. {
  83. Texture = <texBloom4>;
  84. MinFilter = LINEAR;
  85. MagFilter = LINEAR;
  86. MipFilter = NONE;//NONE;
  87. AddressU = Clamp;
  88. AddressV = Clamp;
  89. SRGBTexture=FALSE;
  90. MaxMipLevel=0;
  91. MipMapLodBias=0;
  92. };
  93.  
  94. sampler2D SamplerBloom5 = sampler_state
  95. {
  96. Texture = <texBloom5>;
  97. MinFilter = LINEAR;
  98. MagFilter = LINEAR;
  99. MipFilter = NONE;//NONE;
  100. AddressU = Clamp;
  101. AddressV = Clamp;
  102. SRGBTexture=FALSE;
  103. MaxMipLevel=0;
  104. MipMapLodBias=0;
  105. };
  106.  
  107.  
  108.  
  109. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  110. //
  111. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  112. VS_OUTPUT_POST VS_Bloom(VS_INPUT_POST IN)
  113. {
  114. VS_OUTPUT_POST OUT;
  115.  
  116. OUT.vpos=float4(IN.pos.x,IN.pos.y,IN.pos.z,1.0);
  117.  
  118. OUT.txcoord0.xy=IN.txcoord0.xy+TempParameters.xy;//1.0/(bloomtexsize*2.0)
  119.  
  120. return OUT;
  121. }
  122.  
  123. float4 PS_BloomPrePass(VS_OUTPUT_POST In) : COLOR
  124. {
  125. float4 destroygpu;
  126. float4 formathddsteal;
  127. float bloomrape = 40;
  128.  
  129.  
  130. float4 bloom=tex2D(SamplerBloom1, In.txcoord0);
  131. const float2 offset[16]=
  132. {
  133. float2(-0.94201624, -0.39906216),
  134. float2(0.94558609, -0.76890725),
  135. float2(-10.09418410, -25.92938870),
  136. float2(10.34495938, 10.29387760),
  137. float2(-7.91588581, 0.45771432),
  138. float2(-0.81544232, -0.87912464),
  139. float2(-0.38277543, 0.27676845),
  140. float2(0.97484398, 0.75648379),
  141. float2(0.44323325, -0.97511554),
  142. float2(0.53742981, -0.47373420),
  143. float2(-0.26496911, -0.41893023),
  144. float2(0.79197514, 0.19090188),
  145. float2(-0.24188840, 0.99706507),
  146. float2(-0.81409955, 0.91437590),
  147. float2(0.19984126, 0.78641367),
  148. float2(0.14383161, -0.14100790)
  149. };
  150. float2 screenfact=1.0;
  151. screenfact.y*=ScreenSize.z;
  152. screenfact.xy*=TempParameters.z*1.5;
  153. float4 srcbloom=bloom;
  154.  
  155. for (int i=0; i<8; i++)
  156. {
  157. destroygpu.xy= In.txcoord0.xy;
  158.  
  159. //destroygpu.xy=offset[i];
  160. //destroygpu.xy=(destroygpu.xy*screenfact.xy)+In.txcoord0.xy;//-(1.0/256.0);//-(1.0/512.0);
  161.  
  162. destroygpu.x = destroygpu.x - 0.5;
  163. destroygpu.y = 0.5 - destroygpu.y;
  164.  
  165. destroygpu.xy -= destroygpu.xy* floor(i*0.5) *0.25;
  166. destroygpu.xy = -destroygpu.xy;
  167.  
  168. destroygpu.xy *= 1.25 + i * 0.3;
  169.  
  170. destroygpu.x = destroygpu.x + 0.5;
  171. destroygpu.y = 0.5 - destroygpu.y;
  172.  
  173. destroygpu.xy = saturate(destroygpu.xy);
  174.  
  175. formathddsteal = tex2D(SamplerBloom1, destroygpu.xy);
  176. formathddsteal.w = dot(formathddsteal.xyz, 0.3333);
  177. formathddsteal.w = saturate(formathddsteal.w - bloomrape);
  178. if(formathddsteal.w) bloom.xyz += formathddsteal.xyz;
  179. else
  180. {
  181. destroygpu.xy=offset[i];
  182. destroygpu.xy=(destroygpu.xy*screenfact.xy)+In.txcoord0.xy;//-(1.0/256.0);//-(1.0/512.0);
  183. bloom+=tex2D(SamplerBloom1, destroygpu.xy);
  184. }
  185. }
  186. bloom*=0.1000;//0.125;
  187.  
  188. bloom.w=1.0;
  189. return bloom;
  190. }
  191.  
  192. float4 PS_BloomTexture1(VS_OUTPUT_POST In) : COLOR
  193. {
  194. float4 destroygpu;
  195. float4 destroygpu2;
  196.  
  197. float4 bloom=tex2D(SamplerBloom1, In.txcoord0);
  198. const float2 offset[16]=
  199. {
  200. float2(-0.94201624, -0.39906216),
  201. float2( 0.94558609, -0.76890725),
  202. float2(-0.09418410, -0.92938870),
  203. float2( 0.34495938, 0.29387760),
  204. float2(-0.91588581, 0.45771432),
  205. float2(-0.81544232, -0.87912464),
  206. float2(-0.38277543, 0.27676845),
  207. float2( 0.97484398, 0.75648379),
  208. float2( 0.44323325, -0.97511554),
  209. float2( 0.53742981, -0.47373420),
  210. float2(-0.26496911, -0.41893023),
  211. float2( 0.79197514, 0.19090188),
  212. float2(-0.24188840, 0.99706507),
  213. float2(-0.81409955, 0.91437590),
  214. float2( 0.19984126, 0.78641367),
  215. float2( 0.14383161, -0.14100790)
  216. };
  217. float2 screenfact=1.0;
  218. screenfact.y*=ScreenSize.z;
  219. screenfact.xy/=ScreenSize.x;
  220. float4 srcbloom=bloom;
  221. float step=(TempParameters.w-0.5);//*1.5;
  222. screenfact.xy*=step;
  223.  
  224. float4 bloomadd=bloom;
  225. for (int i=0; i<8; i++)
  226. {
  227. destroygpu.xy=offset[i]*BloomParameters.x;
  228. destroygpu.xy=(destroygpu.xy*screenfact.xy)+In.txcoord0.xy;//-(1.0/256.0);//-(1.0/512.0);
  229.  
  230. destroygpu2.xy=offset[i]*Nintendo;
  231. destroygpu2.xy=(destroygpu2.xy*screenfact.xy)+In.txcoord0.xy;
  232.  
  233. //v2
  234. float4 tempbloom1=tex2D(SamplerBloom1, destroygpu.xy);
  235. float4 tempbloom2=tex2D(SamplerBloom1, destroygpu2.xy);
  236.  
  237. float4 tempbloom = lerp(tempbloom1, tempbloom2, Stealers);
  238. bloomadd+=tempbloom;
  239.  
  240. bloom.xyz = max(bloom.xyz, tempbloom.xyz*0.99);
  241.  
  242.  
  243.  
  244.  
  245. }
  246. //v1
  247. bloomadd*=0.111111;
  248. //v0
  249. bloom.xyz=lerp(bloomadd.xyz, bloom.xyz, BloomParameters.w);
  250.  
  251.  
  252. //float3 violet=float3(0.78, 0.5, 1.0);
  253. //float3 violet=float3(0.6, 0.4, 1.0);//v2
  254. float3 violet=float3(0.6, 0.5, 1.0);//v3
  255.  
  256. //this applies when white
  257. //float gray=0.104*dot(srcbloom.xyz, 0.333);//max(srcbloom.x, max(srcbloom.y, srcbloom.z));
  258. //this applies on dark and when contrast
  259. float ttt=dot(bloom.xyz, 0.333)-dot(srcbloom.xyz, 0.333);
  260. ttt=max(ttt, 0.0);
  261. float gray=BloomParameters.z*ttt;//max(srcbloom.x, max(srcbloom.y, srcbloom.z));
  262. float mixfact=(gray/(1.0+gray));
  263. mixfact*=1.0-saturate((TempParameters.w-1.0)*0.3);
  264. violet.xy+=saturate((TempParameters.w-1.0)*0.3);
  265. violet.xy=saturate(violet.xy);
  266. bloom.xyz*=lerp(1.0, violet.xyz, mixfact);
  267.  
  268. bloom.w=1.0;
  269. return bloom;
  270. }
  271.  
  272.  
  273. //second pass
  274. //SamplerBloom1 is result of first pass
  275. float4 PS_BloomTexture2(VS_OUTPUT_POST In) : COLOR
  276. {
  277. float4 destroygpu;
  278. float4 destroygpu2;
  279.  
  280. float4 bloom=tex2D(SamplerBloom1, In.txcoord0);
  281. const float2 offset[16]=
  282. {
  283. float2(-0.94201624, -0.39906216),
  284. float2( 0.94558609, -0.76890725),
  285. float2(-0.09418410, -0.92938870),
  286. float2( 0.34495938, 0.29387760),
  287. float2(-0.91588581, 0.45771432),
  288. float2(-0.81544232, -0.87912464),
  289. float2(-0.38277543, 0.27676845),
  290. float2( 0.97484398, 0.75648379),
  291. float2( 0.44323325, -0.97511554),
  292. float2( 0.53742981, -0.47373420),
  293. float2(-0.26496911, -0.41893023),
  294. float2( 0.79197514, 0.19090188),
  295. float2(-0.24188840, 0.99706507),
  296. float2(-0.81409955, 0.91437590),
  297. float2( 0.19984126, 0.78641367),
  298. float2( 0.14383161, -0.14100790)
  299. };
  300. float2 screenfact=1.0;
  301. screenfact.y*=ScreenSize.z;
  302. screenfact.xy/=ScreenSize.x;
  303. float4 srcbloom=bloom;
  304.  
  305. float step=(TempParameters.w-0.5)*1.2;//v3
  306. screenfact.xy*=step;
  307. float4 rotvec=0.0;
  308. sincos(0.19635, rotvec.x, rotvec.y);
  309. for (int i=0; i<8; i++)
  310. {
  311.  
  312. destroygpu.xy=offset[i];
  313. destroygpu.xy=reflect(destroygpu.xy, rotvec.xy);
  314. destroygpu.xy*=BloomParameters.y;
  315. //separate code is much faster without constant table operations
  316. destroygpu.xy=(destroygpu.xy*screenfact.xy)+In.txcoord0.xy;//-(1.0/256.0);//-(1.0/512.0);
  317.  
  318. float4 tempbloom1 = tex2D(SamplerBloom1, destroygpu.xy);
  319.  
  320.  
  321.  
  322. destroygpu2.xy=offset[i];
  323. destroygpu2.xy=reflect(destroygpu2.xy, rotvec.xy);
  324. destroygpu2.xy*=WhatIfYouGet2N64;
  325. destroygpu2.xy=(destroygpu2.xy*screenfact.xy)+In.txcoord0.xy;//-(1.0/256.0);//-(1.0/512.0);
  326. float4 tempbloom2 = tex2D(SamplerBloom1, destroygpu2.xy);
  327.  
  328. float4 tempbloom = lerp(tempbloom1, tempbloom2, Stealers);
  329.  
  330. bloom+=tempbloom;
  331.  
  332. }
  333. bloom*=0.15000;//0.125;
  334.  
  335. bloom.w=1.0;
  336. return bloom;
  337. }
  338.  
  339.  
  340.  
  341. //last pass, mix several bloom textures
  342. //SamplerBloom5 is the result of prepass
  343. float4 PS_BloomPostPass(VS_OUTPUT_POST In) : COLOR
  344. {
  345. float4 bloom;
  346. float4 temp;
  347. //v1
  348. bloom =tex2D(SamplerBloom1, In.txcoord0);
  349. bloom+=tex2D(SamplerBloom2, In.txcoord0);
  350. bloom+=tex2D(SamplerBloom3, In.txcoord0);
  351. bloom+=tex2D(SamplerBloom4, In.txcoord0);
  352. bloom+=tex2D(SamplerBloom5, In.txcoord0);
  353. bloom*=0.2;
  354. temp = bloom;
  355.  
  356. //v2
  357. float4 bloom1=tex2D(SamplerBloom1, In.txcoord0);
  358. float4 bloom2=tex2D(SamplerBloom2, In.txcoord0);
  359. float4 bloom3=tex2D(SamplerBloom3, In.txcoord0);
  360. float4 bloom4=tex2D(SamplerBloom4, In.txcoord0);
  361. float4 bloom5=tex2D(SamplerBloom5, In.txcoord0);
  362. bloom=max(bloom1, bloom2);
  363. bloom=max(bloom, bloom3);
  364. bloom=max(bloom, bloom4);
  365. bloom=max(bloom, bloom5);
  366.  
  367. bloom = lerp(temp, bloom, 0.3);
  368.  
  369. //bloom =tex2D(SamplerBloom1, In.txcoord0);
  370.  
  371. bloom.w=1.0;
  372. return bloom;
  373. }
  374.  
  375.  
  376.  
  377. technique BloomPrePass
  378. {
  379. pass p0
  380. {
  381. VertexShader = compile vs_3_0 VS_Bloom();
  382. PixelShader = compile ps_3_0 PS_BloomPrePass();
  383.  
  384. COLORWRITEENABLE=ALPHA|RED|GREEN|BLUE;
  385. CullMode=NONE;
  386. AlphaBlendEnable=FALSE;
  387. AlphaTestEnable=FALSE;
  388. SEPARATEALPHABLENDENABLE=FALSE;
  389. FogEnable=FALSE;
  390. SRGBWRITEENABLE=FALSE;
  391. }
  392. }
  393.  
  394. technique BloomTexture1
  395. {
  396. pass p0
  397. {
  398. VertexShader = compile vs_3_0 VS_Bloom();
  399. PixelShader = compile ps_3_0 PS_BloomTexture1();
  400.  
  401. COLORWRITEENABLE=ALPHA|RED|GREEN|BLUE;
  402. CullMode=NONE;
  403. AlphaBlendEnable=FALSE;
  404. AlphaTestEnable=FALSE;
  405. SEPARATEALPHABLENDENABLE=FALSE;
  406. FogEnable=FALSE;
  407. SRGBWRITEENABLE=FALSE;
  408. }
  409. }
  410.  
  411.  
  412. technique BloomTexture2
  413. {
  414. pass p0
  415. {
  416. VertexShader = compile vs_3_0 VS_Bloom();
  417. PixelShader = compile ps_3_0 PS_BloomTexture2();
  418.  
  419. COLORWRITEENABLE=ALPHA|RED|GREEN|BLUE;
  420. CullMode=NONE;
  421. AlphaBlendEnable=FALSE;
  422. AlphaTestEnable=FALSE;
  423. SEPARATEALPHABLENDENABLE=FALSE;
  424. FogEnable=FALSE;
  425. SRGBWRITEENABLE=FALSE;
  426. }
  427. }
  428.  
  429. technique BloomPostPass
  430. {
  431. pass p0
  432. {
  433. VertexShader = compile vs_3_0 VS_Bloom();
  434. PixelShader = compile ps_3_0 PS_BloomPostPass();
  435.  
  436. COLORWRITEENABLE=ALPHA|RED|GREEN|BLUE;
  437. CullMode=NONE;
  438. AlphaBlendEnable=FALSE;
  439. AlphaTestEnable=FALSE;
  440. SEPARATEALPHABLENDENABLE=FALSE;
  441. FogEnable=FALSE;
  442. SRGBWRITEENABLE=FALSE;
  443. }
  444. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement