Textures.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../" />
  6. <script src="list.js"></script>
  7. <script src="page.js"></script>
  8. <link type="text/css" rel="stylesheet" href="page.css" />
  9. </head>
  10. <body>
  11. <h1>Texture Constants</h1>
  12. <h2>Mapping Modes</h2>
  13. <code>
  14. THREE.UVMapping
  15. THREE.CubeReflectionMapping
  16. THREE.CubeRefractionMapping
  17. THREE.EquirectangularReflectionMapping
  18. THREE.EquirectangularRefractionMapping
  19. THREE.SphericalReflectionMapping
  20. THREE.CubeUVReflectionMapping
  21. THREE.CubeUVRefractionMapping
  22. </code>
  23. <div>
  24. These can also be accessed using:
  25. </div>
  26. <code>
  27. THREE.TextureMappingUVMapping
  28. THREE.TextureMapping.CubeReflectionMapping
  29. THREE.TextureMapping.CubeRefractionMapping
  30. THREE.TextureMapping.EquirectangularReflectionMapping
  31. THREE.TextureMapping.EquirectangularRefractionMapping
  32. THREE.TextureMapping.SphericalReflectionMapping
  33. THREE.TextureMapping.CubeUVReflectionMapping
  34. THREE.TextureMapping.CubeUVRefractionMapping
  35. </code>
  36. <div>
  37. These define the texture's mapping mode.<br />
  38. [page:Constant UVMapping] is the default, and maps the texture using the mesh's UV coordinates.<br /><br />
  39. The rest define environment mapping types.<br /><br />
  40. [page:Constant CubeReflectionMapping] and [page:Constant CubeRefractionMapping] are for
  41. use with a [page:CubeTexture CubeTexture], which is made up of six textures, one for each face of the cube.<br />
  42. [page:Constant CubeReflectionMapping] is the default for a [page:CubeTexture CubeTexture]. <br /><br />
  43. [page:Constant EquirectangularReflectionMapping] and [page:Constant EquirectangularRefractionMapping]
  44. are for use with an equirectangular environment map.<br /><br />
  45. [page:Constant SphericalReflectionMapping] is for use with a spherical reflection map.<br /><br />
  46. See the [example:webgl_materials_envmaps materials / envmaps] example.
  47. </div>
  48. <h2>Wrapping Modes</h2>
  49. <code>
  50. THREE.RepeatWrapping
  51. THREE.ClampToEdgeWrapping
  52. THREE.MirroredRepeatWrapping
  53. </code>
  54. <div>
  55. These can also be accessed using:
  56. </div>
  57. <code>
  58. THREE.TextureWrapping.RepeatWrapping
  59. THREE.TextureWrapping.ClampToEdgeWrapping
  60. THREE.TextureWrapping.MirroredRepeatWrapping
  61. </code>
  62. <div>
  63. These define the texture's [page:Texture.wrapS wrapS] and [page:Texture.wrapT wrapT] properties,
  64. which define horizontal and vertical texture wrapping.<br /><br />
  65. With [page:constant RepeatWrapping] the texture will simply repeat to infinity.<br /><br />
  66. [page:constant ClampToEdgeWrapping] is the default.
  67. The last pixel of the texture stretches to the edge of the mesh.<br /><br />
  68. With [page:constant MirroredRepeatWrapping] the texture will repeats to infinity, mirroring on each repeat.<br />
  69. </div>
  70. <h2>Magnification Filters</h2>
  71. <code>
  72. THREE.NearestFilter
  73. THREE.LinearFilter
  74. </code>
  75. <div>
  76. These can also be accessed using:
  77. </div>
  78. <code>
  79. THREE.TextureFilter.NearestFilter
  80. THREE.TextureFilter.LinearFilter
  81. </code>
  82. <div>
  83. For use with a texture's [page:Texture.magFilter magFilter] property,
  84. these define the texture magnification function to be used when the pixel being textured maps to an
  85. area less than or equal to one texture element (texel).<br /><br />
  86. [page:constant NearestFilter] returns the value of the texture element that is nearest
  87. (in Manhattan distance) to the specified texture coordinates.<br /><br />
  88. [page:constant LinearFilter] is the default and returns the weighted average
  89. of the four texture elements that are closest to the specified texture coordinates,
  90. and can include items wrapped or repeated from other parts of a texture,
  91. depending on the values of [page:Texture.wrapS wrapS] and [page:Texture.wrapT wrapT], and on the exact mapping.
  92. </div>
  93. <h2>Minification Filters</h2>
  94. <code>
  95. THREE.NearestFilter
  96. THREE.NearestMipMapNearestFilter
  97. THREE.NearestMipMapLinearFilter
  98. THREE.LinearFilter
  99. THREE.LinearMipMapNearestFilter
  100. THREE.LinearMipMapLinearFilter
  101. </code>
  102. <div>
  103. These can also be accessed using:
  104. </div>
  105. <code>
  106. THREE.TextureFilter.NearestFilter
  107. THREE.TextureFilter.NearestMipMapNearestFilter
  108. THREE.TextureFilter.NearestMipMapLinearFilter
  109. THREE.TextureFilter.LinearFilter
  110. THREE.TextureFilter.LinearMipMapNearestFilter
  111. THREE.TextureFilter.LinearMipMapLinearFilter
  112. </code>
  113. <div>
  114. For use with a texture's [page:Texture.minFilter minFilter] property, these define
  115. the texture minifying function that is used whenever the pixel being textured maps
  116. to an area greater than one texture element (texel).<br /><br />
  117. In addition to [page:constant NearestFilter] and [page:constant LinearFilter],
  118. the following four functions can be used for minification:<br /><br />
  119. [page:constant NearestMipMapNearestFilter] chooses the mipmap that most closely
  120. matches the size of the pixel being textured
  121. and uses the [page:constant NearestFilter] criterion (the texel nearest to the
  122. center of the pixel) to produce a texture value.<br /><br />
  123. [page:constant NearestMipMapLinearFilter] chooses the two mipmaps that most closely
  124. match the size of the pixel being textured and uses the [page:constant NearestFilter] criterion to produce
  125. a texture value from each mipmap. The final texture value is a weighted average of those two values.<br /><br />
  126. [page:constant LinearMipMapNearestFilter] chooses the mipmap that most closely matches
  127. the size of the pixel being textured and uses the [page:constant LinearFilter] criterion
  128. (a weighted average of the four texels that are closest to the center of the pixel)
  129. to produce a texture value.<br /><br />
  130. [page:constant LinearMipMapLinearFilter] is the default and chooses the two mipmaps
  131. that most closely match the size of the pixel being textured and uses the [page:constant LinearFilter] criterion
  132. to produce a texture value from each mipmap. The final texture value is a weighted average of those two values.<br /><br />
  133. See the [example:webgl_materials_texture_filters materials / texture / filters] example.
  134. </div>
  135. <h2>Types</h2>
  136. <code>
  137. THREE.UnsignedByteType
  138. THREE.ByteType
  139. THREE.ShortType
  140. THREE.UnsignedShortType
  141. THREE.IntType
  142. THREE.UnsignedIntType
  143. THREE.FloatType
  144. THREE.HalfFloatType
  145. THREE.UnsignedShort4444Type
  146. THREE.UnsignedShort5551Type
  147. THREE.UnsignedShort565Type
  148. THREE.UnsignedInt248Type
  149. </code>
  150. <div>
  151. For use with a texture's [page:Texture.type type] property, which must correspond to the correct format. See below for details.<br /><br />
  152. [page:constant UnsignedByteType] is the default.
  153. </div>
  154. <h2>Formats</h2>
  155. <code>
  156. THREE.AlphaFormat
  157. THREE.RGBFormat
  158. THREE.RGBAFormat
  159. THREE.LuminanceFormat
  160. THREE.LuminanceAlphaFormat
  161. THREE.RGBEFormat
  162. THREE.DepthFormat
  163. THREE.DepthStencilFormat
  164. </code>
  165. <div>
  166. For use with a texture's [page:Texture.format format] property, these define
  167. how elements of a 2d texture, or *texels*, are read by shaders.<br /><br />
  168. [page:constant AlphaFormat] discards the red, green and blue components and reads just the alpha component.
  169. The [page:Texture.type type] must be [page:constant UnsignedByteType].<br /><br />
  170. [page:constant RGBFormat] discards the alpha components and reads the red, green and blue components.
  171. The [page:Texture.type type] must be [page:constant UnsignedByteType] or [page:constant UnsignedShort565Type].<br /><br />
  172. [page:constant RGBAFormat] is the default and reads the red, green, blue and alpha components.
  173. The [page:Texture.type type] must be [page:constant UnsignedByteType], [page:constant UnsignedShort4444Type] or [page:constant THREE.UnsignedShort5551Type].<br /><br />
  174. [page:constant LuminanceFormat] reads each element as a single luminance component.
  175. This is then converted to a floating point, clamped to the range [0,1], and then assembled
  176. into an RGBA element by placing the luminance value in the red, green and blue channels,
  177. and attaching 1.0 to the alpha channel. The [page:Texture.type type] must be [page:constant UnsignedByteType].<br /><br />
  178. [page:constant LuminanceAlphaFormat] reads each element as a luminance/alpha double.
  179. The same process occurs as for the [page:constant LuminanceFormat], except that the
  180. alpha channel may have values other than *1.0*. The [page:Texture.type type] must be [page:constant UnsignedByteType].<br /><br />
  181. [page:constant RGBEFormat] is identical to [page:constant RGBAFormat].<br /><br />
  182. [page:constant DepthFormat] reads each element as a single depth value, converts it to floating point, and clamps to the range [0,1].
  183. The [page:Texture.type type] must be [page:constant UnsignedIntType] or [page:constant UnsignedShortType].
  184. This is the default for [page:DepthTexture DepthTexture].<br /><br />
  185. [page:constant DepthStencilFormat] reads each element is a pair of depth and stencil values.
  186. The depth component of the pair is interpreted as in [page:constant DepthFormat].
  187. The stencil component is interpreted based on the depth + stencil internal format.
  188. The [page:Texture.type type] must be [page:constant UnsignedInt248Type].<br /><br />
  189. Note that the texture must have the correct [page:Texture.type type] set, as described above.
  190. See <a href="https://developer.mozilla.org/en/docs/Web/API/WebGLRenderingContext/texImage2D">this page</a> for details.
  191. </div>
  192. <h2>DDS / ST3C Compressed Texture Formats</h2>
  193. <code>
  194. THREE.RGB_S3TC_DXT1_Format
  195. THREE.RGBA_S3TC_DXT1_Format
  196. THREE.RGBA_S3TC_DXT3_Format
  197. THREE.RGBA_S3TC_DXT5_Format
  198. </code>
  199. <div>
  200. For use with a [page:CompressedTexture CompressedTexture]'s [page:Texture.format format] property,
  201. these require support for the
  202. <a href="https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_s3tc/">WEBGL_compressed_texture_s3tc</a>
  203. extension. <br />
  204. According to <a href="http://webglstats.com/">WebglStats</a>, as of February 2016
  205. over 80% of WebGL enabled devices support this extension.<br /><br />
  206. There are four <a href="https://en.wikipedia.org/wiki/S3_Texture_Compression">S3TC</a> formats available via this extension. These are:<br />
  207. [page:constant RGB_S3TC_DXT1_Format]: A DXT1-compressed image in an RGB image format.<br />
  208. [page:constant RGBA_S3TC_DXT1_Format]: A DXT1-compressed image in an RGB image format with a simple on/off alpha value.<br />
  209. [page:constant RGBA_S3TC_DXT3_Format]: A DXT3-compressed image in an RGBA image format. Compared to a 32-bit RGBA texture, it offers 4:1 compression.<br />
  210. [page:constant RGBA_S3TC_DXT5_Format]: A DXT5-compressed image in an RGBA image format. It also provides a 4:1 compression, but differs to the DXT3 compression in how the alpha compression is done.<br />
  211. </div>
  212. <h2>PVRTC Compressed Texture Formats</h2>
  213. <code>
  214. THREE.RGB_PVRTC_4BPPV1_Format
  215. THREE.RGB_PVRTC_2BPPV1_Format
  216. THREE.RGBA_PVRTC_4BPPV1_Format
  217. THREE.RGBA_PVRTC_2BPPV1_Format
  218. </code>
  219. <div>
  220. For use with a [page:CompressedTexture CompressedTexture]'s [page:Texture.format format] property,
  221. these require support for the <a href="https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_pvrtc/">WEBGL_compressed_texture_pvrtc</a>
  222. extension. <br />
  223. According to <a href="http://webglstats.com/">WebglStats</a>, as of February 2016
  224. less than 8% of WebGL enabled devices support this extenstion.
  225. PVRTC is typically only available on mobile devices with PowerVR chipsets,
  226. which are mainly Apple devices.<br /><br />
  227. There are four <a href="https://en.wikipedia.org/wiki/PVRTC">PVRTC</a> formats available via this extension. These are:<br />
  228. [page:constant RGB_PVRTC_4BPPV1_Format]: RGB compression in 4-bit mode. One block for each 4×4 pixels.<br />
  229. [page:constant RGB_PVRTC_2BPPV1_Format]: RGB compression in 2-bit mode. One block for each 8×4 pixels.<br />
  230. [page:constant RGBA_PVRTC_4BPPV1_Format]: RGBA compression in 4-bit mode. One block for each 4×4 pixels.<br />
  231. [page:constant RGBA_PVRTC_2BPPV1_Format]: RGBA compression in 2-bit mode. One block for each 8×4 pixels.<br />
  232. </div>
  233. <h2>ETC Compressed Texture Format</h2>
  234. <code>
  235. THREE.RGB_ETC1_Format
  236. </code>
  237. <div>
  238. For use with a [page:CompressedTexture CompressedTexture]'s [page:Texture.format format] property,
  239. these require support for the <a href="https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_etc1/">WEBGL_compressed_texture_etc1</a>
  240. extension. <br />
  241. According to <a href="http://webglstats.com/">WebglStats</a>, as of February 2016
  242. just over 13% of WebGL enabled devices support this extenstion.<br /><br />
  243. </div>
  244. <h2>Encoding</h2>
  245. <code>
  246. THREE.LinearEncoding
  247. THREE.sRGBEncoding
  248. THREE.GammaEncoding
  249. THREE.RGBEEncoding
  250. THREE.LogLuvEncoding
  251. THREE.RGBM7Encoding
  252. THREE.RGBM16Encoding
  253. THREE.RGBDEncoding
  254. THREE.BasicDepthPacking
  255. THREE.RGBADepthPacking
  256. </code>
  257. <div>
  258. For use with a Texture's [page:Texture.encoding encoding] property.<br /><br />
  259. If the encoding type is changed after the texture has already been used by a material,
  260. you will need to set [page:Material.needsUpdate Material.needsUpdate] to *true* to make the material recompile.<br /><br />
  261. [page:constant LinearEncoding] is the default.
  262. Values other than this are only valid for a material's map, envMap and emissiveMap.
  263. </div>
  264. <h2>Source</h2>
  265. [link:https://github.com/mrdoob/three.js/blob/master/src/constants.js src/constants.js]
  266. </body>
  267. </html>