public class SoTexture2 extends SoTexture
SoTextureUnit) and is used to apply texture to subsequent shapes as they are rendered. The image may be loaded from a file, loaded from an image in memory or created by rendering a scene graph.
Loading an image
The texture can be read from a file specified in the
filename field. Open Inventor supports most common file formats including: BMP, DDS, GIF, JPEG, PNG and TIFF. See
SoRasterImageRW for a complete list. If Open Inventor recognizes the extension part of the file name, for example "png" for a PNG format image, it will automatically use the corresponding image reader (
SoPNGImageRW). If the file extension is not recognized, Open Inventor will attempt to determine the actual image file format by opening the file with each of the built-in image file reader classes.
Note that the image file is read immediately when the filename field is set. If you want to postpone the texture loading, set the
loadingMode field to
MANUAL before setting the
filename field. In this case, you must call
loadTexture() to load and display the texture. Alternatively, consider using
SoExtTexture2, which defers loading the image until the texture node is actually traversed.
Once the texture has been read, the
image field contains the texture data. However, this field is marked so the image is not written out when the texture node is written to a file. To turn off texturing, set the
filename field to an empty string ("").
DDS format files load faster because the compressed image can be sent directly to the graphics hardware. This format can also embed mipmaps (levels of resolution). Note that the
image field is not filled with the image data when using DDS files. DDS format is not supported on all hardware. The GL_EXT_texture_compression_s3tc extension is required. If it is not available, the DDS texture is not loaded.
Modifying a texture image
You can modify a subset of the image without causing the OpenGL texture to be recreated. Open Inventor will automatically use glTexSubImage2D if the image is modified using the SoSFImage.setSubValue() method. This is much more efficient than using the startEditing and finishEditing methods because when these methods are used Open Inventor must assume that the entire image has been modified.
SoTexture.magFilter fields can be used to specifically control the texture minification and magnification "filter" algorithms used by the GPU. The minification filter is used when the rendered size of the geometry is smaller than the texture image (for example: far away objects). Conversely the magnification filter is used when the rendered size of the geometry is larger than the texture image (near objects). Effectively these settings control whether the GPU will select the "nearest" texel value or do linear interpolation (smoothing) or (in the case of minification) interpolate between mipmap levels. Using NEAREST may allow better performance, but the LINEAR options produce much higher quality rendering. If mipmap filtering is required, mipmaps are automatically created.
NOTE: The default value for these
SoTexture fields is AUTO, meaning that the minification and magnification algorithms are actually controlled by the
SoComplexity.textureQuality field. To maximize performance, the default value for textureQuality is 0.5, which selects NEAREST filtering. For best image quality we recommend setting this field to (at least) 0.75.
Texture images can contain transparency (alpha values less than 1) and modify the transparency of geometry in the scene. But transparent geometry will not render correctly in the default transparency mode (SCREEN_DOOR). Set the transparency mode to a non-default value, for example DELAYED_BLEND, using the setTransparencyType method in the Viewer class or using an
SoTransparencyType node. Also note that some image file formats, for example JPEG, do not support transparency information (alpha channel).
If the texture image's width or height is not a power of 2, e.g. 128 or 256, and the Non Power Of Two (NPOT) extension is available on your graphics board, by default Open Inventor will send the image to OpenGL without modification. Almost all modern graphics hardware support this extension (check using SoTexture.isSupported(HW_NPOT)). However if your application must run on graphics hardware that does not support NPOT, please read the following.
If the texture image's width or height is not a power of 2 (and the Non Power Of Two (NPOT) extension is not available on your graphics board), or the image's width or height is greater than the maximum supported by OpenGL, then the image will be automatically scaled up or down to the nearest power of 2 or the maximum texture size. For maximum speed, point-sampling is used to do the scaling. If you want higher quality scaling, pre-filter your images to a power of 2 smaller than the maximum texture size. Use the OpenGL glGetIntegerv(GL_MAX_TEXTURE_SIZE...) call to determine the maximum texture dimension for a specific OpenGL implementation. Setting the environment variable OIV_USE_NPOT to 0 will force the image to be rescaled (when necessary) even if the NPOT extension is available.
Performance Note: Automatic scaling of texture images to a power of 2 is a very convenient feature for prototyping, but it does take additional time the first time the texture node is traversed for rendering. For large images, or a large number of images, this can make the application seem slow while starting up or loading a new data file. Avoid this effect by either pre-scaling the image or by storing it as a sub-image in a "power of 2" image (then provide explicit texture coordinates such that only the sub-image is used). (Not applicable if GPU supports non-power-of-2 images. Most do.)
Performance Note: The performance advantage of modifying a sub-image is significantly less when the texture image needs to be automatically scaled to a power of 2. This is because each sub-image must be scaled before sending it to OpenGL. (Not applicable if GPU supports non-power-of-2 images. Most do.)
|image||0 0 0|
|blendColor||0 0 0|
|borderColor||0 0 0 1|
|Modifier and Type||Class and Description|
SoTexture.FileTypes, SoTexture.Filters, SoTexture.HW_Features, SoTexture.InternalFormats, SoTexture.Models, SoTexture.WrapType
|Modifier and Type||Field and Description|
Name of the file from which to read texture image.
Contains an in-memory representation of the texture map.
Specifies the loading mode.
Indicates what to do when texture coordinates in the T (vertical) direction lie outside the range 0-1.
ADD, ALPHA_FLOAT16, ALPHA_FLOAT32, ALPHA_FORMAT, ALPHA12, ALPHA16, ALPHA4, ALPHA8, AUTO_INTERNAL_FORMAT, BLEND, blendColor, BMP, borderColor, CLAMP, CLAMP_TO_BORDER, CLAMP_TO_EDGE, COMBINE, COMPRESSED_ALPHA, COMPRESSED_INTENSITY, COMPRESSED_LUMINANCE, COMPRESSED_LUMINANCE_ALPHA, COMPRESSED_LUMINANCE_ALPHA_LATC2, COMPRESSED_LUMINANCE_LATC1, COMPRESSED_RED_GREEN_RGTC2, COMPRESSED_RED_RGTC1, COMPRESSED_RGB, COMPRESSED_RGBA, COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2, COMPRESSED_SIGNED_LUMINANCE_LATC1, COMPRESSED_SIGNED_RED_GREEN_RGTC2, COMPRESSED_SIGNED_RED_RGTC1, DDS, DECAL, DEPTH_COMPONENT16, DEPTH_COMPONENT24, DEPTH24_STENCIL8, enableBorder, enableCompressedTexture, GIF, HDRI, HW_AUTOMIPMAP, HW_BORDER_CLAMP, HW_COMPRESSION_LATC, HW_COMPRESSION_RGTC, HW_COMPRESSION_S3TC, HW_DEPTHFORMAT, HW_EDGE_CLAMP, HW_FLOATFORMAT, HW_LAST, HW_MIRRORED_REPEAT, HW_NPOT, INTENSITY_FLOAT16, INTENSITY_FLOAT32, INTENSITY_FORMAT, INTENSITY12, INTENSITY16, INTENSITY4, INTENSITY8, internalFormat, JPEG, JPEG2000, LINEAR, LINEAR_MIPMAP_LINEAR, LINEAR_MIPMAP_NEAREST, LUMINANCE_ALPHA, LUMINANCE_ALPHA_FLOAT16, LUMINANCE_ALPHA_FLOAT32, LUMINANCE_FLOAT16, LUMINANCE_FLOAT32, LUMINANCE_FORMAT, LUMINANCE12, LUMINANCE12_ALPHA12, LUMINANCE12_ALPHA4, LUMINANCE16, LUMINANCE16_ALPHA16, LUMINANCE4, LUMINANCE4_ALPHA4, LUMINANCE6_ALPHA2, LUMINANCE8, LUMINANCE8_ALPHA8, magFilter, maxAnisotropy, minFilter, MIRRORED_REPEAT, model, MODULATE, NEAREST, NEAREST_MIPMAP_LINEAR, NEAREST_MIPMAP_NEAREST, NUM_FILETYPES, PGX, PNG, PNM, R3_G3_B2, RAS, REPEAT, REPLACE, RGB, RGB_FLOAT16, RGB_FLOAT32, RGB_FORMAT, RGB10, RGB10_ALPHA2, RGB12, RGB16, RGB4, RGB5, RGB5_ALPHA1, RGB8, RGBA_FLOAT16, RGBA_FLOAT32, RGBA_FORMAT, RGBA12, RGBA16, RGBA2, RGBA4, RGBA8, SGI, TIFF, UNKNOWN, useAutoMipmap, wrapS
|Constructor and Description|
Creates a texture node with default settings.
|Modifier and Type||Method and Description|
Loads the texture if the
getBitmapFileType, isSupported, setBitmapFileType
affectsState, callback, copy, copy, distribute, doAction, getAlternateRep, getBoundingBox, getByName, getMatrix, getPrimitiveCount, getRenderUnitID, GLRender, GLRenderBelowPath, GLRenderInPath, GLRenderOffPath, grabEventsCleanup, grabEventsSetup, handleEvent, isBoundingBoxIgnoring, isOverride, pick, rayPick, search, setOverride, touch, write
copyFieldValues, copyFieldValues, enableNotify, fieldsAreEqual, get, getAllFields, getEventIn, getEventOut, getField, getFieldName, hasDefaultValues, isNotifyEnabled, set, setToDefaults
dispose, getEXTERNPROTO, getName, getPROTO, isDisposable, isSynchronizable, setName, setSynchronizable
getAddress, getNativeResourceHandle, startInternalThreads, stopInternalThreads
@Deprecated public static final int AUTO
@Deprecated public static final int MANUAL
public final SoSFFilePathString filename
SoRasterImageRWfor the list. If the filename is not an absolute path name, the list of directories maintained by
SoInputis searched. If the texture is not found in any of those directories, then the file is searched for relative to the directory from which the
SoTexture2node was read. For example, if an
SoTexture2node with a filename of "../tofu.rgb" is read from /usr/people/bob/models/food.iv, then /usr/people/bob/tofu.rgb will be read (assuming tofu.rgb isn't found in the directories maintained by
public final SoSFImage image
public final SoSFEnum<SoTexture.WrapType> wrapT
public final SoSFEnum<SoTexture2.Loadings> loadingMode
Loading. Default is AUTO.
public final SoSFNode renderToTextureProperty
SoRenderToTexturePropertynode containing a scene graph that will be rendered to create the texture image. Null by default.
image field is not updated when the scene graph is rendered. That would require reading back the frame buffer from the graphics board, which can be time consuming and would reduce performance.
public void loadTexture()
loadingModefield is set to MANUAL.
Generated on January 29, 2020, Copyright © Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com