Reference texture()

texture()

Sets the texture that will be used on shapes.

A texture is like a skin that wraps around a shape. texture() works with built-in shapes, such as square() and sphere(), and custom shapes created with functions such as buildGeometry(). To texture a geometry created with beginShape(), uv coordinates must be passed to each vertex() call.

The parameter, tex, is the texture to apply. texture() can use a range of sources including images, videos, and offscreen renderers such as p5.Graphics and p5.Framebuffer objects.

To texture a geometry created with beginShape(), you will need to specify uv coordinates in vertex().

Note: texture() can only be used in WebGL mode.

Examples

Syntax

texture(tex)

Parameters

tex

media to use as the texture.

Notice any errors or typos? Please let us know. Please feel free to edit src/webgl/material.js and open a pull request!

Related References