# Book of Shaders

[🏠 Home](../README.md) > [Book of Shaders](./book-of-shaders.md)

**Documents:** 117 | **Avg Quality:** 95%

---

## Contents

- **Appendix** (1 entries)
- **Chapter 00** (1 entries)
- **Chapter 01** (1 entries)
- **Chapter 02** (1 entries)
- **Chapter 03** (1 entries)
- **Chapter 04** (1 entries)
- **Chapter 05** (1 entries)
- **Chapter 06** (1 entries)
- **Chapter 07** (1 entries)
- **Chapter 08** (1 entries)
- **Chapter 09** (1 entries)
- **Chapter 10** (1 entries)
- **Chapter 11** (1 entries)
- **Chapter 12** (1 entries)
- **Chapter 13** (1 entries)
- **Chapter 14** (1 entries)
- **Chapter 15** (1 entries)
- **Chapter 16** (1 entries)
- **Chapter 17** (1 entries)
- **Chapter 18** (1 entries)
- **Examples** (1 entries)
- **Glossary Index** (1 entries)
- **Abs** (1 entry)
- **Acos** (1 entry)
- **All** (1 entry)
- **Any** (1 entry)
- **Asin** (1 entry)
- **Atan** (1 entry)
- **Attribute** (1 entry)
- **Bool** (1 entry)
- **Bvec2** (1 entry)
- **Bvec3** (1 entry)
- **Bvec4** (1 entry)
- **Ceil** (1 entry)
- **Clamp** (1 entry)
- **Const** (1 entry)
- **Cos** (1 entry)
- **Cross** (1 entry)
- **Degrees** (1 entry)
- **Dfdx** (1 entry)
- **Dfdy** (1 entry)
- **Distance** (1 entry)
- **Dot** (1 entry)
- **Equal** (1 entry)
- **Exp** (1 entry)
- **Exp2** (1 entry)
- **Faceforward** (1 entry)
- **Float** (1 entry)
- **Floor** (1 entry)
- **Fract** (1 entry)
- **Gl_Es** (1 entry)
- **Gl_Fragcolor** (1 entry)
- **Gl_Fragcoord** (1 entry)
- **Gl_Frontfacing** (1 entry)
- **Gl_Maxcombinedtextureimageunits** (1 entry)
- **Gl_Maxdrawbuffers** (1 entry)
- **Gl_Maxfragmentuniformvectors** (1 entry)
- **Gl_Maxtextureimageunits** (1 entry)
- **Gl_Maxvaryingvectors** (1 entry)
- **Gl_Maxvertexattribs** (1 entry)
- **Gl_Maxvertextextureimageunits** (1 entry)
- **Gl_Pointcoord** (1 entry)
- **Gl_Pointsize** (1 entry)
- **Gl_Position** (1 entry)
- **Greaterthan** (1 entry)
- **Greaterthanequal** (1 entry)
- **Highp** (1 entry)
- **In** (1 entry)
- **Inout** (1 entry)
- **Int** (1 entry)
- **Inversesqrt** (1 entry)
- **Ivec2** (1 entry)
- **Ivec3** (1 entry)
- **Ivec4** (1 entry)
- **Length** (1 entry)
- **Lessthan** (1 entry)
- **Lessthanequal** (1 entry)
- **Log** (1 entry)
- **Log2** (1 entry)
- **Lowp** (1 entry)
- **Main** (1 entry)
- **Mat2** (1 entry)
- **Mat3** (1 entry)
- **Mat4** (1 entry)
- **Matrixcompmult** (1 entry)
- **Max** (1 entry)
- **Mediump** (1 entry)
- **Min** (1 entry)
- **Mix** (1 entry)
- **Mod** (1 entry)
- **Normalize** (1 entry)
- **Not** (1 entry)
- **Notequal** (1 entry)
- **Out** (1 entry)
- **Pow** (1 entry)
- **Precision** (1 entry)
- **Radians** (1 entry)
- **Reflect** (1 entry)
- **Refract** (1 entry)
- **Return** (1 entry)
- **Sampler2D** (1 entry)
- **Samplercube** (1 entry)
- **Sign** (1 entry)
- **Sin** (1 entry)
- **Smoothstep** (1 entry)
- **Sqrt** (1 entry)
- **Step** (1 entry)
- **Struct** (1 entry)
- **Tan** (1 entry)
- **Texture2D** (1 entry)
- **Texturecube** (1 entry)
- **Uniform** (1 entry)
- **Varying** (1 entry)
- **Vec2** (1 entry)
- **Vec3** (1 entry)
- **Vec4** (1 entry)
- **Void** (1 entry)

---

### Appendix

**Appendix**

_# Appendix

1. [How can I navigate this book off-line?](00/)

2. [How to run the examples on a Raspberry Pi?](01/)

3. [How to print this book?](02/)

4. [How can I collaborate with this book?](03/)

5. [An introduction for those coming from JS](04/) by [Nicolas Barradeau](http://www.barradeau.com/)..._

🔗 [View Source](https://thebookofshaders.com/appendix/)

### Chapter 00

**Chapter 00**

_# Introduction

<canvas id="custom" class="canvas" data-fragment-url="cmyk-halftone.frag" data-textures="vangogh.jpg" width="700px" height="320px"></canvas>

The images above were made in different ways. The first one was made by Van Gogh's hand applying layer over layer of paint. It took him hours...._

🔗 [View Source](https://thebookofshaders.com/00/)

### Chapter 01

**Chapter 01**

_# Getting started
## What is a fragment shader?

In the previous chapter we described shaders as the equivalent of the Gutenberg press for graphics. Why? And more importantly: what's a shader?

![From Letter-by-Letter, Right: William Blades (1891). To Page-by-page, Left: Rolt-Wheeler (1920).](print...._

🔗 [View Source](https://thebookofshaders.com/01/)

### Chapter 02

**Chapter 02**

_## Hello World

Usually the "Hello world!" example is the first step to learning a new language. It's a simple one-line program that outputs an enthusiastic welcoming message and declares opportunities ahead.

In GPU-land rendering text is an overcomplicated task for a first step, instead we'll choo..._

🔗 [View Source](https://thebookofshaders.com/02/)

### Chapter 03

**Chapter 03**

_## Uniforms

So far we have seen how the GPU manages large numbers of parallel threads, each one responsible for assigning the color to a fraction of the total image. Although each parallel thread is blind to the others, we need to be able to send some inputs from the CPU to all the threads. Because..._

🔗 [View Source](https://thebookofshaders.com/03/)

### Chapter 04

**Chapter 04**

_## Running your shader

As part of the construction of this book and my art practice I made an ecosystem of tools to create, display, share and curate shaders. These tools work consistently across Linux, MacOS, Windows and [Raspberry Pi](https://www.raspberrypi.org/) and browsers without the need of..._

🔗 [View Source](https://thebookofshaders.com/04/)

### Chapter 05

**Chapter 05**

_# Algorithmic drawing
## Shaping functions

This chapter could be named "Mr. Miyagi's fence lesson." Previously, we mapped the normalized position of *x* and *y* to the *red* and *green* channels. Essentially we made a function that takes a two dimensional vector (x and y) and returns a four dimensi..._

🔗 [View Source](https://thebookofshaders.com/05/)

### Chapter 06

**Chapter 06**

_![Paul Klee - Color Chart (1931)](klee.jpg)

## Colors

We haven't had much of a chance to talk about GLSL vector types. Before going further it's important to learn more about these variables and the subject of colors is a great way to find out more about them.

If you are familiar with object orie..._

🔗 [View Source](https://thebookofshaders.com/06/)

### Chapter 07

**Chapter 07**

_![Alice Hubbard, Providence, United States, ca. 1892. Photo: Zindman/Freemont.](froebel.jpg)

## Shapes

Finally! We have been building skills for this moment! You have learned most of the GLSL foundations, types and functions. You have practiced your shaping equations over and over. Now is the time..._

🔗 [View Source](https://thebookofshaders.com/07/)

### Chapter 08

**Chapter 08**

_## 2D Matrices

<canvas id="custom" class="canvas" data-fragment-url="matrix.frag"  width="700px" height="200px"></canvas>

### Translate

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 sim..._

🔗 [View Source](https://thebookofshaders.com/08/)

### Chapter 09

**Chapter 09**

_## Patterns

Since shader programs are executed by pixel-by-pixel no matter how much you repeat a shape the number of calculations stays constant. This means that fragment shaders are particulary suitable for tile patterns.

[ ![Nina Warmerdam - The IMPRINT Project (2013)](warmerdam.jpg) ](../edit.p..._

🔗 [View Source](https://thebookofshaders.com/09/)

### Chapter 10

**Chapter 10**

_# Generative designs

It is not a surprise that after so much repetition and order the author is forced to bring some chaos.

## Random

[![Ryoji Ikeda - test pattern (2008) ](ryoji-ikeda.jpg) ](http://www.ryojiikeda.com/project/testpattern/#testpattern_live_set)

Randomness is a maximal expression ..._

🔗 [View Source](https://thebookofshaders.com/10/)

### Chapter 11

**Chapter 11**

_
![NASA / WMAP science team](mcb.jpg)

## Noise

It's time for a break! We've been playing with random functions that look like TV white noise, our head is still spinning thinking about shaders, and our eyes are tired. Time to go out for a walk!

We feel the air on our skin, the sun in our face. The..._

🔗 [View Source](https://thebookofshaders.com/11/)

### Chapter 12

**Chapter 12**

_![](dragonfly.jpg)

## Cellular Noise

In 1996, sixteen years after Perlin's original Noise and five years before his Simplex Noise, [Steven Worley wrote a paper called  “A Cellular Texture Basis Function”](http://www.rhythmiccanvas.com/research/papers/worley.pdf). In it, he describes a procedural t..._

🔗 [View Source](https://thebookofshaders.com/12/)

### Chapter 13

**Chapter 13**

_![Due East over Shadequarter Mountain - Matthew Rangel (2005) ](rangel.jpg)

## Fractal Brownian Motion

Noise tends to mean different things to different people. Musicians will think of it in terms of disturbing sounds, communicators as interference and astrophysicists as cosmic microwave backgroun..._

🔗 [View Source](https://thebookofshaders.com/13/)

### Chapter 14

**Chapter 14**

_## Fractals

Coming soon ...

In the meantime, you can check out some examples with fractals on the [shadertoy.com](https://www.shadertoy.com/results?query=fractals) platform:

[Basic Fractal](https://www.shadertoy.com/view/Mss3Wf)
[Mandelbrot - distance](https://www.shadertoy.com/view/lsX3W4)
[Mand..._

🔗 [View Source](https://thebookofshaders.com/14/)

### Chapter 15

**Chapter 15**

_# Image processing

## Textures

![](01.jpg)

Graphic cards (GPUs) have special memory types for images. Usually on CPUs images are stored as arrays of bytes but GPUs store images as ```sampler2D``` which is more like a table (or matrix) of floating point vectors. More interestingly, the values of t..._

🔗 [View Source](https://thebookofshaders.com/15/)

### Chapter 16

**Chapter 16**

_## Image operations

Below you will see some examples with images where you can play around and uncomment some lines to see the corresponding results.

### Invert

<div class="codeAndCanvas" data="inv.frag" data-textures="00.jpg,01.jpg"></div>

### Add, Subtract, Multiply and others

![](02.jpg)

<d..._

🔗 [View Source](https://thebookofshaders.com/16/)

### Chapter 17

**Chapter 17**

_## Kernel convolutions
..._

🔗 [View Source](https://thebookofshaders.com/17/)

### Chapter 18

**Chapter 18**

_## Filters
..._

🔗 [View Source](https://thebookofshaders.com/18/)

### Examples

**Examples**

_# Examples Gallery

<p class="gallery_author">Created by <a href="https://www.kynd.info">kynd</a>(<a href="https://twitter.com/kyndinfo">@kyndinfo</a>) and Patricio Gonzalez Vivo(<a href="https://twitter.com/patriciogv">@patriciogv</a>)</p>

This is a collection of examples extracted from the chapte..._

🔗 [View Source](https://thebookofshaders.com/examples/)

### Glossary Index

**Glossary Index**

_# Glossary

## By theme

* TYPES

[void](./?search=void)
[bool](./?search=bool)
[int](./?search=int)
[float](./?search=float)
[bvec2](./?search=bvec2)
[bvec3](./?search=bvec3)
[bvec4](./?search=bvec4)
[ivec2](./?search=ivec2)
[ivec3](./?search=ivec3)
[ivec4](./?search=ivec4)
[vec2](./?search=vec2)
[..._

🔗 [View Source](https://thebookofshaders.com/glossary/)

### Abs

## Abs
Return the absolute value of the parameter.

### Declaration
```glsl
float abs(float x)  
vec2 abs(vec2 x)  
vec3 abs(vec3 x)  
vec4 abs(vec4 x)
```

### Parameters
```x``` specifies the value of which to return the absolute.

### Description
```abs()``` returns the absolute value of ```x```.

<div class="simpleFunction" data="y = abs(x); "></div>

### See Also
[sign()](/glossary/?search=si...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=abs)

### Acos

## Acos
Return the arccosine of the parameter

### Declaration
```glsl
float acos(float x)  
vec2 acos(vec2 x)  
vec3 acos(vec3 x)  
vec4 acos(vec4 x)
```

### Parameters
```x``` specifies the value whose arccosine to return.

### Description
```acos()``` returns the angle whose trigonometric cosine is ```x```.

<div class="simpleFunction" data="y = acos(x); "></div>

### See Also
[cos()](/glossar...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=acos)

### All

## All
Check whether all elements of a boolean vector are true

### Declaration
```glsl
bool any(bvec2 x)  
bool any(bvec3 x)  
bool any(bvec4 x)
```

### Parameters
```x``` specifies the vector to be tested for truth.

### Description
```all()``` returns true if all elements of ```x``` are ```true``` and ```false``` otherwise. It is functionally equivalent to:

```glsl
bool all(bvec x){       // ...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=all)

### Any

## Any
Check whether any element of a boolean vector is true

### Declaration
```glsl
bool all(bvec2 x)  
bool all(bvec3 x)  
bool all(bvec4 x)
```

### Parameters
```x``` specifies the vector to be tested for truth.

### Description
```any()``` returns true if any element of ```x``` is ```true``` and ```false``` otherwise. It is functionally equivalent to:

```glsl
bool any(bvec x) {     // bvec ...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=any)

### Asin

## Asin
Return the arcsine of the parameter

### Declaration
```glsl
float asin(float x)  
vec2 asin(vec2 x)  
vec3 asin(vec3 x)  
vec4 asin(vec4 x)
```

### Parameters
```x``` specifies the value whose arcsine to return.

### Description
```asin()``` returns the angle whose trigonometric sine is ```x```.

<div class="simpleFunction" data="y = asin(x); "></div>

### See Also
[cos](/glossary/?searc...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=asin)

### Atan

## Atan
Return the arc-tangent of the parameters

### Declaration
```glsl
float atan(float y, float x)  
vec2 atan(vec2 y, vec2 x)  
vec3 atan(vec3 y, vec3 x)  
vec4 atan(vec4 y, vec4 x)

float atan(float y_over_x)  
vec2 atan(vec2 y_over_x)  
vec3 atan(vec3 y_over_x)  
vec4 atan(vec4 y_over_x)
```

### Parameters
```y``` specifies the numerator of the fraction whose arctangent to return.

```x```...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=atan)

### Attribute

## 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 tex...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=attribute)

### Bool

## 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](/glossary/?search=void), [bool](/glossary/?search=bool), [int](/glossary/?search=int), [float](/glossary/?search=float), [bvec2](/glossary/?search=bvec2), [bvec3](/glossary/?search=bvec3...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=bool)

### Bvec2

## Bvec2
2 dimensional 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 vector with two components. It can be initialized by:

- Providing a scalar value for each component.
- Providing one scalar value. This value is used for a...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=bvec2)

### Bvec3

## Bvec3
3 dimensional 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 vector with three components. It can be initialized by:

- ...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=bvec3)

### Bvec4

## Bvec4
4 dimensional 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 vector with four components. It can be initialized by:

- Providing a scalar value for each component.
- Providing o...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=bvec4)

### Ceil

## Ceil
Find the nearest integer that is greater than or equal to the parameter

### Declaration
```glsl
float ceil(float x)  
vec2 ceil(vec2 x)  
vec3 ceil(vec3 x)  
vec4 ceil(vec4 x)
```

### Parameters
```x``` specifies the value to evaluate.

### Description
```ceil()```  returns a value equal to the nearest integer that is greater than or equal to ```x```.

<div class="simpleFunction" data="y...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=ceil)

### Clamp

## Clamp
Constrain a value to lie between two further values

### Declaration
```glsl
float clamp(float x, float minVal, float maxVal)  
vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal)  
vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal)  
vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal)

vec2 clamp(vec2 x, float minVal, float maxVal)  
vec3 clamp(vec3 x, float minVal, float maxVal)  
vec4 clamp(vec4 x, float ...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=clamp)

### Const

## 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](/glossary/?search=attribute), [uniform](/glossary/?search=uniform), [varying](/glossary/?search=varying)
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=const)

### Cos

## Cos
Return the cosine of the parameter

### Declaration
```glsl
float cos(float angle)  
vec2 cos(vec2 angle)  
vec3 cos(vec3 angle)  
vec4 cos(vec4 angle)
```

### Parameters
```angle``` specify the quantity, in radians, of which to return the cosine.

### Description
```cos()``` returns the trigonometric cosine of angle.

<div class="simpleFunction" data="y = cos(x); "></div>

### See Also
[a...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=cos)

### Cross

## Cross
Calculate the cross product of two vectors

### Declaration
```glsl
vec3 cross(vec3 x, vec3 y)
```

### Parameters
```x``` specifies the first of two vectors

```y``` specifies the second of two vectors

### Description
```cross()``` returns the cross product of two vectors, ```x``` and ```y```. The input parameters can only be 3-component floating vectors. The cross product is equivalent...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=cross)

### Degrees

## Degrees
Convert a quantity in radians to degrees

### Declaration
```glsl
float degrees(float radians)  
vec2 degrees(vec2 radians)  
vec3 degrees(vec3 radians)  
vec4 degrees(vec4 radians)
```

### Parameters
```radians``` specifies the quantity, in radians, to be converted to degrees.

### Description
```degrees()``` converts a quantity, specified in radians into degrees. That is, the return ...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=degrees)

### Dfdx

## 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```. Derivatives are calculated using local differencing. Exp...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=dFdx)

### Dfdy

## 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```. Derivatives are calculated using local differencing. Exp...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=dFdy)

### Distance

## Distance
Calculate the distance between two points

### Declaration
```glsl
float distance(float p0, float p1)  
float distance(vec2 p0, vec2 p1)  
float distance(vec3 p0, vec3 p1)  
float distance(vec4 p0, vec4 p1)
```

### Parameters
```p0``` specifies the first of two points

```p1``` specifies the second of two points

### Description
```distance()``` returns the distance between the two po...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=distance)

### Dot

## Dot
Calculate the dot product of two vectors

### Declaration
```glsl
float dot(float x, float y)  
float dot(vec2 x, vec2 y)  
float dot(vec3 x, vec3 y)  
float dot(vec4 x, vec4 y)
```

### Parameters
```x``` specifies the first of two vectors

```y``` specifies the second of two vectors

### Description
```dot()``` returns the dot product of two vectors, ```x``` and ```y```. i.e., ```x[0]⋅y[0...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=dot)

### Equal

## Equal
Perform a component-wise equal-to comparison of two vectors

### Declaration
```glsl
bvec2 equal(vec2 x, vec2 y)  
bvec3 equal(vec3 x, vec3 y)  
bvec4 equal(vec4 x, vec4 y)  

bvec2 equal(ivec2 x, ivec2 y)  
bvec3 equal(ivec3 x, ivec3 y)  
bvec4 equal(ivec4 x, ivec4 y)
```

### Parameters
```x``` specifies the first vector to be used in the comparison operation.

```y``` specifies the sec...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=equal)

### Exp

## Exp
Return the natural exponentiation of the parameter

### Declaration
```glsl
float exp(float x)  
vec2 exp(vec2 x)  
vec3 exp(vec3 x)  
vec4 exp(vec4 x)
```

### Parameters
```x``` specifies the value to exponentiate.

### Description
```exp()``` returns the natural exponentiation of ```x```.

<div class="simpleFunction" data="y = exp(x); "></div>

### See Also

[log](/glossary/?search=log),...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=exp)

### Exp2

## Exp2
Return 2 raised to the power of the parameter

### Declaration
```glsl
float exp2(float x)  
vec2 exp2(vec2 x)  
vec3 exp2(vec3 x)  
vec4 exp2(vec4 x)
```

### Parameters
```x``` specifies the value of the power to which 2 will be raised.

### Description
```exp2()``` returns 2 raised to the power of ```x```.

<div class="simpleFunction" data="y = exp2(x); "></div>

### See Also

[log](/gl...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=exp2)

### Faceforward

## Faceforward
Return a vector pointing in the same direction as another

### Declaration
```glsl
float faceforward(float N, float I, float Nref)  
vec2 faceforward(vec2 N, vec2 I, vec2 Nref)  
vec3 faceforward(vec3 N, vec3 I, vec3 Nref)  
vec4 faceforward(vec4 N, vec4 I, vec4 Nref)
```

### Parameters
```N``` specifies the vector to orient.

```I``` specifies the incident vector.

```Nref``` spec...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=faceforward)

### Float

## 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](/glossary/?search=void), [bool](/glossary/?search=bool), [int](/glossary/?search=int), [float](/glossary/?search=float), [bvec2](/glossary/?search=bvec2), [bvec3](/glossar...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=float)

### Floor

## Floor
Find the nearest integer less than or equal to the parameter

### Declaration
```glsl
float floor(float x)  
vec2 floor(vec2 x)  
vec3 floor(vec3 x)  
vec4 floor(vec4 x)
```

### Parameters
```x``` specifies the value to evaluate.

### Description
```floor()``` returns a value equal to the nearest integer that is less than or equal to ```x```.

<div class="simpleFunction" data="y = floor(...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=floor)

### Fract

## Fract
Compute the fractional part of the argument

### Declaration
```glsl
float fract(float x)  
vec2 fract(vec2 x)  
vec3 fract(vec3 x)  
vec4 fract(vec4 x)
```

### Parameters
```x``` specifies the value to evaluate.

### Description
```fract()``` returns the fractional part of ```x```. This is calculated as ```x - floor(x)```.

<div class="simpleFunction" data="y = fract(x); "></div>

### S...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=fract)

### Gl_Es

## GL_ES

### Declaration / Example

### Parameters

### Description

### See Also
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=GL_ES)

### Gl_Fragcolor

## Gl_FragColor

### Declaration / Example

### Parameters

### Description

### See Also
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=gl_FragColor)

### Gl_Fragcoord

## Gl_FragCoord

### Declaration / Example

### Parameters

### Description

### See Also
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=gl_FragCoord)

### Gl_Frontfacing

## Gl_FrontFacing

### Declaration / Example

### Parameters

### Description

### See Also
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=gl_FrontFacing)

### Gl_Maxcombinedtextureimageunits

## Gl_MaxCombinedTextureImages

### Declaration / Example

### Parameters

### Description

### See Also
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=gl_MaxCombinedTextureImageUnits)

### Gl_Maxdrawbuffers

## Gl_MaxDrawBuffers

### Declaration / Example

### Parameters

### Description

### See Also
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=gl_MaxDrawBuffers)

### Gl_Maxfragmentuniformvectors

## Gl_MaxFragmentUniformVectors

### Declaration / Example

### Parameters

### Description

### See Also
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=gl_MaxFragmentUniformVectors)

### Gl_Maxtextureimageunits

## Gl_MaxTextureImageUnits

### Declaration / Example

### Parameters

### Description

### See Also
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=gl_MaxTextureImageUnits)

### Gl_Maxvaryingvectors

## Gl_MaxVaryingVectors

### Declaration / Example

### Parameters

### Description

### See Also
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=gl_MaxVaryingVectors)

### Gl_Maxvertexattribs

## Gl_MaxVertexAttrbis

### Declaration / Example

### Parameters

### Description

### See Also
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=gl_MaxVertexAttribs)

### Gl_Maxvertextextureimageunits

## Gl_MaxVertexTextureImageUnits

### Declaration / Example

### Parameters

### Description

### See Also
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=gl_MaxVertexTextureImageUnits)

### Gl_Pointcoord

## Gl_PointCoord

### Declaration / Example

### Parameters

### Description

### See Also
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=gl_PointCoord)

### Gl_Pointsize

## Gl_PointSize

### Declaration / Example

### Parameters

### Description

### See Also
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=gl_PointSize)

### Gl_Position

## Gl_Position

### Declaration / Example

### Parameters

### Description

### See Also
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=gl_Position)

### Greaterthan

## GreaterThan
Perform a component-wise greater-than comparison of two vectors

### Declaration
```glsl
bvec2 greaterThan(vec2 x, vec2 y)  
bvec3 greaterThan(vec3 x, vec3 y)  
bvec4 greaterThan(vec4 x, vec4 y)  

bvec2 greaterThan(ivec2 x, ivec2 y)  
bvec3 greaterThan(ivec3 x, ivec3 y)  
bvec4 greaterThan(ivec4 x, ivec4 y)
```

### Parameters
```x``` specifies the first vector to be used in the co...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=greaterThan)

### Greaterthanequal

## GreaterThanEqual
Perform a component-wise greater-than-or-equal comparison of two vectors

### Declaration
```glsl
bvec2 greaterThanEqual(vec2 x, vec2 y)  
bvec3 greaterThanEqual(vec3 x, vec3 y)  
bvec4 greaterThanEqual(vec4 x, vec4 y)  

bvec2 greaterThanEqual(ivec2 x, ivec2 y)  
bvec3 greaterThanEqual(ivec3 x, ivec3 y)  
bvec4 greaterThanEqual(ivec4 x, ivec4 y)
```

### Parameters
```x``` spe...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=greaterThanEqual)

### Highp

## Highp

### Declaration / Example

### Parameters

### Description

### See Also
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=highp)

### In

## In

### Declaration / Example

### Parameters

### Description

### See Also
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=in)

### Inout

## Inout

### Declaration / Example

### Parameters

### Description

### See Also
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=inout)

### Int

## 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](/glossary/?search=void), [bool](/glossary/?search=bool), [int](/glossary/?search=int), [float](/glossary/?search=float), [ivec2](/glossary/?search=ivec2), [ivec3](/glossary/?search=ivec3), [ivec4](/glossary/?...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=int)

### Inversesqrt

## Inversesqrt
Return the inverse of the square root of the parameter

### Declaration
```glsl
float inversesqrt(float x)  
vec2 inversesqrt(vec2 x)  
vec3 inversesqrt(vec3 x)  
vec4 inversesqrt(vec4 x)
```

### Parameters
```x``` specifies the value of which to take the inverse of the square root.

### Description
```inversesqrt()``` returns the inverse of the square root of  ```x```.

<div class...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=inversesqrt)

### Ivec2

## Ivec2
2 dimensional 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 an integer vector with two components. It can be initialized by:

- Providing a scalar value for each component.
- Providing one scalar value. This value is used for all compo...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=ivec2)

### Ivec3

## Ivec3
3 dimensional 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 an integer vector with three components. It can be initialized by:

- Providing a s...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=ivec3)

### Ivec4

## Ivec4
4 dimensional 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 an integer vector with four components. It can be initialized by:

- Providing a scalar value for each component.
- Providing one scalar va...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=ivec4)

### Length

## Length
Calculate the length of a vector

### Declaration
```glsl
float length(float x)  
float length(vec2 x)  
float length(vec3 x)  
float length(vec4 x)
```

### Parameters
```x``` specifies a vector of which to calculate the length.

### Description
```length()``` returns the length of the vector.

<div class="codeAndCanvas" data="../07/circle-making.frag"></div>

### See Also

[distance()]...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=length)

### Lessthan

## LessThan
Perform a component-wise less-than comparison of two vectors

### Declaration
```glsl
bvec2 lessThan(vec2 x, vec2 y)  
bvec3 lessThan(vec3 x, vec3 y)    
bvec4 lessThan(vec4 x, vec4 y)  

bvec2 lessThan(ivec2 x, ivec2 y)  
bvec3 lessThan(ivec3 x, ivec3 y)  
bvec4 lessThan(ivec4 x, ivec4 y)
```

### Parameters
```x``` specifies the first vector to be used in the comparison operation.

`...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=lessThan)

### Lessthanequal

## LessThanEqual
Perform a component-wise less-than-or-equal comparison of two vectors

### Declaration
```glsl
bvec2 lessThanEqual(vec2 x, vec2 y)  
bvec3 lessThanEqual(vec3 x, vec3 y)  
bvec4 lessThanEqual(vec4 x, vec4 y)  

bvec2 lessThanEqual(ivec2 x, ivec2 y)  
bvec3 lessThanEqual(ivec3 x, ivec3 y)  
bvec4 lessThanEqual(ivec4 x, ivec4 y)
```

### Parameters
```x``` specifies the first vector ...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=lessThanEqual)

### Log

## Log
Return the natural logarithm of the parameter

### Declaration
```glsl
float log(float x)  
vec2 log(vec2 x)  
vec3 log(vec3 x)  
vec4 log(vec4 x)
```

### Parameters
```x``` specifies the value of which to take the natural logarithm.

### Description
```log()``` returns the natural logarithm of ```x```.

<div class="simpleFunction" data="y = log(x); "></div>

### See Also

[log2](/glossary...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=log)

### Log2

## Log2
Return the base 2 logarithm of the parameter

### Declaration
```glsl
float log2(float x)  
vec2 log2(vec2 x)  
vec3 log2(vec3 x)  
vec4 log2(vec4 x)
```

### Parameters
```x``` specifies the value of which to take the base 2 logarithm.

### Description
```log2()``` returns the base 2 logarithm of ```x```.

<div class="simpleFunction" data="y = log2(x); "></div>

### See Also

[log](/gloss...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=log2)

### Lowp

## Lowp

### Declaration / Example

### Parameters

### Description

### See Also
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=lowp)

### Main

## Main

### Declaration / Example

### Parameters

### Description

### See Also
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=main)

### Mat2

## Mat2
2x2 floating point matrix

### Declaration
```glsl
mat2 aMat2 = mat2(1.0, 0.0,  // 1. column
                  0.0, 1.0); // 2. column
mat2 bMat2 = mat2(1.0);
mat2 cMat2 = mat2(aVec2, bVec2);
mat2 dMat2 = mat2(aVec3, aFloat);
```

### Description
```mat2``` data type is compose for a 2x2 matrix of floating point. As you can see above, can be initialize in different ways:

- Providing a val...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=mat2)

### Mat3

## Mat3
3x3 floating point matrix

### Declaration
```glsl
mat3 aMat3 = mat3(1.0, 0.0, 0.0,  // 1. column
                  0.0, 1.0, 0.0,  // 2. column
                  0.0, 0.0, 1.0); // 3. column
mat3 bMat3 = mat3(1.0);

mat3 cMat3 = mat3(aVec3, bVec3, cVec3);
mat3 dMat3 = mat3(aVec4, aVec3, bVec4, aFloat);
```

### Description
```mat3``` data type is compose for a 3x3 matrix of floating point...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=mat3)

### Mat4

## Mat4
4x4 floating point matrix

### Declaration
```glsl
mat4 aMat4 = mat4(1.0, 0.0, 0.0, 0.0,  // 1. column
                  0.0, 1.0, 0.0, 0.0,  // 2. column
                  0.0, 0.0, 1.0, 0.0,  // 3. column
                  0.0, 0.0, 0.0, 1.0); // 4. column
mat4 bMat4 = mat4(1.0);

mat4 cMat4 = mat4(aVec4, bVec4, cVec4, dVec4);
mat4 dMat4 = mat4(aVec4, aVec3, bVec4, cVec4, aFloat);
```

#...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=mat4)

### Matrixcompmult

## MatrixCompMult
Perform a component-wise multiplication of two matrices

### Declaration
```glsl
mat2 matrixCompMult(mat2 x, mat2 y)  
mat3 matrixCompMult(mat3 x, mat3 y)  
mat4 matrixCompMult(mat4 x, mat4 y)
```

### Parameters
```x``` specifies the first matrix multiplicand.

```y``` specifies the second matrix multiplicand.

### Description
```matrixCompMult()``` performs a component-wise mul...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=matrixCompMult)

### Max

## Max
Return the greater of two values

### Declaration
```glsl
float max(float x, float y)  
vec2 max(vec2 x, vec2 y)  
vec3 max(vec3 x, vec3 y)  
vec4 max(vec4 x, vec4 y)

vec2 max(vec2 x, float y)  
vec3 max(vec3 x, float y)  
vec4 max(vec4 x, float y)
```

### Parameters
```x``` specifies the first value to compare.

```y``` specifies the second value to compare.

### Description
```max()``` ...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=max)

### Mediump

## Mediump

### Declaration / Example

### Parameters

### Description

### See Also
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=mediump)

### Min

## Min
Return the lesser of two values

### Declaration
```glsl
float min(float x, float y)  
vec2 min(vec2 x, vec2 y)  
vec3 min(vec3 x, vec3 y)  
vec4 min(vec4 x, vec4 y)

vec2 min(vec2 x, float y)  
vec3 min(vec3 x, float y)  
vec4 min(vec4 x, float y)
```

### Parameters
```x``` specifies the first value to compare.

```y``` specifies the second value to compare.

### Description
```min()``` r...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=min)

### Mix

## Mix
Constrain a value to lie between two further values

### Declaration
```glsl
float mix(float x, float y, float a)  
vec2 mix(vec2 x, vec2 y, vec2 a)  
vec3 mix(vec3 x, vec3 y, vec3 a)  
vec4 mix(vec4 x, vec4 y, vec4 a)

vec2 mix(vec2 x, vec2 y, float a)  
vec3 mix(vec3 x, vec3 y, float a)  
vec4 mix(vec4 x, vec4 y, float a)
```

### Parameters
```x``` specifies the start of the range in whi...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=mix)

### Mod

## Mod
Compute value of one parameter modulo another

### Declaration
```glsl
float mod(float x, float y)  
vec2 mod(vec2 x, vec2 y)  
vec3 mod(vec3 x, vec3 y)  
vec4 mod(vec4 x, vec4 y)

vec2 mod(vec2 x, float y)  
vec3 mod(vec3 x, float y)  
vec4 mod(vec4 x, float y)
```

### Parameters
```x``` specifies the value to evaluate.
```y``` specifies the value to obtain the modulo of.

### Description...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=mod)

### Normalize

## Normalize
Calculate the unit vector in the same direction as the input vector

### Declaration
```glsl
float normalize(float x)  
vec2 normalize(vec2 x)  
vec3 normalize(vec3 x)  
vec4 normalize(vec4 x)
```

### Parameters
```x``` specifies the vector to normalize.

### Description
```normalize()``` returns a vector with the same direction as its parameter, ```x```, but with length 1.

### See ...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=normalize)

### Not

## Not
Logically invert a boolean vector

### Declaration
```glsl
bvec2 not(bvec2 x)  
bvec3 not(bvec3 x)  
bvec4 not(bvec4 x)
```

### Parameters
```x``` specifies the vector to be inverted.

### Description
```not()``` logically inverts the boolean vector ```x```. It returns a new boolean vector for which each element ```i``` is computed as ```!x[i]```.

### See Also
[any()](/glossary/?search=an...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=not)

### Notequal

## NotEqual
Perform a component-wise not-equal-to comparison of two vectors

### Declaration
```glsl
bvec2 notEqual(vec2 x, vec2 y)  
bvec3 notEqual(vec3 x, vec3 y)  
bvec4 notEqual(vec4 x, vec4 y)  

bvec2 notEqual(ivec2 x, ivec2 y)  
bvec3 notEqual(ivec3 x, ivec3 y)  
bvec4 notEqual(ivec4 x, ivec4 y)
```

### Parameters
```x``` specifies the first vector to be used in the comparison operation.

...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=notEqual)

### Out

## Out

### Declaration / Example

### Parameters

### Description

### See Also
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=out)

### Pow

## Pow
Return the value of the first parameter raised to the power of the second.

### Declaration
```glsl
float pow(float x, float y)  
vec2 pow(vec2 x, vec2 y)  
vec3 pow(vec3 x, vec3 y)  
vec4 pow(vec4 x, vec4 y)
```

### Parameters
```x``` specifies the value to raise to the power ```y```.

```y``` specifies the power to which to raise ```x```.

### Description
```pow()``` returns the value of...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=pow)

### Precision

## Precision

### Declaration / Example

### Parameters

### Description

### See Also
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=precision)

### Radians

## Radians
Convert a quantity in degrees to radians

### Declaration
```glsl
float radians(float degrees)  
vec2 radians(vec2 degrees)  
vec3 radians(vec3 degrees)  
vec4 radians(vec4 degrees)
```

### Parameters
```degrees``` specifies the quantity, in degrees, to be converted to radians.

### Description
```radians()``` converts a quantity, specified in degrees into radians. That is, the return ...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=radians)

### Reflect

## Reflect
Calculate the reflection direction for an incident vector

### Declaration
```glsl
float reflect(float I, float N)  
vec2 reflect(vec2 I, vec2 N)  
vec3 reflect(vec3 I, vec3 N)  
vec4 reflect(vec4 I, vec4 N)
```

### Parameters
```I``` specifies the incident vector.

```N``` specifies the normal vector.

### Description
For a given incident vector ```I``` and surface normal ```N``` refl...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=reflect)

### Refract

## Refract
Calculate the refraction direction for an incident vector

### Declaration
```glsl
float refract(float I, float N, float eta)  
vec2 refract(vec2 I, vec2 N, float eta)  
vec3 refract(vec3 I, vec3 N, float eta)  
vec4 refract(vec4 I, vec4 N, float eta)
```

### Parameters
```I``` specifies the incident vector.

```N``` specifies the normal vector.

```eta``` specifies the ratio of indice...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=refract)

### Return

## Return

### Declaration / Example

### Parameters

### Description

### See Also
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=return)

### Sampler2D

## Sampler2D

### Declaration / Example

### Parameters

### Description

### See Also
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=sampler2D)

### Samplercube

## SamplerCube

### Declaration / Example

### Parameters

### Description

### See Also
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=samplerCube)

### Sign

## Sign
Extract the sign of the parameter

### Declaration
```glsl
float sign(float x)  
vec2 sign(vec2 x)  
vec3 sign(vec3 x)  
vec4 sign(vec4 x)
```

### Parameters
```x``` specifies the value from which to extract the sign.

### Description
```sign()``` returns -1.0 if x is less than 0.0, 0.0 if x is equal to 0.0, and +1.0 if x is greater than 0.0.

<div class="simpleFunction" data="y = sign(x)...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=sign)

### Sin

## Sin
Return the sine of the parameter

### Declaration
```glsl
float sin(float angle)  
vec2 sin(vec2 angle)  
vec3 sin(vec3 angle)  
vec4 sin(vec4 angle)
```

### Parameters
```angle``` specifies the quantity, in radians, of which to return the sine.

### Description
```sin()``` returns the trigonometric sine of angle.

<div class="simpleFunction" data="y = sin(x); "></div>

### See Also
[acos]...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=sin)

### Smoothstep

## Smoothstep
Perform Hermite interpolation between two values

### Declaration
```glsl
float smoothstep(float edge0, float edge1, float x)  
vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x)  
vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x)  
vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x)

vec2 smoothstep(float edge0, float edge1, vec2 x)  
vec3 smoothstep(float edge0, float edge1, vec3 x)  
vec4 ...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=smoothstep)

### Sqrt

## Sqrt
Return the square root of the parameter

### Declaration
```glsl
float sqrt(float x)  
vec2 sqrt(vec2 x)  
vec3 sqrt(vec3 x)  
vec4 sqrt(vec4 x)
```

### Parameters
```x``` specifies the value of which to take the square root.

### Description
```sqrt()``` returns the square root of ```x```.

<div class="simpleFunction" data="y = sqrt(x); "></div>

<div class="codeAndCanvas" data="../07/ci...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=sqrt)

### Step

## Step
Generate a step function by comparing two values

### Declaration
```glsl
float step(float edge, float x)  
vec2 step(vec2 edge, vec2 x)  
vec3 step(vec3 edge, vec3 x)  
vec4 step(vec4 edge, vec4 x)

vec2 step(float edge, vec2 x)  
vec3 step(float edge, vec3 x)  
vec4 step(float edge, vec4 x)
```

### Parameters
```edge``` specifies the location of the edge of the step function.

```x``` s...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=step)

### Struct

## 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`...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=struct)

### Tan

## Tan
Return the tangent of the parameter

### Declaration
```glsl
float tan(float angle)  
vec2 tan(vec2 angle)  
vec3 tan(vec3 angle)  
vec4 tan(vec4 angle)
```

### Parameters
```angle``` specifies the quantity, in radians, of which to return the tangent.

### Description
```tan()``` returns the trigonometric tangent of angle.

<div class="simpleFunction" data="y = tan(x); "></div>

### See Al...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=tan)

### Texture2D

## Texture2D
Retrieves texels from a texture

### Declaration
```glsl
vec4 texture2D(sampler2D sampler, vec2 coord)  
vec4 texture2D(sampler2D sampler, vec2 coord, float bias)
```

### Parameters
```sampler``` specifies the sampler to which the texture from which texels will be retrieved is bound.

```coord``` specifies the texture coordinates at which texture will be sampled.

```bias``` specifie...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=texture2D)

### Texturecube

## TextureCube
Retrieves texels from a texture

### Declaration
```glsl
vec4 textureCube(samplerCube sampler, vec3 coord)  
vec4 textureCube(samplerCube sampler, vec3 coord, float bias)
```

### Parameters
```sampler``` specifies the sampler to which the texture from which texels will be retrieved is bound.

```coord``` specifies the texture coordinates at which texture will be sampled.

```bias``...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=textureCube)

### Uniform

## Uniform
Uniform variable qualifier.

### Example
```glsl
uniform vec4 direction;
```

### Description
```uniform``` variables contain read-only data shared from WebGL/OpenGL environment to a vertex or fragment shader.

The value is per primitive, so is useful for variables which remain constant along a primitive, frame or scene.

### See Also
[attribute](/glossary/?search=attribute), [const](/g...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=uniform)

### Varying

## Varying
Varying variable qualifier.

### Example
```glsl
varying vec3 position;
```

### Description
```varying``` variables contain data shared from a vertex shader to a fragment shader.

The variable must be written in the vertex shader and the read-only value in the fragment shader is then interpolated from the vertices which make up the fragment.

### See Also
[attribute](/glossary/?search=...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=varying)

### Vec2

## Vec2
2 dimensional floating 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 floating point vector with two components. It can be initialized by:

- Providing a scalar value for each component.
- Providing one scalar value. This value is used for all com...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=vec2)

### Vec3

## Vec3
3 dimensional 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
```vec3``` is a floating point vector with three components. It can be initialized by:

- Providing...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=vec3)

### Vec4

## Vec4
4 dimensional floating point vector

### Declaration
```glsl
vec4 aVec4 = vec4(1.0, 1.0, 1.0, 1.0);
vec4 bVec4 = vec4(1.0);

vec4 cVec4 = vec4(aVec2, aFloat, aVec3);
vec4 dVec4 = vec4(aBvec2.x, aBvec2.y, aFloat, aBvec3.x);
```

### Description
```vec4``` is a floating point vector with four components. It can be initialized by:

- Providing a scalar value for each component.
- Providing on...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=vec4)

### Void

## Void

### Declaration
```glsl
void main(void);
int aFunction(void);
void bFunction(float);
```

### Description
```void``` is used when a function has no parameters or when a function does not return a value.

### See Also
[void](/glossary/?search=void), [bool](/glossary/?search=bool), [int](/glossary/?search=int), [float](/glossary/?search=float)
...

[📖 View Full Entry](https://thebookofshaders.com/glossary/?search=void)

