Most visited

Recently visited

Texture

public class Texture
extends Object

java.lang.Object
   ↳ com.viro.core.Texture
Known Direct Subclasses
VideoTexture VideoTexture plays video from local or remote sources. 


Texture is an image used to add surface detail and color to a Material. The most common form of Texture is a diffuse texture, which determines a Material's base color. Other common textures are specular textures, which affect the color of light reflected directly toward the user, and normal textures, which specify the orientation of a surface at each pixel.

Textures consist of image data and properties that define how they map to a given surface. These properties include the texture's wrapping mode (e.g. repeat or clamp), and its various filtering modes, which determine how the texture is sampled when it's size on the screen is smaller or larger than its underlying image size.

Summary

Nested classes

enum Texture.FilterMode

FilterMode determines how samples are chosen from the Texture when its rendered size is larger or smaller than the underlying image's actual size. 

enum Texture.Format

Texture.Format identifies the format of the pixel-data underlying the Texture

enum Texture.StereoMode

StereoMode is used in VR to render a Texture in stereo. 

class Texture.TextureBuilder

Builder for creating Texture objects. 

enum Texture.WrapMode

WrapMode determines what happens when the texture coordinates extend outside the [0.0, 1.0] range when mapping the image. 

Public constructors

Texture(Bitmap image, Texture.Format storageFormat, boolean sRGB, boolean generateMipmaps, Texture.StereoMode stereoMode)

Construct a new stereo 2D Texture out of the given image represented as a Bitmap.

Texture(ByteBuffer data, int width, int height, Texture.Format inputFormat, Texture.Format storageFormat, boolean sRGB, boolean generateMipmaps, Texture.StereoMode stereoMode)

Construct a new 2D Texture out of the image contained in the given ByteBuffer, stored in the indicated format.

Texture(ByteBuffer data, Texture.StereoMode stereoMode)

Construct a new 2D HDR Texture out of the image contained in VHD format in the given ByteBuffer.

Public methods

static Texture.TextureBuilder builderWithData(ByteBuffer data)

Builder for creating Texture objects from given ByteBuffer data.

static Texture.TextureBuilder builderWithImage(Bitmap image)

Builder for creating Texture objects with bitmap images.

static Texture.TextureBuilder builderWithPx(Bitmap px)

Builder for creating Texture objects with cube map bitmaps (px, nx, pz, nz, py, zy).

void dispose()

Release native resources associated with this Texture.

int getHeight()

Get the height of this Texture in pixels.

Texture.FilterMode getMagnificationFilter()

Get the magnification Texture.FilterMode used by this Texture.

Texture.FilterMode getMinificationFilter()

Get the minification Texture.FilterMode used by this Texture.

Texture.FilterMode getMipFilter()

Get the mip Texture.FilterMode used by this Texture.

int getWidth()

Get the width of this Texture in pixels.

Texture.WrapMode getWrapS()

Get the horizontal Texture.WrapMode used for this Texture.

Texture.WrapMode getWrapT()

Get the vertical Texture.WrapMode used for this Texture.

static Texture loadRadianceHDRTexture(Uri uri)

Loads the Radiance HDR (.hdr) texture at the given URI.

void setMagnificationFilter(Texture.FilterMode magnificationFilter)

Set the magnification filter to use for this Texture.

void setMinificationFilter(Texture.FilterMode minificationFilter)

Set the minification filter to use for this Texture.

void setMipFilter(Texture.FilterMode mipFilter)

Set the filter to use when mipmapping the Texture.

void setWrapS(Texture.WrapMode wrapS)

Set the horizontal Texture.WrapMode.

void setWrapT(Texture.WrapMode wrapT)

Set the vertical Texture.WrapMode.

Public constructors

Texture

Texture (Bitmap image, 
                Texture.Format storageFormat, 
                boolean sRGB, 
                boolean generateMipmaps, 
                Texture.StereoMode stereoMode)

Construct a new stereo 2D Texture out of the given image represented as a Bitmap.

Parameters
image Bitmap: The Bitmap to turn into a Texture.

storageFormat Texture.Format: The format in which to store the Texture in memory. Bitmaps can be stored as either RGBA8 or RGB565.

sRGB boolean: True if the image is in a gamma-corrected (sRGB) format. If true, Viro will linearize the texture during shading computations. This option should generally be set to true for diffuse and specular images, and false for non-visual images like normal maps.

generateMipmaps boolean: True if Viro should generate mipmaps for the image and store them in the Texture. Mipmapping dramatically improves the visual quality and performance of Textures when they are rendered onto small surfaces.

stereoMode Texture.StereoMode: The Texture.StereoMode indicating which half of the image to render to the left eye, and which to render to the right eye. Null if the image is not stereo.

Texture

Texture (ByteBuffer data, 
                int width, 
                int height, 
                Texture.Format inputFormat, 
                Texture.Format storageFormat, 
                boolean sRGB, 
                boolean generateMipmaps, 
                Texture.StereoMode stereoMode)

Construct a new 2D Texture out of the image contained in the given ByteBuffer, stored in the indicated format. Not all input formats are compatible with all storage formats. This method can be used to load images that are not in Bitmap form: for example, raw images or HDR images.

Parameters
data ByteBuffer: The raw image data to turn into a Texture. This must be a direct ByteBuffer. The image data must start at position 0 in the buffer and end at the buffer's capacity.

width int: The width of the image stored in data.

height int: The height of the image stored in data.

inputFormat Texture.Format: The format of the data stored in data.

storageFormat Texture.Format: The format in which to store the Texture in memory.

sRGB boolean: True if the image is in a gamma-corrected (sRGB) format. If true, Viro will linearize the texture during shading computations. This option should generally be set to true for diffuse and specular images, and false for non-visual images like normal maps.

generateMipmaps boolean: True if Viro should generate mipmaps for the image and store them in the Texture. Mipmapping dramatically improves the visual quality and performance of Textures when they are rendered onto small surfaces. Mipmap generation is not possible for all input formats.

stereoMode Texture.StereoMode: The Texture.StereoMode indicating which half of the image to render to the left eye, and which to render to the right eye. Null if the image is not stereo.

Texture

Texture (ByteBuffer data, 
                Texture.StereoMode stereoMode)

Construct a new 2D HDR Texture out of the image contained in VHD format in the given ByteBuffer.

Parameters
data ByteBuffer: The raw image data to turn into a Texture. This must be a direct ByteBuffer. The image data must start at position 0 in the buffer and end at the buffer's capacity.

stereoMode Texture.StereoMode: The Texture.StereoMode indicating which half of the image to render to the left eye, and which to render to the right eye. Null if the image is not stereo.

Public methods

builderWithData

Texture.TextureBuilder builderWithData (ByteBuffer data)

Builder for creating Texture objects from given ByteBuffer data.

Parameters
data ByteBuffer

Returns
Texture.TextureBuilder The Texture.TextureBuilder.

builderWithImage

Texture.TextureBuilder builderWithImage (Bitmap image)

Builder for creating Texture objects with bitmap images. This builder can be used to build textures with normal bitmap images as well as bitmap images with any Texture.StereoMode configuration.

Parameters
image Bitmap

Returns
Texture.TextureBuilder The Texture.TextureBuilder.

builderWithPx

Texture.TextureBuilder builderWithPx (Bitmap px)

Builder for creating Texture objects with cube map bitmaps (px, nx, pz, nz, py, zy).

Parameters
px Bitmap

Returns
Texture.TextureBuilder The Texture.TextureBuilder.

dispose

void dispose ()

Release native resources associated with this Texture.

getHeight

int getHeight ()

Get the height of this Texture in pixels.

Returns
int The height of the Texture.

getMagnificationFilter

Texture.FilterMode getMagnificationFilter ()

Get the magnification Texture.FilterMode used by this Texture.

Returns
Texture.FilterMode The magnification filter.

getMinificationFilter

Texture.FilterMode getMinificationFilter ()

Get the minification Texture.FilterMode used by this Texture.

Returns
Texture.FilterMode The minification filter.

getMipFilter

Texture.FilterMode getMipFilter ()

Get the mip Texture.FilterMode used by this Texture.

Returns
Texture.FilterMode The mip filter.

getWidth

int getWidth ()

Get the width of this Texture in pixels.

Returns
int The width of this Texture.

getWrapS

Texture.WrapMode getWrapS ()

Get the horizontal Texture.WrapMode used for this Texture.

Returns
Texture.WrapMode The horizontal wrap mode.

getWrapT

Texture.WrapMode getWrapT ()

Get the vertical Texture.WrapMode used for this Texture.

Returns
Texture.WrapMode The vertical wrap mode.

loadRadianceHDRTexture

Texture loadRadianceHDRTexture (Uri uri)

Loads the Radiance HDR (.hdr) texture at the given URI. These textures are commonly used for lighting environments.

Parameters
uri Uri: The URI of the texture. To load the texture from an Android asset, use URI's of the form file:///android_asset/[asset-name].

Returns
Texture The loaded HDR Texture, null if the .hdr texture fails to load.

setMagnificationFilter

void setMagnificationFilter (Texture.FilterMode magnificationFilter)

Set the magnification filter to use for this Texture. The magnification filter is used when the texture image needs to be rendered onto a surface *larger* than the image. This occurs, for example, when rendering a textured surface very close to the camera.

Parameters
magnificationFilter Texture.FilterMode: The magnification Texture.FilterMode to use for this Texture.

setMinificationFilter

void setMinificationFilter (Texture.FilterMode minificationFilter)

Set the minification filter to use for this Texture. The minification filter is used when the texture image needs to be rendered onto a surface smaller than the image. This occurs, for example, when rendering a textured surface very far away from the camera.

Parameters
minificationFilter Texture.FilterMode: The minification Texture.FilterMode to use for this Texture.

setMipFilter

void setMipFilter (Texture.FilterMode mipFilter)

Set the filter to use when mipmapping the Texture. Mipmapping increases rendering performance when rendering textures at small sizes. When used, Viro will create scaled down versions of the texture, and during rendering will sample the version that's closest to the size of the surface being rendered.

NEAREST filtering will return the color from the mip-level closest to the size of the rendered surface.

LINEAR' filtering will return the color found by interpolating between the two nearest mip-levels.

Parameters
mipFilter Texture.FilterMode: The mip Texture.FilterMode to use for this Texture.

setWrapS

void setWrapS (Texture.WrapMode wrapS)

Set the horizontal Texture.WrapMode. This determines what happens when the texture coordinates extend outside the [0.0, 1.0] in the X direction of the Texture.

Parameters
wrapS Texture.WrapMode: The horizontal Texture.WrapMode.

setWrapT

void setWrapT (Texture.WrapMode wrapT)

Set the vertical Texture.WrapMode. This determines what happens when the texture coordinates extend outside the [0.0, 1.0] in the Y direction of the Texture.

Parameters
wrapT Texture.WrapMode: The vertical Texture.WrapMode.

Hooray!