Constructor for the GLSL program sent to vertex and fragment shaders, including default uniforms and attributes.
// = 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;
// default vertex attributes provided by BufferGeometry
attribute vec3 position;
attribute vec3 normal;
attribute vec2 uv;
Note that you can therefore calculate the position of a vertex in the vertex shader by:
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
or alternatively
gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.0);
#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
#ifdef USE_MORPHTARGETS
attribute vec3 morphTarget0;
attribute vec3 morphTarget1;
attribute vec3 morphTarget2;
attribute vec3 morphTarget3;
attribute vec3 morphTarget4;
attribute vec3 morphTarget5;
#ifdef USE_MORPHNORMALS
attribute vec3 morphNormal0;
attribute vec3 morphNormal1;
attribute vec3 morphNormal2;
attribute vec3 morphNormal3;
attribute vec3 morphNormal4;
attribute vec3 morphNormal5;
#else
attribute vec3 morphTarget6;
attribute vec3 morphTarget7;
attribute vec3 morphTarget8;
attribute vec3 morphTarget9;
attribute vec3 morphTarget10;
attribute vec3 morphTarget11;
#endif
#endif
#ifdef USE_SKINNING
attribute vec4 skinIndex;
attribute vec4 skinWeight;
#endif
#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
uniform mat4 viewMatrix;
uniform vec3 cameraPosition;
For parameters see WebGLRenderer.
The name of the respective shader program.
The identifier of this instance.
This key enables the reusability of a single WebGLProgram for different materials.
How many times this instance is used for rendering render items.
The actual shader program.
The vertex shader.
The fragment shader.
Returns a name-value mapping of all active uniform locations.
Returns a name-value mapping of all active vertex attribute locations.
Destroys an instance of WebGLProgram.
For more info on how to obtain the source code of this module see this page.