WebGLProgram.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <script src="../../../list.js"></script>
  6. <script src="../../../page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="../../../page.css" />
  8. </head>
  9. <body>
  10. <h1>[name]</h1>
  11. <div class="desc">Constructor for the GLSL program sent to vertex and fragment shaders, including default uniforms and attributes.</div>
  12. <h2>Built-in uniforms and attributes</h2>
  13. <h3>Vertex shader (unconditional):</h3>
  14. <div>
  15. <code>
  16. // = object.matrixWorld
  17. uniform mat4 modelMatrix;
  18. // = camera.matrixWorldInverse * object.matrixWorld
  19. uniform mat4 modelViewMatrix;
  20. // = camera.projectionMatrix
  21. uniform mat4 projectionMatrix;
  22. // = camera.matrixWorldInverse
  23. uniform mat4 viewMatrix;
  24. // = inverse transpose of modelViewMatrix
  25. uniform mat3 normalMatrix;
  26. // = camera.position
  27. uniform vec3 cameraPosition;
  28. </code>
  29. <code>
  30. attribute vec3 position;
  31. attribute vec3 normal;
  32. attribute vec2 uv;
  33. attribute vec2 uv2;
  34. </code></div>
  35. <h3>Vertex shader (conditional):</h3>
  36. <code>
  37. #ifdef USE_COLOR
  38. attribute vec3 color;
  39. #endif
  40. </code>
  41. <code>
  42. #ifdef USE_MORPHTARGETS
  43. attribute vec3 morphTarget0;
  44. attribute vec3 morphTarget1;
  45. attribute vec3 morphTarget2;
  46. attribute vec3 morphTarget3;
  47. #ifdef USE_MORPHNORMALS
  48. attribute vec3 morphNormal0;
  49. attribute vec3 morphNormal1;
  50. attribute vec3 morphNormal2;
  51. attribute vec3 morphNormal3;
  52. #else
  53. attribute vec3 morphTarget4;
  54. attribute vec3 morphTarget5;
  55. attribute vec3 morphTarget6;
  56. attribute vec3 morphTarget7;
  57. #endif
  58. #endif
  59. </code>
  60. <code>
  61. #ifdef USE_SKINNING
  62. attribute vec4 skinIndex;
  63. attribute vec4 skinWeight;
  64. #endif
  65. </code>
  66. </div>
  67. <h3>Fragment shader:</h3>
  68. <div>
  69. <code>
  70. uniform mat4 viewMatrix;
  71. uniform vec3 cameraPosition;
  72. </code>
  73. </div>
  74. <h2>Constructor</h2>
  75. <h3>[name]( [page:WebGLRenderer renderer], [page:Object code], [page:Material material], [page:Object parameters] )</h3>
  76. <div>For parameters see [page:WebGLRenderer WebGLRenderer]</div>
  77. <h2>Properties</h2>
  78. <h3>.[page:Object uniforms]</h3>
  79. <div></div>
  80. <h3>.[page:Object attributes]</h3>
  81. <div></div>
  82. <h3>.[page:String id]</h3>
  83. <div></div>
  84. <h3>.[page:String code]</h3>
  85. <div></div>
  86. <h3>.[page:Integer usedTimes]</h3>
  87. <div></div>
  88. <h3>.[page:Object program]</h3>
  89. <div></div>
  90. <h3>.[page:WebGLShader vertexShader]</h3>
  91. <div></div>
  92. <h3>.[page:WebGLShader fragmentShader]</h3>
  93. <div></div>
  94. <h2>Methods</h2>
  95. <h3>none</h3>
  96. <div></div>
  97. <h2>Source</h2>
  98. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  99. </body>
  100. </html>