newShader.lua 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. return {
  2. tag = 'graphics-objects',
  3. summary = 'Create a new Shader.',
  4. description = [[
  5. Creates a Shader, which is a small program that runs on the GPU.
  6. Shader code is usually written in GLSL and compiled to SPIR-V bytecode. SPIR-V is faster to
  7. load but requires a build step. Either form can be used to create a shader.
  8. ]],
  9. arguments = {
  10. vertex = {
  11. type = 'string',
  12. description = [[
  13. A string, path to a file, or Blob containing GLSL or SPIR-V code for the vertex stage. Can
  14. also be a `DefaultShader` to use that shader's vertex code.
  15. ]]
  16. },
  17. fragment = {
  18. type = 'string',
  19. description = [[
  20. A string, path to a file, or Blob containing GLSL or SPIR-V code for the fragment stage.
  21. Can also be a `DefaultShader` to use that shader's fragment code.
  22. ]]
  23. },
  24. compute = {
  25. type = 'string',
  26. description = [[
  27. A string, path to a file, or Blob containing GLSL or SPIR-V code for the compute stage.
  28. ]]
  29. },
  30. default = {
  31. type = 'DefaultShader',
  32. description = 'The default shader to use.'
  33. },
  34. options = {
  35. type = 'table',
  36. description = 'Shader options.',
  37. table = {
  38. {
  39. name = 'flags',
  40. type = 'table',
  41. description = [[
  42. A table of shader flags. The keys of the table should be flag names or flag ID numbers.
  43. The values can be numbers or booleans, depending on the type of the flag as declared in
  44. the shader.
  45. ]]
  46. },
  47. {
  48. name = 'label',
  49. type = 'string',
  50. description = 'A label to use for the shader in debugging tools.'
  51. }
  52. }
  53. }
  54. },
  55. returns = {
  56. shader = {
  57. type = 'Shader',
  58. description = 'The new shader.'
  59. }
  60. },
  61. variants = {
  62. {
  63. description = [[
  64. Create a graphics shader. It has a vertex stage that computes vertex positions, and a
  65. fragment stage that computes pixel colors.
  66. ]],
  67. arguments = { 'vertex', 'fragment', 'options' },
  68. returns = { 'shader' }
  69. },
  70. {
  71. description = 'Create a compute shader.',
  72. arguments = { 'compute', 'options' },
  73. returns = { 'shader' }
  74. },
  75. {
  76. description = [[
  77. Create a copy of one of the default shaders (used to provide different flags).
  78. ]],
  79. arguments = { 'default', 'options' },
  80. returns = { 'shader' }
  81. }
  82. },
  83. related = {
  84. 'lovr.graphics.compileShader',
  85. 'ShaderType',
  86. 'ShaderStage'
  87. }
  88. }