finishing matrix

pull/14/head
Patricio Gonzalez Vivo 9 years ago
parent 3163df5f01
commit 28d7613843

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 38 KiB

@ -2,11 +2,9 @@
### Translate
![](translate.jpg)
In the previous chapter we learned how to make some shapes - the trick to moving those shapes is to move the coordinate system itself. We can achieve that by simply adding a vector to the ```st``` variable that contains the location of each fragment. This causes the whole space coordinate system to move.
![](translate-space.jpg)
![](translate.jpg)
This is easier to see than to explain, so to see for yourself:
@ -22,7 +20,7 @@ Now try the following exercise:
To rotate objects we also need to move the entire space system. For that we are going to use a [matrix](http://en.wikipedia.org/wiki/Matrix_%28mathematics%29). A matrix is an organized set of numbers in columns and rows. Vectors are multiplied by matrices following a precise set of rules in order to modify the values of the vector in a particular way.
![](matrixes.png)
[![Wikipedia entry for Matrix (mathematics) ](matrixes.png)](https://en.wikipedia.org/wiki/Matrix)
GLSL has native support for two, three and four dimensional matrices: [```mat2```](../glossary/index.html#mat2.md) (2x2), [```mat3```](../glossary/index.html#mat3.md) (3x3) and [```mat4```](../glossary/index.html#mat4.md) (4x4). GLSL also supports matrix multiplication (```*```) and a matrix specific function ([```matrixCompMult()```](../glossary/index.html#matrixCompMult.md)).
@ -32,9 +30,9 @@ Based on how matrices behave it's possible to construct matrices to produce spec
More interestingly, we can use a matrix to rotate the coordinate system:
![](2drotmat.png)
![](rotmat.png)
Take a look at the following code for a function that constructs a 2D rotation matrix. This function follows the above [formula](http://en.wikipedia.org/wiki/Rotation_matrix) to rotate the coordinates around the ```vec2(0.0)``` point.
Take a look at the following code for a function that constructs a 2D rotation matrix. This function follows the above [formula](http://en.wikipedia.org/wiki/Rotation_matrix) for two dimentional vectors to rotate the coordinates around the ```vec2(0.0)``` point.
```glsl
mat2 rotate2d(float _angle){
@ -47,7 +45,7 @@ According to the way we've been drawing shapes, this is not exactly what we want
![](rotate.jpg)
That will looks like the following code:
That looks like the following code:
<div class="codeAndCanvas" data="cross-rotate.frag"></div>
@ -63,7 +61,7 @@ Try the following exercises:
We've seen how matrices are used to translate and rotate objects in space. (Or more precisely to transform the coordinate system to rotate and move the objects.) If you've used 3D modeling software or the push and pop matrix functions in Processing, you will know that matrices can also be used to scale the size of an object.
![](3dscalemat.png)
![](scale.png)
Following the previous formula, we can figure out how to make a 2D scaling matrix:
@ -98,4 +96,4 @@ The following code is an interesting opportunity to use matrix operations in GLS
As you can see we are treating colors as vectors by multiplying them with matrices. In that way we “move” the values around.
In this chapter we have learn about how to use matrix transformation to move, rotate and scale vectors. This will be esential to compose shapes like the once we learn to do in the previus chapter. On our next step we will apply all what we have learn to make beatiful procedural patterns. You will find that coding repetition and variation can be an exciting practice.
In this chapter we've learned how to use matrix transformations to move, rotate and scale vectors. These transformations will be essential for making compositions out of the shapes we learned about in the previous chapter. In the next chapter we'll apply all we've learned to make beautiful procedural patterns. You will find that coding repetition and variation can be an exciting practice.

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 171 KiB

@ -0,0 +1,9 @@
## GL_ES
### Declaration / Example
### Parameters
### Description
### See Also

@ -2,6 +2,61 @@
## By theme
* TYPES
[void](index.html#void.md)
[bool](index.html#bool.md)
[int](index.html#int.md)
[float](index.html#float.md)
[bvec2](index.html#bvec2.md)
[bvec3](index.html#bvec3.md)
[bvec4](index.html#bvec4.md)
[ivec2](index.html#ivec2.md)
[ivec3](index.html#ivec3.md)
[ivec4](index.html#ivec4.md)
[vec2](index.html#vec2.md)
[vec3](index.html#vec3.md)
[vec4](index.html#vec4.md)
[mat2](index.html#mat2.md)
[mat3](index.html#mat3.md)
[mat4](index.html#mat4.md)
[sampler2D](index.html#sampler2D.md)
[samplerCube](index.html#samplerCube.md)
[struct](index.html#struct.md)
* QUALIFIERS
[attribute](index.html#attribute.md)
[const](index.html#const.md)
[uniform](index.html#uniform.md)
[varying](index.html#varying.md)
[precision](index.html#precision.md)
[highp](index.html#highp.md)
[mediump](index.html#mediump.md)
[lowp](index.html#lowp.md)
[in](index.html#in.md)
[out](index.html#out.md)
[inout](index.html#inout.md)
* BUILT-IN VARIABLES
[gl_Position](index.html#gl_Position.md)
[gl_PointSize](index.html#gl_PointSize.md)
[gl_PointCoord](index.hmtl#gl_PointCoord.md)
[gl_FrontFacing](index.html#gl_FrontFacing.md)
[gl_FragCoord](index.html#gl_FragCoord.md)
[gl_FragColor](index.html#gl_FragColor.md)
* BUILT-IN CONSTANTS
[gl_MaxVertexAttribs](index.html#gl_MaxVertexAttribs.md)
[gl_MaxVaryingVectors](index.html#gl_MaxVaryingVectors.md)
[gl_MaxVertexTextureImageUnits](index.html#gl_MaxVertexTextureImageUnits.md)
[gl_MaxCombinedTextureImageUnits](index.html#gl_MaxCombinedTextureImageUnits.md)
[gl_MaxTextureImageUnits](index.html#gl_MaxTextureImageUnits.md)
[gl_MaxFragmentUniformVectors](index.html#gl_MaxFragmentUniformVectors.md)
[gl_MaxDrawBuffers](index.html#gl_MaxDrawBuffers.md)
* ANGLE & TRIGONOMETRY FUNCTIONS
[radians()](index.html#radians.md)
@ -80,17 +135,28 @@
[any()](index.html#any.md)
[asin()](index.html#asin.md)
[atan()](index.html#atan.md)
[attribute](index.html#attribute.md)
* B
[bool](index.html#bool.md)
[bvec2](index.html#bvec2.md)
[bvec3](index.html#bvec3.md)
[bvec4](index.html#bvec4.md)
* C
[ceil()](index.html#ceil.md)
[clamp()](index.html#clamp.md)
[const](index.html#const.md)
[cos()](index.html#cos.md)
[cross()](index.html#cross.md)
* D
[degrees()](index.html#degrees.md)
[dFdx()](index.html#dFdx.md)
[dFdy()](index.html#dFdy.md)
[distance()](index.html#distance.md)
[dot()](index.html#dot.md)
@ -103,6 +169,7 @@
* F
[faceforward()](index.html#faceforward.md)
[float](index.html#float.md)
[floor()](index.html#floor.md)
[fract()](index.html#fract.md)
@ -110,10 +177,33 @@
[greaterThan()](index.html#greaterThan.md)
[greaterThanEqual()](index.html#greaterThanEqual.md)
[gl_FragColor](index.html#gl_FragColor.md)
[gl_FragCoord](index.html#gl_FragCoord.md)
[gl_FrontFacing](index.html#gl_FrontFacing.md)
[gl_PointCoord](index.hmtl#gl_PointCoord.md)
[gl_PointSize](index.html#gl_PointSize.md)
[gl_Position](index.html#gl_Position.md)
[gl_MaxCombinedTextureImageUnits](index.html#gl_MaxCombinedTextureImageUnits.md)
[gl_MaxDrawBuffers](index.html#gl_MaxDrawBuffers.md)
[gl_MaxFragmentUniformVectors](index.html#gl_MaxFragmentUniformVectors.md)
[gl_MaxVaryingVectors](index.html#gl_MaxVaryingVectors.md)
[gl_MaxVertexAttribs](index.html#gl_MaxVertexAttribs.md)
[gl_MaxVertexTextureImageUnits](index.html#gl_MaxVertexTextureImageUnits.md)
[gl_MaxTextureImageUnits](index.html#gl_MaxTextureImageUnits.md)
* H
[highp](index.html#highp.md)
* I
[in](index.html#in.md)
[inout](index.html#inout.md)
[int](index.html#int.md)
[inversesqrt()](index.html#inversesqrt.md)
[ivec2](index.html#ivec2.md)
[ivec3](index.html#ivec3.md)
[ivec4](index.html#ivec4.md)
* L
@ -122,11 +212,16 @@
[lessThanEqual()](index.html#lessThanEqual.md)
[log()](index.html#log.md)
[log2()](index.html#log2.md)
[lowp](index.html#lowp.md)
* M
[matrixCompMult()](index.html#matrixCompMult.md)
[mat2](index.html#mat2.md)
[mat3](index.html#mat3.md)
[mat4](index.html#mat4.md)
[max()](index.html#max.md)
[mediump](index.html#mediump.md)
[min()](index.html#min.md)
[mix()](index.html#mix.md)
[mod()](index.html#mod.md)
@ -137,8 +232,13 @@
[not()](index.html#not.md)
[notEqual()](index.html#notEqual.md)
* O
[out](index.html#out.md)
* P
[precision](index.html#precision.md)
[pow()](index.html#pow.md)
* R
@ -149,14 +249,29 @@
* S
[sampler2D](index.html#sampler2D.md)
[samplerCube](index.html#samplerCube.md)
[sign()](index.html#sign.md)
[sin()](index.html#sin.md)
[smoothstep()](index.html#smoothstep.md)
[sqrt()](index.html#sqrt.md)
[step()](index.html#step.md)
[struct](index.html#struct.md)
* T
[tan()](index.html#tan.md)
[texture2D()](index.html#texture2D.md)
[textureCube()](index.html#textureCube.md)
* U
[uniform](index.html#uniform.md)
* V
[varying](index.html#varying.md)
[vec2](index.html#vec2.md)
[vec3](index.html#vec3.md)
[vec4](index.html#vec4.md)
[void](index.html#void.md)

@ -0,0 +1,15 @@
## Attribute
Vertex attribute data.
### Example
```glsl
attribute vec4 v_color;
```
### Description
```attribute``` read-only variables containing data shared from WebGL/OpenGL environment to the vertex shader.
Because the vertex shader is executed one time for each vertex, attributes are specify per vertex data typically with information such as: space position, color, normal direction and texture coordinates of a vertex.
### See Also
[const](index.html#const.md), [uniform](index.html#uniform.md), [varying](index.html#varying.md), [Chapter 03: Uniforms](.../03/)

@ -0,0 +1,15 @@
## Bool
Boolean variable type
### Declaration
```glsl
bool aBool = true;
bool bBool = bool(aInt);
bool cBool = bool(aFloat);
```
### Description
```bool``` data type is either true or false.
### See Also
[void](index.html#void.md), [bool](index.html#bool.md), [int](index.html#int.md), [float](index.html#float.md), [bvec2](index.html#bvec2.md), [bvec3](index.html#bvec3.md), [bvec4](index.html#bvec4.md), [struct](index.html#struct.md)

@ -0,0 +1,21 @@
## Bvec2
2 dimentional boolean vector
### Declaration
```glsl
bvec2 aBvec2 = bvec2(true, true);
bvec2 bBvec2 = bvec2(true);
bvec2 cBvec2 = bvec2(aBvec3);
bvec2 dBvec2 = bvec2(aBvec3.x, aBvec3.y);
```
### Description
```bvec2``` is a boolean vectors with two components. Can be initialize by:
- Providing a scalar value for each component.
- Providing one scalar value. This value is used for all components.
- Providing a vector of higher dimension. The respective values are used to initialize the components.
### See Also
[bool](index.html#bool.md), [int](index.html#int.md), [float](index.html#float.md), [bvec2](index.html#bvec2.md), [bvec3](index.html#bvec3.md), [bvec4](index.html#bvec4.md), [ivec2](index.html#ivec2.md), [ivec3](index.html#ivec3.md), [ivec4](index.html#ivec4.md), [vec2](index.html#vec2.md), [vec3](index.html#vec3.md), [vec4](index.html#vec4.md), [mat2](index.html#mat2.md), [mat3](index.html#mat3.md), [mat4](index.html#mat4.md)

@ -0,0 +1,25 @@
## Bvec3
3 dimentional boolean vector
### Declaration
```glsl
vec3 aBvec3 = bvec3(true, true, true);
vec3 bBvec3 = bvec3(true);
vec3 cBvec3 = bvec3(aBvec4);
vec3 dBvec3 = bvec3(aBvec4.x, aBvec4.y, aBvec4.z);
vec3 eBvec3 = bvec3(aBvec2, aBool);
vec3 fBvec3 = bvec3(aBvec2.x, aBvec2.y, aBool);
```
### Description
```bvec3``` is a boolean vectors with three components. Can be initialize by:
- Providing a scalar value for each component.
- Providing one scalar value. This value is used for all components.
- Providing a vector of higher dimension. The respective values are used to initialize the components.
- Providing a combination of vectors and/or scalars. The respective values are used to initialize the vector. The arguments of the constructor must have at least as many components as the vector that is initialized.
### See Also
[bool](index.html#bool.md), [int](index.html#int.md), [float](index.html#float.md), [bvec2](index.html#bvec2.md), [bvec3](index.html#bvec3.md), [bvec4](index.html#bvec4.md), [ivec2](index.html#ivec2.md), [ivec3](index.html#ivec3.md), [ivec4](index.html#ivec4.md), [vec2](index.html#vec2.md), [vec3](index.html#vec3.md), [vec4](index.html#vec4.md), [mat2](index.html#mat2.md), [mat3](index.html#mat3.md), [mat4](index.html#mat4.md)

@ -0,0 +1,21 @@
## Bvec4
4 dimentional boolean vector
### Declaration
```glsl
vec4 aBvec4 = bvec4(true, true, true, true);
vec4 bBvec4 = bvec4(true);
vec4 cBvec4 = bvec4(aBvec2, aBool, aBvec3);
vec4 dBvec4 = bvec4(aBvec2.x, aBvec2.y, aBool, aBvec3.x);
```
### Description
```bvec4``` is a boolean vectors with four components. Can be initialize by:
- Providing a scalar value for each component.
- Providing one scalar value. This value is used for all components.
- Providing a combination of vectors and scalars. The respective values are used to initialize the components. The arguments of the constructor must have at least as many components as the vector that is initialized.
### See Also
[bool](index.html#bool.md), [int](index.html#int.md), [float](index.html#float.md), [bvec2](index.html#bvec2.md), [bvec3](index.html#bvec3.md), [bvec4](index.html#bvec4.md), [ivec2](index.html#ivec2.md), [ivec3](index.html#ivec3.md), [ivec4](index.html#ivec4.md), [vec2](index.html#vec2.md), [vec3](index.html#vec3.md), [vec4](index.html#vec4.md), [mat2](index.html#mat2.md), [mat3](index.html#mat3.md), [mat4](index.html#mat4.md)

@ -0,0 +1,13 @@
## Const
Constant qualifier
### Example
```glsl
const float PI = 3.14159265359;
```
### Description
```const``` qualifier can be applied to the declaration of any variable to specify that its value will not be changed.
### See also
[attribute](index.html#attribute.md), [uniform](index.html#uniform.md), [varying](index.html#varying.md)

@ -0,0 +1,16 @@
## DFdx
Return the partial derivative of an argument with respect to x
### Declaration
```glsl
genType dFdx(float x);
```
### Parameters
```p``` specifies the expression of which to take the partial derivative.
### Description
Available only in the fragment shader, ```dFdx``` return the partial derivative of expression ```p``` in ```x```. Deviatives are calculated using local differencing. Expressions that imply higher order derivatives such as ```dFdx(dFdx(n))``` have undefined results, as do mixed-order derivatives such as ```dFdx(dFdy(n))```. It is assumed that the expression ```p``` is continuous and therefore, expressions evaluated via non-uniform control flow may be undefined.
### See Also
[dFdy()](index.html#dFdy.md)

@ -0,0 +1,16 @@
## DFdy
Return the partial derivative of an argument with respect to y
### Declaration
```glsl
genType dFdy(float y);
```
### Parameters
```p``` specifies the expression of which to take the partial derivative.
### Description
Available only in the fragment shader, ```dFdy``` return the partial derivative of expression ```p``` in ```y```. Deviatives are calculated using local differencing. Expressions that imply higher order derivatives such as ```dFdy(dFdy(n))``` have undefined results, as do mixed-order derivatives such as ```dFdy(dFdx(n))```. It is assumed that the expression ```p``` is continuous and therefore, expressions evaluated via non-uniform control flow may be undefined.
### See Also
[dFdx()](index.html#dFdx.md)

@ -20,5 +20,4 @@ vec4 faceforward(vec4 N, vec4 I, vec4 Nref)
```faceforward()``` orients a vector to point away from a surface as defined by its normal. ```If dot(Nref, I) < 0``` faceforward returns ```N```, otherwise it returns ```-N```.
### See Also
[reflect()](index.html#reflect.md), [refract()](index.html#refract.md)

@ -0,0 +1,15 @@
## Float
Floating-point variable type
### Declaration
```glsl
float aFloat = 1.0;
float bFloat = float(aBool);
float cFloat = float(aInt);
```
### Description
```float``` is used for floating point values.
### See Also
[void](index.html#void.md), [bool](index.html#bool.md), [int](index.html#int.md), [float](index.html#float.md), [bvec2](index.html#bvec2.md), [bvec3](index.html#bvec3.md), [bvec4](index.html#bvec4.md), [struct](index.html#struct.md)

@ -0,0 +1,9 @@
## Gl_FragColor
### Declaration / Example
### Parameters
### Description
### See Also

@ -0,0 +1,9 @@
## G_FragCoord
### Declaration / Example
### Parameters
### Description
### See Also

@ -0,0 +1,9 @@
## Gl_FrontFacing
### Declaration / Example
### Parameters
### Description
### See Also

@ -0,0 +1,9 @@
## Gl_MaxCombinedTextureImages
### Declaration / Example
### Parameters
### Description
### See Also

@ -0,0 +1,9 @@
## Gl_MaxDrawBuffers
### Declaration / Example
### Parameters
### Description
### See Also

@ -0,0 +1,9 @@
## Gl_MaxFragmentUniformVectors
### Declaration / Example
### Parameters
### Description
### See Also

@ -0,0 +1,9 @@
## Gl_MaxTextureImageUnits
### Declaration / Example
### Parameters
### Description
### See Also

@ -0,0 +1,9 @@
## Gl_MaxVaryingVectors
### Declaration / Example
### Parameters
### Description
### See Also

@ -0,0 +1,9 @@
## Gl_MaxVertexAttrbis
### Declaration / Example
### Parameters
### Description
### See Also

@ -0,0 +1,9 @@
## Gl_MaxVertexTextureImageUnits
### Declaration / Example
### Parameters
### Description
### See Also

@ -0,0 +1,9 @@
## Gl_PointCoord
### Declaration / Example
### Parameters
### Description
### See Also

@ -0,0 +1,9 @@
## Gl_PointSize
### Declaration / Example
### Parameters
### Description
### See Also

@ -0,0 +1,9 @@
## Gl_Position
### Declaration / Example
### Parameters
### Description
### See Also

@ -0,0 +1,9 @@
## Highp
### Declaration / Example
### Parameters
### Description
### See Also

@ -0,0 +1,9 @@
## In
### Declaration / Example
### Parameters
### Description
### See Also

@ -0,0 +1,9 @@
## Inout
### Declaration / Example
### Parameters
### Description
### See Also

@ -0,0 +1,15 @@
## Int
Integer data type
### Declaration
```glsl
int aInt = 42;
int bInt = int(aBool);
int cInt = int(aFloat);
```
### Description
```int``` is used for integer values.
### See Also
[void](index.html#void.md), [bool](index.html#bool.md), [int](index.html#int.md), [float](index.html#float.md), [ivec2](index.html#ivec2.md), [ivec3](index.html#ivec3.md), [ivec4](index.html#ivec4.md)

@ -0,0 +1,21 @@
## Ivec2
2 dimentional integer vector
### Declaration
```glsl
bvec2 aIvec2 = ivec2(1, 1);
bvec2 bIvec2 = ivec2(1);
bvec2 cIvec2 = ivec2(aIvec3);
bvec2 dIvec2 = ivec2(aIvec3.x, aIvec3.y);
```
### Description
```ivec2``` is a integer vectors with two components. Can be initialize by:
- Providing a scalar value for each component.
- Providing one scalar value. This value is used for all components.
- Providing a vector of higher dimension. The respective values are used to initialize the components.
### See Also
[bool](index.html#bool.md), [int](index.html#int.md), [float](index.html#float.md), [bvec2](index.html#bvec2.md), [bvec3](index.html#bvec3.md), [bvec4](index.html#bvec4.md), [ivec2](index.html#ivec2.md), [ivec3](index.html#ivec3.md), [ivec4](index.html#ivec4.md), [vec2](index.html#vec2.md), [vec3](index.html#vec3.md), [vec4](index.html#vec4.md), [mat2](index.html#mat2.md), [mat3](index.html#mat3.md), [mat4](index.html#mat4.md)

@ -0,0 +1,25 @@
## Ivec3
3 dimentional integer vector
### Declaration
```glsl
vec3 aIvec3 = ivec3(1, 1, 1);
vec3 bIvec3 = ivec3(1);
vec3 cIvec3 = ivec3(aIvec4);
vec3 dIvec3 = ivec3(aIvec4.x, aIvec4.y, aIvec4.z);
vec3 eIvec3 = ivec3(aIvec2, aInt);
vec3 fIvec3 = ivec3(aIvec2.x, aIvec2.y, aInt);
```
### Description
```ivec3``` is a integer vectors with three components. Can be initialize by:
- Providing a scalar value for each component.
- Providing one scalar value. This value is used for all components.
- Providing a vector of higher dimension. The respective values are used to initialize the components.
- Providing a combination of vectors and/or scalars. The respective values are used to initialize the vector. The arguments of the constructor must have at least as many components as the vector that is initialized.
### See Also
[bool](index.html#bool.md), [int](index.html#int.md), [float](index.html#float.md), [bvec2](index.html#bvec2.md), [bvec3](index.html#bvec3.md), [bvec4](index.html#bvec4.md), [ivec2](index.html#ivec2.md), [ivec3](index.html#ivec3.md), [ivec4](index.html#ivec4.md), [vec2](index.html#vec2.md), [vec3](index.html#vec3.md), [vec4](index.html#vec4.md), [mat2](index.html#mat2.md), [mat3](index.html#mat3.md), [mat4](index.html#mat4.md)

@ -0,0 +1,21 @@
## Ivec4
4 dimentional integer vector
### Declaration
```glsl
vec4 aIvec4 = ivec4(1, 1, 1, 1);
vec4 bIvec4 = ivec4(1);
vec4 cIvec4 = ivec4(aIvec2, aInteger, aIvec3);
vec4 dIvec4 = ivec4(aIvec2.x, aIvec2.y, aInt, aIvec3.x);
```
### Description
```ivec4``` is a integer vectors with four components. Can be initialize by:
- Providing a scalar value for each component.
- Providing one scalar value. This value is used for all components.
- Providing a combination of vectors and/or scalars. The respective values are used to initialize the vector. The arguments of the constructor must have at least as many components as the vector that is initialized.
### See Also
[bool](index.html#bool.md), [int](index.html#int.md), [float](index.html#float.md), [bvec2](index.html#bvec2.md), [bvec3](index.html#bvec3.md), [bvec4](index.html#bvec4.md), [ivec2](index.html#ivec2.md), [ivec3](index.html#ivec3.md), [ivec4](index.html#ivec4.md), [vec2](index.html#vec2.md), [vec3](index.html#vec3.md), [vec4](index.html#vec4.md), [mat2](index.html#mat2.md), [mat3](index.html#mat3.md), [mat4](index.html#mat4.md)

@ -0,0 +1,9 @@
## Lowp
### Declaration / Example
### Parameters
### Description
### See Also

@ -0,0 +1,9 @@
## Main
### Declaration / Example
### Parameters
### Description
### See Also

@ -0,0 +1,9 @@
## Mediump
### Declaration / Example
### Parameters
### Description
### See Also

@ -0,0 +1,9 @@
## Out
### Declaration / Example
### Parameters
### Description
### See Also

@ -0,0 +1,9 @@
## Precision
### Declaration / Example
### Parameters
### Description
### See Also

@ -0,0 +1,9 @@
## Return
### Declaration / Example
### Parameters
### Description
### See Also

@ -0,0 +1,9 @@
## Sampler2D
### Declaration / Example
### Parameters
### Description
### See Also

@ -0,0 +1,9 @@
## SamplerCube
### Declaration / Example
### Parameters
### Description
### See Also

@ -0,0 +1,20 @@
## Struct
Structure variable type
### Example
```glsl
struct matStruct {
vec4 ambientColor;
vec4 diffuseColor;
vec4 specularColor;
float specularExponent;
} newMaterial;
newMaterial = matStruct(vec4(0.1, 0.1, 0.1, 1.0),
vec4(1.0, 0.0, 0.0, 1.0),
vec4(0.7, 0.7, 0.7, 1.0),
50.0);
```
### Description
```struct``` declare a custom data structures based on standard types. A constructor for the structure with the same name is created automatically. The declaration of a variable (in this case "newMaterial") is optional.

@ -1,4 +1,10 @@
## Uniform
### See
### Declaration / Example
### Parameters
### Description
### See Also
[Chapter 03: Uniforms](../05/)

@ -0,0 +1,9 @@
## Varying
### Declaration / Example
### Parameters
### Description
### See Also

@ -0,0 +1,21 @@
## Vec2
2 dimentional float point vector
### Declaration
```glsl
vec2 aVec2 = vec2(1.0, 1.0);
vec2 bVec2 = vec2(1.0);
vec2 cVec2 = vec2(aVec3);
vec2 dVec2 = vec2(aVec3.x, aVec3.y);
```
### Description
```vec2``` is a float point vectors with two components. Can be initialize by:
- Providing a scalar value for each component.
- Providing one scalar value. This value is used for all components.
- Providing a vector of higher dimension. The respective values are used to initialize the components.
### See Also
[bool](index.html#bool.md), [int](index.html#int.md), [float](index.html#float.md), [bvec2](index.html#bvec2.md), [bvec3](index.html#bvec3.md), [bvec4](index.html#bvec4.md), [ivec2](index.html#ivec2.md), [ivec3](index.html#ivec3.md), [ivec4](index.html#ivec4.md), [vec2](index.html#vec2.md), [vec3](index.html#vec3.md), [vec4](index.html#vec4.md), [mat2](index.html#mat2.md), [mat3](index.html#mat3.md), [mat4](index.html#mat4.md)

@ -0,0 +1,25 @@
## Vec3
3 dimentional floating point vector
### Declaration
```glsl
vec3 aVec3 = vec3(1.0, 1.0, 1.0);
vec3 bVec3 = vec3(1.0);
vec3 cVec3 = vec3(aVec4);
vec3 dVec3 = vec3(aVec4.x, aVec4.y, aVec4.z);
vec3 eVec3 = vec3(aVec2, aFloat);
vec3 fVec3 = vec3(aVec2.x, aVec2.y, aFloat);
```
### Description
```bvec3``` is a floating point vectors with three components. Can be initialize by:
- Providing a scalar value for each component.
- Providing one scalar value. This value is used for all components.
- Providing a vector of higher dimension. The respective values are used to initialize the components.
- Providing a combination of vectors and/or scalars. The respective values are used to initialize the vector. The arguments of the constructor must have at least as many components as the vector that is initialized.
### See Also
[bool](index.html#bool.md), [int](index.html#int.md), [float](index.html#float.md), [bvec2](index.html#bvec2.md), [bvec3](index.html#bvec3.md), [bvec4](index.html#bvec4.md), [ivec2](index.html#ivec2.md), [ivec3](index.html#ivec3.md), [ivec4](index.html#ivec4.md), [vec2](index.html#vec2.md), [vec3](index.html#vec3.md), [vec4](index.html#vec4.md), [mat2](index.html#mat2.md), [mat3](index.html#mat3.md), [mat4](index.html#mat4.md)

@ -0,0 +1,21 @@
## Vec4
4 dimentional floating point vector
### Declaration
```glsl
vec4 aBvec4 = bvec4(true, true, true, true);
vec4 bBvec4 = bvec4(true);
vec4 cBvec4 = bvec4(aBvec2, aBool, aBvec3);
vec4 dBvec4 = bvec4(aBvec2.x, aBvec2.y, aBool, aBvec3.x);
```
### Description
```bvec4``` is a floating point vectors with four components. Can be initialize by:
- Providing a scalar value for each component.
- Providing one scalar value. This value is used for all components.
- Providing a combination of vectors and scalars. The respective values are used to initialize the components. The arguments of the constructor must have at least as many components as the vector that is initialized.
### See Also
[bool](index.html#bool.md), [int](index.html#int.md), [float](index.html#float.md), [bvec2](index.html#bvec2.md), [bvec3](index.html#bvec3.md), [bvec4](index.html#bvec4.md), [ivec2](index.html#ivec2.md), [ivec3](index.html#ivec3.md), [ivec4](index.html#ivec4.md), [vec2](index.html#vec2.md), [vec3](index.html#vec3.md), [vec4](index.html#vec4.md), [mat2](index.html#mat2.md), [mat3](index.html#mat3.md), [mat4](index.html#mat4.md)

@ -0,0 +1,14 @@
## Void
### Declaration
```glsl
void main(void);
int aFunction(void);
void bFunction(float);
```
### Description
```void``` is used when a function have no parameters or when a function does not return a value.
### See Also
[void](index.html#void.md), [bool](index.html#bool.md), [int](index.html#int.md), [float](index.html#float.md)
Loading…
Cancel
Save