|
@@ -11,43 +11,88 @@
|
|
|
|
|
|
<div class="desc">Constructor for the GLSL program sent to vertex and fragment shaders, including default uniforms and attributes.</div>
|
|
|
|
|
|
+ <h2>Built-in uniforms and attributes</h2>
|
|
|
+
|
|
|
+ <h3>Vertex shader (unconditional):</h3>
|
|
|
+ <div>
|
|
|
+ <code>
|
|
|
+ // = object.matrixWorld
|
|
|
+ uniform mat4 modelMatrix;
|
|
|
+
|
|
|
+ // = camera.matrixWorldInverse * object.matrixWorld
|
|
|
+ uniform mat4 modelViewMatrix;
|
|
|
+
|
|
|
+ // = camera.projectionMatrix
|
|
|
+ uniform mat4 projectionMatrix;
|
|
|
+
|
|
|
+ // = camera.matrixWorldInverse
|
|
|
+ uniform mat4 viewMatrix;
|
|
|
+
|
|
|
+ // = inverse transpose of modelViewMatrix
|
|
|
+ uniform mat3 normalMatrix;
|
|
|
+
|
|
|
+ // = camera.position
|
|
|
+ uniform vec3 cameraPosition;
|
|
|
+ </code>
|
|
|
+ <code>
|
|
|
+ attribute vec3 position;
|
|
|
+ attribute vec3 normal;
|
|
|
+ attribute vec2 uv;
|
|
|
+ attribute vec2 uv2;
|
|
|
+ </code></div>
|
|
|
+
|
|
|
+ <h3>Vertex shader (conditional):</h3>
|
|
|
+ <code>
|
|
|
+ #ifdef USE_COLOR
|
|
|
+ attribute vec3 color;
|
|
|
+ #endif
|
|
|
+ </code>
|
|
|
+ <code>
|
|
|
+ #ifdef USE_MORPHTARGETS
|
|
|
+
|
|
|
+ attribute vec3 morphTarget0;
|
|
|
+ attribute vec3 morphTarget1;
|
|
|
+ attribute vec3 morphTarget2;
|
|
|
+ attribute vec3 morphTarget3;
|
|
|
+
|
|
|
+ #ifdef USE_MORPHNORMALS
|
|
|
+
|
|
|
+ attribute vec3 morphNormal0;
|
|
|
+ attribute vec3 morphNormal1;
|
|
|
+ attribute vec3 morphNormal2;
|
|
|
+ attribute vec3 morphNormal3;
|
|
|
+
|
|
|
+ #else
|
|
|
+
|
|
|
+ attribute vec3 morphTarget4;
|
|
|
+ attribute vec3 morphTarget5;
|
|
|
+ attribute vec3 morphTarget6;
|
|
|
+ attribute vec3 morphTarget7;
|
|
|
+
|
|
|
+ #endif
|
|
|
+ #endif
|
|
|
+ </code>
|
|
|
+ <code>
|
|
|
+ #ifdef USE_SKINNING
|
|
|
+ attribute vec4 skinIndex;
|
|
|
+ attribute vec4 skinWeight;
|
|
|
+ #endif
|
|
|
+ </code>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <h3>Fragment shader:</h3>
|
|
|
+ <div>
|
|
|
+ <code>
|
|
|
+ uniform mat4 viewMatrix;
|
|
|
+ uniform vec3 cameraPosition;
|
|
|
+ </code>
|
|
|
+ </div>
|
|
|
+
|
|
|
+
|
|
|
<h2>Constructor</h2>
|
|
|
|
|
|
<h3>[name]( [page:WebGLRenderer renderer], [page:Object code], [page:Material material], [page:Object parameters] )</h3>
|
|
|
<div>For parameters see [page:WebGLRenderer WebGLRenderer]</div>
|
|
|
- <div>Standard defaults for vertex shader:<br/><br/>
|
|
|
- uniform mat4 modelMatrix;<br/>
|
|
|
- uniform mat4 modelViewMatrix;<br/>
|
|
|
- uniform mat4 projectionMatrix;<br/>
|
|
|
- uniform mat4 viewMatrix;<br/>
|
|
|
- uniform mat3 normalMatrix;<br/>
|
|
|
- uniform vec3 cameraPosition;<br/><br/>
|
|
|
- attribute vec3 position;<br/>
|
|
|
- attribute vec3 normal;<br/>
|
|
|
- attribute vec2 uv;<br/>
|
|
|
- attribute vec2 uv2;</div>
|
|
|
-
|
|
|
- <div>Conditional defaults for vertex shader:<br/><br/>
|
|
|
- attribute vec3 color;<br/><br/>
|
|
|
- attribute vec3 morphTarget0;<br/>
|
|
|
- attribute vec3 morphTarget1;<br/>
|
|
|
- attribute vec3 morphTarget2;<br/>
|
|
|
- attribute vec3 morphTarget3;<br/><br/>
|
|
|
- attribute vec3 morphNormal0;<br/>
|
|
|
- attribute vec3 morphNormal1;<br/>
|
|
|
- attribute vec3 morphNormal2;<br/>
|
|
|
- attribute vec3 morphNormal3;<br/><br/>
|
|
|
- attribute vec3 morphTarget4;<br/>
|
|
|
- attribute vec3 morphTarget5;<br/>
|
|
|
- attribute vec3 morphTarget6;<br/>
|
|
|
- attribute vec3 morphTarget7;<br/><br/>
|
|
|
- attribute vec4 skinIndex;<br/>
|
|
|
- attribute vec4 skinWeight;</div>
|
|
|
-
|
|
|
- <div>Standard defaults for fragment shader:<br/><br/>
|
|
|
- uniform mat4 viewMatrix;<br/>
|
|
|
- uniform vec3 cameraPosition;</div>
|
|
|
-
|
|
|
|
|
|
<h2>Properties</h2>
|
|
|
|
|
@@ -57,10 +102,10 @@
|
|
|
<h3>.[page:Object attributes]</h3>
|
|
|
<div></div>
|
|
|
|
|
|
- <h3>.[page:Integer id]</h3>
|
|
|
+ <h3>.[page:String id]</h3>
|
|
|
<div></div>
|
|
|
|
|
|
- <h3>.[page:Object code]</h3>
|
|
|
+ <h3>.[page:String code]</h3>
|
|
|
<div></div>
|
|
|
|
|
|
<h3>.[page:Integer usedTimes]</h3>
|
|
@@ -69,10 +114,10 @@
|
|
|
<h3>.[page:Object program]</h3>
|
|
|
<div></div>
|
|
|
|
|
|
- <h3>.[page:Object vertexShader]</h3>
|
|
|
+ <h3>.[page:WebGLShader vertexShader]</h3>
|
|
|
<div></div>
|
|
|
|
|
|
- <h3>.[page:Object fragmentShader]</h3>
|
|
|
+ <h3>.[page:WebGLShader fragmentShader]</h3>
|
|
|
<div></div>
|
|
|
|
|
|
|