Examples.compositor
上传用户:xhbjoy
上传日期:2014-10-07
资源大小:38068k
文件大小:14k
源码类别:

游戏引擎

开发平台:

Visual C++

  1. // Manuel's bloom
  2. // Needs a scene-sized rtt, but does only one render of the scene
  3. compositor Bloom
  4. {
  5.     technique
  6.     {
  7.         // Temporary textures
  8.         texture rt0 128 128 PF_A8R8G8B8
  9.         texture rt1 128 128 PF_A8R8G8B8
  10.         target rt1
  11.         {
  12.             // Render output from previous compositor (or original scene)
  13.             input previous
  14.         }
  15.         target rt0
  16.         {
  17.             // Start with clear texture
  18.             input none
  19.             // Vertical blur pass
  20.             pass render_quad
  21.             {
  22.                 // Renders a fullscreen quad with a material
  23.                 material Ogre/Compositor/Blur0
  24.                 input 0 rt1
  25.             }
  26.         }
  27.         target rt1
  28.         {
  29.             // Start with clear texture
  30.             input none
  31.             // Horizontal blur pass
  32.             pass render_quad
  33.             {
  34.                 // Renders a fullscreen quad with a material
  35.                 material Ogre/Compositor/Blur1
  36.                 input 0 rt0
  37.             }
  38.         }
  39.         target_output
  40.         {
  41.             // Start with clear output
  42.             input previous
  43.             // Draw a fullscreen quad
  44.             pass render_quad
  45.             {
  46.                 // Renders a fullscreen quad with a material
  47.                 material Ogre/Compositor/BloomBlend
  48.                 input 0 rt1
  49.             }
  50.         }
  51.     }
  52. }
  53. compositor Glass
  54. {
  55.     technique
  56.     {
  57.         texture rt0 target_width target_height PF_R8G8B8
  58.         target rt0 { input previous }
  59.         target_output
  60.         {
  61.             // Start with clear output
  62.             input none
  63.             pass render_quad
  64.             {
  65.                 material Ogre/Compositor/GlassPass
  66.                 input 0 rt0
  67.             }
  68.         }
  69.     }
  70. }
  71. compositor "Old TV"
  72. {
  73.     technique
  74.     {
  75.         texture rt0 target_width target_height PF_R8G8B8
  76.         // render scene to a texture
  77.         target rt0 { input previous }
  78.         target_output
  79.         {
  80.             // Start with clear output
  81.             input none
  82.             pass render_quad
  83.             {
  84.                 // convert the previous render target to a black and white image, add some noise, distort it,
  85.                 // then render to scene aligned quad
  86.                 material Ogre/Compositor/OldTV
  87.                 input 0 rt0
  88.             }
  89.         }
  90.     }
  91. }
  92. // Black and white effect
  93. compositor B&W
  94. {
  95.     technique
  96.     {
  97.         // Temporary textures
  98.         texture rt0 target_width target_height PF_A8R8G8B8
  99.         target rt0
  100.         {
  101.             // Render output from previous compositor (or original scene)
  102.             input previous
  103.         }
  104.         target_output
  105.         {
  106.             // Start with clear output
  107.             input none
  108.             // Draw a fullscreen quad with the black and white image
  109.             pass render_quad
  110.             {
  111.                 // Renders a fullscreen quad with a material
  112.                 material Ogre/Compositor/BlackAndWhite
  113.                 input 0 rt0
  114.             }
  115.         }
  116.     }
  117. }
  118. //compositor DOF // based on Blur but final pass does depth of field
  119. //{
  120. //    technique
  121. //    {
  122. //        // Temporary textures
  123. //        texture rt0 target_width target_height PF_A8R8G8B8
  124. //        texture rt1 target_width target_height PF_A8R8G8B8
  125. //
  126. //        target rt1
  127. //        {
  128. //            // Render output from previous compositor (or original scene)
  129. //            input previous
  130. //        }
  131. //
  132. //        target rt0
  133. //        {
  134. //            // Start with clear texture
  135. //            input none
  136. //            // Vertical blur pass
  137. //            pass render_quad
  138. //            {
  139. //                // Renders a fullscreen quad with a material
  140. //                material Ogre/Compositor/DOF_Blur0
  141. //                input 0 rt1
  142. //            }
  143. //        }
  144. //
  145. //        target rt1
  146. //        {
  147. //            // Start with clear texture
  148. //            input none
  149. //            // Horizontal blur pass
  150. //            pass render_quad
  151. //            {
  152. //                // Renders a fullscreen quad with a material
  153. //                material Ogre/Compositor/DOF_Blur1
  154. //                input 0 rt0
  155. //            }
  156. //        }
  157. //
  158. //        target_output
  159. //        {
  160. //            // Start with clear output
  161. //            input none
  162. //            // Draw a fullscreen quad
  163. //            pass render_quad
  164. //            {
  165. //                // Renders a fullscreen quad with a material
  166. //                material Ogre/Compositor/DOF_Blend
  167. //                input 0 rt0
  168. //                input 1 rt1
  169. //            }
  170. //        }
  171. //    }
  172. //}
  173. // Embossed (fake bump) effect
  174. compositor Embossed
  175. {
  176.     technique
  177.     {
  178.         // Temporary textures
  179.         texture rt0 target_width target_height PF_A8R8G8B8
  180.         target rt0
  181.         {
  182.             // Render output from previous compositor (or original scene)
  183.             input previous
  184.         }
  185.         target_output
  186.         {
  187.             // Start with clear output
  188.             input none
  189.             // Draw a fullscreen quad with the black and white image
  190.             pass render_quad
  191.             {
  192.                 // Renders a fullscreen quad with a material
  193.                 material Ogre/Compositor/Embossed
  194.                 input 0 rt0
  195.             }
  196.         }
  197.     }
  198. }
  199. // SharpenEdges
  200. compositor Sharpen Edges
  201. {
  202.     technique
  203.     {
  204.         // Temporary textures
  205.         texture rt0 target_width target_height PF_A8R8G8B8
  206.         target rt0
  207.         {
  208.             // Render output from previous compositor (or original scene)
  209.             input previous
  210.         }
  211.         target_output
  212.         {
  213.             // Start with clear output
  214.             input none
  215.             // Draw a fullscreen quad with the black and white image
  216.             pass render_quad
  217.             {
  218.                 // Renders a fullscreen quad with a material
  219.                 material Ogre/Compositor/SharpenEdges
  220.                 input 0 rt0
  221.             }
  222.         }
  223.     }
  224. }
  225. // Invert
  226. compositor Invert
  227. {
  228.     technique
  229.     {
  230.         // Temporary textures
  231.         texture rt0 target_width target_height PF_A8R8G8B8
  232.         target rt0
  233.         {
  234.             // Render output from previous compositor (or original scene)
  235.             input previous
  236.         }
  237.         target_output
  238.         {
  239.             // Start with clear output
  240.             input none
  241.             // Draw a fullscreen quad with the black and white image
  242.             pass render_quad
  243.             {
  244.                 // Renders a fullscreen quad with a material
  245.                 material Ogre/Compositor/Invert
  246.                 input 0 rt0
  247.             }
  248.         }
  249.     }
  250. }
  251. // Posterize
  252. compositor Posterize
  253. {
  254.     technique
  255.     {
  256.         // Temporary textures
  257.         texture rt0 target_width target_height PF_A8R8G8B8
  258.         target rt0
  259.         {
  260.             // Render output from previous compositor (or original scene)
  261.             input previous
  262.         }
  263.         target_output
  264.         {
  265.             // Start with clear output
  266.             input none
  267.             // Draw a fullscreen quad with the black and white image
  268.             pass render_quad
  269.             {
  270.                 // Renders a fullscreen quad with a material
  271.                 material Ogre/Compositor/Posterize
  272.                 input 0 rt0
  273.             }
  274.         }
  275.     }
  276. }
  277. // Laplace
  278. compositor Laplace
  279. {
  280.     technique
  281.     {
  282.         // Temporary textures
  283.         texture rt0 target_width target_height PF_A8R8G8B8
  284.         target rt0
  285.         {
  286.             // Render output from previous compositor (or original scene)
  287.             input previous
  288.         }
  289.         target_output
  290.         {
  291.             // Start with clear output
  292.             input none
  293.             // Draw a fullscreen quad with the black and white image
  294.             pass render_quad
  295.             {
  296.                 // Renders a fullscreen quad with a material
  297.                 material Ogre/Compositor/Laplace
  298.                 input 0 rt0
  299.             }
  300.         }
  301.     }
  302. }
  303. // Tiling
  304. compositor Tiling
  305. {
  306.     technique
  307.     {
  308.         // Temporary textures
  309.         texture rt0 target_width target_height PF_A8R8G8B8
  310.         target rt0
  311.         {
  312.             // Render output from previous compositor (or original scene)
  313.             input previous
  314.         }
  315.         target_output
  316.         {
  317.             // Start with clear output
  318.             input none
  319.             // Draw a fullscreen quad with the black and white image
  320.             pass render_quad
  321.             {
  322.                 // Renders a fullscreen quad with a material
  323.                 material Ogre/Compositor/Tiling
  324.                 input 0 rt0
  325.             }
  326.         }
  327.     }
  328. }
  329. // Old Movie
  330. compositor Old Movie
  331. {
  332.     technique
  333.     {
  334.         // Temporary textures
  335.         texture rt0 target_width target_height PF_A8R8G8B8
  336.         target rt0
  337.         {
  338.             // Render output from previous compositor (or original scene)
  339.             input previous
  340.         }
  341.         target_output
  342.         {
  343.             // Start with clear output
  344.             input none
  345.             // Draw a fullscreen quad with the black and white image
  346.             pass render_quad
  347.             {
  348.                 // Renders a fullscreen quad with a material
  349.                 material Ogre/Compositor/OldMovie
  350.                 input 0 rt0
  351.             }
  352.         }
  353.     }
  354. }
  355. // HDR
  356. compositor HDR
  357. {
  358. // floating point only for now
  359. technique
  360. {
  361.         // Temporary textures
  362. // Fullsize HDR render target, used as tone mapping source
  363.         texture rt_full target_width target_height PF_FLOAT16_RGB
  364. // Targets used for luminance evaluation (3x3 downsample, point filtering)
  365. texture rt_lum0 1 1 PF_FLOAT16_RGB
  366. texture rt_lum1 4 4 PF_FLOAT16_RGB
  367. texture rt_lum2 16 16 PF_FLOAT16_RGB
  368. texture rt_lum3 64 64 PF_FLOAT16_RGB
  369. texture rt_lum4 128 128 PF_FLOAT16_RGB
  370. // Bright-pass filtered target (tone mapped)
  371. texture rt_brightpass 128 128 PF_R8G8B8
  372. // Bloom filter targets
  373. texture rt_bloom0 128 128 PF_R8G8B8
  374. texture rt_bloom1 128 128 PF_R8G8B8
  375. target rt_full
  376. {
  377. // No input, render differently
  378. input none
  379. // Use float target HDR material scheme (unclamped shaders)
  380. material_scheme HDR
  381. pass clear
  382. {
  383. }
  384. pass render_scene
  385. {
  386. }
  387. }
  388. // Downsample the original HDR scene to extract luminence value
  389. target rt_lum4
  390. {
  391.             input none
  392.             pass render_quad
  393.             {
  394.                 // Downsample using a 2x2 filter and convert to greyscale
  395.                 material Ogre/Compositor/HDR/Downsample2x2Luminence
  396.                 input 0 rt_full
  397.                 identifier 994
  398.             }
  399. }
  400. target rt_lum3
  401. {
  402.             input none
  403.             pass render_quad
  404.             {
  405. // Downsample using a 3x3 filter
  406.                 material Ogre/Compositor/HDR/Downsample3x3
  407.                 input 0 rt_lum4
  408.                 identifier 993
  409.             }
  410. }
  411. target rt_lum2
  412. {
  413.             input none
  414.             pass render_quad
  415.             {
  416.                 // Downsample using a 3x3 filter
  417.                 material Ogre/Compositor/HDR/Downsample3x3
  418.                 input 0 rt_lum3
  419.                 identifier 992
  420.             }
  421. }
  422. target rt_lum1
  423. {
  424.             input none
  425.             pass render_quad
  426.             {
  427.                 // Downsample using a 3x3 filter
  428.                 material Ogre/Compositor/HDR/Downsample3x3
  429.                 input 0 rt_lum2
  430.                 identifier 991
  431.             }
  432. }
  433. target rt_lum0
  434. {
  435.             input none
  436.             pass render_quad
  437.             {
  438.                 // Downsample using a 3x3 filter
  439.                 material Ogre/Compositor/HDR/Downsample3x3
  440.                 input 0 rt_lum1
  441.                 identifier 990
  442.             }
  443. }
  444. target rt_brightpass
  445. {
  446.             input none
  447.             pass render_quad
  448.             {
  449.                 // Downsample using a 3x3 filter, hi-pass and tone map
  450.                 material Ogre/Compositor/HDR/Downsample3x3Brightpass
  451.                 input 0 rt_full
  452.         input 1 rt_lum0
  453. identifier 800
  454.             }
  455. }
  456. target rt_bloom1
  457. {
  458. input none
  459. pass render_quad
  460. {
  461. // Blur horizontally
  462. material Ogre/Compositor/HDR/GaussianBloom1
  463. input 0 rt_brightpass
  464. identifier 701
  465. }
  466. }
  467. target rt_bloom0
  468. {
  469. input none
  470. pass render_quad
  471. {
  472. // Blur horizontally
  473. material Ogre/Compositor/HDR/GaussianBloom0
  474. input 0 rt_bloom1
  475. identifier 700
  476. }
  477. }
  478. // Final output combines tone mapping of the original scene, with an
  479. // exposure setting passed in as a GPU parameter, and an additive bloom
  480. // effect
  481. target_output
  482. {
  483. input none
  484. pass render_quad
  485. {
  486. material Ogre/Compositor/HDR/ToneMapping
  487. input 0 rt_full
  488. input 1 rt_bloom0
  489. input 2 rt_lum0
  490. }
  491. }
  492. }
  493. }
  494. // Gaussian blur effect
  495. compositor Gaussian Blur
  496. {
  497.     technique
  498.     {
  499.         // Temporary textures
  500.         texture rt0 target_width target_height PF_A8R8G8B8
  501.         texture rt1 target_width target_height PF_A8R8G8B8
  502.         target rt0
  503.         {
  504.             // Render output from previous compositor (or original scene)
  505.             input previous
  506.         }
  507.         target rt1
  508.         {
  509.             // Blur horizontally
  510.             input none
  511. pass render_quad
  512. {
  513. material Ogre/Compositor/HDR/GaussianBloom0
  514. input 0 rt0
  515. identifier 700
  516. }
  517.         }
  518. target_output
  519.         {
  520.             // Start with clear output
  521.             input none
  522.             // Blur vertically
  523.             pass render_quad
  524.             {
  525.                 // Renders a fullscreen quad with a material
  526. material Ogre/Compositor/HDR/GaussianBloom1
  527.                 input 0 rt1
  528. identifier 701
  529.             }
  530.         }
  531.     }
  532. }