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.
fragColor *= texture(texture0,texcoords0);
fragColor *= texture(textureatlases[materialdefs[materialid].textureslot],vec3(texcoords0,materialdefs[materialid].texturelayer));
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.
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.