setCanvas.lua 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. return {
  2. tag = 'canvas',
  3. summary = 'Set the Pass\'s canvas.',
  4. description = [[
  5. Sets the Pass's canvas. The canvas is a set of textures that the Pass will draw to when it's
  6. submitted, along with configuration for the depth buffer and antialiasing.
  7. ]],
  8. arguments = {
  9. ['...textures'] = {
  10. type = 'Texture',
  11. description = 'One or more color textures the pass will render to.'
  12. },
  13. canvas = {
  14. type = 'table',
  15. description = [[
  16. The canvas. Each numeric key is a color texture to render to (up to 4), along with the
  17. following keys to control depth buffer and antialiasing settings:
  18. ]],
  19. table = {
  20. {
  21. name = 'depth',
  22. type = '*',
  23. default = 'd32f',
  24. description = 'A `Texture` or `TextureFormat` with the depth buffer.'
  25. },
  26. {
  27. name = 'samples',
  28. type = 'number',
  29. default = '4',
  30. description = 'The number of multisamples used for antialiasing (either 1 or 4).'
  31. }
  32. }
  33. }
  34. },
  35. returns = {},
  36. variants = {
  37. {
  38. arguments = { '...textures' },
  39. returns = {}
  40. },
  41. {
  42. arguments = { 'canvas' },
  43. returns = {}
  44. },
  45. {
  46. description = [[
  47. Disable the canvas. Any draws in the Pass will be skipped when it is submitted (compute
  48. shaders will still run though).
  49. ]],
  50. arguments = {},
  51. returns = {}
  52. }
  53. },
  54. notes = [[
  55. Changing the canvas will reset the pass, as though `Pass:reset` was called.
  56. All textures must have the same dimensions, layer counts, and multisample counts. They also
  57. must have been created with the `render` usage flag.
  58. The number of layers in the textures determines how many views (cameras) the pass has. Each
  59. draw will be rendered to all texture layers, as seen from the corresponding camera. For
  60. example, VR rendering will use a canvas texture with 2 layers, one for each eye.
  61. To render to a specific mipmap level or layer of a texture, use texture views
  62. (`Texture:newView`).
  63. Mipmaps will be regenerated for all of canvas textures at the end of a render pass.
  64. If the Pass has multiple color textures, a fragment shader should be used to write a different
  65. color to each texture. Here's an example that writes red to the first texture and blue to the
  66. second texture:
  67. // Declare an output variable for the second texture
  68. layout(location = 1) out vec4 secondColor;
  69. vec4 lovrmain() {
  70. secondColor = vec4(0, 0, 1, 1);
  71. return vec4(1, 0, 0, 1);
  72. }
  73. ]],
  74. related = {
  75. 'Pass:getClear',
  76. 'Pass:setClear',
  77. 'Pass:getWidth',
  78. 'Pass:getHeight',
  79. 'Pass:getDimensions'
  80. }
  81. }