123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8" />
- <base href="../../../../" />
- <script src="page.js"></script>
- <link type="text/css" rel="stylesheet" href="page.css" />
- </head>
- <body>
- <h1>[name]</h1>
- <p class="desc">Constructor for the GLSL program sent to vertex and fragment shaders, including default uniforms and attributes.</p>
- <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 in world space
- uniform vec3 cameraPosition;
- </code>
- <code>
- // default vertex attributes provided by BufferGeometry
- attribute vec3 position;
- attribute vec3 normal;
- attribute vec2 uv;
- </code>
- <p>
- Note that you can therefore calculate the position of a vertex in the vertex shader by:
- <code>
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- </code>
- or alternatively
- <code>
- gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4( position, 1.0 );
- </code>
- </p>
- </div>
- <h3>Vertex shader (conditional):</h3>
- <div>
- <code>
- #ifdef USE_TANGENT
- attribute vec4 tangent;
- #endif
- #if defined( USE_COLOR_ALPHA )
- // vertex color attribute with alpha
- attribute vec4 color;
- #elif defined( USE_COLOR )
- // vertex color attribute
- 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>
- <code>
- #ifdef USE_INSTANCING
- // Note that modelViewMatrix is not set when rendering an instanced model,
- // but can be calculated from viewMatrix * modelMatrix.
- //
- // Basic Usage:
- // gl_Position = projectionMatrix * viewMatrix * modelMatrix * instanceMatrix * vec4(position, 1.0);
- attribute mat4 instanceMatrix;
- #endif
- </code>
- </div>
- <h3>Fragment shader:</h3>
- <div>
- <code>
- uniform mat4 viewMatrix;
- uniform vec3 cameraPosition;
- </code>
- </div>
- <h2>Constructor</h2>
- <h3>[name]( [param:WebGLRenderer renderer], [param:String cacheKey], [param:Object parameters] )</h3>
- <p>For parameters see [page:WebGLRenderer WebGLRenderer].</p>
- <h2>Properties</h2>
- <h3>[property:String name]</h3>
- <p>The name of the respective shader program.</p>
- <h3>[property:String id]</h3>
- <p>The identifier of this instance.</p>
- <h3>[property:String cacheKey]</h3>
- <p>This key enables the reusability of a single [name] for different materials.</p>
- <h3>[property:Integer usedTimes]</h3>
- <p>How many times this instance is used for rendering render items.</p>
- <h3>[property:Object program]</h3>
- <p>The actual shader program.</p>
- <h3>[property:WebGLShader vertexShader]</h3>
- <p>The vertex shader.</p>
- <h3>[property:WebGLShader fragmentShader]</h3>
- <p>The fragment shader.</p>
- <h2>Methods</h2>
- <h3>[method:Object getUniforms]()</h3>
- <p>
- Returns a name-value mapping of all active uniform locations.
- </p>
- <h3>[method:Object getAttributes]()</h3>
- <p>
- Returns a name-value mapping of all active vertex attribute locations.
- </p>
- <h3>[method:undefined destroy]()</h3>
- <p>
- Destroys an instance of [name].
- </p>
- <h2>Source</h2>
- <p>
- [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
- </p>
- </body>
- </html>
|