File: WebGLProgram.html

package info (click to toggle)
three.js 111%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 15,184 kB
  • sloc: javascript: 133,174; makefile: 24; sh: 1
file content (149 lines) | stat: -rw-r--r-- 3,254 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<base href="../../../../" />
		<script src="list.js"></script>
		<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 Geometry and 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_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>
		</div>

		<h3>Fragment shader:</h3>
		<div>
		<code>
		uniform mat4 viewMatrix;
		uniform vec3 cameraPosition;
		</code>
		</div>


		<h2>Constructor</h2>

		<h3>[name]( [param:WebGLRenderer renderer], [param:Object code], [param:Material material], [param:Object parameters] )</h3>
		<p>For parameters see [page:WebGLRenderer WebGLRenderer]</p>

		<h2>Properties</h2>

		<h3>[property:String id]</h3>
		<p></p>

		<h3>[property:String code]</h3>
		<p></p>

		<h3>[property:Integer usedTimes]</h3>
		<p></p>

		<h3>[property:Object program]</h3>
		<p></p>

		<h3>[property:WebGLShader vertexShader]</h3>
		<p></p>

		<h3>[property:WebGLShader fragmentShader]</h3>
		<p></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>

		<h2>Source</h2>

		<p>
			[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
		</p>
	</body>
</html>