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 2 of 2

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

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2011
    Posts
    20

    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?

    Thanks.

  2. #2
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    474
    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).

Posting Permissions

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