setViewport.lua 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. return {
  2. tag = 'camera',
  3. summary = 'Set the viewport.',
  4. description = [[
  5. Sets the viewport. Everything rendered will get mapped to the rectangle defined by the
  6. viewport. More specifically, this defines the transformation from normalized device coordinates
  7. to pixel coordinates.
  8. ]],
  9. arguments = {
  10. x = {
  11. type = 'number',
  12. description = 'The x coordinate of the upper-left corner of the viewport.',
  13. },
  14. y = {
  15. type = 'number',
  16. description = 'The y coordinate of the upper-left corner of the viewport.',
  17. },
  18. w = {
  19. type = 'number',
  20. description = 'The width of the viewport. Must be positive.',
  21. },
  22. h = {
  23. type = 'number',
  24. description = 'The height of the viewport. May be negative.',
  25. },
  26. dmin = {
  27. type = 'number',
  28. default = '0.0',
  29. description = 'The min component of the depth range, between 0 and 1.'
  30. },
  31. dmax = {
  32. type = 'number',
  33. default = '1.0',
  34. description = 'The max component of the depth range, between 0 and 1.'
  35. }
  36. },
  37. returns = {},
  38. variants = {
  39. {
  40. arguments = { 'x', 'y', 'w', 'h', 'dmin', 'dmax' },
  41. returns = {}
  42. },
  43. {
  44. description = 'Disable the viewport.',
  45. arguments = {},
  46. returns = {}
  47. }
  48. },
  49. notes = [[
  50. The viewport will apply to all draws in a Pass when the pass is submitted, even if this function
  51. is called after adding the draws.
  52. The viewport rectangle can use floating point numbers.
  53. A negative viewport height (with a y coordinate equal to the bottom of the viewport) can be used
  54. to flip the rendering vertically.
  55. The default viewport extends from `(0, 0)` to the dimensions of the target textures, with min
  56. depth and max depth respectively set to 0 and 1.
  57. ]],
  58. related = {
  59. 'Pass:getScissor',
  60. 'Pass:setScissor',
  61. 'Pass:getDimensions'
  62. }
  63. }