Advertisement
Guest User

[Fallout 4] Kawase blur bloom 1.1

a guest
Aug 31st, 2016
679
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. // ENBSeries Fallout 4 hlsl DX11 format, sample file of bloom
  3. // visit http://enbdev.com for updates
  4. // Author: Boris Vorontsov
  5. // It's works with hdr input and output
  6. // Bloom texture is always forced to 1024*1024 resolution
  7. //
  8. // With some additions from Natural Bloom.
  9. // Credits to MaxTheUniqueGamer, JawZ, Wolrajh,
  10. // and several others on the ENB forums.
  11. //
  12. // With gaussian-like "Kawase blur" bloom. v1.1
  13. // Ported by roxahris. Original algorithms by Filip S. and Masaki Kawase.
  14. // Additional credits are below near the code.
  15. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  16.  
  17. //+++++++++++++++++++++++++++++
  18. //internal parameters, modify or add new
  19. //+++++++++++++++++++++++++++++
  20. /*
  21. //example parameters with annotations for in-game editor
  22. float ExampleScalar
  23. <
  24. string UIName="Example scalar";
  25. string UIWidget="spinner";
  26. float UIMin=0.0;
  27. float UIMax=1000.0;
  28. > = {1.0};
  29.  
  30. float3 ExampleColor
  31. <
  32. string UIName = "Example color";
  33. string UIWidget = "color";
  34. > = {0.0, 1.0, 0.0};
  35.  
  36. float4 ExampleVector
  37. <
  38. string UIName="Example vector";
  39. string UIWidget="vector";
  40. > = {0.0, 1.0, 0.0, 0.0};
  41.  
  42. int ExampleQuality
  43. <
  44. string UIName="Example quality";
  45. string UIWidget="quality";
  46. int UIMin=0;
  47. int UIMax=3;
  48. > = {1};
  49.  
  50. Texture2D ExampleTexture
  51. <
  52. string UIName = "Example texture";
  53. string ResourceName = "test.bmp";
  54. >;
  55. SamplerState ExampleSampler
  56. {
  57. Filter = MIN_MAG_MIP_LINEAR;
  58. AddressU = Clamp;
  59. AddressV = Clamp;
  60. };
  61. */
  62.  
  63. //#define RuntimeScale
  64. #ifdef RuntimeScale
  65. float scale <
  66. string UIName="ENB Bloom: Scale";
  67. string UIWidget="Spinner";
  68. float UIMin=0.0;
  69. float UIMax=32.0;
  70. float UIStep=0.01;
  71. > = {4.0};
  72. #endif
  73.  
  74.  
  75. //+++++++++++++++++++++++++++++
  76. //external enb parameters, do not modify
  77. //+++++++++++++++++++++++++++++
  78. //x = generic timer in range 0..1, period of 16777216 ms (4.6 hours), y = average fps, w = frame time elapsed (in seconds)
  79. float4 Timer;
  80. //x = Width, y = 1/Width, z = aspect, w = 1/aspect, aspect is Width/Height
  81. float4 ScreenSize;
  82.  
  83. //+++++++++++++++++++++++++++++
  84. //external enb debugging parameters for shader programmers, do not modify
  85. //+++++++++++++++++++++++++++++
  86. //keyboard controlled temporary variables. Press and hold key 1,2,3...8 together with PageUp or PageDown to modify. By default all set to 1.0
  87. float4 tempF1; //0,1,2,3
  88. float4 tempF2; //5,6,7,8
  89. float4 tempF3; //9,0
  90. // xy = cursor position in range 0..1 of screen;
  91. // z = is shader editor window active;
  92. // w = mouse buttons with values 0..7 as follows:
  93. // 0 = none
  94. // 1 = left
  95. // 2 = right
  96. // 3 = left+right
  97. // 4 = middle
  98. // 5 = left+middle
  99. // 6 = right+middle
  100. // 7 = left+right+middle (or rather cat is sitting on your mouse)
  101. float4 tempInfo1;
  102. // xy = cursor position of previous left mouse button click
  103. // zw = cursor position of previous right mouse button click
  104. float4 tempInfo2;
  105.  
  106.  
  107.  
  108. //+++++++++++++++++++++++++++++
  109. //mod parameters, do not modify
  110. //+++++++++++++++++++++++++++++
  111. Texture2D TextureDownsampled; //color R16B16G16A16 64 bit or R11G11B10 32 bit hdr format. 1024*1024 size
  112. Texture2D TextureColor; //color which is output of previous technique (except when drawed to temporary render target), R16B16G16A16 64 bit hdr format. 1024*1024 size
  113.  
  114. Texture2D TextureOriginal; //color R16B16G16A16 64 bit or R11G11B10 32 bit hdr format, screen size. PLEASE AVOID USING IT BECAUSE OF ALIASING ARTIFACTS, UNLESS YOU FIX THEM
  115. Texture2D TextureDepth; //scene depth R32F 32 bit hdr format, screen size. PLEASE AVOID USING IT BECAUSE OF ALIASING ARTIFACTS, UNLESS YOU FIX THEM
  116. Texture2D TextureAperture; //this frame aperture 1*1 R32F hdr red channel only. computed in PS_Aperture of enbdepthoffield.fx
  117.  
  118. //temporary textures which can be set as render target for techniques via annotations like <string RenderTarget="RenderTargetRGBA32";>
  119. Texture2D RenderTarget1024; //R16B16G16A16F 64 bit hdr format, 1024*1024 size
  120. Texture2D RenderTarget512; //R16B16G16A16F 64 bit hdr format, 512*512 size
  121. Texture2D RenderTarget256; //R16B16G16A16F 64 bit hdr format, 256*256 size
  122. Texture2D RenderTarget128; //R16B16G16A16F 64 bit hdr format, 128*128 size
  123. Texture2D RenderTarget64; //R16B16G16A16F 64 bit hdr format, 64*64 size
  124. Texture2D RenderTarget32; //R16B16G16A16F 64 bit hdr format, 32*32 size
  125. Texture2D RenderTarget16; //R16B16G16A16F 64 bit hdr format, 16*16 size
  126. Texture2D RenderTargetRGBA32; //R8G8B8A8 32 bit ldr format, screen size
  127. Texture2D RenderTargetRGBA64F; //R16B16G16A16F 64 bit hdr format, screen size
  128.  
  129. SamplerState Sampler0
  130. {
  131. Filter = MIN_MAG_MIP_POINT;
  132. AddressU = Clamp;
  133. AddressV = Clamp;
  134. };
  135. SamplerState Sampler1
  136. {
  137. Filter = MIN_MAG_MIP_LINEAR;
  138. AddressU = Clamp;
  139. AddressV = Clamp;
  140. };
  141.  
  142.  
  143.  
  144. //+++++++++++++++++++++++++++++
  145. //
  146. //+++++++++++++++++++++++++++++
  147. struct VS_INPUT_POST
  148. {
  149. float3 pos : POSITION;
  150. float2 txcoord : TEXCOORD0;
  151. };
  152. struct VS_OUTPUT_POST
  153. {
  154. float4 pos : SV_POSITION;
  155. float2 txcoord0 : TEXCOORD0;
  156. };
  157.  
  158.  
  159.  
  160. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  161. //
  162. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  163. VS_OUTPUT_POST VS_Quad(VS_INPUT_POST IN)
  164. {
  165. VS_OUTPUT_POST OUT;
  166. float4 pos;
  167. pos.xyz=IN.pos.xyz;
  168. pos.w=1.0;
  169. OUT.pos=pos;
  170. OUT.txcoord0.xy=IN.txcoord.xy;
  171. return OUT;
  172. }
  173.  
  174. float linearDepth(float d, float n, float f)
  175. {
  176. return (2.0 * n)/(f + n - d * (f - n));
  177. }
  178.  
  179. // SHADERS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  180. //
  181.  
  182. float3 FuncBlur(Texture2D inputtex, float2 uvsrc, float srcsize, float destsize)
  183. {
  184. #ifndef RuntimeScale
  185. const float scale=8.0; //7.0; //14.0; //blurring range, samples count (performance) is factor of scale*scale
  186. #endif
  187.  
  188. float2 invtargetsize=scale/srcsize;
  189. invtargetsize.y*=ScreenSize.z; //correct by aspect ratio
  190.  
  191. float2 fstepcount;
  192. fstepcount=srcsize;
  193.  
  194. fstepcount*=invtargetsize;
  195. #if 0
  196. fstepcount=min(fstepcount, 32.0); // Steps upper limit
  197. fstepcount=max(fstepcount, 1.0); // Steps lower limit
  198. #elif 0
  199. fstepcount=min(fstepcount, 16.0);
  200. fstepcount=max(fstepcount, 1.0);
  201. #else
  202. fstepcount=min(fstepcount, 48.0);
  203. fstepcount=max(fstepcount, 1.0);
  204. #endif
  205.  
  206. int stepcountX=(int)(fstepcount.x+0.4999);
  207. int stepcountY=(int)(fstepcount.y+0.4999);
  208.  
  209. fstepcount=1.0/fstepcount;
  210. float4 curr=0.0;
  211. curr.w=0.000001;
  212. float2 pos;
  213. float2 halfstep=0.5*fstepcount.xy;
  214. pos.x=-0.5+halfstep.x;
  215. invtargetsize *= 2.0;
  216. for (int x=0; x<stepcountX; x++)
  217. {
  218. pos.y=-0.5+halfstep.y;
  219. for (int y=0; y<stepcountY; y++)
  220. {
  221. float2 coord=pos.xy * invtargetsize + uvsrc.xy;
  222. float3 tempcurr=inputtex.Sample(Sampler1, coord.xy).xyz;
  223. float tempweight;
  224. float2 dpos=pos.xy*2.0;
  225. float rangefactor=dot(dpos.xy, dpos.xy);
  226. //loosing many pixels here, don't program such unefficient cycle yourself!
  227. tempweight=saturate(1001.0 - 1000.0*rangefactor);//arithmetic version to cut circle from square
  228. tempweight*=saturate(1.0 - rangefactor); //softness, without it bloom looks like bokeh dof
  229. curr.xyz+=tempcurr.xyz * tempweight;
  230. curr.w+=tempweight;
  231.  
  232. pos.y+=fstepcount.y;
  233. }
  234. pos.x+=fstepcount.x;
  235. }
  236. curr.xyz/=curr.w;
  237.  
  238. return curr.xyz;
  239. }
  240.  
  241. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  242. //example 1. draw in single pass directly to bloom texture of 1024*1024 size
  243. float4 PS_ExampleBloom1(VS_OUTPUT_POST IN, float4 v0 : SV_Position0,
  244. uniform Texture2D inputtex, uniform float srcsize, uniform float destsize) : SV_Target
  245. {
  246. float4 res;
  247.  
  248. res.xyz=FuncBlur(inputtex, IN.txcoord0.xy, srcsize, destsize);
  249.  
  250. res=max(res, 0.0);
  251. res=min(res, 16384.0);
  252.  
  253. res.w=1.0;
  254. return res;
  255. }
  256.  
  257. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  258. //example 2. draw in several passes to different render targets
  259. float4 PS_Resize(VS_OUTPUT_POST IN, float4 v0 : SV_Position0,
  260. uniform Texture2D inputtex, uniform float srcsize, uniform float destsize) : SV_Target
  261. {
  262. float4 res;
  263.  
  264. res.xyz=FuncBlur(inputtex, IN.txcoord0.xy, srcsize, destsize);
  265.  
  266. res=max(res, 0.0);
  267. res=min(res, 16384.0);
  268.  
  269. res.w=1.0;
  270. return res;
  271. }
  272.  
  273. float4 PS_ResizeFirst(VS_OUTPUT_POST IN, float4 v0 : SV_Position0,
  274. uniform Texture2D inputtex, uniform float srcsize, uniform float destsize) : SV_Target
  275. {
  276. float4 res;
  277.  
  278. res.xyz=FuncBlur(inputtex, IN.txcoord0.xy, srcsize, destsize);
  279.  
  280. res=max(res, 0.0);
  281. res=min(res, 16384.0);
  282.  
  283. res.w=1.0;
  284. return res;
  285. }
  286.  
  287. float4 PS_BloomMix(VS_OUTPUT_POST IN, float4 v0 : SV_Position0) : SV_Target
  288. {
  289. float4 res;
  290.  
  291. #if 0
  292. res.xyz=RenderTarget1024.Sample(Sampler1, IN.txcoord0.xy);
  293. res.xyz+=RenderTarget512.Sample(Sampler1, IN.txcoord0.xy);
  294. res.xyz+=RenderTarget256.Sample(Sampler1, IN.txcoord0.xy);
  295. res.xyz+=RenderTarget128.Sample(Sampler1, IN.txcoord0.xy);
  296. res.xyz+=RenderTarget64.Sample(Sampler1, IN.txcoord0.xy);
  297. res.xyz+=RenderTarget32.Sample(Sampler1, IN.txcoord0.xy);
  298. res.xyz /= 6;
  299. #else
  300. res.xyz=RenderTarget1024.Sample(Sampler1, IN.txcoord0.xy)*0.5;
  301. res.xyz+=RenderTarget512.Sample(Sampler1, IN.txcoord0.xy)*0.8*0.75;
  302. res.xyz+=RenderTarget256.Sample(Sampler1, IN.txcoord0.xy)*0.6;
  303. res.xyz+=RenderTarget128.Sample(Sampler1, IN.txcoord0.xy)*0.45;
  304. res.xyz+=RenderTarget64.Sample(Sampler1, IN.txcoord0.xy) *0.32;
  305. res.xyz+=RenderTarget32.Sample(Sampler1, IN.txcoord0.xy) *0.23;
  306. res.xyz /= 2.2;
  307. #endif
  308.  
  309. res=max(res, 0.0);
  310. res=min(res, 16384.0);
  311.  
  312. res.w=1.0;
  313. return res;
  314. }
  315.  
  316.  
  317. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  318. // Kawase blur bloom.
  319. // This is supposedly a very fast approximation of a gaussian blur.
  320. // Source: https://software.intel.com/en-us/blogs/2014/07/15/an-investigation-of-fast-real-time-gpu-based-image-blur-algorithms
  321. float3 KawaseBlurFilter( Texture2D tex, float2 texCoord, float2 pixelSize, float iteration )
  322. {
  323. float2 texCoordSample;
  324. float2 halfPixelSize = pixelSize / 2.0f;
  325. float2 dUV = ( pixelSize.xy * float2( iteration, iteration ) ) + halfPixelSize.xy;
  326.  
  327. float3 cOut;
  328.  
  329. // Sample top left pixel
  330. texCoordSample.x = texCoord.x - dUV.x;
  331. texCoordSample.y = texCoord.y + dUV.y;
  332. cOut = tex.Sample(Sampler1, texCoordSample ).xyz;
  333.  
  334. // Sample top right pixel
  335. texCoordSample.x = texCoord.x + dUV.x;
  336. texCoordSample.y = texCoord.y + dUV.y;
  337. cOut += tex.Sample(Sampler1, texCoordSample ).xyz;
  338.  
  339. // Sample bottom right pixel
  340. texCoordSample.x = texCoord.x + dUV.x;
  341. texCoordSample.y = texCoord.y - dUV.y;
  342. cOut += tex.Sample(Sampler1, texCoordSample ).xyz;
  343.  
  344. // Sample bottom left pixel
  345. texCoordSample.x = texCoord.x - dUV.x;
  346. texCoordSample.y = texCoord.y - dUV.y;
  347. cOut += tex.Sample(Sampler1, texCoordSample ).xyz;
  348.  
  349. // Average
  350. cOut *= 0.25f;
  351.  
  352. return cOut;
  353. }
  354.  
  355. float4 PS_KawaseBloom(VS_OUTPUT_POST IN, float4 v0 : SV_Position0,
  356. uniform Texture2D inputtex, uniform float destsize, uniform float iteration) : SV_Target
  357. {
  358. float4 res;
  359.  
  360. //float2 pxSize = (1/destsize)*float2(1, ScreenSize.z); // Visibly blocky
  361. float2 pxSize = (1/(destsize*2))*float2(1, ScreenSize.z);
  362.  
  363. res.xyz=KawaseBlurFilter(inputtex, IN.txcoord0.xy, pxSize, iteration);
  364.  
  365. #if 0 // Double blur. This removes artifacing in the raw bloom texture.
  366. // However, it costs more than ENB's bloom and does like 60 passes.
  367. // The aliasing is only noticeable at 100% bloom anyway.
  368. res.xyz+=KawaseBlurFilter(inputtex, IN.txcoord0.xy, pxSize, iteration+1);
  369. res.xyz/=2;
  370. #endif
  371.  
  372. res=max(res, 0.0);
  373. res=min(res, 16384.0);
  374.  
  375. res.w=1.0;
  376. return res;
  377. }
  378.  
  379. float4 PS_KawaseMix(VS_OUTPUT_POST IN, float4 v0 : SV_Position0) : SV_Target
  380. {
  381. float4 res;
  382.  
  383. res.xyz=RenderTarget1024.Sample(Sampler1, IN.txcoord0.xy);
  384.  
  385. res=max(res, 0.0);
  386. res=min(res, 16384.0);
  387.  
  388. res.w=1.0;
  389. return res;
  390. }
  391.  
  392. float4 PS_KawaseMix2(VS_OUTPUT_POST IN, float4 v0 : SV_Position0) : SV_Target
  393. {
  394. float4 res=0;
  395.  
  396.  
  397. #if 0
  398. res.xyz=RenderTarget1024.Sample(Sampler1, IN.txcoord0.xy);
  399. res.xyz+=RenderTarget512.Sample(Sampler1, IN.txcoord0.xy);
  400. res.xyz+=RenderTarget256.Sample(Sampler1, IN.txcoord0.xy);
  401. res.xyz+=RenderTarget128.Sample(Sampler1, IN.txcoord0.xy);
  402. res.xyz+=RenderTarget64.Sample(Sampler1, IN.txcoord0.xy);
  403. res.xyz+=RenderTarget32.Sample(Sampler1, IN.txcoord0.xy);
  404. res.xyz /= 6;
  405. #else
  406. res.xyz=RenderTarget1024.Sample(Sampler1, IN.txcoord0.xy)*0.5;
  407. res.xyz+=RenderTarget512.Sample(Sampler1, IN.txcoord0.xy)*0.8*0.75;
  408. res.xyz+=RenderTarget256.Sample(Sampler1, IN.txcoord0.xy)*0.6;
  409. res.xyz+=RenderTarget128.Sample(Sampler1, IN.txcoord0.xy)*0.45;
  410. res.xyz+=RenderTarget64.Sample(Sampler1, IN.txcoord0.xy) *0.32;
  411. res.xyz+=RenderTarget32.Sample(Sampler1, IN.txcoord0.xy) *0.23;
  412. res.xyz /= 2.2;
  413. #endif
  414.  
  415. res=max(res, 0.0);
  416. res=min(res, 16384.0);
  417.  
  418. res.w=1.0;
  419. return res;
  420. }
  421.  
  422.  
  423. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  424. // Techniques are drawn one after another and they use the result of
  425. // the previous technique as input color to the next one. The number
  426. // of techniques is limited to 255. If UIName is specified, then it
  427. // is a base technique which may have extra techniques with indexing
  428. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  429.  
  430.  
  431. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  432. technique11 KawaseBloomPass <string UIName="Kawase blur bloom (5 passes)"; string RenderTarget="RenderTarget1024";>
  433. {
  434. pass p0
  435. {
  436. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  437. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(TextureDownsampled, 1024.0, 0)));
  438. }
  439. }
  440. technique11 KawaseBloomPass1
  441. {
  442. pass p0
  443. {
  444. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  445. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(RenderTarget1024, 1024.0, 1)));
  446. }
  447. }
  448. technique11 KawaseBloomPass2
  449. {
  450. pass p0
  451. {
  452. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  453. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(TextureColor, 1024.0, 2)));
  454. }
  455. }
  456. technique11 KawaseBloomPass3
  457. {
  458. pass p0
  459. {
  460. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  461. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(TextureColor, 1024.0, 2)));
  462. }
  463. }
  464. technique11 KawaseBloomPass4 <string RenderTarget="RenderTarget1024";>
  465. {
  466. pass p0
  467. {
  468. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  469. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(TextureColor, 1024.0, 3)));
  470. }
  471. }
  472. technique11 KawaseBloomPass5
  473. {
  474. pass p0
  475. {
  476. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  477. SetPixelShader(CompileShader(ps_5_0, PS_KawaseMix()));
  478. }
  479. }
  480.  
  481. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  482. technique11 MKawaseBloomPass <string UIName="Kawase blur bloom (25 passes)"; string RenderTarget="RenderTarget1024";>
  483. {
  484. pass p0
  485. {
  486. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  487. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(TextureDownsampled, 1024.0, 0)));
  488. }
  489. }
  490. technique11 MKawaseBloomPass1 <string RenderTarget="RenderTarget512";>
  491. {
  492. pass p0
  493. {
  494. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  495. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(RenderTarget1024, 512.0, 1)));
  496. }
  497. }
  498. technique11 MKawaseBloomPass2 <string RenderTarget="RenderTarget256";>
  499. {
  500. pass p0
  501. {
  502. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  503. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(RenderTarget512, 256.0, 1)));
  504. }
  505. }
  506. technique11 MKawaseBloomPass3 <string RenderTarget="RenderTarget128";>
  507. {
  508. pass p0
  509. {
  510. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  511. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(RenderTarget256, 128.0, 1)));
  512. }
  513. }
  514. technique11 MKawaseBloomPass4 <string RenderTarget="RenderTarget64";>
  515. {
  516. pass p0
  517. {
  518. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  519. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(RenderTarget128, 64.0, 1)));
  520. }
  521. }
  522. technique11 MKawaseBloomPass5 <string RenderTarget="RenderTarget32";>
  523. {
  524. pass p0
  525. {
  526. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  527. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(RenderTarget64, 32.0, 1)));
  528. }
  529. }
  530. // Passes 1024
  531. technique11 MKawaseBloomPass6
  532. {
  533. pass p0
  534. {
  535. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  536. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(RenderTarget1024, 1024.0, 1)));
  537. }
  538. }
  539. technique11 MKawaseBloomPass7
  540. {
  541. pass p0
  542. {
  543. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  544. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(TextureColor, 1024.0, 2)));
  545. }
  546. }
  547. technique11 MKawaseBloomPass8
  548. {
  549. pass p0
  550. {
  551. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  552. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(TextureColor, 1024.0, 2)));
  553. }
  554. }
  555. technique11 MKawaseBloomPass9 <string RenderTarget="RenderTarget1024";>
  556. {
  557. pass p0
  558. {
  559. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  560. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(TextureColor, 1024.0, 3)));
  561. }
  562. }
  563. // Passes 512
  564. technique11 MKawaseBloomPass10
  565. {
  566. pass p0
  567. {
  568. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  569. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(TextureColor, 512.0, 2)));
  570. }
  571. }
  572. technique11 MKawaseBloomPass11
  573. {
  574. pass p0
  575. {
  576. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  577. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(TextureColor, 512.0, 2)));
  578. }
  579. }
  580. technique11 MKawaseBloomPass12 <string RenderTarget="RenderTarget512";>
  581. {
  582. pass p0
  583. {
  584. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  585. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(TextureColor, 512.0, 3)));
  586. }
  587. }
  588.  
  589. // Passes 256
  590. technique11 MKawaseBloomPass13
  591. {
  592. pass p0
  593. {
  594. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  595. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(TextureColor, 256.0, 2)));
  596. }
  597. }
  598. technique11 MKawaseBloomPass14
  599. {
  600. pass p0
  601. {
  602. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  603. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(TextureColor, 256.0, 2)));
  604. }
  605. }
  606. technique11 MKawaseBloomPass15 <string RenderTarget="RenderTarget256";>
  607. {
  608. pass p0
  609. {
  610. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  611. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(TextureColor, 256.0, 3)));
  612. }
  613. }
  614.  
  615. // Passes 128
  616. technique11 MKawaseBloomPass16
  617. {
  618. pass p0
  619. {
  620. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  621. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(TextureColor, 128.0, 2)));
  622. }
  623. }
  624. technique11 MKawaseBloomPass17
  625. {
  626. pass p0
  627. {
  628. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  629. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(TextureColor, 128.0, 2)));
  630. }
  631. }
  632. technique11 MKawaseBloomPass18 <string RenderTarget="RenderTarget128";>
  633. {
  634. pass p0
  635. {
  636. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  637. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(TextureColor, 128.0, 3)));
  638. }
  639. }
  640.  
  641. // Passes 64
  642. technique11 MKawaseBloomPass19
  643. {
  644. pass p0
  645. {
  646. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  647. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(TextureColor, 64.0, 2)));
  648. }
  649. }
  650. technique11 MKawaseBloomPass20
  651. {
  652. pass p0
  653. {
  654. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  655. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(TextureColor, 64.0, 2)));
  656. }
  657. }
  658. technique11 MKawaseBloomPass21 <string RenderTarget="RenderTarget64";>
  659. {
  660. pass p0
  661. {
  662. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  663. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(TextureColor, 64.0, 3)));
  664. }
  665. }
  666.  
  667. // Passes 32
  668. technique11 MKawaseBloomPass22
  669. {
  670. pass p0
  671. {
  672. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  673. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(TextureColor, 32.0, 2)));
  674. }
  675. }
  676. technique11 MKawaseBloomPass23
  677. {
  678. pass p0
  679. {
  680. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  681. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(TextureColor, 32.0, 2)));
  682. }
  683. }
  684. technique11 MKawaseBloomPass24 <string RenderTarget="RenderTarget32";>
  685. {
  686. pass p0
  687. {
  688. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  689. SetPixelShader(CompileShader(ps_5_0, PS_KawaseBloom(TextureColor, 32.0, 3)));
  690. }
  691. }
  692.  
  693. // End
  694. technique11 MKawaseBloomPass25
  695. {
  696. pass p0
  697. {
  698. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  699. SetPixelShader(CompileShader(ps_5_0, PS_KawaseMix2()));
  700. }
  701. }
  702.  
  703. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  704. //bloom example 1, draw in single pass, very performance heavy and low blurring range
  705. technique11 SinglePassBloom <string UIName="Single pass bloom";>
  706. {
  707. pass p0
  708. {
  709. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  710. SetPixelShader(CompileShader(ps_5_0, PS_ExampleBloom1(TextureDownsampled, 1024.0, 1024.0)));
  711. }
  712. }
  713. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  714. //bloom example 2, draw using several techniques and several render targets
  715. technique11 MultiPassBloom <string UIName="Multipass bloom"; string RenderTarget="RenderTarget1024";>
  716. {
  717. pass p0
  718. {
  719. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  720. SetPixelShader(CompileShader(ps_5_0, PS_ResizeFirst(TextureDownsampled, 1024.0, 1024.0)));
  721. }
  722. }
  723.  
  724. technique11 MultiPassBloom1 <string RenderTarget="RenderTarget512";>
  725. {
  726. pass p0
  727. {
  728. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  729. SetPixelShader(CompileShader(ps_5_0, PS_Resize(RenderTarget1024, 1024.0, 512.0)));
  730. }
  731. }
  732.  
  733. technique11 MultiPassBloom2 <string RenderTarget="RenderTarget256";>
  734. {
  735. pass p0
  736. {
  737. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  738. SetPixelShader(CompileShader(ps_5_0, PS_Resize(RenderTarget512, 512.0, 256.0)));
  739. }
  740. }
  741.  
  742. technique11 MultiPassBloom3 <string RenderTarget="RenderTarget128";>
  743. {
  744. pass p0
  745. {
  746. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  747. SetPixelShader(CompileShader(ps_5_0, PS_Resize(RenderTarget256, 256.0, 128.0)));
  748. }
  749. }
  750.  
  751. technique11 MultiPassBloom4 <string RenderTarget="RenderTarget64";>
  752. {
  753. pass p0
  754. {
  755. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  756. SetPixelShader(CompileShader(ps_5_0, PS_Resize(RenderTarget128, 128.0, 64.0)));
  757. }
  758. }
  759.  
  760. technique11 MultiPassBloom5 <string RenderTarget="RenderTarget32";>
  761. {
  762. pass p0
  763. {
  764. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  765. SetPixelShader(CompileShader(ps_5_0, PS_Resize(RenderTarget64, 64.0, 32.0)));
  766. }
  767. }
  768. //in last pass output to bloom texture
  769. technique11 MultiPassBloom6
  770. {
  771. pass p0
  772. {
  773. SetVertexShader(CompileShader(vs_5_0, VS_Quad()));
  774. SetPixelShader(CompileShader(ps_5_0, PS_BloomMix()));
  775. }
  776. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement