Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm representing terrain in my game as a grid with at each node a composition, for example 100% rock, or 50% grass, 50% soil. I'd like to use this composition vector to blend textures together. I'm using a single texture atlas which contains all my terrain textures.

I've tried various ideas but I always seem to stumble on the rasterization part of the pipeline, because the interpolation does not work correctly between coordinates across the texture atlas.

What is the recommended way to accomplish this?

share|improve this question
up vote 2 down vote accepted

You don't want to interpolate between coordinates in the texture atlas.

Instead, you want to sample from each of your textures within the texture atlas, and interpolate between the colors that are returned from the sampler.

Typically, you'll do this by specifying a texture coordinate as a vertex attribute (along with 'position', 'normal', and whatever other attributes you need), and treat that texture coordinate as being the coordinate within one of the textures in the atlas, as if that texture wasn't in an atlas at all. Then you put code in your GLSL shader to convert from the "generic" texture coordinate you specified before into atlas coordinates for each of the textures you want to blend together, samples from the atlas at those atlas coordinates, and blends the resulting colors together using the ratios expressed in the composition vector.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.