newPass.lua 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. return {
  2. tag = 'graphics-objects',
  3. summary = 'Create a new Pass.',
  4. description = [[
  5. Creates and returns a new Pass object. The canvas (the set of textures the Pass renders to) can
  6. be specified when creating the Pass, or later using `Pass:setCanvas`.
  7. ]],
  8. arguments = {
  9. ['...textures'] = {
  10. type = 'Texture',
  11. description = [[
  12. One or more textures the pass will render to. This can be changed later using
  13. `Pass:setCanvas`.
  14. ]]
  15. },
  16. canvas = {
  17. type = 'table',
  18. description = [[
  19. Render target configuration. Up to 4 textures can be provided in table keys 1 through 4, as
  20. well as the following keys:
  21. ]],
  22. table = {
  23. {
  24. name = 'depth',
  25. type = 'table',
  26. description = [[
  27. Depth/stencil buffer settings. In addition to a table, it can be a `Texture`, a
  28. `TextureFormat`, or `false` to disable the depth buffer.
  29. ]],
  30. table = {
  31. {
  32. name = 'format',
  33. type = 'TextureFormat',
  34. default = [['d32f']],
  35. description = [[
  36. The format of the depth buffer texture, which must be a depth format (the ones that
  37. start with `d`). LÖVR will create or reuse an internal depth buffer with this
  38. format.
  39. ]]
  40. },
  41. {
  42. name = 'texture',
  43. type = 'Texture',
  44. description = 'A Texture to use as the depth buffer. Takes precedence over `format`.'
  45. }
  46. }
  47. },
  48. {
  49. name = 'samples',
  50. type = 'number',
  51. default = '4',
  52. description = [[
  53. The number of multisamples to use. Can be 4 for antialiasing, or 1 to disable
  54. antialiasing.
  55. ]]
  56. }
  57. }
  58. }
  59. },
  60. returns = {
  61. pass = {
  62. type = 'Pass',
  63. description = 'The new Pass.'
  64. }
  65. },
  66. variants = {
  67. {
  68. description = 'Create a pass that renders to a set of textures.',
  69. arguments = { '...textures' },
  70. returns = { 'pass' }
  71. },
  72. {
  73. description = 'Create a pass, with extra canvas settings.',
  74. arguments = { 'canvas' },
  75. returns = { 'pass' }
  76. },
  77. {
  78. description = 'Create an empty Pass without a canvas.',
  79. arguments = {},
  80. returns = { 'pass' }
  81. }
  82. },
  83. notes = [[
  84. Fun facts about render passes:
  85. - Textures must have been created with the `render` `TextureUsage`.
  86. - Textures must have the same dimensions, layer counts, and sample counts.
  87. - When rendering to textures with multiple layers, each draw will be broadcast to all layers.
  88. Render passes have multiple "views" (cameras), and each layer uses a corresponding view,
  89. allowing each layer to be rendered from a different viewpoint. This enables fast stereo
  90. rendering, but can also be used to efficiently render to cubemaps. The `ViewIndex` variable
  91. can also be used in shaders to set up any desired per-view behavior.
  92. - Mipmaps will automatically be generated for textures at the end of the render pass.
  93. - It's okay to have zero color textures, but in this case there must be a depth texture.
  94. - It's possible to render to a specific mipmap level of a Texture, or a subset of its layers, by
  95. rendering to texture views, see `Texture:newView`.
  96. ]],
  97. related = {
  98. 'lovr.graphics.submit',
  99. 'lovr.graphics.getWindowPass',
  100. 'lovr.headset.getPass'
  101. }
  102. }