Sign in to follow this  
Zaph-0

Terrain + Texture Compression

Recommended Posts

Hi guys, I thought about various ways to texture my terrain and decided on using a huge base texture for things far away and blending it with detail textures for things close by (if thats a bad idea, please let me know). Now I considered to use a 1024 x 1024 heightmap and generate a 8192x8192 basemap for it which I hope is not too big. The basemap would be 8k*8k*4 = 256MB memory which is way too much. With texture compression I should get it down to 32MB memory. Since I have absolutely no experience with texture compression, I would like to ask you some things about it: 1. Does using TC decrease the rendering performance (fps) generally or in certain situations ? 2. Are the results I could get with this kind of technique acceptable in quality considering I will use the compressed texture only for things far away ? 3. I don't need alpha so would color (5:6:5) = D3DFMT_DXT1 be the right kind of compression ? If am looking forward to your answers... ^_^

Share this post


Link to post
Share on other sites
Yes, DXT1 would be the best format. Note, however, that by using 8192x8192 textures you're limiting your user base to people who have DX10 level hardware.

Share this post


Link to post
Share on other sites
If you've got a 1024x1024 heightmap, I would suggest using something like a 2048x2048 (or less) base texture to give a more organic feel to your detailed level. I don't think you need to go as detailed as 8192 for a base layer. If you use texture filtering on the base texture, it should blur nicely under the detailed textures.

You can then perhaps use splatting over the top to introduce more detail and for the odd extra different area like oil spills on roads, etc, use a transparent decal or something projected onto the terrain.

If you've got it, I'd advise having a look at Sandbox 2 (free with Crysis) - after playing about with terrains and surface and detail texture layers, you can see how they do it which is similar to what I've described above.

Hope that helps.

Share this post


Link to post
Share on other sites
Quote:
Original post by RobMaddison
If you've got a 1024x1024 heightmap, I would suggest using something like a 2048x2048 (or less) base texture to give a more organic feel to your detailed level. I don't think you need to go as detailed as 8192 for a base layer. If you use texture filtering on the base texture, it should blur nicely under the detailed textures.


Well, I wanted to go that high with the resolution so that I can use it as a sufficiently detailed map by itself from some distance on. The added detailed textures are mostly only put close to the viewer because the triangle count adds up pretty quickly and I thought I could manage that with a high detail base map.

Quote:
Original post by RobMaddison
You can then perhaps use splatting over the top to introduce more detail and for the odd extra different area like oil spills on roads, etc, use a transparent decal or something projected onto the terrain.


That's what I am planning to do...

^_^

Quote:
Original post by RobMaddison
If you've got it, I'd advise having a look at Sandbox 2 (free with Crysis) - after playing about with terrains and surface and detail texture layers, you can see how they do it which is similar to what I've described above.


That sounds interesting. A friend of mine has crysis and I think I have to check it out.

Quote:
Original post by RobMaddison
Hope that helps.


Definitely...

^_^

Share this post


Link to post
Share on other sites
Quote:
Original post by Zaph-0
Quote:
Original post by RobMaddison
If you've got a 1024x1024 heightmap, I would suggest using something like a 2048x2048 (or less) base texture to give a more organic feel to your detailed level. I don't think you need to go as detailed as 8192 for a base layer. If you use texture filtering on the base texture, it should blur nicely under the detailed textures.


Well, I wanted to go that high with the resolution so that I can use it as a sufficiently detailed map by itself from some distance on. The added detailed textures are mostly only put close to the viewer because the triangle count adds up pretty quickly and I thought I could manage that with a high detail base map.


2048x2048 is safest in terms of hardware support, since all cards for quite a few years have supported it. 4096x4096 is available on Radeon x1x00 family and all GeForce cards since GeForceFX (5x00 family). 8192x8192 is only available on cards supporting DX10 (GeForce 8x00 and up, Radeon HD). So choose the size depending on your audience.

The Graphics Card Capability spreadsheet (available from the DirectX Sample Browser in the SDK) will give you more details of which cards support what.

Share this post


Link to post
Share on other sites
The other answers you were after:

1. DXT textures are faster than uncompressed as they use less memory bandwidth. I've never seen them reduce FPS, and they often increase it.

2. Many games compress almost all of their textures with DXT1 / DXT5 - the quality loss is usually minimal even close up, although you can lose some fine detail. The compression works best on textures that don't use many different colours in any 4x4 block.

Share this post


Link to post
Share on other sites
The only issue with DXT is that load times are considerably higher. Especially if you let HW create all mipmaps, then the total load time is doubled-tripled - which is a lot. I heard that if you let DXT tool create mipmaps for you, that the load time is considerably lower.

If you use a lot of textures, the performance goes up with DXT textures. Especially, if you have used all your VRAM and driver needs to swap it. Then you can clearly see that you can load much more textures without driver needing to start swapping.

Try using DXT to see that you can use the textures for close-ups too. The visual difference is negligible, compared to huge memory savings - 8:1 ratio is really a lot !

Rest assured there`s a lot of work in front of you in regards to adjustments of the textures - their contrast/brightness/ color distribution until it fits with the base terrain.

Another advice: It`s more work, but go for 2 detail layers, the second one used only for nearest terrain chunk and being mostly a black-white noise, so it`s easy to blend with previous 2 layers. Then, you don`t need your first detail layer to be of high resolution, only the second one.

Share this post


Link to post
Share on other sites
Quote:
Original post by VladR
The only issue with DXT is that load times are considerably higher. Especially if you let HW create all mipmaps, then the total load time is doubled-tripled - which is a lot. I heard that if you let DXT tool create mipmaps for you, that the load time is considerably lower.


There's a plugin available for photoshop and another for gimp that will let you export images as DDS, and generate those mipmaps at tool time. Doing this, your load times will be faster* than other formats.

* remembering that hard drive access is usually the bottleneck for loading speed, so you'll want to compress the textures as a tool step (yes, you're compressing compressed textures. I know it's weird, but it works usually), and have your program uncompress them at load time.

edit: You will find this useful if you're working with DDSs. With it you can take a 32 bit source image (in DDS), convert it to DXT1 (or 2 or 3 or 4 or 5 or a bunch of other formats), and see the image degradation. And even save out the compressed version.

Share this post


Link to post
Share on other sites
Quote:
Original post by ET3D
Quote:
Original post by Zaph-0
Quote:
Original post by RobMaddison
If you've got a 1024x1024 heightmap, I would suggest using something like a 2048x2048 (or less) base texture to give a more organic feel to your detailed level. I don't think you need to go as detailed as 8192 for a base layer. If you use texture filtering on the base texture, it should blur nicely under the detailed textures.


Well, I wanted to go that high with the resolution so that I can use it as a sufficiently detailed map by itself from some distance on. The added detailed textures are mostly only put close to the viewer because the triangle count adds up pretty quickly and I thought I could manage that with a high detail base map.


2048x2048 is safest in terms of hardware support, since all cards for quite a few years have supported it. 4096x4096 is available on Radeon x1x00 family and all GeForce cards since GeForceFX (5x00 family). 8192x8192 is only available on cards supporting DX10 (GeForce 8x00 and up, Radeon HD). So choose the size depending on your audience.


Yes, going with a lower maximum res for the detail map would be better for compatibility but at first I want to go with maximum visual quality and then downgrade it as necessary.

Quote:
Original post by ET3DThe Graphics Card Capability spreadsheet (available from the DirectX Sample Browser in the SDK) will give you more details of which cards support what.


Thanks, I'll check that out.

Share this post


Link to post
Share on other sites
Quote:
Original post by Adam_42
The other answers you were after:

1. DXT textures are faster than uncompressed as they use less memory bandwidth. I've never seen them reduce FPS, and they often increase it.


I have heard that too but unfortunately still haven't gotten around to test it (trying to implement dynamic lighting atm). I know that the overall bandwith goes down but I wasn't so sure about the time needed for decoding the compressed textures and thought that might decrease the performance. But if the reduced bandwith compensates and exeeds the decoding than that would be very good indeed.

Quote:
Original post by Adam_42
2. Many games compress almost all of their textures with DXT1 / DXT5 - the quality loss is usually minimal even close up, although you can lose some fine detail. The compression works best on textures that don't use many different colours in any 4x4 block.


I have to make a comparison between compressed and noncompressed textures to see if the loss in detail for close-up textures is acceptable. For my low detail terrain map which is only seen at a distance anyway I think it definitely will be ok.

Share this post


Link to post
Share on other sites
Quote:
Original post by VladR
The only issue with DXT is that load times are considerably higher. Especially if you let HW create all mipmaps, then the total load time is doubled-tripled - which is a lot. I heard that if you let DXT tool create mipmaps for you, that the load time is considerably lower.


I have to investigate that. I thought that maybe I could load the textures compressed and then Lock the texture and just copy it in. Is that possible ?

Quote:
Original post by VladR
If you use a lot of textures, the performance goes up with DXT textures. Especially, if you have used all your VRAM and driver needs to swap it. Then you can clearly see that you can load much more textures without driver needing to start swapping.


So far I am not having problems with the memory but I think I have to plan ahead prevent the swapping of the textures in and out at a later stage because I know that that would be a serious performance hit.

Quote:
Original post by VladR
Try using DXT to see that you can use the textures for close-ups too. The visual difference is negligible, compared to huge memory savings - 8:1 ratio is really a lot !


Yeah, when I read I can get 8:1 for textures without alpha I really thought that I have to make use of it to use bigger textures which in the end would *still* have less memory.

Quote:
Original post by VladR
Rest assured there`s a lot of work in front of you in regards to adjustments of the textures - their contrast/brightness/ color distribution until it fits with the base terrain.


I know that is something I have to consider. The compression slightly changes the color values and the changing them into base map does again. I hope I can use some sort of color normalisation and clever blending to get around that, though.

Quote:
Original post by VladR
Another advice: It`s more work, but go for 2 detail layers, the second one used only for nearest terrain chunk and being mostly a black-white noise, so it`s easy to blend with previous 2 layers. Then, you don`t need your first detail layer to be of high resolution, only the second one.


What I am currently thinking about is using a base map for the whole terrain, a detail (mip)map for everything close up and also a big random noise texture to prevent the terrain from looking too uniform which is a big worry right now. That would be 3 layers but I can sort of create in the background a second detail texture out of the details and the noise so that at runtime I only have to blend 2 textures with periodically updating the mixed one.





Share this post


Link to post
Share on other sites
Quote:
Original post by Numsgil
Quote:
Original post by VladR
The only issue with DXT is that load times are considerably higher. Especially if you let HW create all mipmaps, then the total load time is doubled-tripled - which is a lot. I heard that if you let DXT tool create mipmaps for you, that the load time is considerably lower.


There's a plugin available for photoshop and another for gimp that will let you export images as DDS, and generate those mipmaps at tool time. Doing this, your load times will be faster* than other formats.


Yes, that is what I am planning to do.

Quote:
Original post by Numsgil
* remembering that hard drive access is usually the bottleneck for loading speed, so you'll want to compress the textures as a tool step (yes, you're compressing compressed textures. I know it's weird, but it works usually), and have your program uncompress them at load time.


I am thinking about a streaming algorithm that gradually loads all the data I am going to need sometime in the future. But compressing everything I need as much as possible should greatly increase the access to the textures.

Quote:
Original post by Numsgil
edit: You will find this useful if you're working with DDSs. With it you can take a 32 bit source image (in DDS), convert it to DXT1 (or 2 or 3 or 4 or 5 or a bunch of other formats), and see the image degradation. And even save out the compressed version.


Very nice ! That will give me a good view of how the textures will be without me needing to code my own.

Thanks alot !

^_^


Share this post


Link to post
Share on other sites
Quote:
Original post by Zaph-0
Quote:
Original post by Numsgil
* remembering that hard drive access is usually the bottleneck for loading speed, so you'll want to compress the textures as a tool step (yes, you're compressing compressed textures. I know it's weird, but it works usually), and have your program uncompress them at load time.


I am thinking about a streaming algorithm that gradually loads all the data I am going to need sometime in the future. But compressing everything I need as much as possible should greatly increase the access to the textures.


It's not a well known fact (maybe that's part of why load times are so long on some professional games), so spread the word if you have success. It seems counter-intuitive, since it involves the computer doing extra work, but CPUs are just 1000s of times faster than hard drive speeds. Not to mention how embarrassingly parallel uncompressing files from disk is, so multi cores can help a bit (you're still bottlenecking on hard drive times)

About the streaming, I remember reading an article a while back about a technique for allowing the artists to use unlimited texture sizes: they would then be mipmapped and only the mip map levels that the hardware actually needs would be loaded from disk. Since 90% of the textures will never need a mip map level larger than 256x256 or thereabouts, anything higher res than this is almost never loaded from disk (so memory footprint and load times stay low), but it does exist for the few times that the player pushes their character up against a wall to read a poster, for instance (so all those grainy posters in Bioshock would have been crystal clear using this method, in theory). I'm trying to find that article but failing miserably... If anyone can find a link to it, I'd be grateful (I think it was a gamasutra article).

[Edited by - Numsgil on August 2, 2008 1:28:49 PM]

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