* Docs: Fix hyperlinks * Update website link generation * Replace website links with actual file path
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 underlyingWebGLTexturetarget- AlwaysGL.TEXTURE_3Ddepth- the number of texture layerswidth- width of the layer texturesheight- height of the layer texturesformat- 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 contextdata=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 imageformat(enum, defaultGL.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 fromformat) - 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 viaGL.MAX_3D_TEXTURE_SIZE(at least 256).