Results 1 to 2 of 2

Thread: issues about shaders and transformations

  1. #1
    Junior Member Newbie
    Join Date
    May 2013

    Question issues about shaders and transformations

    - If I'm not wrong, shaders are programs that run in GPU, right?
    - Do we send data to this programs using glUniformMatrix*?
    - I don't know if it's right but if I send a MVP matrix to the shader, the object's vertices that I want to render will use the position calculated by the shader right before calling the render function.
    - If I want to render a lot of objects and I must send the MVP matrix then render the object right after, so I will have a code that send to GPU -> render a lot of times. However if I'm not wrong again this is not a good practice because I'm losing performance because the cost of send information to GPU is very expensive. So a way to get a better performance is send all the informations to GPU then render all the objects.

    - And the questions of 1 million dollars is, How can the shader program identify that the MVP matrix is used by a single object and not another one?

  2. #2
    Member Contributor Brokenmind's Avatar
    Join Date
    Feb 2014
    Aachen / Germany
    1) Yes, that's the basic definition. To use them correctly, you should use a bit more than that, though...
    2) Yes, that's one of the possible commands. Keep in mind that they can only be sent if the shader is actually running (glUseProgram).
    3) No, if you send a MVP to the shader, the coordinates you want to draw will be transformed right after calling the render function. However, they will be transformed before the shader assigns colors to them.
    4) What you allude to is instancing, which is basically what you described: Pack the information every object needs into a chunk, send it to the GPU and then use only a single draw call to draw all objects at once.
    5) It can't, it just uses everything you send it and how you coded it. You can, however, add an offset to the position for every instance which will result in a different coordinate, although being transformed with the same MVP.

Similar Threads

  1. Replies: 9
    Last Post: 07-11-2013, 09:31 AM
  2. Replies: 7
    Last Post: 08-11-2012, 01:52 PM
  3. Hardware Transformations vs Software Transformations
    By killersquirrelz in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 12-05-2004, 04:43 AM
  4. Non-linear texture transformations with texture shaders
    By Roman Grigoriev in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 03-26-2003, 09:11 PM
  5. Replies: 1
    Last Post: 08-30-2000, 10:54 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
Proudly hosted by Digital Ocean