Complete Texture API Introduction
Having got the basic texturing example to work, now you need to get familiar with the rest of the texturing APIs and what they can do for you. In general, Aviatrix3D presents all of the normal texturing options that you can use at the OpenGL level, by bundling them into a couple of classes. This tutorial will be about walking you through the various classes that can contribute to the texturing look rather than as a complete end to end application demo.
If you would like to see the some code that uses a reasonable number of these
options then go to the examples/texture directory and look at
When textures are being animated or changed, there are several options that you
can take. The first option is to completely replace the texture contents with a
new set by replacing the entire TextureComponent. To do this, you use the same
method as what you used to set the texture up in the first place -
If you are just wanting to replace a small section of the image, then the high
performance way of doing this is to use the
When developing applications on Aviatrix3D we found that there were also several different types of updates that you could want to do on textures, depending on the content. For some, such as video processing, you know that you are going to need to replace the entire contents - anything that was there will be completely overwritten. For others, you know that you only are updating a couple of independent sub areas of the overall image. The way that we treat these internally can be very different and have some significant performance impacts. So, working with these different goals in mind, we have a set of update strategies flags that let you tell the texture image what optimisations to make. In the video case, we can just discard any other updates that are currently pending, but in the sub region update, we only want to keep the amount of texture data being sent to the video card to a minimum, so we make a number of calls to OpenGL each with its own small area of pixels.
The texture updating strategy can be set through the use of the
There are three strategies that are defined in that class:
Unfortunately, textures don't always look the best. A texture far away, reduced to a few pixels on screen may look rather terrible compared to it's original version - particularly if the full size includes some transparent pixels. That is where the filtering modes come in. These allow you to control how to sample the original pixels of the image as the texture is viewed from varying distances.
AV3D provides three different sets of filtering parameters that you can adjust
Specifying boundary modes is a capability of the
To set the boundary mode, you need to find the appropriate method call. Since
textures can have varying number of dimensions, you won't find all the methods
on the base
Texture functions control how the texture image is applied to the object and
the underlying object colour and lighting model. Control over this ability is
found in the
TextureAttributes attr = new TextureAttributes(); attr.setTextureMode(TextureAttributes.MODE_REPLACE);
Making use of the texture combiner modes and methods are covered in the Multitexturing tutorial, so we won't cover them in detail here.
If your texturing needs to make use of explicit blend colour, such as using
attr.setBlendColor(0, 0, 1, 1);
Texture filtering can be used with the same set of capabilities as that provided by OpenGL. The same restrictions also apply - such as attempting to use mipmap filter modes without providing mip maps will disable texturing. The library is just a thin layer based on the requested modes, the real visual behaviour is defined by the OpenGL specification.
Three filter capabilities are defined - minification, magnification and anisotropic. Each have their own methods. Separate constant sets are defined for each filter as although some options look common, the underlying OpenGL calls use different constants to describe each filter type. It also helps us internally work out quickly whether you've passed us a dodgy value or not.
Each of the filter setting methods are found on the base class
Texture Coordinate Generation
Automatic texture coordinate generation is used in a lot of places,
particularly for the various forms of environment mapping. All of the available
options are wrapped up into the class
All settings are performed through the
Parameter values are only needed if you are using one of the eye or object
linear generation modes. For any other mode, we don't look at it internally,
so you'll be safe to pass a
In large worlds with a lot of textures, there can be significant performance loss due to the underlying graphics APIs having to shuffle the texture image data on and off the video card as each texture is rendered. The use of state sorting by the graphics API can help somewhat with this, but when there are a lot of textures and there's more texture data than available texture memory, then this thrashing can be a significant bottleneck. Some applications know that certain textures will always be required, and others not. A good example of this is grass and road textures in a game. It would benefit performance if you can indicate which textures are prefered to be always kept on the card, and those which you don't care about.
When you know you have a some textures that you would prefer to keep on the video card over others, then you want to make use of texture priorities. These are your way of indicating which textures are more important to be kept on the video card, and those which are ok to be tossed out between frames.
Priorities are indicated with a floating point value between zero and one. A
value of zero means unimportant, with a value of one being the most important.
If you don't care about the texture or any priority, then set a value of
-1. These can be set uing the
Aviatrix3D also allows you to specify textures that describe depth information. Depth textures are used in rendering shadows.
Current Limitations and Missing Capabilities
The following capabilities cannot be used or expressed through the various APIs available in Aviatrix3D. We're considering designs for them, but have nothing solid yet.
[ Home ]
[ License ]
[ javadoc ]
[ Online Examples ]
[ Download ]
[ j3d.org ] [ Aviatrix3D ] [ Code Repository ] [ Java3D ] [ OpenGL ] [ Books ] [ Contact Us ]
Last Updated: $Date: 2010-05-01 04:20:35 -0700 (Sat, 01 May 2010) $