Results 1 to 2 of 2

Thread: confusion about drawing meshes per material and uniform buffer for constants

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2011

    Question confusion about drawing meshes per material and uniform buffer for constants

    Hi there, I've been trying to build a simple rendering engine on my own in the hope of learning more about graphics. Now I have two confusions.

    1. To keep GL state change as few as possible, my idea now is that I render meshes that share the same material all together. But I don't know whether I should keep an array of mesh pointer in each material or create a map with key as material pointer and mapped value as an array of mesh pointer. Or is there other better ways? how is it implemented commonly? what about the case where many objects share the same mesh?

    2. I would like to use uniform buffer objects to store various constants for shaders to use, I know I can use one uniform buffer object per scene to store matrices like view and perspective, but I don't know how many should I create for objects and materials, one for each? or few shared by them?


  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    To minimise the number of draw calls, you want to be able to use multiple materials within a single mesh. Make the material ID a "flat" vertex attribute, with material properties stored in an array and textures stored as layers of an array texture.

    That way, you only need to use separate draw calls for parts of the scene which are structurally different (i.e. those which require completely different shaders, not just different values).

Similar Threads

  1. Replies: 1
    Last Post: 11-02-2018, 03:52 AM
  2. Uniform Buffer confusion
    By Robinson in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 09-10-2011, 08:28 AM
  3. Uniform confusion
    By Vexator in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 01-25-2011, 09:09 AM
  4. Help material on 3D meshes?
    By Ali in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 01-10-2008, 09:53 PM
  5. Help Material on 3d Meshes?
    By Ali in forum OpenGL: General
    Replies: 0
    Last Post: 01-04-2008, 12:02 PM

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