2
\$\begingroup\$

I'm looking for a way to deform tillable texture in a 2D game I'm building using MonoGame but I'm not sure how this effect is called and searching the internet for "deforming textures" gives me mostly articles about 3D.

I want to texture procedurally generated terrain which can contain lots of little hills. Like on the following picture:

Deforming tiled texture example

I've deformed this image using Photoshop's free transform tool and I would like to know how can I do this in code.
And also, I would like not to have this "obviously deformed" look with blurred areas where deformation occurred.

\$\endgroup\$
5
  • \$\begingroup\$ How are you currently generating your terrain? Are you using any noise libraries? \$\endgroup\$
    – jgallant
    Oct 2, 2014 at 12:44
  • \$\begingroup\$ @Jon I'm using smooth 1D Perlin noise described here. Are there better alternatives? \$\endgroup\$
    – chaky173
    Oct 2, 2014 at 13:03
  • \$\begingroup\$ It would be much easier to generate noise with hills, than it would be to manipulate a texture like the way you depicted above. What you could do is chain another noise module, and combine them together, to provide your original noise data with more hills. \$\endgroup\$
    – jgallant
    Oct 2, 2014 at 13:10
  • \$\begingroup\$ @Jon how would I achieve this "cartooney" look using only noise modules? I'm very happy with shape of terrains I currently generate I just don't know how to texture it to look like terrain in Rayman games for example.. \$\endgroup\$
    – chaky173
    Oct 2, 2014 at 13:19
  • \$\begingroup\$ Looks like you could simply use a spline to define the top area and sample from the texture to fill in the the gap between the spline and a set bottom. Will cause stretching/compression but thats kinda unavoidable. \$\endgroup\$ Dec 1, 2014 at 19:30

2 Answers 2

1
\$\begingroup\$

I assume your noise is outputting height values for the terrain - the style shouldn't matter, as that's applied after the noise is done with. Add a lower octave of noise and add (or otherwise combine) them together. The lower the octave (larger amplitude and lower frequency) the larger/longer the features it creates, so to add hills you need to add that sort of noise.

I can't help more specifically without seeing your noise generation code, but hopefully that's enough to get you on the right track.

Edit: I just realized, your terrain looks basically flat. It's only the texture that seems to be procedurally generated, yes? If that's the case, then you just need to do what I was assuming above, and generate a layer of noise that you use for terrain height and then make your "land tiles" vary in shape/size by that noise before even generating the texture.

\$\endgroup\$
1
\$\begingroup\$

All you need to do is first create a mesh and then distort it.

  1. Create a mesh that's just a strip of triangles.

  2. Texture the mesh using your terrain texture.

  3. Deform each vertex of the mesh by using perlin noise. What I mean exactly is this:

    // Deform a 3D vertex by noise
    vertex.position.y += Perlin(vertex.position.x, vertex.position.y, vertex.position.z);
    
  4. Draw the mesh.

You will want to mess with how you sample the noise to get the effect you want. You can even distort the vertex' x coordinate a little to give an interesting overhang effect.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .