2
0

Textures.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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. <p>
  24. These define the texture's mapping mode.<br />
  25. [page:Constant UVMapping] is the default, and maps the texture using the mesh's UV coordinates.<br /><br />
  26. The rest define environment mapping types.<br /><br />
  27. [page:Constant CubeReflectionMapping] and [page:Constant CubeRefractionMapping] are for
  28. use with a [page:CubeTexture CubeTexture], which is made up of six textures, one for each face of the cube.
  29. [page:Constant CubeReflectionMapping] is the default for a [page:CubeTexture CubeTexture]. <br /><br />
  30. [page:Constant EquirectangularReflectionMapping] and [page:Constant EquirectangularRefractionMapping]
  31. are for use with an equirectangular environment map. Also called a lat-long map, an equirectangular
  32. texture represents a 360-degree view along the horizontal centerline, and a 180-degree view along the
  33. vertical axis, with the top and bottom edges of the image corresponding to the north and south poles
  34. of a mapped sphere.<br /><br />
  35. [page:Constant SphericalReflectionMapping] is for use with a spherical reflection map such as may be obtained
  36. by cropping a photograph of a mirrored ball. Sphere maps will be rendered "facing" the camera, irrespective
  37. of the position of the camera relative to the cubemapped object or surface.<br /><br />
  38. See the [example:webgl_materials_envmaps materials / envmaps] example.
  39. </p>
  40. <h2>Wrapping Modes</h2>
  41. <code>
  42. THREE.RepeatWrapping
  43. THREE.ClampToEdgeWrapping
  44. THREE.MirroredRepeatWrapping
  45. </code>
  46. <p>
  47. These define the texture's [page:Texture.wrapS wrapS] and [page:Texture.wrapT wrapT] properties,
  48. which define horizontal and vertical texture wrapping.<br /><br />
  49. With [page:constant RepeatWrapping] the texture will simply repeat to infinity.<br /><br />
  50. [page:constant ClampToEdgeWrapping] is the default.
  51. The last pixel of the texture stretches to the edge of the mesh.<br /><br />
  52. With [page:constant MirroredRepeatWrapping] the texture will repeats to infinity, mirroring on each repeat.
  53. </p>
  54. <h2>Magnification Filters</h2>
  55. <code>
  56. THREE.NearestFilter
  57. THREE.LinearFilter
  58. </code>
  59. <p>
  60. For use with a texture's [page:Texture.magFilter magFilter] property,
  61. these define the texture magnification function to be used when the pixel being textured maps to an
  62. area less than or equal to one texture element (texel).<br /><br />
  63. [page:constant NearestFilter] returns the value of the texture element that is nearest
  64. (in Manhattan distance) to the specified texture coordinates.<br /><br />
  65. [page:constant LinearFilter] is the default and returns the weighted average
  66. of the four texture elements that are closest to the specified texture coordinates,
  67. and can include items wrapped or repeated from other parts of a texture,
  68. depending on the values of [page:Texture.wrapS wrapS] and [page:Texture.wrapT wrapT], and on the exact mapping.
  69. </p>
  70. <h2>Minification Filters</h2>
  71. <code>
  72. THREE.NearestFilter
  73. THREE.NearestMipMapNearestFilter
  74. THREE.NearestMipMapLinearFilter
  75. THREE.LinearFilter
  76. THREE.LinearMipMapNearestFilter
  77. THREE.LinearMipMapLinearFilter
  78. </code>
  79. <p>
  80. For use with a texture's [page:Texture.minFilter minFilter] property, these define
  81. the texture minifying function that is used whenever the pixel being textured maps
  82. to an area greater than one texture element (texel).<br /><br />
  83. In addition to [page:constant NearestFilter] and [page:constant LinearFilter],
  84. the following four functions can be used for minification:<br /><br />
  85. [page:constant NearestMipMapNearestFilter] chooses the mipmap that most closely
  86. matches the size of the pixel being textured
  87. and uses the [page:constant NearestFilter] criterion (the texel nearest to the
  88. center of the pixel) to produce a texture value.<br /><br />
  89. [page:constant NearestMipMapLinearFilter] chooses the two mipmaps that most closely
  90. match the size of the pixel being textured and uses the [page:constant NearestFilter] criterion to produce
  91. a texture value from each mipmap. The final texture value is a weighted average of those two values.<br /><br />
  92. [page:constant LinearMipMapNearestFilter] chooses the mipmap that most closely matches
  93. the size of the pixel being textured and uses the [page:constant LinearFilter] criterion
  94. (a weighted average of the four texels that are closest to the center of the pixel)
  95. to produce a texture value.<br /><br />
  96. [page:constant LinearMipMapLinearFilter] is the default and chooses the two mipmaps
  97. that most closely match the size of the pixel being textured and uses the [page:constant LinearFilter] criterion
  98. to produce a texture value from each mipmap. The final texture value is a weighted average of those two values.<br /><br />
  99. See the [example:webgl_materials_texture_filters materials / texture / filters] example.
  100. </p>
  101. <h2>Types</h2>
  102. <code>
  103. THREE.UnsignedByteType
  104. THREE.ByteType
  105. THREE.ShortType
  106. THREE.UnsignedShortType
  107. THREE.IntType
  108. THREE.UnsignedIntType
  109. THREE.FloatType
  110. THREE.HalfFloatType
  111. THREE.UnsignedShort4444Type
  112. THREE.UnsignedShort5551Type
  113. THREE.UnsignedShort565Type
  114. THREE.UnsignedInt248Type
  115. </code>
  116. <p>
  117. For use with a texture's [page:Texture.type type] property, which must correspond to the correct format. See below for details.<br /><br />
  118. [page:constant UnsignedByteType] is the default.
  119. </p>
  120. <h2>Formats</h2>
  121. <code>
  122. THREE.AlphaFormat
  123. THREE.RGBFormat
  124. THREE.RGBAFormat
  125. THREE.LuminanceFormat
  126. THREE.LuminanceAlphaFormat
  127. THREE.RGBEFormat
  128. THREE.DepthFormat
  129. THREE.DepthStencilFormat
  130. </code>
  131. <p>
  132. For use with a texture's [page:Texture.format format] property, these define
  133. how elements of a 2d texture, or *texels*, are read by shaders.<br /><br />
  134. [page:constant AlphaFormat] discards the red, green and blue components and reads just the alpha component.<br /><br />
  135. [page:constant RGBFormat] discards the alpha components and reads the red, green and blue components.<br /><br />
  136. [page:constant RGBAFormat] is the default and reads the red, green, blue and alpha components.<br /><br />
  137. [page:constant LuminanceFormat] reads each element as a single luminance component.
  138. This is then converted to a floating point, clamped to the range [0,1], and then assembled
  139. into an RGBA element by placing the luminance value in the red, green and blue channels,
  140. and attaching 1.0 to the alpha channel.<br /><br />
  141. [page:constant LuminanceAlphaFormat] reads each element as a luminance/alpha double.
  142. The same process occurs as for the [page:constant LuminanceFormat], except that the
  143. alpha channel may have values other than *1.0*.<br /><br />
  144. [page:constant RGBEFormat] is identical to [page:constant RGBAFormat].<br /><br />
  145. [page:constant DepthFormat] reads each element as a single depth value, converts it to floating point, and clamps to the range [0,1].
  146. This is the default for [page:DepthTexture DepthTexture].<br /><br />
  147. [page:constant DepthStencilFormat] reads each element is a pair of depth and stencil values.
  148. The depth component of the pair is interpreted as in [page:constant DepthFormat].
  149. The stencil component is interpreted based on the depth + stencil internal format.
  150. <br /><br />
  151. Note that the texture must have the correct [page:Texture.type type] set, as described above.
  152. See [link:https://developer.mozilla.org/en/docs/Web/API/WebGLRenderingContext/texImage2D WebGLRenderingContext.texImage2D] for details.
  153. </p>
  154. <h2>DDS / ST3C Compressed Texture Formats</h2>
  155. <code>
  156. THREE.RGB_S3TC_DXT1_Format
  157. THREE.RGBA_S3TC_DXT1_Format
  158. THREE.RGBA_S3TC_DXT3_Format
  159. THREE.RGBA_S3TC_DXT5_Format
  160. </code>
  161. <p>
  162. For use with a [page:CompressedTexture CompressedTexture]'s [page:Texture.format format] property,
  163. these require support for the
  164. [link:https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_s3tc/ WEBGL_compressed_texture_s3tc]
  165. extension. <br /><br />
  166. There are four [link:https://en.wikipedia.org/wiki/S3_Texture_Compression S3TC] formats available via this extension. These are:<br />
  167. [page:constant RGB_S3TC_DXT1_Format]: A DXT1-compressed image in an RGB image format.<br />
  168. [page:constant RGBA_S3TC_DXT1_Format]: A DXT1-compressed image in an RGB image format with a simple on/off alpha value.<br />
  169. [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 />
  170. [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 />
  171. </p>
  172. <h2>PVRTC Compressed Texture Formats</h2>
  173. <code>
  174. THREE.RGB_PVRTC_4BPPV1_Format
  175. THREE.RGB_PVRTC_2BPPV1_Format
  176. THREE.RGBA_PVRTC_4BPPV1_Format
  177. THREE.RGBA_PVRTC_2BPPV1_Format
  178. </code>
  179. <p>
  180. For use with a [page:CompressedTexture CompressedTexture]'s [page:Texture.format format] property,
  181. these require support for the [link:https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_pvrtc/ WEBGL_compressed_texture_pvrtc]
  182. extension. <br />
  183. PVRTC is typically only available on mobile devices with PowerVR chipsets, which are mainly Apple devices.<br /><br />
  184. There are four [link:https://en.wikipedia.org/wiki/PVRTC PVRTC] formats available via this extension. These are:<br />
  185. [page:constant RGB_PVRTC_4BPPV1_Format]: RGB compression in 4-bit mode. One block for each 4×4 pixels.<br />
  186. [page:constant RGB_PVRTC_2BPPV1_Format]: RGB compression in 2-bit mode. One block for each 8×4 pixels.<br />
  187. [page:constant RGBA_PVRTC_4BPPV1_Format]: RGBA compression in 4-bit mode. One block for each 4×4 pixels.<br />
  188. [page:constant RGBA_PVRTC_2BPPV1_Format]: RGBA compression in 2-bit mode. One block for each 8×4 pixels.<br />
  189. </p>
  190. <h2>ETC Compressed Texture Format</h2>
  191. <code>
  192. THREE.RGB_ETC1_Format
  193. </code>
  194. <p>
  195. For use with a [page:CompressedTexture CompressedTexture]'s [page:Texture.format format] property,
  196. these require support for the [link:https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_etc1/ WEBGL_compressed_texture_etc1]
  197. extension. <br /><br />
  198. </p>
  199. <h2>Encoding</h2>
  200. <code>
  201. THREE.LinearEncoding
  202. THREE.sRGBEncoding
  203. THREE.GammaEncoding
  204. THREE.RGBEEncoding
  205. THREE.LogLuvEncoding
  206. THREE.RGBM7Encoding
  207. THREE.RGBM16Encoding
  208. THREE.RGBDEncoding
  209. THREE.BasicDepthPacking
  210. THREE.RGBADepthPacking
  211. </code>
  212. <p>
  213. For use with a Texture's [page:Texture.encoding encoding] property.<br /><br />
  214. If the encoding type is changed after the texture has already been used by a material,
  215. you will need to set [page:Material.needsUpdate Material.needsUpdate] to *true* to make the material recompile.<br /><br />
  216. [page:constant LinearEncoding] is the default.
  217. Values other than this are only valid for a material's map, envMap and emissiveMap.
  218. </p>
  219. <h2>Source</h2>
  220. [link:https://github.com/mrdoob/three.js/blob/master/src/constants.js src/constants.js]
  221. </body>
  222. </html>