Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Don't forget to read Tuesday's email newsletter for your chance to win a free copy of Construct 2!


Atlased Textures and Mip-Mapping


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 ambershee   Members   -  Reputation: 528

Like
0Likes
Like

Posted 25 February 2014 - 08:11 AM

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!



Sponsor:

#2 kauna   Crossbones+   -  Reputation: 2746

Like
1Likes
Like

Posted 25 February 2014 - 10:55 AM

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!



#3 swiftcoder   Senior Moderators   -  Reputation: 10238

Like
1Likes
Like

Posted 25 February 2014 - 11:27 AM

The pictures seem to have disappeared, but Ysaneya published a solid technique on his blog a while back.


Tristam MacDonald - Software Engineer @Amazon - [swiftcoding]


#4 ambershee   Members   -  Reputation: 528

Like
0Likes
Like

Posted 26 February 2014 - 06:24 AM

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!



#5 Styves   Members   -  Reputation: 1054

Like
0Likes
Like

Posted 27 February 2014 - 04:42 AM

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..



#6 Hodgman   Moderators   -  Reputation: 31047

Like
1Likes
Like

Posted 27 February 2014 - 06:09 AM

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.



#7 ambershee   Members   -  Reputation: 528

Like
0Likes
Like

Posted 27 February 2014 - 09:09 AM

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 :/



#8 phil_t   Crossbones+   -  Reputation: 3947

Like
2Likes
Like

Posted 27 February 2014 - 10:33 AM


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/



#9 ambershee   Members   -  Reputation: 528

Like
0Likes
Like

Posted 28 February 2014 - 06:17 AM

Thanks Phil, I'll look that over :)






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS