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 have a procedurally generated terrain, as follows:

enter image description here

It is generated and then built using Farseer Physics, however I haven't found a way to create and apply a mask to texture it properly, I have already played with stencil buffers and pixel shaders but I still have no solution at the moment. How would I do that? Am I going the right direction with stencil and pixel shader? Thank You.

share|improve this question
up vote 2 down vote accepted

I think the easiest way would be to just create some geometry you can actually texture. Just create a quad (2 triangles) for every segment of your world. This should be straight-forward to texture. To optimize this, you can remove quads that leave the screen during gameplay.

For an idea how you could apply your texture using UV coordinates, see this answer.

world geometry

share|improve this answer
I'll accept it as the answer for being the most complete one, even though I successfully implemented my pixel shader approach – V.M. Mar 9 '13 at 20:54

taking a different approach i would look to do something similar to

essentially find what is below the line and generate a color

share|improve this answer
That was almost the exact approach I was trying with pixel shader, Thank you for the link – V.M. Mar 8 '13 at 15:38

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.