Max WebGL Textures

I have been looking for information on WebGL and the maximum number of textures / memory that can be assigned for rendering. It's obviously hardware / device, so I'm looking for a way to handle textures intelligently.

I currently have textures in 512x512 RGBA8 format. The user could potentially load 270 textures into memory. I understand that it works with 4 bytes per pixel multiplied by 4/3 for mip cards. So one texture map plus mip will be in the 4 * 512 * 512 * 1.33 = 1.33 MB area. A total of 359.1 MB to load textures into memory.

This is the worst case and will work well on mid / high end computers, but I also want to optimize for mobile once WebGL is widely available on Android and low spec machines.

If I reduce the textures to 256x256 I will notice a loss in quality, but this might be an option for low level devices. The result is only 4 * 256 * 256 * 1.33 = 0.33 MB per texture and 89.1 MB in total.

Is there anyway an API to determine the total available texture memory before trying to load textures into the WebGL context?

Also is there a limit on the total number of textures that can be loaded into memory at one time?

I want to use the above two parameters to have reasonable defaults when the user loads my page.

+3


source to share


1 answer


As far as I know, there is no way to do this. From toji's answer , it looks like this is for security reasons.

I would have wondered who would be using your application and if this user group is something other than a strict user with large dedicated graphics cards on their desktops, then minify textures for everyone. Perhaps you can allow a higher level of graphics as an option, but understand that this is likely to cause an out of memory exception for some / most people.



If you don't accidentally use all of these textures at once, you can try to keep track of which ones you are using and only load them into memory (and unload textures with gl.deleteTextures

). My guess is that removing and loading these many textures at runtime rather than at startup will take a long time, so doing this carefully (just a few at a time) to maintain frame rates would be wise. Not sure if you will even be able to load a 1.33 MB texture in one frame, or if this even applies to your application.

+1


source







All Articles