Results 1 to 2 of 2

Thread: Scaling and Translating in the Vertexshader

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    2

    Scaling and Translating in the Vertexshader

    Hello folks,

    I must say, I'm new to OpenGL ES 2.0 and I'm working on Android.
    I've written a small vertex shader that implements the scaling and translation of my incoming vertices. Therefor I have a scaling-matrix (mat4 scale) given by
    / sx 0 0 0\
    | 0 sy 0 0|
    | 0 0 sz 0|
    \ 0 0 0 1/
    and a translation-vector (vec4 trans) given by:
    /tx\
    |ty|
    |tz|
    \1/
    so gl_Position = (scale * Vertex) + trans;

    but I thought it's easier to give both operations in just one matrix (mat4 proj), so that gpu has only to perform an multiplication and and not a multiplication AND addition. matrix4 looks like that:
    / sx 0 0 tx\
    | 0 sy 0 ty|
    | 0 0 sz tz|
    \ 0 0 0 1/
    so gl_Position = Vertex*proj;

    Now the problem: the first way coordinate-tranformation works, but when I put both operations together in one martix nothing happens. dont' know what is going wrong? - please help!

  2. #2
    Junior Member
    Join Date
    Jul 2012
    Posts
    2

    Re: Scaling and Translating in the Vertexshader

    It's, as always, you should just wait a day before one bothered others with your problems, since they usually dissolve by themselves.
    The solution is so simple and ingenious: The definition of matrices is performed by the GL-API column-wise and not row by row. As long as one only performs the scaling it has not affect because the factors are on the main diagonal, but with one additional translational is has effect.

Similar Threads

  1. Scaling Texture
    By Rainmaker0929 in forum OpenGL ES general technical discussions
    Replies: 0
    Last Post: 07-04-2011, 06:32 AM
  2. A problem about the non-uniform scaling.
    By akaiwall in forum OpenVG and VGU
    Replies: 3
    Last Post: 04-15-2009, 08:59 AM

Posting Permissions

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