|
@@ -20,8 +20,8 @@
|
|
<code>
|
|
<code>
|
|
uniforms: {
|
|
uniforms: {
|
|
time: { value: 1.0 },
|
|
time: { value: 1.0 },
|
|
- resolution: new THREE.Uniform(new THREE.Vector2())
|
|
|
|
- }
|
|
|
|
|
|
+ resolution: new Uniform( new Vector2() )
|
|
|
|
+ };
|
|
</code>
|
|
</code>
|
|
|
|
|
|
<h2>Uniform types</h2>
|
|
<h2>Uniform types</h2>
|
|
@@ -186,6 +186,63 @@
|
|
(*) Same for an (innermost) array (dimension) of the same GLSL type, containing the components of all vectors or matrices in the array.
|
|
(*) Same for an (innermost) array (dimension) of the same GLSL type, containing the components of all vectors or matrices in the array.
|
|
</p>
|
|
</p>
|
|
|
|
|
|
|
|
+ <h2>Structured Uniforms</h2>
|
|
|
|
+
|
|
|
|
+ <p>
|
|
|
|
+ Sometimes you want to organize uniforms as *structs* in your shader code. The following style must be used so *three.js* is able
|
|
|
|
+ to process structured uniform data.
|
|
|
|
+ </p>
|
|
|
|
+ <code>
|
|
|
|
+ uniforms = {
|
|
|
|
+ data: {
|
|
|
|
+ value: {
|
|
|
|
+ position: new Vector3(),
|
|
|
|
+ direction: new Vector3( 0, 0, 1 )
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ </code>
|
|
|
|
+ This definition can be mapped on the following GLSL code:
|
|
|
|
+ <code>
|
|
|
|
+ struct Data {
|
|
|
|
+ vec3 position;
|
|
|
|
+ vec3 direction;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ uniform Data data;
|
|
|
|
+ </code>
|
|
|
|
+
|
|
|
|
+ <h2>Structured Uniforms with Arrays</h2>
|
|
|
|
+
|
|
|
|
+ <p>
|
|
|
|
+ It's also possible to manage *structs* in arrays. The syntax for this use case looks like so:
|
|
|
|
+ </p>
|
|
|
|
+ <code>
|
|
|
|
+ var entry1 = {
|
|
|
|
+ position: new Vector3(),
|
|
|
|
+ direction: new Vector3( 0, 0, 1 )
|
|
|
|
+ };
|
|
|
|
+ var entry2 = {
|
|
|
|
+ position: new Vector3( 1, 1, 1 ),
|
|
|
|
+ direction: new Vector3( 0, 1, 0 )
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ uniforms = {
|
|
|
|
+ data: {
|
|
|
|
+ value: [ entry1, entry2 ]
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ </code>
|
|
|
|
+ This definition can be mapped on the following GLSL code:
|
|
|
|
+ <code>
|
|
|
|
+ struct Data {
|
|
|
|
+ vec3 position;
|
|
|
|
+ vec3 direction;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ uniform Data data[ 2 ];
|
|
|
|
+ </code>
|
|
|
|
+
|
|
<h2>Constructor</h2>
|
|
<h2>Constructor</h2>
|
|
|
|
|
|
<h3>[name]( [param:Object value] )</h3>
|
|
<h3>[name]( [param:Object value] )</h3>
|