1chandu f05c63a0aa
Doc links (#521)
* Docs: Fix hyperlinks
* Update website link generation
* Replace website links with actual file path
2018-05-24 11:08:10 -07:00

2.1 KiB

Texture3D (WebGL2)

A Texture3D holds a number of textures of the same size and format. The entire array can be passed to the shader which uses an extra texture coordinate to sample from it. A core feature of Texture3D is that the entire stack of images can passed as a single uniform to and accessed in a GLSL shader, and sampled using 3D coordinates.

3D textures are typically used to store volumetric data or for 3D lookup tables in shaders.

Most texture related functionality is implemented by and documented on the Texture base class. For additional information, see OpenGL Wiki.

Usage

Create a new texture array

if (Texture3D.isSupported()) {
  texture3D = new Texture3D(gl, {...});
}

Members

  • handle - The underlying WebGLTexture
  • target - Always GL.TEXTURE_3D
  • depth - the number of texture layers
  • width - width of the layer textures
  • height - height of the layer textures
  • format - format of the layer textures

Methods

Texture3D is a subclass of the Texture and Resource classes and inherit all methods and members of those classes.

Texture3D.isSupported(gl)

Returns true if the context supports creation of Texture3Ds.

constructor

new Texture3D(gl, {parameters});

  • gl (WebGLRenderingContext) - gl context
  • data=null (*) - See below.
  • width=0 (Number) - The width of the texture.
  • height=0 (Number) - The height of the texture.
  • mipmaps=GL/ (*Enum*, default false) - n`th mipmap reduction level, 0 represents base image
  • format (enum, default GL.RGBA) - internal format that WebGL should use.
  • type (enum, default is autodeduced from format) - type of pixel data (GL.UNSIGNED_BYTE, GL.FLOAT etc).
  • dataFormat (enum, default is autodeduced from format) - internal format that WebGL should use.
  • parameters={} (object) - texture

Limits

  • The maximum size of a Texture3D (width/height/depth) is implementation defined, it can be queried via GL.MAX_3D_TEXTURE_SIZE (at least 256).