getMaterial.lua 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. return {
  2. summary = 'Get the material properties for a material in the model.',
  3. description = 'Returns a table with all of the properties of a material.',
  4. arguments = {
  5. index = {
  6. type = 'number',
  7. description = 'The index of a material.'
  8. },
  9. name = {
  10. type = 'string',
  11. description = 'The name of a material.'
  12. }
  13. },
  14. returns = {
  15. properties = {
  16. type = 'table',
  17. description = 'The material properties.',
  18. table = {
  19. {
  20. name = 'color',
  21. type = 'table',
  22. description = [[
  23. The color of the material. The table contains the `r`, `g`, `b`, and `a` components of the color,
  24. from 0 to 1.
  25. ]]
  26. },
  27. {
  28. name = 'glow',
  29. type = 'table',
  30. description = [[
  31. The glow color of the material (sometimes called emissive). The table contains the `r`,
  32. `g`, and `b` components of the color from 0 to 1, and a fourth number indicating the
  33. strength of the glow.
  34. ]]
  35. },
  36. {
  37. name = 'uvShift',
  38. type = 'table',
  39. description = 'A table with 2 numbers indicating an offset to apply to UVs.'
  40. },
  41. {
  42. name = 'uvScale',
  43. type = 'table',
  44. description = [[
  45. A table with 2 numbers indicating a scale to apply to UVs. By default, shaders apply
  46. the UV scale before the UV offset.
  47. ]]
  48. },
  49. {
  50. name = 'metalness',
  51. type = 'number',
  52. description = [[
  53. The metalness parameter of the material. This is typically 0 or 1. By default, shaders
  54. multiply this property with the value from the metalness texture (when present) to get
  55. the final metalness used for shading.
  56. ]]
  57. },
  58. {
  59. name = 'roughness',
  60. type = 'number',
  61. description = [[
  62. The roughness parameter of the material. By default, shaders multiply this property
  63. with the value from the roughness texture (when present) to get the final roughness used
  64. for shading.
  65. ]]
  66. },
  67. {
  68. name = 'clearcoat',
  69. type = 'number',
  70. description = 'The clearcoat parameter of the material.'
  71. },
  72. {
  73. name = 'clearcoatRoughness',
  74. type = 'number',
  75. description = 'The roughness of the clearcoat layer.'
  76. },
  77. {
  78. name = 'occlusionStrength',
  79. type = 'number',
  80. description = [[
  81. A number multiplied by the value from the ambient occlusion texture to control how
  82. strong the occlusion effect is.
  83. ]]
  84. },
  85. {
  86. name = 'normalScale',
  87. type = 'number',
  88. description = [[
  89. A number multiplied by the value from the normal texture to control how strong the
  90. normal mapping effect is.
  91. ]]
  92. },
  93. {
  94. name = 'alphaCutoff',
  95. type = 'number',
  96. description = [[
  97. If a pixel has an alpha value less than the alpha cutoff, it will be discarded, which
  98. prevents it from occluding things behind it. This is sometimes called "holepunch" or
  99. "cutout" alpha. It's useful for textures with transparency.
  100. ]]
  101. },
  102. {
  103. name = 'texture',
  104. type = 'number',
  105. description = 'The index of the Image used for the color texture.',
  106. },
  107. {
  108. name = 'glowTexture',
  109. type = 'number',
  110. description = 'The index of the Image used for the glow texture.',
  111. },
  112. {
  113. name = 'occlusionTexture',
  114. type = 'number',
  115. description = [[
  116. The index of the Image used for the ambient occlusion texture. The red channel of the
  117. texture is used for ambient occlusion, allowing multiple parameters to use the same
  118. texture.
  119. ]]
  120. },
  121. {
  122. name = 'metalnessTexture',
  123. type = 'number',
  124. description = [[
  125. The index of the Image used for the metalness texture. The blue channel of the texture
  126. is used for metalness, allowing multiple parameters to use the same texture.
  127. ]]
  128. },
  129. {
  130. name = 'roughnessTexture',
  131. type = 'number',
  132. description = [[
  133. The index of the Image to use for the roughness texture. The green channel of the
  134. texture is used for roughness, allowing multiple parameters to use the same texture.
  135. ]]
  136. },
  137. {
  138. name = 'clearcoatTexture',
  139. type = 'number',
  140. description = [[
  141. The index of the Image to use for the clearcoat texture. The red channel of the texture
  142. is used for the clearcoat parameter, allowing multiple parameters to use the same
  143. texture.
  144. ]]
  145. },
  146. {
  147. name = 'normalTexture',
  148. type = 'number',
  149. description = 'The index of the Image to use for the normal map.'
  150. }
  151. }
  152. }
  153. },
  154. variants = {
  155. {
  156. arguments = { 'index' },
  157. returns = { 'properties' }
  158. },
  159. {
  160. arguments = { 'name' },
  161. returns = { 'properties' }
  162. }
  163. },
  164. notes = 'All images are optional and may be `nil`.',
  165. related = {
  166. 'ModelData:getMaterialCount',
  167. 'ModelData:getMeshMaterial',
  168. 'lovr.graphics.newMaterial',
  169. 'Model:getMaterial'
  170. }
  171. }