|
| TextureAtlasSampler () |
| Class default constructor. More...
|
|
virtual void | copyFrom (const SubRenderState &rhs) |
|
virtual bool | createCpuSubPrograms (ProgramSet *programSet) |
| Create sub programs that represents this sub render state as part of a program set. More...
|
|
SubRenderStateAccessorPtr | getAccessor () |
| Return the accessor object to this sub render state. More...
|
|
SubRenderStateAccessorPtr | getAccessor () const |
| Return the accessor object to this sub render state. More...
|
|
virtual int | getExecutionOrder () const |
|
virtual const String & | getType () const |
|
void | operator delete (void *ptr) |
|
void | operator delete (void *ptr, const char *, int, const char *) |
|
void | operator delete (void *ptr, void *) |
|
void | operator delete[] (void *ptr) |
|
void | operator delete[] (void *ptr, const char *, int, const char *) |
|
void * | operator new (size_t sz) |
|
void * | operator new (size_t sz, const char *file, int line, const char *func) |
| operator new, with debug line info More...
|
|
void * | operator new (size_t sz, void *ptr) |
| placement operator new More...
|
|
void * | operator new[] (size_t sz) |
|
void * | operator new[] (size_t sz, const char *file, int line, const char *func) |
| array operator new, with debug line info More...
|
|
virtual bool | preAddToRenderState (const RenderState *renderState, Pass *srcPass, Pass *dstPass) |
|
virtual void | updateGpuProgramsParams (Renderable *rend, Pass *pass, const AutoParamDataSource *source, const LightList *pLightList) |
|
Implements texture atlas sampling.
This class implements a sub render state which allows sampling of a texture from a texture atlas.
Note: This class does not implement the entire texture sub-render state. It only implement the sampling of textures. This class needs to work in conjunction with the default FFPTexturing to work.
- Using the TextureAtlasSampler
- There are 2 pieces of information that are need to be provided for this sub render state to work.
The first is the texture atlas table. This table consists of several records containing the position and size of each texture in the in the texture atlas. This information needs to be provided per atlas texture. The information is entered to the system though the TextureAtlasSamplerFactory using the functions setTextureAtlasTable and removeTextureAtlasTable.
The second information is the index of the record in the texture atlas table to which a given texture is associated with. This information is provided through an extra texture coordinate in the vertex buffer. This texture coordinate might can be placed either relative or in absolute position.
For example:
- given 3 texture sand a relative position of 2, the shader will search assume that the indexes exist in texture coordinate 5 (2+3)
- given an absolute position of 2, the shader will search for the indexes in texture coordinate 2, regardless of the amount of textures
The position of the indexes can be controlled globally through the TextureAtlasSamplerFactory class using the function setTableIndexPosition The default index position is set to relative + 1.
- Preparing atlas textures
- When preparing the atlas texture to be used in this system you should make sure that all texture with in the atlas have power-of-2 dimensions. And also that the inserted textures will be padded with 1 pixel of their own border color. This will prevent visual artifacts caused when sampling textures at their borders.
- Border issues
- There is an inherit problem in texture atlases. This issue occurs because individual textures within the atlas texture are adjacent to one another. when polling the color of a texture near the texture's edges, especially in lower mipmaps pixel color from other images may be mixed in with the result. There are 3 ways to handle this issue, each with it's own limitations:
- Ignore the problem - bad for repetitive images in which the border colour may be quite apparent.
- Auto adjust the polling position - This the default implementation of the TextureAtlasSampler SRS. Auto adjust the polling position in the shader according the mipmap level in use. This means that a different (smaller) section of an image may be polled instead of the original section (especially with in mipmaps). Bad for non repetitive accurate images.
- Generate a texture atlas where each image will contain around it a wrapped version of itself. This solves all visual problems but is wasteful in gpu memory (up to 3 times the size of the original image)
You can use the NVidia "Texture Atlas Tools" to create the texture.