Difference between revisions of "Image System"
Steve Linden (talk | contribs) |
Steve Linden (talk | contribs) |
||
Line 42: | Line 42: | ||
= Code Description = | = Code Description = | ||
== Viewer Image == | == Viewer Image == | ||
[[Image:class_l_l_viewer_image.png]] | [[Image:class_l_l_viewer_image.png]] LLImageGL defines the interface between Second Life image data and OpenGL. It includes methods for setting the image data, reading it back, discarding mip levels, setting GL paramaters (like clamping), and various accessors. LLViewerImage contains additional state data for calculating the image priority and desired discard level. It also has methods for texture fetching. |
Revision as of 17:02, 4 December 2006
Overview
The texture pipeline handles the requesting, loading, and decoding of texture data. It also handles passing the data to OpenGL, and discarding unwanted data. It uses a priority scheme to determine what data to load and to discard.
Definitions
Format
SecondLife uses JPEG 2000 textures which are decoded in the client and sent to OpenGL as uncompressed 24 bit or 32 bit textures.
Discard Level and Mip Mapping
- Discard level
Discard level 0 represents the highest resolution version of a texture. Discard level 1 represents a texture half the resolution of discard level 0 in each dimension, so one quarter of the pixel area and one quarter of the required texture memory. It is primarily a function of total pixel area, e.g. if a 256x256 texture is covering a 128x128 portion of the screen, the desired discard level is 1.
- Mip Mapping is a technique where multiple resolutions of a texture are stored in order to optimize rendering. To support mipmapping, when discard level 0 is loaded, discard levels 1-N are also loaded (where N represents the smallest useful image). e.g. When a 256x128 texture is loaded, the following textures are also generated and loaded: 128x64, 64x32, 32x16, 16x8, 8x4. This incurs a 33% increase in the amount of texture memory consumed, but makes a significnt improvement in performance and visual quality.
Prioritization
- Total pixel area
This is an approximation of the total number of pixels of a texture from all faces that are currently being rendered. This is a factor in determining the priority (see below) of a texture.
- Maximum pixel area
This is an approximation of the maximum number of pixels of a texture on a single face that are currently being rendered. This is the primary factor in determining the desired discard level (see below) of a texture.
- Boost level
This is used to increase the prioritization of some textures over others. For example, textures on selected faces are boosted.
- Priority
Also referred to as decode priority, this is used to determine in what order texture data is downloaded and decoded. It is a function of the total pixel area, the boost level, and the difference between the current discard level and the desired discard level.
Feature Description
Texture Pipeline
- The render pipeline determines which textures are required, their desired discard level, and their priority.
- At this point, the following steps are followed:
- Requests are sent to the texture fetcher for texture data
- The texture fetcher does the following with each request:
- Load data from cache if available
- Send requests to the servers for additional texture data if needed
- Receive data from the servers
- Cache received data
- Decode the texture
- When the texture data is ready the render pipeline is notified
- The decoded texture data is passed to OpenGL for rendering
- Each frame a limited number of textures are examined and processed as follows:
- If the desired discard level of the texture decreases significantly, more texture data is requested and the texture is updated with the higher resolution data
- If the desired discard level of the texture increases significantly, the undesired discard levels are discarded from memory
Code Description
Viewer Image
LLImageGL defines the interface between Second Life image data and OpenGL. It includes methods for setting the image data, reading it back, discarding mip levels, setting GL paramaters (like clamping), and various accessors. LLViewerImage contains additional state data for calculating the image priority and desired discard level. It also has methods for texture fetching.