Jump to content

Bindless Textures


Josh

5,284 views

 Share

The clustered forward renderer in Leadwerks 5 / Turbo Game Engine required me to implement a texture array to store all shadow maps in. Since all shadow maps are packed into a single 3D texture, the shader can access all required textures outside of the number of available texture units, which only gives 16 guaranteed slots.

I realized I could use this same technique to pack all scene textures into a few arrays and completely eliminate the overhead of binding different textures. In order to do this I had to introduce some restrictions. The max texture size, by default, is 4096x4096. Only two texture formats, RGBA and DXT5, are supported. Other texture formats will be converted to RGBA during loading. If a texture is smaller than 1024x1024, it will still take up a layer in the 1024x1024 texture array.

This also makes texture lookups in shaders quite a bit more complicated.

Before:

fragColor *= texture(texture0,texcoords0);

After:

fragColor *= texture(textureatlases[materialdefs[materialid].textureslot[0]],vec3(texcoords0,materialdefs[materialid].texturelayer[0]));

However, making shaders easy to read is not a priority in my design. Performance is. When you have one overarching design goal these decisions are easy to make.

Materials can now access up to 256 textures. Or however many I decide to allow.

The real reason for this is it will help support my goal to render the entire scene with all objects in just one or a few passes, thereby completely eliminating all the overhead of the CPU/GPU interaction to reach 100% GPU utilization, for ultra maximum performance, to eliminate VR nausea once and for all.

Also, I went out walking yesterday and randomly found this item in a small shop.

image1.jpeg.64226bcfc2593981217489f66b72cdcf.jpeg

There's something bigger at work here:

  • Most of my money comes through Steam.
  • Valve invented the technology the HTC Vive is based on.
  • Gabe Newell gave me the Gigabyte Brix mini PC that the new engine architecture was invented on.
  • The new engine makes VR performance 10x faster.

If this isn't a clear sign that divine providence is on our side, I don't know what is.

  • Like 3
  • Upvote 1
 Share

4 Comments


Recommended Comments

I figured out how to resize array textures, so we can start with a small array texture and then resize it bigger and bigger as more textures are added into it. This was also a necessary step to finish the lighting system. Previously, I had just been allocating one big texture based on a maximum number of lights, but we need that to be dynamic.

With any luck the new engine will be able to render a scene like The Zone in one single draw call at 1000 FPS.

  • Upvote 1
Link to comment

How does it compare if at all to the ID, Rage/ Ubisoft, Far Cry / Dice implementations of Megatextures/Adaptive Virtual Textures ?

 

Various Videos from the implimentors.

 

 

 

 

 

 

Link to comment

Our terrain system is actually very similar to that, the only difference being that we generate the "megatextures" dynamically instead of storing a lot of data.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...