Jump to content
  • Advertisement
Sign in to follow this  

Material textures: to pack or not to pack

This topic is 2062 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts



TL;DR: Just jump down to the last paragraph. ^^


I've come to the point where I want to implement most of the features our material system is planned to support, and I suddenly find myself surrounded by lots of textures!

I have:

 - Diffuse + alpha maps, 4 channels (alpha is used for alpha-testing)

 - Glow maps, 1 channel

 - Normal maps, 3 channels

 - Specular maps, 1 channel

 - Gloss maps, 1 channel


In total I need 10 channels, which could be packed into 2 RGBA8 textures + 1 RG8 texture for optimal memory usage. However, I'm having doubts on the benefit of doing so due to the fact that not all maps are mandatory. Since I'm using deferred shading, almost all the data in the textures is just copied directly to the G-buffers. Memory bandwidth is a huge bottleneck here, and not all maps are needed for all materials. 


To reduce the number of shader permutations I intend to simply use a 4x4 "null" texture when a map isn't needed instead of a custom shader that doesn't sample that texture. Diffuse, normal and specular maps are almost always used while glow and gloss maps are much rarer. With that in mind, keeping the above 5 maps in separate textures could reduce bandwidth usage even more than packing since I could just replace a texture with a 4x4 "null" texture if it's not needed. However, this would require 5 texture samples instead of 3, although there would be less data sampled per texture so the total should be the same. Memory-wise, only the normal map is padded to RGBA, so it'd increase memory usage by 10% (10 ---> 11 channels).




I guess it all boils down to a single question: Do the number of texture samples (from different textures) affect performance or is it just how many total bytes of data that is read from textures that affects performance? Texture access is very cache friendly.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!