| OGRE 1.11.1 Object-Oriented Graphics Rendering Engine

Public Member Functions | Static Public Attributes | List of all members
Ogre::RTShader::TextureAtlasSampler Class Reference
Optional Components » RTShaderSystem

Implements texture atlas sampling. More...

`#include <OgreShaderExTextureAtlasSampler.h>`

Inheritance diagram for Ogre::RTShader::TextureAtlasSampler:
[legend]

## Public Member Functions
| TextureAtlasSampler ()
| Class default constructor. More...
virtual void | copyFrom (const SubRenderState &rhs)
| More...
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
| More...
virtual const String & | getType () const
| More...
virtual bool | preAddToRenderState (const RenderState *renderState, Pass *srcPass, Pass *dstPass)
| More...
virtual void | updateGpuProgramsParams (Renderable *rend, Pass *pass, const AutoParamDataSource *source, const LightList *pLightList)
| More...

## Static Public Attributes
static String | Type

## Detailed Description

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:
  1. Ignore the problem - bad for repetitive images in which the border colour may be quite apparent.
  2. 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.
  3. 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.

## Constructor & Destructor Documentation

## ◆ TextureAtlasSampler()

Ogre::RTShader::TextureAtlasSampler::TextureAtlasSampler | ( |  | ) |

Class default constructor.

## Member Function Documentation

## ◆ getType()

virtual const String& Ogre::RTShader::TextureAtlasSampler::getType | ( |  | ) | const
| virtual

See also
  SubRenderState::getType.

Implements Ogre::RTShader::SubRenderState.

## ◆ getExecutionOrder()

virtual int Ogre::RTShader::TextureAtlasSampler::getExecutionOrder | ( |  | ) | const
| virtual

See also
  SubRenderState::getType.

Implements Ogre::RTShader::SubRenderState.

## ◆ copyFrom()

virtual void Ogre::RTShader::TextureAtlasSampler::copyFrom | ( | const SubRenderState & | rhs | ) |
| virtual

See also
  SubRenderState::copyFrom.

Implements Ogre::RTShader::SubRenderState.

## ◆ updateGpuProgramsParams()

virtual void Ogre::RTShader::TextureAtlasSampler::updateGpuProgramsParams | ( | Renderable * | rend,
|  | Pass * | pass,
|  | const AutoParamDataSource * | source,
|  | const LightList * | pLightList
| ) |  |
| virtual

See also
  SubRenderState::updateGpuProgramsParams.

Reimplemented from Ogre::RTShader::SubRenderState.

## ◆ preAddToRenderState()

virtual bool Ogre::RTShader::TextureAtlasSampler::preAddToRenderState | ( | const RenderState * | renderState,
|  | Pass * | srcPass,
|  | Pass * | dstPass
| ) |  |
| virtual

See also
  SubRenderState::preAddToRenderState.

Reimplemented from Ogre::RTShader::SubRenderState.

## ◆ createCpuSubPrograms()

virtual bool Ogre::RTShader::SubRenderState::createCpuSubPrograms | ( | ProgramSet * | programSet | ) |
| virtual inherited

Create sub programs that represents this sub render state as part of a program set.

The given program set contains CPU programs that represents a vertex shader and pixel shader. One should use these program class API to create a representation of the sub state he wished to implement.

Parameters

  programSet | container class of CPU and GPU programs that this sub state will affect on.

Reimplemented in Ogre::RTShader::FFPTransform.

## ◆ getAccessor() [1/2]

SubRenderStateAccessorPtr Ogre::RTShader::SubRenderState::getAccessor | ( |  | ) |
| inherited

Return the accessor object to this sub render state.

See also
  SubRenderStateAccessor.

## ◆ getAccessor() [2/2]

SubRenderStateAccessorPtr Ogre::RTShader::SubRenderState::getAccessor | ( |  | ) | const
| inherited

Return the accessor object to this sub render state.

See also
  SubRenderStateAccessor.

## Member Data Documentation

## ◆ Type

String Ogre::RTShader::TextureAtlasSampler::Type
| static

The documentation for this class was generated from the following file:

- OgreShaderExTextureAtlasSampler.h