Advertisement
Danfun64

Untitled

Nov 20th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 99.48 KB | None | 0 0
  1. tty console mode disabled
  2. Unvanquished 0.21.0 x86_64 Nov 4 2013
  3. +set fs_libpath /usr/lib/games/unvanquished +set fs_basepath /var/games/unvanquished
  4. Have SSE support
  5. pk3: /var/games/unvanquished/main/map-arachnid2-gpp.pk3 ( 67 files )
  6. pk3: /var/games/unvanquished/main/map-karith-gpp.pk3 ( 118 files )
  7. pk3: /var/games/unvanquished/main/map-methane-beta1.pk3 ( 196 files )
  8. pk3: /var/games/unvanquished/main/map-nano.pk3 ( 108 files )
  9. pk3: /var/games/unvanquished/main/map-nexus6-gpp.pk3 ( 151 files )
  10. pk3: /var/games/unvanquished/main/map-niveus-gpp.pk3 ( 134 files )
  11. pk3: /var/games/unvanquished/main/map-orion-beta2.pk3 ( 101 files )
  12. pk3: /var/games/unvanquished/main/map-parpax-d02.pk3 ( 391 files )
  13. pk3: /var/games/unvanquished/main/map-plat23-b10.pk3 ( 124 files )
  14. pk3: /var/games/unvanquished/main/map-spacetracks-r1.pk3 ( 207 files )
  15. pk3: /var/games/unvanquished/main/map-station15-r1.pk3 ( 205 files )
  16. pk3: /var/games/unvanquished/main/map-thunder-b3.pk3 ( 232 files )
  17. pk3: /var/games/unvanquished/main/map-tremor-gpp.pk3 ( 47 files )
  18. pk3: /var/games/unvanquished/main/map-UTCSfinal.pk3 ( 82 files )
  19. pk3: /var/games/unvanquished/main/map-yocto-b1a.pk3 ( 230 files )
  20. pk3: /var/games/unvanquished/main/navmesh-0.21.0.pk3 ( 177 files )
  21. pk3: /var/games/unvanquished/main/pak0.pk3 ( 1590 files )
  22. pk3: /var/games/unvanquished/main/pak1.pk3 ( 981 files )
  23. pk3: /var/games/unvanquished/main/pak2.pk3 ( 166 files )
  24. pk3: /var/games/unvanquished/main/pak3.pk3 ( 117 files )
  25. pk3: /var/games/unvanquished/main/pak4.pk3 ( 148 files )
  26. pk3: /var/games/unvanquished/main/pak5.pk3 ( 143 files )
  27. pk3: /var/games/unvanquished/main/pak6.pk3 ( 148 files )
  28. pk3: /var/games/unvanquished/main/pak7.pk3 ( 268 files )
  29. pk3: /var/games/unvanquished/main/pak8.pk3 ( 132 files )
  30. pk3: /var/games/unvanquished/main/pak9.pk3 ( 122 files )
  31. pk3: /var/games/unvanquished/main/pakA.pk3 ( 31 files )
  32. pk3: /var/games/unvanquished/main/pakB.pk3 ( 226 files )
  33. pk3: /var/games/unvanquished/main/pakC.pk3 ( 19 files )
  34. pk3: /var/games/unvanquished/main/pakD.pk3 ( 140 files )
  35. pk3: /var/games/unvanquished/main/pakE.pk3 ( 20 files )
  36. pk3: /var/games/unvanquished/main/pakF.pk3 ( 70 files )
  37. pk3: /var/games/unvanquished/main/pakG.pk3 ( 227 files )
  38. pk3: /var/games/unvanquished/main/pakH.pk3 ( 185 files )
  39. pk3: /var/games/unvanquished/main/pakI.pk3 ( 125 files )
  40. pk3: /var/games/unvanquished/main/pakJ.pk3 ( 180 files )
  41. pk3: /var/games/unvanquished/main/pakK.pk3 ( 300 files )
  42. pk3: /var/games/unvanquished/main/pakK.1.pk3 ( 12 files )
  43. pk3: /var/games/unvanquished/main/pakK.2.pk3 ( 3 files )
  44. pk3: /var/games/unvanquished/main/vms-0.21.0.pk3 ( 3 files )
  45. FS_AddGameDirectory("/var/games/unvanquished", "main") found 40 .pk3 and 0 .pk3dir
  46. FS_AddGameDirectory("/usr/lib/games/unvanquished", "main") found 0 .pk3 and 0 .pk3dir
  47. FS_AddGameDirectory("/home/danfun64/.Unvanquished", "main") found 0 .pk3 and 0 .pk3dir
  48. Loaded 7 languages
  49. execing default.cfg
  50. couldn't exec autogen.cfg
  51. couldn't exec keybindings.cfg
  52. couldn't exec autoexec.cfg
  53. Set language to English
  54. Couldn't read conhistory.
  55. ----- Client Initialization -----
  56. ----- Client Initialization Complete -----
  57. ----- Initializing Renderer -----
  58. Loading "/usr/lib/games/unvanquished/librendererGL3.so"…done
  59. Calling GetRefAPI…
  60. SDL_Init( SDL_INIT_VIDEO )... Using SDL Version 1.2.15
  61. SDL using driver "x11"
  62. Initializing OpenGL display
  63. Display aspect: 1.779
  64. ...setting mode 6: 1024 768
  65. Using 24 Color bits, 24 depth, 8 stencil display.
  66. Using GLEW 1.7.0
  67. Using enhanced (GL3) Renderer in GL 2.x mode...
  68. Available modes: '1280x720 1366x768 848x480 720x480 1152x768 640x480 800x600 1024x768 '
  69. GL_RENDERER: Gallium 0.4 on AMD SUMO
  70. Detected graphics driver class 'Mesa'
  71. Detected graphics hardware class 'AMD Radeon DX10-class'
  72. Initializing OpenGL extensions
  73. ...GL_ARB_debug_output not found
  74. ...using GL_ARB_multitexture
  75. ...using GL_ARB_depth_texture
  76. ...using GL_ARB_texture_cube_map
  77. ...using GL_ARB_vertex_program
  78. ...using GL_ARB_vertex_buffer_object
  79. ...using GL_ARB_occlusion_query
  80. ...using GL_ARB_shader_objects
  81. ...using GL_ARB_vertex_shader
  82. ...using GL_ARB_fragment_shader
  83. ...found shading language version 120
  84. ...using GL_ARB_shading_language_100
  85. ...using GL_ARB_texture_non_power_of_two
  86. ...using GL_ARB_draw_buffers
  87. ...using GL_ARB_half_float_pixel
  88. ...using GL_ARB_texture_float
  89. ...using GL_ARB_texture_rg
  90. ...ignoring GL_ARB_texture_compression
  91. ...using GL_ARB_vertex_array_object
  92. ...GL_EXT_texture_compression_s3tc not found
  93. ...using GL_EXT_texture3D
  94. ...using GL_EXT_stencil_wrap
  95. ...using GL_EXT_texture_filter_anisotropic
  96. ...using GL_EXT_stencil_two_side
  97. ...GL_EXT_depth_bounds_test not found
  98. ...using GL_EXT_framebuffer_object
  99. ...GL_EXT_packed_depth_stencil not found
  100. ...using GL_EXT_framebuffer_blit
  101. ...using GL_ATI_separate_stencil
  102. ...using GL_SGIS_generate_mipmap
  103. ...GL_GREMEDY_string_marker not found
  104. ...GL_ARB_get_program_binary not found
  105. #version 120
  106. #ifndef COMPAT_Q3A
  107. #define COMPAT_Q3A 1
  108. #endif
  109. #ifndef COMPAT_ET
  110. #define COMPAT_ET 1
  111. #endif
  112. #ifndef TEXTURE_RG
  113. #define TEXTURE_RG 1
  114. #endif
  115. #ifndef r_SpecularScale
  116. #define r_SpecularScale 1.400000
  117. #endif
  118. #ifndef M_PI
  119. #define M_PI 3.141593
  120. #endif
  121. #ifndef MAX_SHADOWMAPS
  122. #define MAX_SHADOWMAPS 5
  123. #endif
  124. #ifndef MAX_SHADER_DEFORM_PARMS
  125. #define MAX_SHADER_DEFORM_PARMS 28
  126. #endif
  127. #ifndef deform_t
  128. #define deform_t
  129. #endif
  130. #ifndef DEFORM_WAVE
  131. #define DEFORM_WAVE 1
  132. #endif
  133. #ifndef DEFORM_BULGE
  134. #define DEFORM_BULGE 3
  135. #endif
  136. #ifndef DEFORM_MOVE
  137. #define DEFORM_MOVE 4
  138. #endif
  139. #ifndef genFunc_t
  140. #define genFunc_t
  141. #endif
  142. #ifndef GF_NONE
  143. #define GF_NONE 0.000000
  144. #endif
  145. #ifndef GF_SIN
  146. #define GF_SIN 1.000000
  147. #endif
  148. #ifndef GF_SQUARE
  149. #define GF_SQUARE 2.000000
  150. #endif
  151. #ifndef GF_TRIANGLE
  152. #define GF_TRIANGLE 3.000000
  153. #endif
  154. #ifndef GF_SAWTOOTH
  155. #define GF_SAWTOOTH 4.000000
  156. #endif
  157. #ifndef GF_INVERSE_SAWTOOTH
  158. #define GF_INVERSE_SAWTOOTH 5.000000
  159. #endif
  160. #ifndef GF_NOISE
  161. #define GF_NOISE 6.000000
  162. #endif
  163. #ifndef r_FBufScale
  164. #define r_FBufScale vec2( 0.000977, 0.001302 )
  165. #endif
  166. #ifndef r_NPOTScale
  167. #define r_NPOTScale vec2( 1.000000, 1.000000 )
  168. #endif
  169. #ifndef GLDRV_MESA
  170. #define GLDRV_MESA 1
  171. #endif
  172. #ifndef GLHW_ATI_DX10
  173. #define GLHW_ATI_DX10 1
  174. #endif
  175. #ifndef r_precomputedLighting
  176. #define r_precomputedLighting 1
  177. #endif
  178. #ifndef r_VertexSkinning
  179. #define r_VertexSkinning 1
  180. #endif
  181. #ifndef MAX_GLSL_BONES
  182. #define MAX_GLSL_BONES 128
  183. #endif
  184. #ifndef r_WrapAroundLighting
  185. #define r_WrapAroundLighting 0.700000
  186. #endif
  187. #ifndef r_HalfLambertLighting
  188. #define r_HalfLambertLighting 1
  189. #endif
  190. #line 0
  191. /*============================================================================
  192.  
  193.  
  194. NVIDIA FXAA 3.11 by TIMOTHY LOTTES
  195.  
  196.  
  197. ------------------------------------------------------------------------------
  198. COPYRIGHT (C) 2010, 2011 NVIDIA CORPORATION. ALL RIGHTS RESERVED.
  199. ------------------------------------------------------------------------------
  200. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED
  201. *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS
  202. OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
  203. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA
  204. OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR
  205. CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR
  206. LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION,
  207. OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE
  208. THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
  209. DAMAGES.
  210.  
  211. kangz: This code has been set in the public domain by TIMOTHY LOTTES
  212.  
  213. ============================================================================*/
  214.  
  215. //Due to our shader system, we put the defines for the control knobs here
  216. #define FXAA_PC 1
  217. #if __VERSION__ == 120
  218. #define FXAA_GLSL_120 1
  219. #else
  220. #define FXAA_GLSL_130 1
  221. #endif
  222.  
  223. #define FXAA_QUALITY_PRESET 12
  224. #define FXAA_GREEN_AS_LUMA 1
  225.  
  226. /*============================================================================
  227. ------------------------------------------------------------------------------
  228. INTEGRATION CHECKLIST
  229. ------------------------------------------------------------------------------
  230. (1.)
  231. In the shader source, setup defines for the desired configuration.
  232. When providing multiple shaders (for different presets),
  233. simply setup the defines differently in multiple files.
  234. Example,
  235.  
  236. #define FXAA_PC 1
  237. #define FXAA_HLSL_5 1
  238. #define FXAA_QUALITY_PRESET 12
  239.  
  240. Or,
  241.  
  242. #define FXAA_360 1
  243.  
  244. Or,
  245.  
  246. #define FXAA_PS3 1
  247.  
  248. Etc.
  249.  
  250. (2.)
  251. Then include this file,
  252.  
  253. #include "Fxaa3_11.h"
  254.  
  255. (3.)
  256. Then call the FXAA pixel shader from within your desired shader.
  257. Look at the FXAA Quality FxaaPixelShader() for docs on inputs.
  258. As for FXAA 3.11 all inputs for all shaders are the same
  259. to enable easy porting between platforms.
  260.  
  261. return FxaaPixelShader(...);
  262.  
  263. (4.)
  264. Insure pass prior to FXAA outputs RGBL (see next section).
  265. Or use,
  266.  
  267. #define FXAA_GREEN_AS_LUMA 1
  268.  
  269. (5.)
  270. Setup engine to provide the following constants
  271. which are used in the FxaaPixelShader() inputs,
  272.  
  273. FxaaFloat2 fxaaQualityRcpFrame,
  274. FxaaFloat4 fxaaConsoleRcpFrameOpt,
  275. FxaaFloat4 fxaaConsoleRcpFrameOpt2,
  276. FxaaFloat4 fxaaConsole360RcpFrameOpt2,
  277. FxaaFloat fxaaQualitySubpix,
  278. FxaaFloat fxaaQualityEdgeThreshold,
  279. FxaaFloat fxaaQualityEdgeThresholdMin,
  280. FxaaFloat fxaaConsoleEdgeSharpness,
  281. FxaaFloat fxaaConsoleEdgeThreshold,
  282. FxaaFloat fxaaConsoleEdgeThresholdMin,
  283. FxaaFloat4 fxaaConsole360ConstDir
  284.  
  285. Look at the FXAA Quality FxaaPixelShader() for docs on inputs.
  286.  
  287. (6.)
  288. Have FXAA vertex shader run as a full screen triangle,
  289. and output "pos" and "fxaaConsolePosPos"
  290. such that inputs in the pixel shader provide,
  291.  
  292. // {xy} = center of pixel
  293. FxaaFloat2 pos,
  294.  
  295. // {xy__} = upper left of pixel
  296. // {__zw} = lower right of pixel
  297. FxaaFloat4 fxaaConsolePosPos,
  298.  
  299. (7.)
  300. Insure the texture sampler(s) used by FXAA are set to bilinear filtering.
  301.  
  302.  
  303. ------------------------------------------------------------------------------
  304. INTEGRATION - RGBL AND COLORSPACE
  305. ------------------------------------------------------------------------------
  306. FXAA3 requires RGBL as input unless the following is set,
  307.  
  308. #define FXAA_GREEN_AS_LUMA 1
  309.  
  310. In which case the engine uses green in place of luma,
  311. and requires RGB input is in a non-linear colorspace.
  312.  
  313. RGB should be LDR (low dynamic range).
  314. Specifically do FXAA after tonemapping.
  315.  
  316. RGB data as returned by a texture fetch can be non-linear,
  317. or linear when FXAA_GREEN_AS_LUMA is not set.
  318. Note an "sRGB format" texture counts as linear,
  319. because the result of a texture fetch is linear data.
  320. Regular "RGBA8" textures in the sRGB colorspace are non-linear.
  321.  
  322. If FXAA_GREEN_AS_LUMA is not set,
  323. luma must be stored in the alpha channel prior to running FXAA.
  324. This luma should be in a perceptual space (could be gamma 2.0).
  325. Example pass before FXAA where output is gamma 2.0 encoded,
  326.  
  327. color.rgb = ToneMap(color.rgb); // linear color output
  328. color.rgb = sqrt(color.rgb); // gamma 2.0 color output
  329. return color;
  330.  
  331. To use FXAA,
  332.  
  333. color.rgb = ToneMap(color.rgb); // linear color output
  334. color.rgb = sqrt(color.rgb); // gamma 2.0 color output
  335. color.a = dot(color.rgb, FxaaFloat3(0.299, 0.587, 0.114)); // compute luma
  336. return color;
  337.  
  338. Another example where output is linear encoded,
  339. say for instance writing to an sRGB formated render target,
  340. where the render target does the conversion back to sRGB after blending,
  341.  
  342. color.rgb = ToneMap(color.rgb); // linear color output
  343. return color;
  344.  
  345. To use FXAA,
  346.  
  347. color.rgb = ToneMap(color.rgb); // linear color output
  348. color.a = sqrt(dot(color.rgb, FxaaFloat3(0.299, 0.587, 0.114))); // compute luma
  349. return color;
  350.  
  351. Getting luma correct is required for the algorithm to work correctly.
  352.  
  353.  
  354. ------------------------------------------------------------------------------
  355. BEING LINEARLY CORRECT?
  356. ------------------------------------------------------------------------------
  357. Applying FXAA to a framebuffer with linear RGB color will look worse.
  358. This is very counter intuitive, but happends to be true in this case.
  359. The reason is because dithering artifacts will be more visiable
  360. in a linear colorspace.
  361.  
  362.  
  363. ------------------------------------------------------------------------------
  364. COMPLEX INTEGRATION
  365. ------------------------------------------------------------------------------
  366. Q. What if the engine is blending into RGB before wanting to run FXAA?
  367.  
  368. A. In the last opaque pass prior to FXAA,
  369. have the pass write out luma into alpha.
  370. Then blend into RGB only.
  371. FXAA should be able to run ok
  372. assuming the blending pass did not any add aliasing.
  373. This should be the common case for particles and common blending passes.
  374.  
  375. A. Or use FXAA_GREEN_AS_LUMA.
  376.  
  377. ============================================================================*/
  378.  
  379. /*============================================================================
  380.  
  381. INTEGRATION KNOBS
  382.  
  383. ============================================================================*/
  384. //
  385. // FXAA_PS3 and FXAA_360 choose the console algorithm (FXAA3 CONSOLE).
  386. // FXAA_360_OPT is a prototype for the new optimized 360 version.
  387. //
  388. // 1 = Use API.
  389. // 0 = Don't use API.
  390. //
  391. /*--------------------------------------------------------------------------*/
  392. #ifndef FXAA_PS3
  393. #define FXAA_PS3 0
  394. #endif
  395. /*--------------------------------------------------------------------------*/
  396. #ifndef FXAA_360
  397. #define FXAA_360 0
  398. #endif
  399. /*--------------------------------------------------------------------------*/
  400. #ifndef FXAA_360_OPT
  401. #define FXAA_360_OPT 0
  402. #endif
  403. /*==========================================================================*/
  404. #ifndef FXAA_PC
  405. //
  406. // FXAA Quality
  407. // The high quality PC algorithm.
  408. //
  409. #define FXAA_PC 0
  410. #endif
  411. /*--------------------------------------------------------------------------*/
  412. #ifndef FXAA_PC_CONSOLE
  413. //
  414. // The console algorithm for PC is included
  415. // for developers targeting really low spec machines.
  416. // Likely better to just run FXAA_PC, and use a really low preset.
  417. //
  418. #define FXAA_PC_CONSOLE 0
  419. #endif
  420. /*--------------------------------------------------------------------------*/
  421. #ifndef FXAA_GLSL_120
  422. #define FXAA_GLSL_120 0
  423. #endif
  424. /*--------------------------------------------------------------------------*/
  425. #ifndef FXAA_GLSL_130
  426. #define FXAA_GLSL_130 0
  427. #endif
  428. /*--------------------------------------------------------------------------*/
  429. #ifndef FXAA_HLSL_3
  430. #define FXAA_HLSL_3 0
  431. #endif
  432. /*--------------------------------------------------------------------------*/
  433. #ifndef FXAA_HLSL_4
  434. #define FXAA_HLSL_4 0
  435. #endif
  436. /*--------------------------------------------------------------------------*/
  437. #ifndef FXAA_HLSL_5
  438. #define FXAA_HLSL_5 0
  439. #endif
  440. /*==========================================================================*/
  441. #ifndef FXAA_GREEN_AS_LUMA
  442. //
  443. // For those using non-linear color,
  444. // and either not able to get luma in alpha, or not wanting to,
  445. // this enables FXAA to run using green as a proxy for luma.
  446. // So with this enabled, no need to pack luma in alpha.
  447. //
  448. // This will turn off AA on anything which lacks some amount of green.
  449. // Pure red and blue or combination of only R and B, will get no AA.
  450. //
  451. // Might want to lower the settings for both,
  452. // fxaaConsoleEdgeThresholdMin
  453. // fxaaQualityEdgeThresholdMin
  454. // In order to insure AA does not get turned off on colors
  455. // which contain a minor amount of green.
  456. //
  457. // 1 = On.
  458. // 0 = Off.
  459. //
  460. #define FXAA_GREEN_AS_LUMA 0
  461. #endif
  462. /*--------------------------------------------------------------------------*/
  463. #ifndef FXAA_EARLY_EXIT
  464. //
  465. // Controls algorithm's early exit path.
  466. // On PS3 turning this ON adds 2 cycles to the shader.
  467. // On 360 turning this OFF adds 10ths of a millisecond to the shader.
  468. // Turning this off on console will result in a more blurry image.
  469. // So this defaults to on.
  470. //
  471. // 1 = On.
  472. // 0 = Off.
  473. //
  474. #define FXAA_EARLY_EXIT 1
  475. #endif
  476. /*--------------------------------------------------------------------------*/
  477. #ifndef FXAA_DISCARD
  478. //
  479. // Only valid for PC OpenGL currently.
  480. // Probably will not work when FXAA_GREEN_AS_LUMA = 1.
  481. //
  482. // 1 = Use discard on pixels which don't need AA.
  483. // For APIs which enable concurrent TEX+ROP from same surface.
  484. // 0 = Return unchanged color on pixels which don't need AA.
  485. //
  486. #define FXAA_DISCARD 0
  487. #endif
  488. /*--------------------------------------------------------------------------*/
  489. #ifndef FXAA_FAST_PIXEL_OFFSET
  490. //
  491. // Used for GLSL 120 only.
  492. //
  493. // 1 = GL API supports fast pixel offsets
  494. // 0 = do not use fast pixel offsets
  495. //
  496. #ifdef GL_EXT_gpu_shader4
  497. #define FXAA_FAST_PIXEL_OFFSET 1
  498. #extension GL_EXT_gpu_shader4 : enable
  499. #endif
  500. #ifdef GL_NV_gpu_shader5
  501. #define FXAA_FAST_PIXEL_OFFSET 1
  502. #extension GL_NV_gpu_shader5 : enable
  503. #endif
  504. #ifdef GL_ARB_gpu_shader5
  505. #define FXAA_FAST_PIXEL_OFFSET 1
  506. #extension GL_ARB_gpu_shader5 : enable
  507. #endif
  508. #ifndef FXAA_FAST_PIXEL_OFFSET
  509. #define FXAA_FAST_PIXEL_OFFSET 0
  510. #endif
  511. #endif
  512. /*--------------------------------------------------------------------------*/
  513. #ifndef FXAA_GATHER4_ALPHA
  514. //
  515. // 1 = API supports gather4 on alpha channel.
  516. // 0 = API does not support gather4 on alpha channel.
  517. //
  518. #if (FXAA_HLSL_5 == 1)
  519. #define FXAA_GATHER4_ALPHA 1
  520. #endif
  521. #ifdef GL_ARB_gpu_shader5
  522. #define FXAA_GATHER4_ALPHA 1
  523. #extension GL_ARB_gpu_shader5 : enable
  524. #endif
  525. #ifdef GL_NV_gpu_shader5
  526. #define FXAA_GATHER4_ALPHA 1
  527. #extension GL_NV_gpu_shader5 : enable
  528. #endif
  529. #ifndef FXAA_GATHER4_ALPHA
  530. #define FXAA_GATHER4_ALPHA 0
  531. #endif
  532. #endif
  533.  
  534. /*============================================================================
  535. FXAA CONSOLE PS3 - TUNING KNOBS
  536. ============================================================================*/
  537. #ifndef FXAA_CONSOLE_PS3_EDGE_SHARPNESS
  538. //
  539. // Consoles the sharpness of edges on PS3 only.
  540. // Non-PS3 tuning is done with shader input.
  541. //
  542. // Due to the PS3 being ALU bound,
  543. // there are only two safe values here: 4 and 8.
  544. // These options use the shaders ability to a free *|/ by 2|4|8.
  545. //
  546. // 8.0 is sharper
  547. // 4.0 is softer
  548. // 2.0 is really soft (good for vector graphics inputs)
  549. //
  550. #if 1
  551. #define FXAA_CONSOLE_PS3_EDGE_SHARPNESS 8.0
  552. #endif
  553. #if 0
  554. #define FXAA_CONSOLE_PS3_EDGE_SHARPNESS 4.0
  555. #endif
  556. #if 0
  557. #define FXAA_CONSOLE_PS3_EDGE_SHARPNESS 2.0
  558. #endif
  559. #endif
  560. /*--------------------------------------------------------------------------*/
  561. #ifndef FXAA_CONSOLE_PS3_EDGE_THRESHOLD
  562. //
  563. // Only effects PS3.
  564. // Non-PS3 tuning is done with shader input.
  565. //
  566. // The minimum amount of local contrast required to apply algorithm.
  567. // The console setting has a different mapping than the quality setting.
  568. //
  569. // This only applies when FXAA_EARLY_EXIT is 1.
  570. //
  571. // Due to the PS3 being ALU bound,
  572. // there are only two safe values here: 0.25 and 0.125.
  573. // These options use the shaders ability to a free *|/ by 2|4|8.
  574. //
  575. // 0.125 leaves less aliasing, but is softer
  576. // 0.25 leaves more aliasing, and is sharper
  577. //
  578. #if 1
  579. #define FXAA_CONSOLE_PS3_EDGE_THRESHOLD 0.125
  580. #else
  581. #define FXAA_CONSOLE_PS3_EDGE_THRESHOLD 0.25
  582. #endif
  583. #endif
  584.  
  585. /*============================================================================
  586. FXAA QUALITY - TUNING KNOBS
  587. ------------------------------------------------------------------------------
  588. NOTE the other tuning knobs are now in the shader function inputs!
  589. ============================================================================*/
  590. #ifndef FXAA_QUALITY_PRESET
  591. //
  592. // Choose the quality preset.
  593. // This needs to be compiled into the shader as it effects code.
  594. // Best option to include multiple presets is to
  595. // in each shader define the preset, then include this file.
  596. //
  597. // OPTIONS
  598. // -----------------------------------------------------------------------
  599. // 10 to 15 - default medium dither (10=fastest, 15=highest quality)
  600. // 20 to 29 - less dither, more expensive (20=fastest, 29=highest quality)
  601. // 39 - no dither, very expensive
  602. //
  603. // NOTES
  604. // -----------------------------------------------------------------------
  605. // 12 = slightly faster then FXAA 3.9 and higher edge quality (default)
  606. // 13 = about same speed as FXAA 3.9 and better than 12
  607. // 23 = closest to FXAA 3.9 visually and performance wise
  608. // _ = the lowest digit is directly related to performance
  609. // _ = the highest digit is directly related to style
  610. //
  611. #define FXAA_QUALITY_PRESET 12
  612. #endif
  613.  
  614.  
  615. /*============================================================================
  616.  
  617. FXAA QUALITY - PRESETS
  618.  
  619. ============================================================================*/
  620.  
  621. /*============================================================================
  622. FXAA QUALITY - MEDIUM DITHER PRESETS
  623. ============================================================================*/
  624. #if (FXAA_QUALITY_PRESET == 10)
  625. #define FXAA_QUALITY_PS 3
  626. #define FXAA_QUALITY_P0 1.5
  627. #define FXAA_QUALITY_P1 3.0
  628. #define FXAA_QUALITY_P2 12.0
  629. #endif
  630. /*--------------------------------------------------------------------------*/
  631. #if (FXAA_QUALITY_PRESET == 11)
  632. #define FXAA_QUALITY_PS 4
  633. #define FXAA_QUALITY_P0 1.0
  634. #define FXAA_QUALITY_P1 1.5
  635. #define FXAA_QUALITY_P2 3.0
  636. #define FXAA_QUALITY_P3 12.0
  637. #endif
  638. /*--------------------------------------------------------------------------*/
  639. #if (FXAA_QUALITY_PRESET == 12)
  640. #define FXAA_QUALITY_PS 5
  641. #define FXAA_QUALITY_P0 1.0
  642. #define FXAA_QUALITY_P1 1.5
  643. #define FXAA_QUALITY_P2 2.0
  644. #define FXAA_QUALITY_P3 4.0
  645. #define FXAA_QUALITY_P4 12.0
  646. #endif
  647. /*--------------------------------------------------------------------------*/
  648. #if (FXAA_QUALITY_PRESET == 13)
  649. #define FXAA_QUALITY_PS 6
  650. #define FXAA_QUALITY_P0 1.0
  651. #define FXAA_QUALITY_P1 1.5
  652. #define FXAA_QUALITY_P2 2.0
  653. #define FXAA_QUALITY_P3 2.0
  654. #define FXAA_QUALITY_P4 4.0
  655. #define FXAA_QUALITY_P5 12.0
  656. #endif
  657. /*--------------------------------------------------------------------------*/
  658. #if (FXAA_QUALITY_PRESET == 14)
  659. #define FXAA_QUALITY_PS 7
  660. #define FXAA_QUALITY_P0 1.0
  661. #define FXAA_QUALITY_P1 1.5
  662. #define FXAA_QUALITY_P2 2.0
  663. #define FXAA_QUALITY_P3 2.0
  664. #define FXAA_QUALITY_P4 2.0
  665. #define FXAA_QUALITY_P5 4.0
  666. #define FXAA_QUALITY_P6 12.0
  667. #endif
  668. /*--------------------------------------------------------------------------*/
  669. #if (FXAA_QUALITY_PRESET == 15)
  670. #define FXAA_QUALITY_PS 8
  671. #define FXAA_QUALITY_P0 1.0
  672. #define FXAA_QUALITY_P1 1.5
  673. #define FXAA_QUALITY_P2 2.0
  674. #define FXAA_QUALITY_P3 2.0
  675. #define FXAA_QUALITY_P4 2.0
  676. #define FXAA_QUALITY_P5 2.0
  677. #define FXAA_QUALITY_P6 4.0
  678. #define FXAA_QUALITY_P7 12.0
  679. #endif
  680.  
  681. /*============================================================================
  682. FXAA QUALITY - LOW DITHER PRESETS
  683. ============================================================================*/
  684. #if (FXAA_QUALITY_PRESET == 20)
  685. #define FXAA_QUALITY_PS 3
  686. #define FXAA_QUALITY_P0 1.5
  687. #define FXAA_QUALITY_P1 2.0
  688. #define FXAA_QUALITY_P2 8.0
  689. #endif
  690. /*--------------------------------------------------------------------------*/
  691. #if (FXAA_QUALITY_PRESET == 21)
  692. #define FXAA_QUALITY_PS 4
  693. #define FXAA_QUALITY_P0 1.0
  694. #define FXAA_QUALITY_P1 1.5
  695. #define FXAA_QUALITY_P2 2.0
  696. #define FXAA_QUALITY_P3 8.0
  697. #endif
  698. /*--------------------------------------------------------------------------*/
  699. #if (FXAA_QUALITY_PRESET == 22)
  700. #define FXAA_QUALITY_PS 5
  701. #define FXAA_QUALITY_P0 1.0
  702. #define FXAA_QUALITY_P1 1.5
  703. #define FXAA_QUALITY_P2 2.0
  704. #define FXAA_QUALITY_P3 2.0
  705. #define FXAA_QUALITY_P4 8.0
  706. #endif
  707. /*--------------------------------------------------------------------------*/
  708. #if (FXAA_QUALITY_PRESET == 23)
  709. #define FXAA_QUALITY_PS 6
  710. #define FXAA_QUALITY_P0 1.0
  711. #define FXAA_QUALITY_P1 1.5
  712. #define FXAA_QUALITY_P2 2.0
  713. #define FXAA_QUALITY_P3 2.0
  714. #define FXAA_QUALITY_P4 2.0
  715. #define FXAA_QUALITY_P5 8.0
  716. #endif
  717. /*--------------------------------------------------------------------------*/
  718. #if (FXAA_QUALITY_PRESET == 24)
  719. #define FXAA_QUALITY_PS 7
  720. #define FXAA_QUALITY_P0 1.0
  721. #define FXAA_QUALITY_P1 1.5
  722. #define FXAA_QUALITY_P2 2.0
  723. #define FXAA_QUALITY_P3 2.0
  724. #define FXAA_QUALITY_P4 2.0
  725. #define FXAA_QUALITY_P5 3.0
  726. #define FXAA_QUALITY_P6 8.0
  727. #endif
  728. /*--------------------------------------------------------------------------*/
  729. #if (FXAA_QUALITY_PRESET == 25)
  730. #define FXAA_QUALITY_PS 8
  731. #define FXAA_QUALITY_P0 1.0
  732. #define FXAA_QUALITY_P1 1.5
  733. #define FXAA_QUALITY_P2 2.0
  734. #define FXAA_QUALITY_P3 2.0
  735. #define FXAA_QUALITY_P4 2.0
  736. #define FXAA_QUALITY_P5 2.0
  737. #define FXAA_QUALITY_P6 4.0
  738. #define FXAA_QUALITY_P7 8.0
  739. #endif
  740. /*--------------------------------------------------------------------------*/
  741. #if (FXAA_QUALITY_PRESET == 26)
  742. #define FXAA_QUALITY_PS 9
  743. #define FXAA_QUALITY_P0 1.0
  744. #define FXAA_QUALITY_P1 1.5
  745. #define FXAA_QUALITY_P2 2.0
  746. #define FXAA_QUALITY_P3 2.0
  747. #define FXAA_QUALITY_P4 2.0
  748. #define FXAA_QUALITY_P5 2.0
  749. #define FXAA_QUALITY_P6 2.0
  750. #define FXAA_QUALITY_P7 4.0
  751. #define FXAA_QUALITY_P8 8.0
  752. #endif
  753. /*--------------------------------------------------------------------------*/
  754. #if (FXAA_QUALITY_PRESET == 27)
  755. #define FXAA_QUALITY_PS 10
  756. #define FXAA_QUALITY_P0 1.0
  757. #define FXAA_QUALITY_P1 1.5
  758. #define FXAA_QUALITY_P2 2.0
  759. #define FXAA_QUALITY_P3 2.0
  760. #define FXAA_QUALITY_P4 2.0
  761. #define FXAA_QUALITY_P5 2.0
  762. #define FXAA_QUALITY_P6 2.0
  763. #define FXAA_QUALITY_P7 2.0
  764. #define FXAA_QUALITY_P8 4.0
  765. #define FXAA_QUALITY_P9 8.0
  766. #endif
  767. /*--------------------------------------------------------------------------*/
  768. #if (FXAA_QUALITY_PRESET == 28)
  769. #define FXAA_QUALITY_PS 11
  770. #define FXAA_QUALITY_P0 1.0
  771. #define FXAA_QUALITY_P1 1.5
  772. #define FXAA_QUALITY_P2 2.0
  773. #define FXAA_QUALITY_P3 2.0
  774. #define FXAA_QUALITY_P4 2.0
  775. #define FXAA_QUALITY_P5 2.0
  776. #define FXAA_QUALITY_P6 2.0
  777. #define FXAA_QUALITY_P7 2.0
  778. #define FXAA_QUALITY_P8 2.0
  779. #define FXAA_QUALITY_P9 4.0
  780. #define FXAA_QUALITY_P10 8.0
  781. #endif
  782. /*--------------------------------------------------------------------------*/
  783. #if (FXAA_QUALITY_PRESET == 29)
  784. #define FXAA_QUALITY_PS 12
  785. #define FXAA_QUALITY_P0 1.0
  786. #define FXAA_QUALITY_P1 1.5
  787. #define FXAA_QUALITY_P2 2.0
  788. #define FXAA_QUALITY_P3 2.0
  789. #define FXAA_QUALITY_P4 2.0
  790. #define FXAA_QUALITY_P5 2.0
  791. #define FXAA_QUALITY_P6 2.0
  792. #define FXAA_QUALITY_P7 2.0
  793. #define FXAA_QUALITY_P8 2.0
  794. #define FXAA_QUALITY_P9 2.0
  795. #define FXAA_QUALITY_P10 4.0
  796. #define FXAA_QUALITY_P11 8.0
  797. #endif
  798.  
  799. /*============================================================================
  800. FXAA QUALITY - EXTREME QUALITY
  801. ============================================================================*/
  802. #if (FXAA_QUALITY_PRESET == 39)
  803. #define FXAA_QUALITY_PS 12
  804. #define FXAA_QUALITY_P0 1.0
  805. #define FXAA_QUALITY_P1 1.0
  806. #define FXAA_QUALITY_P2 1.0
  807. #define FXAA_QUALITY_P3 1.0
  808. #define FXAA_QUALITY_P4 1.0
  809. #define FXAA_QUALITY_P5 1.5
  810. #define FXAA_QUALITY_P6 2.0
  811. #define FXAA_QUALITY_P7 2.0
  812. #define FXAA_QUALITY_P8 2.0
  813. #define FXAA_QUALITY_P9 2.0
  814. #define FXAA_QUALITY_P10 4.0
  815. #define FXAA_QUALITY_P11 8.0
  816. #endif
  817.  
  818.  
  819.  
  820. /*============================================================================
  821.  
  822. API PORTING
  823.  
  824. ============================================================================*/
  825. #if (FXAA_GLSL_120 == 1) || (FXAA_GLSL_130 == 1)
  826. #define FxaaBool bool
  827. #define FxaaDiscard discard
  828. #define FxaaFloat float
  829. #define FxaaFloat2 vec2
  830. #define FxaaFloat3 vec3
  831. #define FxaaFloat4 vec4
  832. #define FxaaHalf float
  833. #define FxaaHalf2 vec2
  834. #define FxaaHalf3 vec3
  835. #define FxaaHalf4 vec4
  836. #define FxaaInt2 ivec2
  837. #define FxaaSat(x) clamp(x, 0.0, 1.0)
  838. #define FxaaTex sampler2D
  839. #else
  840. #define FxaaBool bool
  841. #define FxaaDiscard clip(-1)
  842. #define FxaaFloat float
  843. #define FxaaFloat2 float2
  844. #define FxaaFloat3 float3
  845. #define FxaaFloat4 float4
  846. #define FxaaHalf half
  847. #define FxaaHalf2 half2
  848. #define FxaaHalf3 half3
  849. #define FxaaHalf4 half4
  850. #define FxaaSat(x) saturate(x)
  851. #endif
  852. /*--------------------------------------------------------------------------*/
  853. #if (FXAA_GLSL_120 == 1)
  854. // Requires,
  855. // #version 120
  856. // And at least,
  857. // #extension GL_EXT_gpu_shader4 : enable
  858. // (or set FXAA_FAST_PIXEL_OFFSET 1 to work like DX9)
  859. #define FxaaTexTop(t, p) texture2DLod(t, p, 0.0)
  860. #if (FXAA_FAST_PIXEL_OFFSET == 1)
  861. #define FxaaTexOff(t, p, o, r) texture2DLodOffset(t, p, 0.0, o)
  862. #else
  863. #define FxaaTexOff(t, p, o, r) texture2DLod(t, p + (o * r), 0.0)
  864. #endif
  865. #if (FXAA_GATHER4_ALPHA == 1)
  866. // use #extension GL_ARB_gpu_shader5 : enable
  867. #define FxaaTexAlpha4(t, p) textureGather(t, p, 3)
  868. #define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)
  869. #define FxaaTexGreen4(t, p) textureGather(t, p, 1)
  870. #define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)
  871. #endif
  872. #endif
  873. /*--------------------------------------------------------------------------*/
  874. #if (FXAA_GLSL_130 == 1)
  875. // Requires "#version 130" or better
  876. #define FxaaTexTop(t, p) textureLod(t, p, 0.0)
  877. #define FxaaTexOff(t, p, o, r) textureLodOffset(t, p, 0.0, o)
  878. #if (FXAA_GATHER4_ALPHA == 1)
  879. // use #extension GL_ARB_gpu_shader5 : enable
  880. #define FxaaTexAlpha4(t, p) textureGather(t, p, 3)
  881. #define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)
  882. #define FxaaTexGreen4(t, p) textureGather(t, p, 1)
  883. #define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)
  884. #endif
  885. #endif
  886. /*--------------------------------------------------------------------------*/
  887. #if (FXAA_HLSL_3 == 1) || (FXAA_360 == 1) || (FXAA_PS3 == 1)
  888. #define FxaaInt2 float2
  889. #define FxaaTex sampler2D
  890. #define FxaaTexTop(t, p) tex2Dlod(t, float4(p, 0.0, 0.0))
  891. #define FxaaTexOff(t, p, o, r) tex2Dlod(t, float4(p + (o * r), 0, 0))
  892. #endif
  893. /*--------------------------------------------------------------------------*/
  894. #if (FXAA_HLSL_4 == 1)
  895. #define FxaaInt2 int2
  896. struct FxaaTex { SamplerState smpl; Texture2D tex; };
  897. #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)
  898. #define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)
  899. #endif
  900. /*--------------------------------------------------------------------------*/
  901. #if (FXAA_HLSL_5 == 1)
  902. #define FxaaInt2 int2
  903. struct FxaaTex { SamplerState smpl; Texture2D tex; };
  904. #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)
  905. #define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)
  906. #define FxaaTexAlpha4(t, p) t.tex.GatherAlpha(t.smpl, p)
  907. #define FxaaTexOffAlpha4(t, p, o) t.tex.GatherAlpha(t.smpl, p, o)
  908. #define FxaaTexGreen4(t, p) t.tex.GatherGreen(t.smpl, p)
  909. #define FxaaTexOffGreen4(t, p, o) t.tex.GatherGreen(t.smpl, p, o)
  910. #endif
  911.  
  912.  
  913. /*============================================================================
  914. GREEN AS LUMA OPTION SUPPORT FUNCTION
  915. ============================================================================*/
  916. #if (FXAA_GREEN_AS_LUMA == 0)
  917. FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.w; }
  918. #else
  919. FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.y; }
  920. #endif
  921.  
  922.  
  923.  
  924.  
  925. /*============================================================================
  926.  
  927. FXAA3 QUALITY - PC
  928.  
  929. ============================================================================*/
  930. #if (FXAA_PC == 1)
  931. /*--------------------------------------------------------------------------*/
  932. FxaaFloat4 FxaaPixelShader(
  933. //
  934. // Use noperspective interpolation here (turn off perspective interpolation).
  935. // {xy} = center of pixel
  936. FxaaFloat2 pos,
  937. //
  938. // Used only for FXAA Console, and not used on the 360 version.
  939. // Use noperspective interpolation here (turn off perspective interpolation).
  940. // {xy__} = upper left of pixel
  941. // {__zw} = lower right of pixel
  942. FxaaFloat4 fxaaConsolePosPos,
  943. //
  944. // Input color texture.
  945. // {rgb_} = color in linear or perceptual color space
  946. // if (FXAA_GREEN_AS_LUMA == 0)
  947. // {___a} = luma in perceptual color space (not linear)
  948. FxaaTex tex,
  949. //
  950. // Only used on the optimized 360 version of FXAA Console.
  951. // For everything but 360, just use the same input here as for "tex".
  952. // For 360, same texture, just alias with a 2nd sampler.
  953. // This sampler needs to have an exponent bias of -1.
  954. FxaaTex fxaaConsole360TexExpBiasNegOne,
  955. //
  956. // Only used on the optimized 360 version of FXAA Console.
  957. // For everything but 360, just use the same input here as for "tex".
  958. // For 360, same texture, just alias with a 3nd sampler.
  959. // This sampler needs to have an exponent bias of -2.
  960. FxaaTex fxaaConsole360TexExpBiasNegTwo,
  961. //
  962. // Only used on FXAA Quality.
  963. // This must be from a constant/uniform.
  964. // {x_} = 1.0/screenWidthInPixels
  965. // {_y} = 1.0/screenHeightInPixels
  966. FxaaFloat2 fxaaQualityRcpFrame,
  967. //
  968. // Only used on FXAA Console.
  969. // This must be from a constant/uniform.
  970. // This effects sub-pixel AA quality and inversely sharpness.
  971. // Where N ranges between,
  972. // N = 0.50 (default)
  973. // N = 0.33 (sharper)
  974. // {x___} = -N/screenWidthInPixels
  975. // {_y__} = -N/screenHeightInPixels
  976. // {__z_} = N/screenWidthInPixels
  977. // {___w} = N/screenHeightInPixels
  978. FxaaFloat4 fxaaConsoleRcpFrameOpt,
  979. //
  980. // Only used on FXAA Console.
  981. // Not used on 360, but used on PS3 and PC.
  982. // This must be from a constant/uniform.
  983. // {x___} = -2.0/screenWidthInPixels
  984. // {_y__} = -2.0/screenHeightInPixels
  985. // {__z_} = 2.0/screenWidthInPixels
  986. // {___w} = 2.0/screenHeightInPixels
  987. FxaaFloat4 fxaaConsoleRcpFrameOpt2,
  988. //
  989. // Only used on FXAA Console.
  990. // Only used on 360 in place of fxaaConsoleRcpFrameOpt2.
  991. // This must be from a constant/uniform.
  992. // {x___} = 8.0/screenWidthInPixels
  993. // {_y__} = 8.0/screenHeightInPixels
  994. // {__z_} = -4.0/screenWidthInPixels
  995. // {___w} = -4.0/screenHeightInPixels
  996. FxaaFloat4 fxaaConsole360RcpFrameOpt2,
  997. //
  998. // Only used on FXAA Quality.
  999. // This used to be the FXAA_QUALITY_SUBPIX define.
  1000. // It is here now to allow easier tuning.
  1001. // Choose the amount of sub-pixel aliasing removal.
  1002. // This can effect sharpness.
  1003. // 1.00 - upper limit (softer)
  1004. // 0.75 - default amount of filtering
  1005. // 0.50 - lower limit (sharper, less sub-pixel aliasing removal)
  1006. // 0.25 - almost off
  1007. // 0.00 - completely off
  1008. FxaaFloat fxaaQualitySubpix,
  1009. //
  1010. // Only used on FXAA Quality.
  1011. // This used to be the FXAA_QUALITY_EDGE_THRESHOLD define.
  1012. // It is here now to allow easier tuning.
  1013. // The minimum amount of local contrast required to apply algorithm.
  1014. // 0.333 - too little (faster)
  1015. // 0.250 - low quality
  1016. // 0.166 - default
  1017. // 0.125 - high quality
  1018. // 0.063 - overkill (slower)
  1019. FxaaFloat fxaaQualityEdgeThreshold,
  1020. //
  1021. // Only used on FXAA Quality.
  1022. // This used to be the FXAA_QUALITY_EDGE_THRESHOLD_MIN define.
  1023. // It is here now to allow easier tuning.
  1024. // Trims the algorithm from processing darks.
  1025. // 0.0833 - upper limit (default, the start of visible unfiltered edges)
  1026. // 0.0625 - high quality (faster)
  1027. // 0.0312 - visible limit (slower)
  1028. // Special notes when using FXAA_GREEN_AS_LUMA,
  1029. // Likely want to set this to zero.
  1030. // As colors that are mostly not-green
  1031. // will appear very dark in the green channel!
  1032. // Tune by looking at mostly non-green content,
  1033. // then start at zero and increase until aliasing is a problem.
  1034. FxaaFloat fxaaQualityEdgeThresholdMin,
  1035. //
  1036. // Only used on FXAA Console.
  1037. // This used to be the FXAA_CONSOLE_EDGE_SHARPNESS define.
  1038. // It is here now to allow easier tuning.
  1039. // This does not effect PS3, as this needs to be compiled in.
  1040. // Use FXAA_CONSOLE_PS3_EDGE_SHARPNESS for PS3.
  1041. // Due to the PS3 being ALU bound,
  1042. // there are only three safe values here: 2 and 4 and 8.
  1043. // These options use the shaders ability to a free *|/ by 2|4|8.
  1044. // For all other platforms can be a non-power of two.
  1045. // 8.0 is sharper (default!!!)
  1046. // 4.0 is softer
  1047. // 2.0 is really soft (good only for vector graphics inputs)
  1048. FxaaFloat fxaaConsoleEdgeSharpness,
  1049. //
  1050. // Only used on FXAA Console.
  1051. // This used to be the FXAA_CONSOLE_EDGE_THRESHOLD define.
  1052. // It is here now to allow easier tuning.
  1053. // This does not effect PS3, as this needs to be compiled in.
  1054. // Use FXAA_CONSOLE_PS3_EDGE_THRESHOLD for PS3.
  1055. // Due to the PS3 being ALU bound,
  1056. // there are only two safe values here: 1/4 and 1/8.
  1057. // These options use the shaders ability to a free *|/ by 2|4|8.
  1058. // The console setting has a different mapping than the quality setting.
  1059. // Other platforms can use other values.
  1060. // 0.125 leaves less aliasing, but is softer (default!!!)
  1061. // 0.25 leaves more aliasing, and is sharper
  1062. FxaaFloat fxaaConsoleEdgeThreshold,
  1063. //
  1064. // Only used on FXAA Console.
  1065. // This used to be the FXAA_CONSOLE_EDGE_THRESHOLD_MIN define.
  1066. // It is here now to allow easier tuning.
  1067. // Trims the algorithm from processing darks.
  1068. // The console setting has a different mapping than the quality setting.
  1069. // This only applies when FXAA_EARLY_EXIT is 1.
  1070. // This does not apply to PS3,
  1071. // PS3 was simplified to avoid more shader instructions.
  1072. // 0.06 - faster but more aliasing in darks
  1073. // 0.05 - default
  1074. // 0.04 - slower and less aliasing in darks
  1075. // Special notes when using FXAA_GREEN_AS_LUMA,
  1076. // Likely want to set this to zero.
  1077. // As colors that are mostly not-green
  1078. // will appear very dark in the green channel!
  1079. // Tune by looking at mostly non-green content,
  1080. // then start at zero and increase until aliasing is a problem.
  1081. FxaaFloat fxaaConsoleEdgeThresholdMin,
  1082. //
  1083. // Extra constants for 360 FXAA Console only.
  1084. // Use zeros or anything else for other platforms.
  1085. // These must be in physical constant registers and NOT immedates.
  1086. // Immedates will result in compiler un-optimizing.
  1087. // {xyzw} = float4(1.0, -1.0, 0.25, -0.25)
  1088. FxaaFloat4 fxaaConsole360ConstDir
  1089. ) {
  1090. /*--------------------------------------------------------------------------*/
  1091. FxaaFloat2 posM;
  1092. posM.x = pos.x;
  1093. posM.y = pos.y;
  1094. #if (FXAA_GATHER4_ALPHA == 1)
  1095. #if (FXAA_DISCARD == 0)
  1096. FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);
  1097. #if (FXAA_GREEN_AS_LUMA == 0)
  1098. #define lumaM rgbyM.w
  1099. #else
  1100. #define lumaM rgbyM.y
  1101. #endif
  1102. #endif
  1103. #if (FXAA_GREEN_AS_LUMA == 0)
  1104. FxaaFloat4 luma4A = FxaaTexAlpha4(tex, posM);
  1105. FxaaFloat4 luma4B = FxaaTexOffAlpha4(tex, posM, FxaaInt2(-1, -1));
  1106. #else
  1107. FxaaFloat4 luma4A = FxaaTexGreen4(tex, posM);
  1108. FxaaFloat4 luma4B = FxaaTexOffGreen4(tex, posM, FxaaInt2(-1, -1));
  1109. #endif
  1110. #if (FXAA_DISCARD == 1)
  1111. #define lumaM luma4A.w
  1112. #endif
  1113. #define lumaE luma4A.z
  1114. #define lumaS luma4A.x
  1115. #define lumaSE luma4A.y
  1116. #define lumaNW luma4B.w
  1117. #define lumaN luma4B.z
  1118. #define lumaW luma4B.x
  1119. #else
  1120. FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);
  1121. #if (FXAA_GREEN_AS_LUMA == 0)
  1122. #define lumaM rgbyM.w
  1123. #else
  1124. #define lumaM rgbyM.y
  1125. #endif
  1126. FxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0, 1), fxaaQualityRcpFrame.xy));
  1127. FxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 0), fxaaQualityRcpFrame.xy));
  1128. FxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0,-1), fxaaQualityRcpFrame.xy));
  1129. FxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 0), fxaaQualityRcpFrame.xy));
  1130. #endif
  1131. /*--------------------------------------------------------------------------*/
  1132. FxaaFloat maxSM = max(lumaS, lumaM);
  1133. FxaaFloat minSM = min(lumaS, lumaM);
  1134. FxaaFloat maxESM = max(lumaE, maxSM);
  1135. FxaaFloat minESM = min(lumaE, minSM);
  1136. FxaaFloat maxWN = max(lumaN, lumaW);
  1137. FxaaFloat minWN = min(lumaN, lumaW);
  1138. FxaaFloat rangeMax = max(maxWN, maxESM);
  1139. FxaaFloat rangeMin = min(minWN, minESM);
  1140. FxaaFloat rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;
  1141. FxaaFloat range = rangeMax - rangeMin;
  1142. FxaaFloat rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);
  1143. FxaaBool earlyExit = range < rangeMaxClamped;
  1144. /*--------------------------------------------------------------------------*/
  1145. if(earlyExit)
  1146. #if (FXAA_DISCARD == 1)
  1147. FxaaDiscard;
  1148. #else
  1149. return rgbyM;
  1150. #endif
  1151. /*--------------------------------------------------------------------------*/
  1152. #if (FXAA_GATHER4_ALPHA == 0)
  1153. FxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1,-1), fxaaQualityRcpFrame.xy));
  1154. FxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 1), fxaaQualityRcpFrame.xy));
  1155. FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1,-1), fxaaQualityRcpFrame.xy));
  1156. FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));
  1157. #else
  1158. FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1, -1), fxaaQualityRcpFrame.xy));
  1159. FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));
  1160. #endif
  1161. /*--------------------------------------------------------------------------*/
  1162. FxaaFloat lumaNS = lumaN + lumaS;
  1163. FxaaFloat lumaWE = lumaW + lumaE;
  1164. FxaaFloat subpixRcpRange = 1.0/range;
  1165. FxaaFloat subpixNSWE = lumaNS + lumaWE;
  1166. FxaaFloat edgeHorz1 = (-2.0 * lumaM) + lumaNS;
  1167. FxaaFloat edgeVert1 = (-2.0 * lumaM) + lumaWE;
  1168. /*--------------------------------------------------------------------------*/
  1169. FxaaFloat lumaNESE = lumaNE + lumaSE;
  1170. FxaaFloat lumaNWNE = lumaNW + lumaNE;
  1171. FxaaFloat edgeHorz2 = (-2.0 * lumaE) + lumaNESE;
  1172. FxaaFloat edgeVert2 = (-2.0 * lumaN) + lumaNWNE;
  1173. /*--------------------------------------------------------------------------*/
  1174. FxaaFloat lumaNWSW = lumaNW + lumaSW;
  1175. FxaaFloat lumaSWSE = lumaSW + lumaSE;
  1176. FxaaFloat edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);
  1177. FxaaFloat edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);
  1178. FxaaFloat edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;
  1179. FxaaFloat edgeVert3 = (-2.0 * lumaS) + lumaSWSE;
  1180. FxaaFloat edgeHorz = abs(edgeHorz3) + edgeHorz4;
  1181. FxaaFloat edgeVert = abs(edgeVert3) + edgeVert4;
  1182. /*--------------------------------------------------------------------------*/
  1183. FxaaFloat subpixNWSWNESE = lumaNWSW + lumaNESE;
  1184. FxaaFloat lengthSign = fxaaQualityRcpFrame.x;
  1185. FxaaBool horzSpan = edgeHorz >= edgeVert;
  1186. FxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;
  1187. /*--------------------------------------------------------------------------*/
  1188. if(!horzSpan) lumaN = lumaW;
  1189. if(!horzSpan) lumaS = lumaE;
  1190. if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;
  1191. FxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;
  1192. /*--------------------------------------------------------------------------*/
  1193. FxaaFloat gradientN = lumaN - lumaM;
  1194. FxaaFloat gradientS = lumaS - lumaM;
  1195. FxaaFloat lumaNN = lumaN + lumaM;
  1196. FxaaFloat lumaSS = lumaS + lumaM;
  1197. FxaaBool pairN = abs(gradientN) >= abs(gradientS);
  1198. FxaaFloat gradient = max(abs(gradientN), abs(gradientS));
  1199. if(pairN) lengthSign = -lengthSign;
  1200. FxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);
  1201. /*--------------------------------------------------------------------------*/
  1202. FxaaFloat2 posB;
  1203. posB.x = posM.x;
  1204. posB.y = posM.y;
  1205. FxaaFloat2 offNP;
  1206. offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;
  1207. offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;
  1208. if(!horzSpan) posB.x += lengthSign * 0.5;
  1209. if( horzSpan) posB.y += lengthSign * 0.5;
  1210. /*--------------------------------------------------------------------------*/
  1211. FxaaFloat2 posN;
  1212. posN.x = posB.x - offNP.x * FXAA_QUALITY_P0;
  1213. posN.y = posB.y - offNP.y * FXAA_QUALITY_P0;
  1214. FxaaFloat2 posP;
  1215. posP.x = posB.x + offNP.x * FXAA_QUALITY_P0;
  1216. posP.y = posB.y + offNP.y * FXAA_QUALITY_P0;
  1217. FxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;
  1218. FxaaFloat lumaEndN = FxaaLuma(FxaaTexTop(tex, posN));
  1219. FxaaFloat subpixE = subpixC * subpixC;
  1220. FxaaFloat lumaEndP = FxaaLuma(FxaaTexTop(tex, posP));
  1221. /*--------------------------------------------------------------------------*/
  1222. if(!pairN) lumaNN = lumaSS;
  1223. FxaaFloat gradientScaled = gradient * 1.0/4.0;
  1224. FxaaFloat lumaMM = lumaM - lumaNN * 0.5;
  1225. FxaaFloat subpixF = subpixD * subpixE;
  1226. FxaaBool lumaMLTZero = lumaMM < 0.0;
  1227. /*--------------------------------------------------------------------------*/
  1228. lumaEndN -= lumaNN * 0.5;
  1229. lumaEndP -= lumaNN * 0.5;
  1230. FxaaBool doneN = abs(lumaEndN) >= gradientScaled;
  1231. FxaaBool doneP = abs(lumaEndP) >= gradientScaled;
  1232. if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P1;
  1233. if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P1;
  1234. FxaaBool doneNP = (!doneN) || (!doneP);
  1235. if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P1;
  1236. if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;
  1237. /*--------------------------------------------------------------------------*/
  1238. if(doneNP) {
  1239. if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
  1240. if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
  1241. if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
  1242. if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
  1243. doneN = abs(lumaEndN) >= gradientScaled;
  1244. doneP = abs(lumaEndP) >= gradientScaled;
  1245. if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P2;
  1246. if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P2;
  1247. doneNP = (!doneN) || (!doneP);
  1248. if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P2;
  1249. if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P2;
  1250. /*--------------------------------------------------------------------------*/
  1251. #if (FXAA_QUALITY_PS > 3)
  1252. if(doneNP) {
  1253. if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
  1254. if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
  1255. if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
  1256. if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
  1257. doneN = abs(lumaEndN) >= gradientScaled;
  1258. doneP = abs(lumaEndP) >= gradientScaled;
  1259. if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P3;
  1260. if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P3;
  1261. doneNP = (!doneN) || (!doneP);
  1262. if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P3;
  1263. if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P3;
  1264. /*--------------------------------------------------------------------------*/
  1265. #if (FXAA_QUALITY_PS > 4)
  1266. if(doneNP) {
  1267. if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
  1268. if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
  1269. if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
  1270. if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
  1271. doneN = abs(lumaEndN) >= gradientScaled;
  1272. doneP = abs(lumaEndP) >= gradientScaled;
  1273. if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P4;
  1274. if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P4;
  1275. doneNP = (!doneN) || (!doneP);
  1276. if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P4;
  1277. if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P4;
  1278. /*--------------------------------------------------------------------------*/
  1279. #if (FXAA_QUALITY_PS > 5)
  1280. if(doneNP) {
  1281. if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
  1282. if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
  1283. if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
  1284. if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
  1285. doneN = abs(lumaEndN) >= gradientScaled;
  1286. doneP = abs(lumaEndP) >= gradientScaled;
  1287. if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P5;
  1288. if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P5;
  1289. doneNP = (!doneN) || (!doneP);
  1290. if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P5;
  1291. if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P5;
  1292. /*--------------------------------------------------------------------------*/
  1293. #if (FXAA_QUALITY_PS > 6)
  1294. if(doneNP) {
  1295. if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
  1296. if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
  1297. if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
  1298. if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
  1299. doneN = abs(lumaEndN) >= gradientScaled;
  1300. doneP = abs(lumaEndP) >= gradientScaled;
  1301. if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P6;
  1302. if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P6;
  1303. doneNP = (!doneN) || (!doneP);
  1304. if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P6;
  1305. if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P6;
  1306. /*--------------------------------------------------------------------------*/
  1307. #if (FXAA_QUALITY_PS > 7)
  1308. if(doneNP) {
  1309. if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
  1310. if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
  1311. if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
  1312. if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
  1313. doneN = abs(lumaEndN) >= gradientScaled;
  1314. doneP = abs(lumaEndP) >= gradientScaled;
  1315. if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P7;
  1316. if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P7;
  1317. doneNP = (!doneN) || (!doneP);
  1318. if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P7;
  1319. if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P7;
  1320. /*--------------------------------------------------------------------------*/
  1321. #if (FXAA_QUALITY_PS > 8)
  1322. if(doneNP) {
  1323. if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
  1324. if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
  1325. if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
  1326. if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
  1327. doneN = abs(lumaEndN) >= gradientScaled;
  1328. doneP = abs(lumaEndP) >= gradientScaled;
  1329. if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P8;
  1330. if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P8;
  1331. doneNP = (!doneN) || (!doneP);
  1332. if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P8;
  1333. if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P8;
  1334. /*--------------------------------------------------------------------------*/
  1335. #if (FXAA_QUALITY_PS > 9)
  1336. if(doneNP) {
  1337. if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
  1338. if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
  1339. if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
  1340. if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
  1341. doneN = abs(lumaEndN) >= gradientScaled;
  1342. doneP = abs(lumaEndP) >= gradientScaled;
  1343. if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P9;
  1344. if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P9;
  1345. doneNP = (!doneN) || (!doneP);
  1346. if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P9;
  1347. if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P9;
  1348. /*--------------------------------------------------------------------------*/
  1349. #if (FXAA_QUALITY_PS > 10)
  1350. if(doneNP) {
  1351. if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
  1352. if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
  1353. if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
  1354. if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
  1355. doneN = abs(lumaEndN) >= gradientScaled;
  1356. doneP = abs(lumaEndP) >= gradientScaled;
  1357. if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P10;
  1358. if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P10;
  1359. doneNP = (!doneN) || (!doneP);
  1360. if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P10;
  1361. if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P10;
  1362. /*--------------------------------------------------------------------------*/
  1363. #if (FXAA_QUALITY_PS > 11)
  1364. if(doneNP) {
  1365. if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
  1366. if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
  1367. if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
  1368. if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
  1369. doneN = abs(lumaEndN) >= gradientScaled;
  1370. doneP = abs(lumaEndP) >= gradientScaled;
  1371. if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P11;
  1372. if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P11;
  1373. doneNP = (!doneN) || (!doneP);
  1374. if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P11;
  1375. if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P11;
  1376. /*--------------------------------------------------------------------------*/
  1377. #if (FXAA_QUALITY_PS > 12)
  1378. if(doneNP) {
  1379. if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
  1380. if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
  1381. if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
  1382. if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
  1383. doneN = abs(lumaEndN) >= gradientScaled;
  1384. doneP = abs(lumaEndP) >= gradientScaled;
  1385. if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P12;
  1386. if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P12;
  1387. doneNP = (!doneN) || (!doneP);
  1388. if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P12;
  1389. if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P12;
  1390. /*--------------------------------------------------------------------------*/
  1391. }
  1392. #endif
  1393. /*--------------------------------------------------------------------------*/
  1394. }
  1395. #endif
  1396. /*--------------------------------------------------------------------------*/
  1397. }
  1398. #endif
  1399. /*--------------------------------------------------------------------------*/
  1400. }
  1401. #endif
  1402. /*--------------------------------------------------------------------------*/
  1403. }
  1404. #endif
  1405. /*--------------------------------------------------------------------------*/
  1406. }
  1407. #endif
  1408. /*--------------------------------------------------------------------------*/
  1409. }
  1410. #endif
  1411. /*--------------------------------------------------------------------------*/
  1412. }
  1413. #endif
  1414. /*--------------------------------------------------------------------------*/
  1415. }
  1416. #endif
  1417. /*--------------------------------------------------------------------------*/
  1418. }
  1419. #endif
  1420. /*--------------------------------------------------------------------------*/
  1421. }
  1422. /*--------------------------------------------------------------------------*/
  1423. FxaaFloat dstN = posM.x - posN.x;
  1424. FxaaFloat dstP = posP.x - posM.x;
  1425. if(!horzSpan) dstN = posM.y - posN.y;
  1426. if(!horzSpan) dstP = posP.y - posM.y;
  1427. /*--------------------------------------------------------------------------*/
  1428. FxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;
  1429. FxaaFloat spanLength = (dstP + dstN);
  1430. FxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;
  1431. FxaaFloat spanLengthRcp = 1.0/spanLength;
  1432. /*--------------------------------------------------------------------------*/
  1433. FxaaBool directionN = dstN < dstP;
  1434. FxaaFloat dst = min(dstN, dstP);
  1435. FxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;
  1436. FxaaFloat subpixG = subpixF * subpixF;
  1437. FxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;
  1438. FxaaFloat subpixH = subpixG * fxaaQualitySubpix;
  1439. /*--------------------------------------------------------------------------*/
  1440. FxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;
  1441. FxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);
  1442. if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;
  1443. if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;
  1444. #if (FXAA_DISCARD == 1)
  1445. return FxaaTexTop(tex, posM);
  1446. #else
  1447. return FxaaFloat4(FxaaTexTop(tex, posM).xyz, lumaM);
  1448. #endif
  1449. }
  1450. /*==========================================================================*/
  1451. #endif
  1452.  
  1453.  
  1454.  
  1455.  
  1456. /*============================================================================
  1457.  
  1458. FXAA3 CONSOLE - PC VERSION
  1459.  
  1460. ------------------------------------------------------------------------------
  1461. Instead of using this on PC, I'd suggest just using FXAA Quality with
  1462. #define FXAA_QUALITY_PRESET 10
  1463. Or
  1464. #define FXAA_QUALITY_PRESET 20
  1465. Either are higher qualilty and almost as fast as this on modern PC GPUs.
  1466. ============================================================================*/
  1467. #if (FXAA_PC_CONSOLE == 1)
  1468. /*--------------------------------------------------------------------------*/
  1469. FxaaFloat4 FxaaPixelShader(
  1470. // See FXAA Quality FxaaPixelShader() source for docs on Inputs!
  1471. FxaaFloat2 pos,
  1472. FxaaFloat4 fxaaConsolePosPos,
  1473. FxaaTex tex,
  1474. FxaaTex fxaaConsole360TexExpBiasNegOne,
  1475. FxaaTex fxaaConsole360TexExpBiasNegTwo,
  1476. FxaaFloat2 fxaaQualityRcpFrame,
  1477. FxaaFloat4 fxaaConsoleRcpFrameOpt,
  1478. FxaaFloat4 fxaaConsoleRcpFrameOpt2,
  1479. FxaaFloat4 fxaaConsole360RcpFrameOpt2,
  1480. FxaaFloat fxaaQualitySubpix,
  1481. FxaaFloat fxaaQualityEdgeThreshold,
  1482. FxaaFloat fxaaQualityEdgeThresholdMin,
  1483. FxaaFloat fxaaConsoleEdgeSharpness,
  1484. FxaaFloat fxaaConsoleEdgeThreshold,
  1485. FxaaFloat fxaaConsoleEdgeThresholdMin,
  1486. FxaaFloat4 fxaaConsole360ConstDir
  1487. ) {
  1488. /*--------------------------------------------------------------------------*/
  1489. FxaaFloat lumaNw = FxaaLuma(FxaaTexTop(tex, fxaaConsolePosPos.xy));
  1490. FxaaFloat lumaSw = FxaaLuma(FxaaTexTop(tex, fxaaConsolePosPos.xw));
  1491. FxaaFloat lumaNe = FxaaLuma(FxaaTexTop(tex, fxaaConsolePosPos.zy));
  1492. FxaaFloat lumaSe = FxaaLuma(FxaaTexTop(tex, fxaaConsolePosPos.zw));
  1493. /*--------------------------------------------------------------------------*/
  1494. FxaaFloat4 rgbyM = FxaaTexTop(tex, pos.xy);
  1495. #if (FXAA_GREEN_AS_LUMA == 0)
  1496. FxaaFloat lumaM = rgbyM.w;
  1497. #else
  1498. FxaaFloat lumaM = rgbyM.y;
  1499. #endif
  1500. /*--------------------------------------------------------------------------*/
  1501. FxaaFloat lumaMaxNwSw = max(lumaNw, lumaSw);
  1502. lumaNe += 1.0/384.0;
  1503. FxaaFloat lumaMinNwSw = min(lumaNw, lumaSw);
  1504. /*--------------------------------------------------------------------------*/
  1505. FxaaFloat lumaMaxNeSe = max(lumaNe, lumaSe);
  1506. FxaaFloat lumaMinNeSe = min(lumaNe, lumaSe);
  1507. /*--------------------------------------------------------------------------*/
  1508. FxaaFloat lumaMax = max(lumaMaxNeSe, lumaMaxNwSw);
  1509. FxaaFloat lumaMin = min(lumaMinNeSe, lumaMinNwSw);
  1510. /*--------------------------------------------------------------------------*/
  1511. FxaaFloat lumaMaxScaled = lumaMax * fxaaConsoleEdgeThreshold;
  1512. /*--------------------------------------------------------------------------*/
  1513. FxaaFloat lumaMinM = min(lumaMin, lumaM);
  1514. FxaaFloat lumaMaxScaledClamped = max(fxaaConsoleEdgeThresholdMin, lumaMaxScaled);
  1515. FxaaFloat lumaMaxM = max(lumaMax, lumaM);
  1516. FxaaFloat dirSwMinusNe = lumaSw - lumaNe;
  1517. FxaaFloat lumaMaxSubMinM = lumaMaxM - lumaMinM;
  1518. FxaaFloat dirSeMinusNw = lumaSe - lumaNw;
  1519. if(lumaMaxSubMinM < lumaMaxScaledClamped) return rgbyM;
  1520. /*--------------------------------------------------------------------------*/
  1521. FxaaFloat2 dir;
  1522. dir.x = dirSwMinusNe + dirSeMinusNw;
  1523. dir.y = dirSwMinusNe - dirSeMinusNw;
  1524. /*--------------------------------------------------------------------------*/
  1525. FxaaFloat2 dir1 = normalize(dir.xy);
  1526. FxaaFloat4 rgbyN1 = FxaaTexTop(tex, pos.xy - dir1 * fxaaConsoleRcpFrameOpt.zw);
  1527. FxaaFloat4 rgbyP1 = FxaaTexTop(tex, pos.xy + dir1 * fxaaConsoleRcpFrameOpt.zw);
  1528. /*--------------------------------------------------------------------------*/
  1529. FxaaFloat dirAbsMinTimesC = min(abs(dir1.x), abs(dir1.y)) * fxaaConsoleEdgeSharpness;
  1530. FxaaFloat2 dir2 = clamp(dir1.xy / dirAbsMinTimesC, -2.0, 2.0);
  1531. /*--------------------------------------------------------------------------*/
  1532. FxaaFloat4 rgbyN2 = FxaaTexTop(tex, pos.xy - dir2 * fxaaConsoleRcpFrameOpt2.zw);
  1533. FxaaFloat4 rgbyP2 = FxaaTexTop(tex, pos.xy + dir2 * fxaaConsoleRcpFrameOpt2.zw);
  1534. /*--------------------------------------------------------------------------*/
  1535. FxaaFloat4 rgbyA = rgbyN1 + rgbyP1;
  1536. FxaaFloat4 rgbyB = ((rgbyN2 + rgbyP2) * 0.25) + (rgbyA * 0.25);
  1537. /*--------------------------------------------------------------------------*/
  1538. #if (FXAA_GREEN_AS_LUMA == 0)
  1539. FxaaBool twoTap = (rgbyB.w < lumaMin) || (rgbyB.w > lumaMax);
  1540. #else
  1541. FxaaBool twoTap = (rgbyB.y < lumaMin) || (rgbyB.y > lumaMax);
  1542. #endif
  1543. if(twoTap) rgbyB.xyz = rgbyA.xyz * 0.5;
  1544. return rgbyB; }
  1545. /*==========================================================================*/
  1546. #endif
  1547.  
  1548.  
  1549.  
  1550. /*============================================================================
  1551.  
  1552. FXAA3 CONSOLE - 360 PIXEL SHADER
  1553.  
  1554. ------------------------------------------------------------------------------
  1555. This optimized version thanks to suggestions from Andy Luedke.
  1556. Should be fully tex bound in all cases.
  1557. As of the FXAA 3.11 release, I have still not tested this code,
  1558. however I fixed a bug which was in both FXAA 3.9 and FXAA 3.10.
  1559. And note this is replacing the old unoptimized version.
  1560. If it does not work, please let me know so I can fix it.
  1561. ============================================================================*/
  1562. #if (FXAA_360 == 1)
  1563. /*--------------------------------------------------------------------------*/
  1564. [reduceTempRegUsage(4)]
  1565. float4 FxaaPixelShader(
  1566. // See FXAA Quality FxaaPixelShader() source for docs on Inputs!
  1567. FxaaFloat2 pos,
  1568. FxaaFloat4 fxaaConsolePosPos,
  1569. FxaaTex tex,
  1570. FxaaTex fxaaConsole360TexExpBiasNegOne,
  1571. FxaaTex fxaaConsole360TexExpBiasNegTwo,
  1572. FxaaFloat2 fxaaQualityRcpFrame,
  1573. FxaaFloat4 fxaaConsoleRcpFrameOpt,
  1574. FxaaFloat4 fxaaConsoleRcpFrameOpt2,
  1575. FxaaFloat4 fxaaConsole360RcpFrameOpt2,
  1576. FxaaFloat fxaaQualitySubpix,
  1577. FxaaFloat fxaaQualityEdgeThreshold,
  1578. FxaaFloat fxaaQualityEdgeThresholdMin,
  1579. FxaaFloat fxaaConsoleEdgeSharpness,
  1580. FxaaFloat fxaaConsoleEdgeThreshold,
  1581. FxaaFloat fxaaConsoleEdgeThresholdMin,
  1582. FxaaFloat4 fxaaConsole360ConstDir
  1583. ) {
  1584. /*--------------------------------------------------------------------------*/
  1585. float4 lumaNwNeSwSe;
  1586. #if (FXAA_GREEN_AS_LUMA == 0)
  1587. asm {
  1588. tfetch2D lumaNwNeSwSe.w___, tex, pos.xy, OffsetX = -0.5, OffsetY = -0.5, UseComputedLOD=false
  1589. tfetch2D lumaNwNeSwSe._w__, tex, pos.xy, OffsetX = 0.5, OffsetY = -0.5, UseComputedLOD=false
  1590. tfetch2D lumaNwNeSwSe.__w_, tex, pos.xy, OffsetX = -0.5, OffsetY = 0.5, UseComputedLOD=false
  1591. tfetch2D lumaNwNeSwSe.___w, tex, pos.xy, OffsetX = 0.5, OffsetY = 0.5, UseComputedLOD=false
  1592. };
  1593. #else
  1594. asm {
  1595. tfetch2D lumaNwNeSwSe.y___, tex, pos.xy, OffsetX = -0.5, OffsetY = -0.5, UseComputedLOD=false
  1596. tfetch2D lumaNwNeSwSe._y__, tex, pos.xy, OffsetX = 0.5, OffsetY = -0.5, UseComputedLOD=false
  1597. tfetch2D lumaNwNeSwSe.__y_, tex, pos.xy, OffsetX = -0.5, OffsetY = 0.5, UseComputedLOD=false
  1598. tfetch2D lumaNwNeSwSe.___y, tex, pos.xy, OffsetX = 0.5, OffsetY = 0.5, UseComputedLOD=false
  1599. };
  1600. #endif
  1601. /*--------------------------------------------------------------------------*/
  1602. lumaNwNeSwSe.y += 1.0/384.0;
  1603. float2 lumaMinTemp = min(lumaNwNeSwSe.xy, lumaNwNeSwSe.zw);
  1604. float2 lumaMaxTemp = max(lumaNwNeSwSe.xy, lumaNwNeSwSe.zw);
  1605. float lumaMin = min(lumaMinTemp.x, lumaMinTemp.y);
  1606. float lumaMax = max(lumaMaxTemp.x, lumaMaxTemp.y);
  1607. /*--------------------------------------------------------------------------*/
  1608. float4 rgbyM = tex2Dlod(tex, float4(pos.xy, 0.0, 0.0));
  1609. #if (FXAA_GREEN_AS_LUMA == 0)
  1610. float lumaMinM = min(lumaMin, rgbyM.w);
  1611. float lumaMaxM = max(lumaMax, rgbyM.w);
  1612. #else
  1613. float lumaMinM = min(lumaMin, rgbyM.y);
  1614. float lumaMaxM = max(lumaMax, rgbyM.y);
  1615. #endif
  1616. if((lumaMaxM - lumaMinM) < max(fxaaConsoleEdgeThresholdMin, lumaMax * fxaaConsoleEdgeThreshold)) return rgbyM;
  1617. /*--------------------------------------------------------------------------*/
  1618. float2 dir;
  1619. dir.x = dot(lumaNwNeSwSe, fxaaConsole360ConstDir.yyxx);
  1620. dir.y = dot(lumaNwNeSwSe, fxaaConsole360ConstDir.xyxy);
  1621. dir = normalize(dir);
  1622. /*--------------------------------------------------------------------------*/
  1623. float4 dir1 = dir.xyxy * fxaaConsoleRcpFrameOpt.xyzw;
  1624. /*--------------------------------------------------------------------------*/
  1625. float4 dir2;
  1626. float dirAbsMinTimesC = min(abs(dir.x), abs(dir.y)) * fxaaConsoleEdgeSharpness;
  1627. dir2 = saturate(fxaaConsole360ConstDir.zzww * dir.xyxy / dirAbsMinTimesC + 0.5);
  1628. dir2 = dir2 * fxaaConsole360RcpFrameOpt2.xyxy + fxaaConsole360RcpFrameOpt2.zwzw;
  1629. /*--------------------------------------------------------------------------*/
  1630. float4 rgbyN1 = tex2Dlod(fxaaConsole360TexExpBiasNegOne, float4(pos.xy + dir1.xy, 0.0, 0.0));
  1631. float4 rgbyP1 = tex2Dlod(fxaaConsole360TexExpBiasNegOne, float4(pos.xy + dir1.zw, 0.0, 0.0));
  1632. float4 rgbyN2 = tex2Dlod(fxaaConsole360TexExpBiasNegTwo, float4(pos.xy + dir2.xy, 0.0, 0.0));
  1633. float4 rgbyP2 = tex2Dlod(fxaaConsole360TexExpBiasNegTwo, float4(pos.xy + dir2.zw, 0.0, 0.0));
  1634. /*--------------------------------------------------------------------------*/
  1635. float4 rgbyA = rgbyN1 + rgbyP1;
  1636. float4 rgbyB = rgbyN2 + rgbyP2 + rgbyA * 0.5;
  1637. /*--------------------------------------------------------------------------*/
  1638. float4 rgbyR = ((FxaaLuma(rgbyB) - lumaMax) > 0.0) ? rgbyA : rgbyB;
  1639. rgbyR = ((FxaaLuma(rgbyB) - lumaMin) > 0.0) ? rgbyR : rgbyA;
  1640. return rgbyR; }
  1641. /*==========================================================================*/
  1642. #endif
  1643.  
  1644.  
  1645.  
  1646. /*============================================================================
  1647.  
  1648. FXAA3 CONSOLE - OPTIMIZED PS3 PIXEL SHADER (NO EARLY EXIT)
  1649.  
  1650. ==============================================================================
  1651. The code below does not exactly match the assembly.
  1652. I have a feeling that 12 cycles is possible, but was not able to get there.
  1653. Might have to increase register count to get full performance.
  1654. Note this shader does not use perspective interpolation.
  1655.  
  1656. Use the following cgc options,
  1657.  
  1658. --fenable-bx2 --fastmath --fastprecision --nofloatbindings
  1659.  
  1660. ------------------------------------------------------------------------------
  1661. NVSHADERPERF OUTPUT
  1662. ------------------------------------------------------------------------------
  1663. For reference and to aid in debug, output of NVShaderPerf should match this,
  1664.  
  1665. Shader to schedule:
  1666. 0: texpkb h0.w(TRUE), v5.zyxx, #0
  1667. 2: addh h2.z(TRUE), h0.w, constant(0.001953, 0.000000, 0.000000, 0.000000).x
  1668. 4: texpkb h0.w(TRUE), v5.xwxx, #0
  1669. 6: addh h0.z(TRUE), -h2, h0.w
  1670. 7: texpkb h1.w(TRUE), v5, #0
  1671. 9: addh h0.x(TRUE), h0.z, -h1.w
  1672. 10: addh h3.w(TRUE), h0.z, h1
  1673. 11: texpkb h2.w(TRUE), v5.zwzz, #0
  1674. 13: addh h0.z(TRUE), h3.w, -h2.w
  1675. 14: addh h0.x(TRUE), h2.w, h0
  1676. 15: nrmh h1.xz(TRUE), h0_n
  1677. 16: minh_m8 h0.x(TRUE), |h1|, |h1.z|
  1678. 17: maxh h4.w(TRUE), h0, h1
  1679. 18: divx h2.xy(TRUE), h1_n.xzzw, h0_n
  1680. 19: movr r1.zw(TRUE), v4.xxxy
  1681. 20: madr r2.xz(TRUE), -h1, constant(cConst5.x, cConst5.y, cConst5.z, cConst5.w).zzww, r1.zzww
  1682. 22: minh h5.w(TRUE), h0, h1
  1683. 23: texpkb h0(TRUE), r2.xzxx, #0
  1684. 25: madr r0.zw(TRUE), h1.xzxz, constant(cConst5.x, cConst5.y, cConst5.z, cConst5.w), r1
  1685. 27: maxh h4.x(TRUE), h2.z, h2.w
  1686. 28: texpkb h1(TRUE), r0.zwzz, #0
  1687. 30: addh_d2 h1(TRUE), h0, h1
  1688. 31: madr r0.xy(TRUE), -h2, constant(cConst5.x, cConst5.y, cConst5.z, cConst5.w).xyxx, r1.zwzz
  1689. 33: texpkb h0(TRUE), r0, #0
  1690. 35: minh h4.z(TRUE), h2, h2.w
  1691. 36: fenct TRUE
  1692. 37: madr r1.xy(TRUE), h2, constant(cConst5.x, cConst5.y, cConst5.z, cConst5.w).xyxx, r1.zwzz
  1693. 39: texpkb h2(TRUE), r1, #0
  1694. 41: addh_d2 h0(TRUE), h0, h2
  1695. 42: maxh h2.w(TRUE), h4, h4.x
  1696. 43: minh h2.x(TRUE), h5.w, h4.z
  1697. 44: addh_d2 h0(TRUE), h0, h1
  1698. 45: slth h2.x(TRUE), h0.w, h2
  1699. 46: sgth h2.w(TRUE), h0, h2
  1700. 47: movh h0(TRUE), h0
  1701. 48: addx.c0 rc(TRUE), h2, h2.w
  1702. 49: movh h0(c0.NE.x), h1
  1703.  
  1704. IPU0 ------ Simplified schedule: --------
  1705. Pass | Unit | uOp | PC: Op
  1706. -----+--------+------+-------------------------
  1707. 1 | SCT0/1 | mov | 0: TXLr h0.w, g[TEX1].zyxx, const.xxxx, TEX0;
  1708. | TEX | txl | 0: TXLr h0.w, g[TEX1].zyxx, const.xxxx, TEX0;
  1709. | SCB1 | add | 2: ADDh h2.z, h0.--w-, const.--x-;
  1710. | | |
  1711. 2 | SCT0/1 | mov | 4: TXLr h0.w, g[TEX1].xwxx, const.xxxx, TEX0;
  1712. | TEX | txl | 4: TXLr h0.w, g[TEX1].xwxx, const.xxxx, TEX0;
  1713. | SCB1 | add | 6: ADDh h0.z,-h2, h0.--w-;
  1714. | | |
  1715. 3 | SCT0/1 | mov | 7: TXLr h1.w, g[TEX1], const.xxxx, TEX0;
  1716. | TEX | txl | 7: TXLr h1.w, g[TEX1], const.xxxx, TEX0;
  1717. | SCB0 | add | 9: ADDh h0.x, h0.z---,-h1.w---;
  1718. | SCB1 | add | 10: ADDh h3.w, h0.---z, h1;
  1719. | | |
  1720. 4 | SCT0/1 | mov | 11: TXLr h2.w, g[TEX1].zwzz, const.xxxx, TEX0;
  1721. | TEX | txl | 11: TXLr h2.w, g[TEX1].zwzz, const.xxxx, TEX0;
  1722. | SCB0 | add | 14: ADDh h0.x, h2.w---, h0;
  1723. | SCB1 | add | 13: ADDh h0.z, h3.--w-,-h2.--w-;
  1724. | | |
  1725. 5 | SCT1 | mov | 15: NRMh h1.xz, h0;
  1726. | SRB | nrm | 15: NRMh h1.xz, h0;
  1727. | SCB0 | min | 16: MINh*8 h0.x, |h1|, |h1.z---|;
  1728. | SCB1 | max | 17: MAXh h4.w, h0, h1;
  1729. | | |
  1730. 6 | SCT0 | div | 18: DIVx h2.xy, h1.xz--, h0;
  1731. | SCT1 | mov | 19: MOVr r1.zw, g[TEX0].--xy;
  1732. | SCB0 | mad | 20: MADr r2.xz,-h1, const.z-w-, r1.z-w-;
  1733. | SCB1 | min | 22: MINh h5.w, h0, h1;
  1734. | | |
  1735. 7 | SCT0/1 | mov | 23: TXLr h0, r2.xzxx, const.xxxx, TEX0;
  1736. | TEX | txl | 23: TXLr h0, r2.xzxx, const.xxxx, TEX0;
  1737. | SCB0 | max | 27: MAXh h4.x, h2.z---, h2.w---;
  1738. | SCB1 | mad | 25: MADr r0.zw, h1.--xz, const, r1;
  1739. | | |
  1740. 8 | SCT0/1 | mov | 28: TXLr h1, r0.zwzz, const.xxxx, TEX0;
  1741. | TEX | txl | 28: TXLr h1, r0.zwzz, const.xxxx, TEX0;
  1742. | SCB0/1 | add | 30: ADDh/2 h1, h0, h1;
  1743. | | |
  1744. 9 | SCT0 | mad | 31: MADr r0.xy,-h2, const.xy--, r1.zw--;
  1745. | SCT1 | mov | 33: TXLr h0, r0, const.zzzz, TEX0;
  1746. | TEX | txl | 33: TXLr h0, r0, const.zzzz, TEX0;
  1747. | SCB1 | min | 35: MINh h4.z, h2, h2.--w-;
  1748. | | |
  1749. 10 | SCT0 | mad | 37: MADr r1.xy, h2, const.xy--, r1.zw--;
  1750. | SCT1 | mov | 39: TXLr h2, r1, const.zzzz, TEX0;
  1751. | TEX | txl | 39: TXLr h2, r1, const.zzzz, TEX0;
  1752. | SCB0/1 | add | 41: ADDh/2 h0, h0, h2;
  1753. | | |
  1754. 11 | SCT0 | min | 43: MINh h2.x, h5.w---, h4.z---;
  1755. | SCT1 | max | 42: MAXh h2.w, h4, h4.---x;
  1756. | SCB0/1 | add | 44: ADDh/2 h0, h0, h1;
  1757. | | |
  1758. 12 | SCT0 | set | 45: SLTh h2.x, h0.w---, h2;
  1759. | SCT1 | set | 46: SGTh h2.w, h0, h2;
  1760. | SCB0/1 | mul | 47: MOVh h0, h0;
  1761. | | |
  1762. 13 | SCT0 | mad | 48: ADDxc0_s rc, h2, h2.w---;
  1763. | SCB0/1 | mul | 49: MOVh h0(NE0.xxxx), h1;
  1764.  
  1765. Pass SCT TEX SCB
  1766. 1: 0% 100% 25%
  1767. 2: 0% 100% 25%
  1768. 3: 0% 100% 50%
  1769. 4: 0% 100% 50%
  1770. 5: 0% 0% 50%
  1771. 6: 100% 0% 75%
  1772. 7: 0% 100% 75%
  1773. 8: 0% 100% 100%
  1774. 9: 0% 100% 25%
  1775. 10: 0% 100% 100%
  1776. 11: 50% 0% 100%
  1777. 12: 50% 0% 100%
  1778. 13: 25% 0% 100%
  1779.  
  1780. MEAN: 17% 61% 67%
  1781.  
  1782. Pass SCT0 SCT1 TEX SCB0 SCB1
  1783. 1: 0% 0% 100% 0% 100%
  1784. 2: 0% 0% 100% 0% 100%
  1785. 3: 0% 0% 100% 100% 100%
  1786. 4: 0% 0% 100% 100% 100%
  1787. 5: 0% 0% 0% 100% 100%
  1788. 6: 100% 100% 0% 100% 100%
  1789. 7: 0% 0% 100% 100% 100%
  1790. 8: 0% 0% 100% 100% 100%
  1791. 9: 0% 0% 100% 0% 100%
  1792. 10: 0% 0% 100% 100% 100%
  1793. 11: 100% 100% 0% 100% 100%
  1794. 12: 100% 100% 0% 100% 100%
  1795. 13: 100% 0% 0% 100% 100%
  1796.  
  1797. MEAN: 30% 23% 61% 76% 100%
  1798. Fragment Performance Setup: Driver RSX Compiler, GPU RSX, Flags 0x5
  1799. Results 13 cycles, 3 r regs, 923,076,923 pixels/s
  1800. ============================================================================*/
  1801. #if (FXAA_PS3 == 1) && (FXAA_EARLY_EXIT == 0)
  1802. /*--------------------------------------------------------------------------*/
  1803. #pragma regcount 7
  1804. #pragma disablepc all
  1805. #pragma option O3
  1806. #pragma option OutColorPrec=fp16
  1807. #pragma texformat default RGBA8
  1808. /*==========================================================================*/
  1809. half4 FxaaPixelShader(
  1810. // See FXAA Quality FxaaPixelShader() source for docs on Inputs!
  1811. FxaaFloat2 pos,
  1812. FxaaFloat4 fxaaConsolePosPos,
  1813. FxaaTex tex,
  1814. FxaaTex fxaaConsole360TexExpBiasNegOne,
  1815. FxaaTex fxaaConsole360TexExpBiasNegTwo,
  1816. FxaaFloat2 fxaaQualityRcpFrame,
  1817. FxaaFloat4 fxaaConsoleRcpFrameOpt,
  1818. FxaaFloat4 fxaaConsoleRcpFrameOpt2,
  1819. FxaaFloat4 fxaaConsole360RcpFrameOpt2,
  1820. FxaaFloat fxaaQualitySubpix,
  1821. FxaaFloat fxaaQualityEdgeThreshold,
  1822. FxaaFloat fxaaQualityEdgeThresholdMin,
  1823. FxaaFloat fxaaConsoleEdgeSharpness,
  1824. FxaaFloat fxaaConsoleEdgeThreshold,
  1825. FxaaFloat fxaaConsoleEdgeThresholdMin,
  1826. FxaaFloat4 fxaaConsole360ConstDir
  1827. ) {
  1828. /*--------------------------------------------------------------------------*/
  1829. // (1)
  1830. half4 dir;
  1831. half4 lumaNe = h4tex2Dlod(tex, half4(fxaaConsolePosPos.zy, 0, 0));
  1832. #if (FXAA_GREEN_AS_LUMA == 0)
  1833. lumaNe.w += half(1.0/512.0);
  1834. dir.x = -lumaNe.w;
  1835. dir.z = -lumaNe.w;
  1836. #else
  1837. lumaNe.y += half(1.0/512.0);
  1838. dir.x = -lumaNe.y;
  1839. dir.z = -lumaNe.y;
  1840. #endif
  1841. /*--------------------------------------------------------------------------*/
  1842. // (2)
  1843. half4 lumaSw = h4tex2Dlod(tex, half4(fxaaConsolePosPos.xw, 0, 0));
  1844. #if (FXAA_GREEN_AS_LUMA == 0)
  1845. dir.x += lumaSw.w;
  1846. dir.z += lumaSw.w;
  1847. #else
  1848. dir.x += lumaSw.y;
  1849. dir.z += lumaSw.y;
  1850. #endif
  1851. /*--------------------------------------------------------------------------*/
  1852. // (3)
  1853. half4 lumaNw = h4tex2Dlod(tex, half4(fxaaConsolePosPos.xy, 0, 0));
  1854. #if (FXAA_GREEN_AS_LUMA == 0)
  1855. dir.x -= lumaNw.w;
  1856. dir.z += lumaNw.w;
  1857. #else
  1858. dir.x -= lumaNw.y;
  1859. dir.z += lumaNw.y;
  1860. #endif
  1861. /*--------------------------------------------------------------------------*/
  1862. // (4)
  1863. half4 lumaSe = h4tex2Dlod(tex, half4(fxaaConsolePosPos.zw, 0, 0));
  1864. #if (FXAA_GREEN_AS_LUMA == 0)
  1865. dir.x += lumaSe.w;
  1866. dir.z -= lumaSe.w;
  1867. #else
  1868. dir.x += lumaSe.y;
  1869. dir.z -= lumaSe.y;
  1870. #endif
  1871. /*--------------------------------------------------------------------------*/
  1872. // (5)
  1873. half4 dir1_pos;
  1874. dir1_pos.xy = normalize(dir.xyz).xz;
  1875. half dirAbsMinTimesC = min(abs(dir1_pos.x), abs(dir1_pos.y)) * half(FXAA_CONSOLE_PS3_EDGE_SHARPNESS);
  1876. /*--------------------------------------------------------------------------*/
  1877. // (6)
  1878. half4 dir2_pos;
  1879. dir2_pos.xy = clamp(dir1_pos.xy / dirAbsMinTimesC, half(-2.0), half(2.0));
  1880. dir1_pos.zw = pos.xy;
  1881. dir2_pos.zw = pos.xy;
  1882. half4 temp1N;
  1883. temp1N.xy = dir1_pos.zw - dir1_pos.xy * fxaaConsoleRcpFrameOpt.zw;
  1884. /*--------------------------------------------------------------------------*/
  1885. // (7)
  1886. temp1N = h4tex2Dlod(tex, half4(temp1N.xy, 0.0, 0.0));
  1887. half4 rgby1;
  1888. rgby1.xy = dir1_pos.zw + dir1_pos.xy * fxaaConsoleRcpFrameOpt.zw;
  1889. /*--------------------------------------------------------------------------*/
  1890. // (8)
  1891. rgby1 = h4tex2Dlod(tex, half4(rgby1.xy, 0.0, 0.0));
  1892. rgby1 = (temp1N + rgby1) * 0.5;
  1893. /*--------------------------------------------------------------------------*/
  1894. // (9)
  1895. half4 temp2N;
  1896. temp2N.xy = dir2_pos.zw - dir2_pos.xy * fxaaConsoleRcpFrameOpt2.zw;
  1897. temp2N = h4tex2Dlod(tex, half4(temp2N.xy, 0.0, 0.0));
  1898. /*--------------------------------------------------------------------------*/
  1899. // (10)
  1900. half4 rgby2;
  1901. rgby2.xy = dir2_pos.zw + dir2_pos.xy * fxaaConsoleRcpFrameOpt2.zw;
  1902. rgby2 = h4tex2Dlod(tex, half4(rgby2.xy, 0.0, 0.0));
  1903. rgby2 = (temp2N + rgby2) * 0.5;
  1904. /*--------------------------------------------------------------------------*/
  1905. // (11)
  1906. // compilier moves these scalar ops up to other cycles
  1907. #if (FXAA_GREEN_AS_LUMA == 0)
  1908. half lumaMin = min(min(lumaNw.w, lumaSw.w), min(lumaNe.w, lumaSe.w));
  1909. half lumaMax = max(max(lumaNw.w, lumaSw.w), max(lumaNe.w, lumaSe.w));
  1910. #else
  1911. half lumaMin = min(min(lumaNw.y, lumaSw.y), min(lumaNe.y, lumaSe.y));
  1912. half lumaMax = max(max(lumaNw.y, lumaSw.y), max(lumaNe.y, lumaSe.y));
  1913. #endif
  1914. rgby2 = (rgby2 + rgby1) * 0.5;
  1915. /*--------------------------------------------------------------------------*/
  1916. // (12)
  1917. #if (FXAA_GREEN_AS_LUMA == 0)
  1918. bool twoTapLt = rgby2.w < lumaMin;
  1919. bool twoTapGt = rgby2.w > lumaMax;
  1920. #else
  1921. bool twoTapLt = rgby2.y < lumaMin;
  1922. bool twoTapGt = rgby2.y > lumaMax;
  1923. #endif
  1924. /*--------------------------------------------------------------------------*/
  1925. // (13)
  1926. if(twoTapLt || twoTapGt) rgby2 = rgby1;
  1927. /*--------------------------------------------------------------------------*/
  1928. return rgby2; }
  1929. /*==========================================================================*/
  1930. #endif
  1931.  
  1932.  
  1933.  
  1934. /*============================================================================
  1935.  
  1936. FXAA3 CONSOLE - OPTIMIZED PS3 PIXEL SHADER (WITH EARLY EXIT)
  1937.  
  1938. ==============================================================================
  1939. The code mostly matches the assembly.
  1940. I have a feeling that 14 cycles is possible, but was not able to get there.
  1941. Might have to increase register count to get full performance.
  1942. Note this shader does not use perspective interpolation.
  1943.  
  1944. Use the following cgc options,
  1945.  
  1946. --fenable-bx2 --fastmath --fastprecision --nofloatbindings
  1947.  
  1948. Use of FXAA_GREEN_AS_LUMA currently adds a cycle (16 clks).
  1949. Will look at fixing this for FXAA 3.12.
  1950. ------------------------------------------------------------------------------
  1951. NVSHADERPERF OUTPUT
  1952. ------------------------------------------------------------------------------
  1953. For reference and to aid in debug, output of NVShaderPerf should match this,
  1954.  
  1955. Shader to schedule:
  1956. 0: texpkb h0.w(TRUE), v5.zyxx, #0
  1957. 2: addh h2.y(TRUE), h0.w, constant(0.001953, 0.000000, 0.000000, 0.000000).x
  1958. 4: texpkb h1.w(TRUE), v5.xwxx, #0
  1959. 6: addh h0.x(TRUE), h1.w, -h2.y
  1960. 7: texpkb h2.w(TRUE), v5.zwzz, #0
  1961. 9: minh h4.w(TRUE), h2.y, h2
  1962. 10: maxh h5.x(TRUE), h2.y, h2.w
  1963. 11: texpkb h0.w(TRUE), v5, #0
  1964. 13: addh h3.w(TRUE), -h0, h0.x
  1965. 14: addh h0.x(TRUE), h0.w, h0
  1966. 15: addh h0.z(TRUE), -h2.w, h0.x
  1967. 16: addh h0.x(TRUE), h2.w, h3.w
  1968. 17: minh h5.y(TRUE), h0.w, h1.w
  1969. 18: nrmh h2.xz(TRUE), h0_n
  1970. 19: minh_m8 h2.w(TRUE), |h2.x|, |h2.z|
  1971. 20: divx h4.xy(TRUE), h2_n.xzzw, h2_n.w
  1972. 21: movr r1.zw(TRUE), v4.xxxy
  1973. 22: maxh h2.w(TRUE), h0, h1
  1974. 23: fenct TRUE
  1975. 24: madr r0.xy(TRUE), -h2.xzzw, constant(cConst5.x, cConst5.y, cConst5.z, cConst5.w).zwzz, r1.zwzz
  1976. 26: texpkb h0(TRUE), r0, #0
  1977. 28: maxh h5.x(TRUE), h2.w, h5
  1978. 29: minh h5.w(TRUE), h5.y, h4
  1979. 30: madr r1.xy(TRUE), h2.xzzw, constant(cConst5.x, cConst5.y, cConst5.z, cConst5.w).zwzz, r1.zwzz
  1980. 32: texpkb h2(TRUE), r1, #0
  1981. 34: addh_d2 h2(TRUE), h0, h2
  1982. 35: texpkb h1(TRUE), v4, #0
  1983. 37: maxh h5.y(TRUE), h5.x, h1.w
  1984. 38: minh h4.w(TRUE), h1, h5
  1985. 39: madr r0.xy(TRUE), -h4, constant(cConst5.x, cConst5.y, cConst5.z, cConst5.w).xyxx, r1.zwzz
  1986. 41: texpkb h0(TRUE), r0, #0
  1987. 43: addh_m8 h5.z(TRUE), h5.y, -h4.w
  1988. 44: madr r2.xy(TRUE), h4, constant(cConst5.x, cConst5.y, cConst5.z, cConst5.w).xyxx, r1.zwzz
  1989. 46: texpkb h3(TRUE), r2, #0
  1990. 48: addh_d2 h0(TRUE), h0, h3
  1991. 49: addh_d2 h3(TRUE), h0, h2
  1992. 50: movh h0(TRUE), h3
  1993. 51: slth h3.x(TRUE), h3.w, h5.w
  1994. 52: sgth h3.w(TRUE), h3, h5.x
  1995. 53: addx.c0 rc(TRUE), h3.x, h3
  1996. 54: slth.c0 rc(TRUE), h5.z, h5
  1997. 55: movh h0(c0.NE.w), h2
  1998. 56: movh h0(c0.NE.x), h1
  1999.  
  2000. IPU0 ------ Simplified schedule: --------
  2001. Pass | Unit | uOp | PC: Op
  2002. -----+--------+------+-------------------------
  2003. 1 | SCT0/1 | mov | 0: TXLr h0.w, g[TEX1].zyxx, const.xxxx, TEX0;
  2004. | TEX | txl | 0: TXLr h0.w, g[TEX1].zyxx, const.xxxx, TEX0;
  2005. | SCB0 | add | 2: ADDh h2.y, h0.-w--, const.-x--;
  2006. | | |
  2007. 2 | SCT0/1 | mov | 4: TXLr h1.w, g[TEX1].xwxx, const.xxxx, TEX0;
  2008. | TEX | txl | 4: TXLr h1.w, g[TEX1].xwxx, const.xxxx, TEX0;
  2009. | SCB0 | add | 6: ADDh h0.x, h1.w---,-h2.y---;
  2010. | | |
  2011. 3 | SCT0/1 | mov | 7: TXLr h2.w, g[TEX1].zwzz, const.xxxx, TEX0;
  2012. | TEX | txl | 7: TXLr h2.w, g[TEX1].zwzz, const.xxxx, TEX0;
  2013. | SCB0 | max | 10: MAXh h5.x, h2.y---, h2.w---;
  2014. | SCB1 | min | 9: MINh h4.w, h2.---y, h2;
  2015. | | |
  2016. 4 | SCT0/1 | mov | 11: TXLr h0.w, g[TEX1], const.xxxx, TEX0;
  2017. | TEX | txl | 11: TXLr h0.w, g[TEX1], const.xxxx, TEX0;
  2018. | SCB0 | add | 14: ADDh h0.x, h0.w---, h0;
  2019. | SCB1 | add | 13: ADDh h3.w,-h0, h0.---x;
  2020. | | |
  2021. 5 | SCT0 | mad | 16: ADDh h0.x, h2.w---, h3.w---;
  2022. | SCT1 | mad | 15: ADDh h0.z,-h2.--w-, h0.--x-;
  2023. | SCB0 | min | 17: MINh h5.y, h0.-w--, h1.-w--;
  2024. | | |
  2025. 6 | SCT1 | mov | 18: NRMh h2.xz, h0;
  2026. | SRB | nrm | 18: NRMh h2.xz, h0;
  2027. | SCB1 | min | 19: MINh*8 h2.w, |h2.---x|, |h2.---z|;
  2028. | | |
  2029. 7 | SCT0 | div | 20: DIVx h4.xy, h2.xz--, h2.ww--;
  2030. | SCT1 | mov | 21: MOVr r1.zw, g[TEX0].--xy;
  2031. | SCB1 | max | 22: MAXh h2.w, h0, h1;
  2032. | | |
  2033. 8 | SCT0 | mad | 24: MADr r0.xy,-h2.xz--, const.zw--, r1.zw--;
  2034. | SCT1 | mov | 26: TXLr h0, r0, const.xxxx, TEX0;
  2035. | TEX | txl | 26: TXLr h0, r0, const.xxxx, TEX0;
  2036. | SCB0 | max | 28: MAXh h5.x, h2.w---, h5;
  2037. | SCB1 | min | 29: MINh h5.w, h5.---y, h4;
  2038. | | |
  2039. 9 | SCT0 | mad | 30: MADr r1.xy, h2.xz--, const.zw--, r1.zw--;
  2040. | SCT1 | mov | 32: TXLr h2, r1, const.xxxx, TEX0;
  2041. | TEX | txl | 32: TXLr h2, r1, const.xxxx, TEX0;
  2042. | SCB0/1 | add | 34: ADDh/2 h2, h0, h2;
  2043. | | |
  2044. 10 | SCT0/1 | mov | 35: TXLr h1, g[TEX0], const.xxxx, TEX0;
  2045. | TEX | txl | 35: TXLr h1, g[TEX0], const.xxxx, TEX0;
  2046. | SCB0 | max | 37: MAXh h5.y, h5.-x--, h1.-w--;
  2047. | SCB1 | min | 38: MINh h4.w, h1, h5;
  2048. | | |
  2049. 11 | SCT0 | mad | 39: MADr r0.xy,-h4, const.xy--, r1.zw--;
  2050. | SCT1 | mov | 41: TXLr h0, r0, const.zzzz, TEX0;
  2051. | TEX | txl | 41: TXLr h0, r0, const.zzzz, TEX0;
  2052. | SCB0 | mad | 44: MADr r2.xy, h4, const.xy--, r1.zw--;
  2053. | SCB1 | add | 43: ADDh*8 h5.z, h5.--y-,-h4.--w-;
  2054. | | |
  2055. 12 | SCT0/1 | mov | 46: TXLr h3, r2, const.xxxx, TEX0;
  2056. | TEX | txl | 46: TXLr h3, r2, const.xxxx, TEX0;
  2057. | SCB0/1 | add | 48: ADDh/2 h0, h0, h3;
  2058. | | |
  2059. 13 | SCT0/1 | mad | 49: ADDh/2 h3, h0, h2;
  2060. | SCB0/1 | mul | 50: MOVh h0, h3;
  2061. | | |
  2062. 14 | SCT0 | set | 51: SLTh h3.x, h3.w---, h5.w---;
  2063. | SCT1 | set | 52: SGTh h3.w, h3, h5.---x;
  2064. | SCB0 | set | 54: SLThc0 rc, h5.z---, h5;
  2065. | SCB1 | add | 53: ADDxc0_s rc, h3.---x, h3;
  2066. | | |
  2067. 15 | SCT0/1 | mul | 55: MOVh h0(NE0.wwww), h2;
  2068. | SCB0/1 | mul | 56: MOVh h0(NE0.xxxx), h1;
  2069.  
  2070. Pass SCT TEX SCB
  2071. 1: 0% 100% 25%
  2072. 2: 0% 100% 25%
  2073. 3: 0% 100% 50%
  2074. 4: 0% 100% 50%
  2075. 5: 50% 0% 25%
  2076. 6: 0% 0% 25%
  2077. 7: 100% 0% 25%
  2078. 8: 0% 100% 50%
  2079. 9: 0% 100% 100%
  2080. 10: 0% 100% 50%
  2081. 11: 0% 100% 75%
  2082. 12: 0% 100% 100%
  2083. 13: 100% 0% 100%
  2084. 14: 50% 0% 50%
  2085. 15: 100% 0% 100%
  2086.  
  2087. MEAN: 26% 60% 56%
  2088.  
  2089. Pass SCT0 SCT1 TEX SCB0 SCB1
  2090. 1: 0% 0% 100% 100% 0%
  2091. 2: 0% 0% 100% 100% 0%
  2092. 3: 0% 0% 100% 100% 100%
  2093. 4: 0% 0% 100% 100% 100%
  2094. 5: 100% 100% 0% 100% 0%
  2095. 6: 0% 0% 0% 0% 100%
  2096. 7: 100% 100% 0% 0% 100%
  2097. 8: 0% 0% 100% 100% 100%
  2098. 9: 0% 0% 100% 100% 100%
  2099. 10: 0% 0% 100% 100% 100%
  2100. 11: 0% 0% 100% 100% 100%
  2101. 12: 0% 0% 100% 100% 100%
  2102. 13: 100% 100% 0% 100% 100%
  2103. 14: 100% 100% 0% 100% 100%
  2104. 15: 100% 100% 0% 100% 100%
  2105.  
  2106. MEAN: 33% 33% 60% 86% 80%
  2107. Fragment Performance Setup: Driver RSX Compiler, GPU RSX, Flags 0x5
  2108. Results 15 cycles, 3 r regs, 800,000,000 pixels/s
  2109. ============================================================================*/
  2110. #if (FXAA_PS3 == 1) && (FXAA_EARLY_EXIT == 1)
  2111. /*--------------------------------------------------------------------------*/
  2112. #pragma regcount 7
  2113. #pragma disablepc all
  2114. #pragma option O2
  2115. #pragma option OutColorPrec=fp16
  2116. #pragma texformat default RGBA8
  2117. /*==========================================================================*/
  2118. half4 FxaaPixelShader(
  2119. // See FXAA Quality FxaaPixelShader() source for docs on Inputs!
  2120. FxaaFloat2 pos,
  2121. FxaaFloat4 fxaaConsolePosPos,
  2122. FxaaTex tex,
  2123. FxaaTex fxaaConsole360TexExpBiasNegOne,
  2124. FxaaTex fxaaConsole360TexExpBiasNegTwo,
  2125. FxaaFloat2 fxaaQualityRcpFrame,
  2126. FxaaFloat4 fxaaConsoleRcpFrameOpt,
  2127. FxaaFloat4 fxaaConsoleRcpFrameOpt2,
  2128. FxaaFloat4 fxaaConsole360RcpFrameOpt2,
  2129. FxaaFloat fxaaQualitySubpix,
  2130. FxaaFloat fxaaQualityEdgeThreshold,
  2131. FxaaFloat fxaaQualityEdgeThresholdMin,
  2132. FxaaFloat fxaaConsoleEdgeSharpness,
  2133. FxaaFloat fxaaConsoleEdgeThreshold,
  2134. FxaaFloat fxaaConsoleEdgeThresholdMin,
  2135. FxaaFloat4 fxaaConsole360ConstDir
  2136. ) {
  2137. /*--------------------------------------------------------------------------*/
  2138. // (1)
  2139. half4 rgbyNe = h4tex2Dlod(tex, half4(fxaaConsolePosPos.zy, 0, 0));
  2140. #if (FXAA_GREEN_AS_LUMA == 0)
  2141. half lumaNe = rgbyNe.w + half(1.0/512.0);
  2142. #else
  2143. half lumaNe = rgbyNe.y + half(1.0/512.0);
  2144. #endif
  2145. /*--------------------------------------------------------------------------*/
  2146. // (2)
  2147. half4 lumaSw = h4tex2Dlod(tex, half4(fxaaConsolePosPos.xw, 0, 0));
  2148. #if (FXAA_GREEN_AS_LUMA == 0)
  2149. half lumaSwNegNe = lumaSw.w - lumaNe;
  2150. #else
  2151. half lumaSwNegNe = lumaSw.y - lumaNe;
  2152. #endif
  2153. /*--------------------------------------------------------------------------*/
  2154. // (3)
  2155. half4 lumaNw = h4tex2Dlod(tex, half4(fxaaConsolePosPos.xy, 0, 0));
  2156. #if (FXAA_GREEN_AS_LUMA == 0)
  2157. half lumaMaxNwSw = max(lumaNw.w, lumaSw.w);
  2158. half lumaMinNwSw = min(lumaNw.w, lumaSw.w);
  2159. #else
  2160. half lumaMaxNwSw = max(lumaNw.y, lumaSw.y);
  2161. half lumaMinNwSw = min(lumaNw.y, lumaSw.y);
  2162. #endif
  2163. /*--------------------------------------------------------------------------*/
  2164. // (4)
  2165. half4 lumaSe = h4tex2Dlod(tex, half4(fxaaConsolePosPos.zw, 0, 0));
  2166. #if (FXAA_GREEN_AS_LUMA == 0)
  2167. half dirZ = lumaNw.w + lumaSwNegNe;
  2168. half dirX = -lumaNw.w + lumaSwNegNe;
  2169. #else
  2170. half dirZ = lumaNw.y + lumaSwNegNe;
  2171. half dirX = -lumaNw.y + lumaSwNegNe;
  2172. #endif
  2173. /*--------------------------------------------------------------------------*/
  2174. // (5)
  2175. half3 dir;
  2176. dir.y = 0.0;
  2177. #if (FXAA_GREEN_AS_LUMA == 0)
  2178. dir.x = lumaSe.w + dirX;
  2179. dir.z = -lumaSe.w + dirZ;
  2180. half lumaMinNeSe = min(lumaNe, lumaSe.w);
  2181. #else
  2182. dir.x = lumaSe.y + dirX;
  2183. dir.z = -lumaSe.y + dirZ;
  2184. half lumaMinNeSe = min(lumaNe, lumaSe.y);
  2185. #endif
  2186. /*--------------------------------------------------------------------------*/
  2187. // (6)
  2188. half4 dir1_pos;
  2189. dir1_pos.xy = normalize(dir).xz;
  2190. half dirAbsMinTimes8 = min(abs(dir1_pos.x), abs(dir1_pos.y)) * half(FXAA_CONSOLE_PS3_EDGE_SHARPNESS);
  2191. /*--------------------------------------------------------------------------*/
  2192. // (7)
  2193. half4 dir2_pos;
  2194. dir2_pos.xy = clamp(dir1_pos.xy / dirAbsMinTimes8, half(-2.0), half(2.0));
  2195. dir1_pos.zw = pos.xy;
  2196. dir2_pos.zw = pos.xy;
  2197. #if (FXAA_GREEN_AS_LUMA == 0)
  2198. half lumaMaxNeSe = max(lumaNe, lumaSe.w);
  2199. #else
  2200. half lumaMaxNeSe = max(lumaNe, lumaSe.y);
  2201. #endif
  2202. /*--------------------------------------------------------------------------*/
  2203. // (8)
  2204. half4 temp1N;
  2205. temp1N.xy = dir1_pos.zw - dir1_pos.xy * fxaaConsoleRcpFrameOpt.zw;
  2206. temp1N = h4tex2Dlod(tex, half4(temp1N.xy, 0.0, 0.0));
  2207. half lumaMax = max(lumaMaxNwSw, lumaMaxNeSe);
  2208. half lumaMin = min(lumaMinNwSw, lumaMinNeSe);
  2209. /*--------------------------------------------------------------------------*/
  2210. // (9)
  2211. half4 rgby1;
  2212. rgby1.xy = dir1_pos.zw + dir1_pos.xy * fxaaConsoleRcpFrameOpt.zw;
  2213. rgby1 = h4tex2Dlod(tex, half4(rgby1.xy, 0.0, 0.0));
  2214. rgby1 = (temp1N + rgby1) * 0.5;
  2215. /*--------------------------------------------------------------------------*/
  2216. // (10)
  2217. half4 rgbyM = h4tex2Dlod(tex, half4(pos.xy, 0.0, 0.0));
  2218. #if (FXAA_GREEN_AS_LUMA == 0)
  2219. half lumaMaxM = max(lumaMax, rgbyM.w);
  2220. half lumaMinM = min(lumaMin, rgbyM.w);
  2221. #else
  2222. half lumaMaxM = max(lumaMax, rgbyM.y);
  2223. half lumaMinM = min(lumaMin, rgbyM.y);
  2224. #endif
  2225. /*--------------------------------------------------------------------------*/
  2226. // (11)
  2227. half4 temp2N;
  2228. temp2N.xy = dir2_pos.zw - dir2_pos.xy * fxaaConsoleRcpFrameOpt2.zw;
  2229. temp2N = h4tex2Dlod(tex, half4(temp2N.xy, 0.0, 0.0));
  2230. half4 rgby2;
  2231. rgby2.xy = dir2_pos.zw + dir2_pos.xy * fxaaConsoleRcpFrameOpt2.zw;
  2232. half lumaRangeM = (lumaMaxM - lumaMinM) / FXAA_CONSOLE_PS3_EDGE_THRESHOLD;
  2233. /*--------------------------------------------------------------------------*/
  2234. // (12)
  2235. rgby2 = h4tex2Dlod(tex, half4(rgby2.xy, 0.0, 0.0));
  2236. rgby2 = (temp2N + rgby2) * 0.5;
  2237. /*--------------------------------------------------------------------------*/
  2238. // (13)
  2239. rgby2 = (rgby2 + rgby1) * 0.5;
  2240. /*--------------------------------------------------------------------------*/
  2241. // (14)
  2242. #if (FXAA_GREEN_AS_LUMA == 0)
  2243. bool twoTapLt = rgby2.w < lumaMin;
  2244. bool twoTapGt = rgby2.w > lumaMax;
  2245. #else
  2246. bool twoTapLt = rgby2.y < lumaMin;
  2247. bool twoTapGt = rgby2.y > lumaMax;
  2248. #endif
  2249. bool earlyExit = lumaRangeM < lumaMax;
  2250. bool twoTap = twoTapLt || twoTapGt;
  2251. /*--------------------------------------------------------------------------*/
  2252. // (15)
  2253. if(twoTap) rgby2 = rgby1;
  2254. if(earlyExit) rgby2 = rgbyM;
  2255. /*--------------------------------------------------------------------------*/
  2256. return rgby2; }
  2257. /*==========================================================================*/
  2258. #endif
  2259. /*
  2260. ===========================================================================
  2261.  
  2262. Daemon GPL Source Code
  2263. Copyright (C) 2013 the Unvanquished developpers
  2264.  
  2265. This file is part of the Daemon GPL Source Code (Daemon Source Code).
  2266.  
  2267. Daemon Source Code is free software: you can redistribute it and/or modify
  2268. it under the terms of the GNU General Public License as published by
  2269. the Free Software Foundation, either version 3 of the License, or
  2270. (at your option) any later version.
  2271.  
  2272. Daemon Source Code is distributed in the hope that it will be useful,
  2273. but WITHOUT ANY WARRANTY; without even the implied warranty of
  2274. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2275. GNU General Public License for more details.
  2276.  
  2277. You should have received a copy of the GNU General Public License
  2278. along with Daemon Source Code. If not, see <http://www.gnu.org/licenses/>.
  2279.  
  2280. ===========================================================================
  2281. */
  2282.  
  2283. /* fxaa_fp.glsl */
  2284.  
  2285. // The FXAA parameters are put directly in fxaa3_11_fp.glsl
  2286. // because we cannot #include in the middle of a shader
  2287.  
  2288. uniform sampler2D u_ColorMap;
  2289.  
  2290. void main()
  2291. {
  2292. gl_FragColor = FxaaPixelShader(
  2293. gl_FragCoord.xy * r_FBufScale, //pos
  2294. vec4(0.0), //not used
  2295. u_ColorMap, //tex
  2296. u_ColorMap, //not used
  2297. u_ColorMap, //not used
  2298. r_FBufScale, //fxaaQualityRcpFrame
  2299. vec4(0.0), //not used
  2300. vec4(0.0), //not used
  2301. vec4(0.0), //not used
  2302. 0.75, //fxaaQualitySubpix
  2303. 0.166, //fxaaQualityEdgeThreshold
  2304. 0.0625, //fxaaQualityEdgeThresholdMin
  2305. 0.0, //not used
  2306. 0.0, //not used
  2307. 0.0, //not used
  2308. vec4(0.0) //not used
  2309. );
  2310. }
  2311.  
  2312. compile log:
  2313. 0:0(0): error: no matching function for call to `texture2DLod(sampler2D, vec2, float)'
  2314. 0:0(0): error: no matching function for call to `texture2DLod(sampler2D, vec2, float)'
  2315. 0:0(0): error: no matching function for call to `FxaaLuma()'
  2316. 0:0(0): error: candidates are: float FxaaLuma(vec4)
  2317. 0:0(0): error: no matching function for call to `texture2DLod(sampler2D, vec2, float)'
  2318. 0:0(0): error: no matching function for call to `FxaaLuma()'
  2319. 0:0(0): error: candidates are: float FxaaLuma(vec4)
  2320. 0:0(0): error: no matching function for call to `texture2DLod(sampler2D, vec2, float)'
  2321. 0:0(0): error: no matching function for call to `FxaaLuma()'
  2322. 0:0(0): error: candidates are: float FxaaLuma(vec4)
  2323. 0:0(0): error: no matching function for call to `texture2DLod(sampler2D, vec2, float)'
  2324. 0:0(0): error: no matching function for call to `FxaaLuma()'
  2325. 0:0(0): error: candidates are: float FxaaLuma(vec4)
  2326. 0:0(0): error: no matching function for call to `texture2DLod(sampler2D, vec2, float)'
  2327. 0:0(0): error: no matching function for call to `FxaaLuma()'
  2328. 0:0(0): error: candidates are: float FxaaLuma(vec4)
  2329. 0:0(0): error: no matching function for call to `texture2DLod(sampler2D, vec2, float)'
  2330. 0:0(0): error: no matching function for call to `FxaaLuma()'
  2331. 0:0(0): error: candidates are: float FxaaLuma(vec4)
  2332. 0:0(0): error: no matching function for call to `texture2DLod(sampler2D, vec2, float)'
  2333. 0:0(0): error: no matching function for call to `FxaaLuma()'
  2334. 0:0(0): error: candidates are: float FxaaLuma(vec4)
  2335. 0:0(0): error: no matching function for call to `texture2DLod(sampler2D, vec2, float)'
  2336. 0:0(0): error: no matching function for call to `FxaaLuma()'
  2337. 0:0(0): error: candidates are: float FxaaLuma(vec4)
  2338. 0:0(0): error: no matching function for call to `texture2DLod(sampler2D, vec2, float)'
  2339. 0:0(0): error: no matching function for call to `FxaaLuma()'
  2340. 0:0(0): error: candidates are: float FxaaLuma(vec4)
  2341. 0:0(0): error: no matching function for call to `texture2DLod(sampler2D, vec2, float)'
  2342. 0:0(0): error: no matching function for call to `FxaaLuma()'
  2343. 0:0(0): error: candidates are: float FxaaLuma(vec4)
  2344. 0:0(0): error: no matching function for call to `texture2DLod(sampler2D, vec2, float)'
  2345. 0:0(0): error: no matching function for call to `FxaaLuma()'
  2346. 0:0(0): error: candidates are: float FxaaLuma(vec4)
  2347. 0:0(0): error: no matching function for call to `texture2DLod(sampler2D, vec2, float)'
  2348. 0:0(0): error: no matching function for call to `FxaaLuma()'
  2349. 0:0(0): error: candidates are: float FxaaLuma(vec4)
  2350. 0:0(0): error: no matching function for call to `texture2DLod(sampler2D, vec2, float)'
  2351. 0:0(0): error: no matching function for call to `FxaaLuma()'
  2352. 0:0(0): error: candidates are: float FxaaLuma(vec4)
  2353. 0:0(0): error: no matching function for call to `texture2DLod(sampler2D, vec2, float)'
  2354. 0:0(0): error: no matching function for call to `FxaaLuma()'
  2355. 0:0(0): error: candidates are: float FxaaLuma(vec4)
  2356. 0:0(0): error: no matching function for call to `texture2DLod(sampler2D, vec2, float)'
  2357. 0:0(0): error: no matching function for call to `FxaaLuma()'
  2358. 0:0(0): error: candidates are: float FxaaLuma(vec4)
  2359. 0:0(0): error: no matching function for call to `texture2DLod(sampler2D, vec2, float)'
  2360. 0:0(0): error: no matching function for call to `FxaaLuma()'
  2361. 0:0(0): error: candidates are: float FxaaLuma(vec4)
  2362. 0:0(0): error: no matching function for call to `texture2DLod(sampler2D, vec2, float)'
  2363. 0:1343(45): error: type mismatch
  2364. 0:1343(8): error: cannot construct `vec4' from a non-numeric data type
  2365. 0:1343(55): error: `return' with wrong type , in function `FxaaPixelShader' returning vec4
  2366.  
  2367. ^8Couldn't compile fragment shader fxaa
  2368.  
  2369. GL_VENDOR: X.Org
  2370. GL_RENDERER: Gallium 0.4 on AMD SUMO
  2371. GL_VERSION: 2.1 Mesa 8.0.5
  2372. GL_SHADING_LANGUAGE_VERSION: 1.20
  2373. GL_MAX_VERTEX_UNIFORM_COMPONENTS 16384
  2374. ------ Initializing Sound ------
  2375. Allocated 96 sources.
  2376. OpenAL default capture device is 'Built-in Audio Analog Stereo'
  2377. OpenAL capture device opened.
  2378. OpenAL info:
  2379. Vendor: OpenAL Community
  2380. Version: 1.1 ALSOFT 1.14
  2381. Renderer: OpenAL Soft
  2382. AL Extensions: AL_EXT_ALAW AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_LOKI_quadriphonic AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data AL_SOFTX_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points
  2383. ALC Extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFT_loopback
  2384. Device: Built-in Audio Analog Stereo
  2385. Available Devices:
  2386. Built-in Audio Analog Stereo
  2387. Built-in Audio Digital Stereo (HDMI)
  2388. Input Device: Built-in Audio Analog Stereo
  2389. Available Input Devices:
  2390. Built-in Audio Analog Stereo
  2391. Monitor of Built-in Audio Digital Stereo (HDMI)
  2392. Monitor of Built-in Audio Analog Stereo
  2393. Sound initialization successful.
  2394. --------------------------------
  2395. Error during initialization
  2396. OpenAL capture device closed.
  2397. Error during initialization
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement