Skip to main content
GameDev.net gamedev.net
🔒 Locked

Atlased Textures and Mip-Mapping

Started by ambershee Feb 25, 2014 at 2:11 PM 7 replies 2.5k views
Original Post
ambershee
ambershee

Hi guys,

I've got a nasty little conundrum that I'm hoping folks may be able to help with. For the purposes of example, assume I am texturing a terrain, and need to atlas a number of textures together to avoid reaching the sampler limit - array textures and volume textures are not available resources.

We can atlas simply, but we will get nasty seams where textures border thanks to sampling. If we create artificial borders between atlased textures, we'll get artifacts at high incidence viewing angles.

We've looked at alternative sampling techniques, but haven't found a viable solution. Our Dx9 solution uses tex2dgrad, but we're primarily working in Dx11 where tex2dgrad doesn't seem to be available. Due to a limitation with our shader system, we are unable to pass or declare a sampler state, so we cannot use the updated equivalent samplegrad either.

Anyone have any ideas?

Cheers!

kauna
kauna

Well using the atlas has two problems : texture color bleeding because of mipmap generation, and texture bleeding because of filtering

I haven't tried this but I assume that the problems could be addressed separately:

- create mipmaps separately (or use algorithm which minds the borders) for each texture inside the atlas and then pack together

- for each mip map level, use 1 pixel for borders

- while doing texture sampling in the shaders, clamp the values so that they will stay inside the border area.

There might be problems at the edges because of discontinuity of the texture coordinates and you may have to calculate the partial derivates.

Cheers!

ambershee
ambershee

Hi Kauna - those are the two problems we are trying to solve. Doing it as you describe will indeed result in artifacts like seams :(

@Swiftcoder - unfortunately that example makes use of texture2DLod, the equivalent of which is SampleBias, which we cannot use for the same reason we can't use SampleGrad, as it requires passing the sampler state which we don't have access to. Otherwise, it's very similar to what we've tried to do already, but gotten stuck when it comes to sampling appropriately!

Styves
Styves

I'm not entirely sure what your problem is regarding sampler states. Can you elaborate a little bit?

You should be able to interchange any texture2D function with texture2DLod, etc, without any issues or "sampler state" changes..

Hodgman
Hodgman

When you create the texture asset itself, you don't have to create a full mip-chain for it (all the way down to 1x1 pixel). You can stop generating mips once you reach the point where the atlas 'cells' start bleeding together. Then when you load the texture from disc, be sure to create the same number of mip-levels as the texture file actually has.

ambershee
ambershee

There's more to the problem than just mips bleeding together. At high incident viewing angles you'll get seams where there's a transition between texture LoDs :/

phil_t
phil_t




There's more to the problem than just mips bleeding together. At high incident viewing angles you'll get seams where there's a transition between texture LoDs :/

I don't understand why this would be... seems like that would only happen if your mipmaps don't "match up", or if you still have a full mip chain.

I have some information on how I construct my terrain texture atlas on my blog, some of it might be useful:

http://mtnphil.wordpress.com/2011/09/22/terrain-engine/

http://mtnphil.wordpress.com/2011/09/26/terrain-texture-atlas-construction/

ambershee
ambershee

Thanks Phil, I'll look that over :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.