Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: suggest a best way to do transformation of matrices in openGLES2.0?

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2014

    suggest a best way to do transformation of matrices in openGLES2.0?

    Hi.I am developing an OpenGLES2.0 application.Time to render the application is crucial thing for me.My application has both static and dynamic objects(moving pointers in dial).To improve the performance I want to reduce the computation burden on CPU. I want to compute the transformation matrices(translate,rotate,scaling) in the shader itself instead of computing them on CPU (only for dynamic objects).Is it advisable to do like this to improve the performance?

    My vertex shader will look this

    Code :
    vertex .c
        int main() 
          if(static==0)   //for static rendering. Value sent from the app 
           gl_Position = mvp* vec4(vert,1.0); // MVP is calculated in the app and sent to shader 
          if(static==1) // for dynamic objects. Value sent from the app
         /* compute translated matrix
         /* Compute rotated matrix
         /* compute scaled matrix
          gl_Postion = mvp*vec4(vert,1.0); /* mvp is calculated in the shader 
    calculation burden will be on GPU instead of CPU only in the case of dynamic objects.Will this improve time to render an application? I need a better FPS.

  2. #2
    Member Regular Contributor Agent D's Avatar
    Join Date
    Sep 2011
    Innsbruck, Austria
    Branches in shader code are generally very bad for performance.

    Even if you don't have branches and compute the matrices every time, doing the same thing multiple times in parallel doesn't make it faster and you simply shift static time overhead from the CPU to the GPU. Even worse, since all vertices probably won't be computed at the same time, you multiply the static time overhead.

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    The vertex shader is run once per-vertex.

    Based on that it should be obvious that for, say, a 200 triangle model you're now computing your transforms 600 times.

    Compare that to once-only for the entire model and the cost of an upload if you just do it on the CPU.

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