Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 7 of 7

Thread: GL ES: Fragment shader optimization

Threaded View

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2013
    Posts
    4

    Question GL ES: Fragment shader optimization

    Summary:
    I get FPS slowdown as soon as I try to tint the sprites (i.e: multiply texture with color in the fragment shader)

    Details:

    Hardware: iPod touch 4

    Using 64x64 png texture containing alpha channel, rendering with glEnable(GL_BLEND). (A smiley face with a drop shadow)

    I am drawing 700 sprites on the screen using glDrawArrays. And yes I am batching all of these in a single draw call. Following shows Vertex data structure:

    Code :
        struct Vertex {
            float Position[2];
            float Color[4];
            float Texture[2];
        };
    Yes I am sending colour with each vertex because I selectively need to tint some sprites but not others. Following is the fragment shader I am using:

    Code :
        varying lowp vec2 TexCoord;
        uniform sampler2D TextureSampler;
     
        void main(void)
        {
            gl_FragColor = texture2D( TextureSampler, TexCoord );
        }

    Till now it is working GREAT, giving me full 60 FPS !!!

    BUT

    As soon as I change the fragment shader to the following (to allowing tinting):

    Code :
        varying lowp vec4 DestinationColor;
        varying lowp vec2 TexCoord;
        uniform sampler2D TextureSampler;
     
        void main(void)
        {
            gl_FragColor = texture2D( TextureSampler, TexCoord ) * DestinationColor;
        }

    The performance drops to 47 FPS only due to this single change {just by multiplication with ONE vector} (FPS measured using xcode instruments and OpenGL detective). Any ideas what is going on ?

    Thanks.
    Last edited by fakhir; 05-23-2013 at 07:50 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •