Sign in to follow this  
lawnjelly

OpenGL ES max active textures in OpenGL ES 2.0

Recommended Posts

I've been making pretty good use of texture atlases in my current game, but as I find myself forced to use another texture (to enable generating tex coords for point sprites), I'm wondering if there may be a better way than currently batching by texture, and calling glBind before each batch.

Instead is it more efficient to pre-bind a whole set of textures to all the available active texture slots, then simply only read from the ones I'm interested in in the fragment shaders (or call glUniform to change the active texture used by the frag shader). Is there any performance penalty to have a load of textures bound, but not being used?

Is this a practical way to work on GLES 2.0, and are there any typical figures for how many active texture slots should be available on mobiles? I'm getting the impression the minimum is 8.

This may make a difference as I'm having to do several render passes on some frames.

Share this post


Link to post
Share on other sites

So, the maximum number of active textures is not the same for every device, you'll need to check it using GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:

https://www.khronos.org/registry/OpenGL-Refpages/es2.0/xhtml/glActiveTexture.xml

As for binding all those texture, do you really need to bind all of them if your not using all of them? As far as i know this *could* be a hit to performance, the drivers may move the resources to a more accessible location for the shader when they are bound. I don't think this is the right approach.

I think your original method of tiling the textures is a better approach if you want to bind less often.

Another way you can do it is to dynamically create these huge textures. basically each sprite you have can be their own resource, then you copy those resources into the larger texture that you will bind and use for that frame. you can keep them in that texture until you need more space for new sprites to be rendered in the frame, then just overwrite "tiles" in that texture that you are no longer using.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Announcements

  • Forum Statistics

    • Total Topics
      628359
    • Total Posts
      2982259
  • Similar Content

    • By lawnjelly
      Here you can see I have got attachments working over the past few days. Each actor can have a number of attachments to specific locations like head, hands, root node etc. It took some fiddling with matrices to get the attachment rotations consistent as I foolishly didn't standardize the rest hand rotations on actor models.
      The weapons, shields and hats etc are pretty good but there is some cutting through when carrying some bulky items. Any game model can be made an attachments, including the huts(!) I'm not sure what they will look like being carried.
      I'm hoping to be able to attach canoes to the root bones and have the hero and natives in canoes on the water. Also I want to add particle emitters to attachments for example for a burning torch or a smokey herbal spliff.  
      Here the player is carrying a sword and wearing a stylish african hat.
    • By KaiNiklas
      Hi there,

      after some years of silence i now will have the time again to do some serious hobby game dev.
      I am a OpenGL / 3D / 2D Expert and can code almost any landuage.

      For some serious hobby game dev i am looking for 1 stable person to join me.
      Best case , you are an artist in 2d or 3d and/or have some game idea.

      I am open to any kind of game that the 2 of us can finisch.

      Find some stuff from / about me here:
      https://www.youtube.com/user/uwi2k2/videos

      cu
      kai
    • By theScore
      Hi !
      I have a drawing problem, display seems to be corrupted.
      The program is opengl es 3.0 running on iPhone.
      I have a file loader and it loaded data correctly before, but if you look at both attached images, the red, blue and green cubes aren't displayed correctly ( and only them).
      I haven't changed the source code of my loader, so I don't think it comes from it.
      I know however one thing, it is that vertices and indices ( and texture coordinates, and normals ) are raw pointers, and I think my problem is in relation to memory data/heap corruption because I didn't freed them before.
      The scenes were displayed correctly before and this problem came suddenly, without changing the source code for the loader and the opengl es class.
      What do you think about this problem ? Can you help me to solve it ?


    • By KaiNiklas
      Hi there,

      i am a Programmer for 20 years and a OpenGL Trainer.
      I am looking for a "grown up" / "reasonable"  Artist/Designer that is willing to work on a Game with me.

      I can do any kind of Programming , so your Part may be any kind of Design and/or Gameideas .. but i am open here.
       
      Sadly the last Artist i worked with had no more time for the Project, so maybe you wanne join me.

      We were working on a 2d TopDown Game in Pixel style, but i am open to any game idea that we can do in a 2 man team.

      I like to work on a 2 people team, as all the other big Projects always seem to end up in chaos.

      would be happy to hear from you.

      regards
      kai

      i attach some screens from the last game project:



    • By cebugdev
      hi all,

      i am trying to build an OpenGL 2D GUI system, (yeah yeah, i know i should not be re inventing the wheel, but this is for educational and some other purpose only),
      i have built GUI system before using 2D systems such as that of HTML/JS canvas, but in 2D system, i can directly match a mouse coordinates to the actual graphic coordinates with additional computation for screen size/ratio/scale ofcourse.
      now i want to port it to OpenGL, i know that to render a 2D object in OpenGL we specify coordiantes in Clip space or use the orthographic projection, now heres what i need help about.
      1. what is the right way of rendering the GUI? is it thru drawing in clip space or switching to ortho projection?
      2. from screen coordinates (top left is 0,0 nd bottom right is width height), how can i map the mouse coordinates to OpenGL 2D so that mouse events such as button click works? In consideration ofcourse to the current screen/size dimension.
      3. when let say if the screen size/dimension is different, how to handle this? in my previous javascript 2D engine using canvas, i just have my working coordinates and then just perform the bitblk or copying my working canvas to screen canvas and scale the mouse coordinates from there, in OpenGL how to work on a multiple screen sizes (more like an OpenGL ES question).
      lastly, if you guys know any books, resources, links or tutorials that handle or discuss this, i found one with marekknows opengl game engine website but its not free,
      Just let me know. Did not have any luck finding resource in google for writing our own OpenGL GUI framework.
      IF there are no any available online, just let me know, what things do i need to look into for OpenGL and i will study them one by one to make it work.
      thank you, and looking forward to positive replies.
  • Popular Now