Constructor for the GLSL program sent to vertex and fragment shaders, including default uniforms and attributes.

Built-in uniforms and attributes

Vertex shader (unconditional):

// = 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 Geometry and 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 );

Vertex shader (conditional):

#ifdef USE_COLOR // vertex color attribute attribute vec3 color; #endif #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 #ifdef USE_SKINNING attribute vec4 skinIndex; attribute vec4 skinWeight; #endif

Fragment shader:

uniform mat4 viewMatrix; uniform vec3 cameraPosition;


[name]( [param:WebGLRenderer renderer], [param:Object code], [param:Material material], [param:Object parameters] )

For parameters see [page:WebGLRenderer WebGLRenderer]


[property:String id]

[property:String code]

[property:Integer usedTimes]

[property:Object program]

[property:WebGLShader vertexShader]

[property:WebGLShader fragmentShader]


[method:Object getUniforms]()

Returns a name-value mapping of all active uniform locations.

[method:Object getAttributes]()

Returns a name-value mapping of all active vertex attribute locations.


[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]