MeshPhongMaterial.html 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="page.css" />
  8. </head>
  9. <body>
  10. [page:Material] &rarr;
  11. <h1>[name]</h1>
  12. <p class="desc">
  13. A material for shiny surfaces with specular highlights.<br /><br />
  14. The material uses a non-physically based
  15. [link:https://en.wikipedia.org/wiki/Blinn-Phong_shading_model Blinn-Phong]
  16. model for calculating reflectance. Unlike the Lambertian model used in the
  17. [page:MeshLambertMaterial] this can simulate shiny surfaces with specular
  18. highlights (such as varnished wood). [name] uses per-fragment shading.<br /><br />
  19. Performance will generally be greater when using this material over the
  20. [page:MeshStandardMaterial] or [page:MeshPhysicalMaterial], at the cost of
  21. some graphical accuracy.
  22. </p>
  23. <iframe
  24. id="scene"
  25. src="scenes/material-browser.html#MeshPhongMaterial"
  26. ></iframe>
  27. <script>
  28. // iOS iframe auto-resize workaround
  29. if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) {
  30. const scene = document.getElementById( 'scene' );
  31. scene.style.width = getComputedStyle( scene ).width;
  32. scene.style.height = getComputedStyle( scene ).height;
  33. scene.setAttribute( 'scrolling', 'no' );
  34. }
  35. </script>
  36. <h2>Constructor</h2>
  37. <h3>[name]( [param:Object parameters] )</h3>
  38. <p>
  39. [page:Object parameters] - (optional) an object with one or more
  40. properties defining the material's appearance. Any property of the
  41. material (including any property inherited from [page:Material]) can be
  42. passed in here.<br /><br />
  43. The exception is the property [page:Hexadecimal color], which can be
  44. passed in as a hexadecimal string and is `0xffffff` (white) by default.
  45. [page:Color.set]( color ) is called internally.
  46. </p>
  47. <h2>Properties</h2>
  48. <p>See the base [page:Material] class for common properties.</p>
  49. <h3>[property:Texture alphaMap]</h3>
  50. <p>
  51. The alpha map is a grayscale texture that controls the opacity across the
  52. surface (black: fully transparent; white: fully opaque). Default is
  53. null.<br /><br />
  54. Only the color of the texture is used, ignoring the alpha channel if one
  55. exists. For RGB and RGBA textures, the [page:WebGLRenderer WebGL] renderer
  56. will use the green channel when sampling this texture due to the extra bit
  57. of precision provided for green in DXT-compressed and uncompressed RGB 565
  58. formats. Luminance-only and luminance/alpha textures will also still work
  59. as expected.
  60. </p>
  61. <h3>[property:Texture aoMap]</h3>
  62. <p>
  63. The red channel of this texture is used as the ambient occlusion map.
  64. Default is null. The aoMap requires a second set of UVs.
  65. </p>
  66. <h3>[property:Float aoMapIntensity]</h3>
  67. <p>
  68. Intensity of the ambient occlusion effect. Range is 0-1, where `0`
  69. disables ambient occlusion. Where intensity is `1` and the [page:.aoMap]
  70. red channel is also `1`, ambient light is fully occluded on a surface.
  71. Default is `1`.
  72. </p>
  73. <h3>[property:Texture bumpMap]</h3>
  74. <p>
  75. The texture to create a bump map. The black and white values map to the
  76. perceived depth in relation to the lights. Bump doesn't actually affect
  77. the geometry of the object, only the lighting. If a normal map is defined
  78. this will be ignored.
  79. </p>
  80. <h3>[property:Float bumpScale]</h3>
  81. <p>
  82. How much the bump map affects the material. Typical ranges are 0-1.
  83. Default is `1`.
  84. </p>
  85. <h3>[property:Color color]</h3>
  86. <p>[page:Color] of the material, by default set to white (0xffffff).</p>
  87. <h3>[property:Integer combine]</h3>
  88. <p>
  89. How to combine the result of the surface's color with the environment map,
  90. if any.<br /><br />
  91. Options are [page:Materials THREE.MultiplyOperation] (default),
  92. [page:Materials THREE.MixOperation], [page:Materials THREE.AddOperation].
  93. If mix is chosen, the [page:.reflectivity] is used to blend between the
  94. two colors.
  95. </p>
  96. <h3>[property:Texture displacementMap]</h3>
  97. <p>
  98. The displacement map affects the position of the mesh's vertices. Unlike
  99. other maps which only affect the light and shade of the material the
  100. displaced vertices can cast shadows, block other objects, and otherwise
  101. act as real geometry. The displacement texture is an image where the value
  102. of each pixel (white being the highest) is mapped against, and
  103. repositions, the vertices of the mesh.
  104. </p>
  105. <h3>[property:Float displacementScale]</h3>
  106. <p>
  107. How much the displacement map affects the mesh (where black is no
  108. displacement, and white is maximum displacement). Without a displacement
  109. map set, this value is not applied. Default is `1`.
  110. </p>
  111. <h3>[property:Float displacementBias]</h3>
  112. <p>
  113. The offset of the displacement map's values on the mesh's vertices.
  114. Without a displacement map set, this value is not applied. Default is `0`.
  115. </p>
  116. <h3>[property:Color emissive]</h3>
  117. <p>
  118. Emissive (light) color of the material, essentially a solid color
  119. unaffected by other lighting. Default is black.
  120. </p>
  121. <h3>[property:Texture emissiveMap]</h3>
  122. <p>
  123. Set emissive (glow) map. Default is null. The emissive map color is
  124. modulated by the emissive color and the emissive intensity. If you have an
  125. emissive map, be sure to set the emissive color to something other than
  126. black.
  127. </p>
  128. <h3>[property:Float emissiveIntensity]</h3>
  129. <p>
  130. Intensity of the emissive light. Modulates the emissive color. Default is
  131. 1.
  132. </p>
  133. <h3>[property:Texture envMap]</h3>
  134. <p>The environment map. Default is null.</p>
  135. <h3>[property:Euler envMapRotation]</h3>
  136. <p>
  137. The rotation of the environment map in radians. Default is `(0,0,0)`.
  138. </p>
  139. <h3>[property:Boolean flatShading]</h3>
  140. <p>
  141. Define whether the material is rendered with flat shading. Default is
  142. false.
  143. </p>
  144. <h3>[property:Boolean fog]</h3>
  145. <p>Whether the material is affected by fog. Default is `true`.</p>
  146. <h3>[property:Texture lightMap]</h3>
  147. <p>
  148. The light map. Default is null. The lightMap requires a second set of UVs.
  149. </p>
  150. <h3>[property:Float lightMapIntensity]</h3>
  151. <p>Intensity of the baked light. Default is `1`.</p>
  152. <h3>[property:Texture map]</h3>
  153. <p>
  154. The color map. May optionally include an alpha channel, typically combined
  155. with [page:Material.transparent .transparent] or [page:Material.alphaTest .alphaTest].
  156. Default is null. The texture map color is modulated by the
  157. diffuse [page:.color].
  158. </p>
  159. <h3>[property:Texture normalMap]</h3>
  160. <p>
  161. The texture to create a normal map. The RGB values affect the surface
  162. normal for each pixel fragment and change the way the color is lit. Normal
  163. maps do not change the actual shape of the surface, only the lighting. In
  164. case the material has a normal map authored using the left handed
  165. convention, the y component of normalScale should be negated to compensate
  166. for the different handedness.
  167. </p>
  168. <h3>[property:Integer normalMapType]</h3>
  169. <p>
  170. The type of normal map.<br /><br />
  171. Options are [page:constant THREE.TangentSpaceNormalMap] (default), and
  172. [page:constant THREE.ObjectSpaceNormalMap].
  173. </p>
  174. <h3>[property:Vector2 normalScale]</h3>
  175. <p>
  176. How much the normal map affects the material. Typical ranges are 0-1.
  177. Default is a [page:Vector2] set to (1,1).
  178. </p>
  179. <h3>[property:Float reflectivity]</h3>
  180. <p>
  181. How much the environment map affects the surface; also see
  182. [page:.combine]. The default value is `1` and the valid range is between `0`
  183. (no reflections) and `1` (full reflections).
  184. </p>
  185. <h3>[property:Float refractionRatio]</h3>
  186. <p>
  187. The index of refraction (IOR) of air (approximately 1) divided by the
  188. index of refraction of the material. It is used with environment mapping
  189. modes [page:Textures THREE.CubeRefractionMapping] and [page:Textures THREE.EquirectangularRefractionMapping].
  190. The refraction ratio should not exceed `1`. Default is `0.98`.
  191. </p>
  192. <h3>[property:Float shininess]</h3>
  193. <p>
  194. How shiny the [page:.specular] highlight is; a higher value gives a
  195. sharper highlight. Default is `30`.
  196. </p>
  197. <h3>[property:Color specular]</h3>
  198. <p>
  199. Specular color of the material. Default is a [page:Color] set to
  200. `0x111111` (very dark grey).<br /><br />
  201. This defines how shiny the material is and the color of its shine.
  202. </p>
  203. <h3>[property:Texture specularMap]</h3>
  204. <p>
  205. The specular map value affects both how much the specular surface
  206. highlight contributes and how much of the environment map affects the
  207. surface. Default is null.
  208. </p>
  209. <h3>[property:Boolean wireframe]</h3>
  210. <p>
  211. Render geometry as wireframe. Default is `false` (i.e. render as flat
  212. polygons).
  213. </p>
  214. <h3>[property:String wireframeLinecap]</h3>
  215. <p>
  216. Define appearance of line ends. Possible values are "butt", "round" and
  217. "square". Default is 'round'.<br /><br />
  218. This corresponds to the
  219. [link:https://developer.mozilla.org/en/docs/Web/API/CanvasRenderingContext2D/lineCap 2D Canvas lineCap]
  220. property and it is ignored by the [page:WebGLRenderer WebGL] renderer.
  221. </p>
  222. <h3>[property:String wireframeLinejoin]</h3>
  223. <p>
  224. Define appearance of line joints. Possible values are "round", "bevel" and
  225. "miter". Default is 'round'.<br /><br />
  226. This corresponds to the
  227. [link:https://developer.mozilla.org/en/docs/Web/API/CanvasRenderingContext2D/lineJoin 2D Canvas lineJoin]
  228. property and it is ignored by the [page:WebGLRenderer WebGL] renderer.
  229. </p>
  230. <h3>[property:Float wireframeLinewidth]</h3>
  231. <p>
  232. Controls wireframe thickness. Default is `1`.<br /><br />
  233. Due to limitations of the
  234. [link:https://www.khronos.org/registry/OpenGL/specs/gl/glspec46.core.pdf OpenGL Core Profile]
  235. with the [page:WebGLRenderer WebGL] renderer on most
  236. platforms linewidth will always be `1` regardless of the set value.
  237. </p>
  238. <h2>Methods</h2>
  239. <p>See the base [page:Material] class for common methods.</p>
  240. <h2>Source</h2>
  241. <p>
  242. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  243. </p>
  244. </body>
  245. </html>