Graphics Reference
In-Depth Information
attribute vec2
Position ,
TextureCoordinates [ LAYER_COUNT ];
varying mediump vec2
vTextureCoordinates [ LAYER_COUNT ];
void main ()
{ gl_Position = vec4 ( Position . xy , 0.0, 1.0 );
for ( int i =0; i < LAYER_COUNT ; i ++ )
{
vTextureCoordinates [ i ]= TextureCoordinates [ i ];
}
}
Listing 5.3. Single draw call vertex shader.
superfluous layers into account; this solution requires packing an extra attribute
containing the number of layers aggregated by the current primitive.
We did not need to implement this, but it should be possible to address the
texture limitation mentioned before (one texture or same textures in same order
for all tiles) by using texture atlases at the cost of a more complex handling of
texture coordinates and wrap modes. A better solution would have been to use
Array Textures if they were available on all platforms [OpenGLWiki 13]. Starting
with OpenGL ES 3.0, this will become a valid option [Khronos 13].
The fragment shader is the same as the one of the multiple draw calls ap-
proach.
Table 5.1 summarizes the main differences between the two approaches. The
main argument for choosing one or the other is related to the number of tiles
to render. When using a high number of tiles (e.g., 64 or more) or if your
application is already sending too many batches, the single draw call approach
should perform better (provided your scene fits its limitations). When using a
relatively low number of tiles, we would recommend using the multiple draw calls
approach, as it is much more flexible, easier to implement and provides more
opportunities to lower memory trac.
5.4.2 Render Target Resolution
For effects such as clouds and smoke, which use textures of relatively low frequen-
cies, a commonly used optimization consists in rendering the effect to a lower
resolution offscreen render target before upsampling it to the final framebuffer.
Search WWH ::




Custom Search