1
\$\begingroup\$

I saw this game Clay Jam, that the user can create a path in the sand. The path is a continuous one, and it can varies from a single point to curves.

How one can develop smooth and continuous paths?

enter image description here

\$\endgroup\$
  • \$\begingroup\$ Using heightmaps \$\endgroup\$ – wolfdawn Mar 24 '14 at 5:36
  • \$\begingroup\$ What exactly do you want to know, how to create paths on sand OR how to make such paths look smooth and continuous? \$\endgroup\$ – Kromster says support Monica Mar 24 '14 at 6:23
  • \$\begingroup\$ How to do the smooth/continuous path. \$\endgroup\$ – Filipe Ferminiano Mar 24 '14 at 7:32
2
\$\begingroup\$

It renders using bump- / specular maps. Refer to this video. The ground geometry is never modified.

Bumpmaps are just heightmaps used for realistic lighting. To clarify definitions,

  1. bumpmapping is a rendering technique, typically written as a shader, which creates the illusion of surface detail on what is in fact a flat piece of geometry... in this case, the ground.
  2. heightmap is a 2D grid / array of scalar values representing heights in different cells of the map. This would be the source of information for the bumpmapping process.

Modifying the heightmap to reflect the user's touch-drag would consist of getting the sequence of touch points (optionally adding some interpolation points to provide a smoother path), then connecting them, and calculating the 2D vector between each point-pair on the drag path.

You'd then carve a groove along each such vector. The carving in v-form would be done with a circular "brush" mini-texture that has high intensity toward the centre, and an intensity approaching zero toward the edge... in fact, there is a slight negative intensity toward the edge, as you can see that a lip is created around the furrow. Onto your clean, flat heightmap texture, the brush shape is painted onto/around every pixel/texel between the start and the end of the vector path. The pixel path is probably best calculated with something like Bresenham's Line Algorithm, or even better, Xiaolin Wu's Line Algorithm, which allows sub-pixel accuracy for a smoother path.

Lastly write your pixel / fragment shader to utilise the heightmap texture for lighting, based on light source direction. There are endless sources both on this site and elsewhere online on how to go about producing and rendering bump and specular maps.

\$\endgroup\$
  • \$\begingroup\$ One tiny note: I think what you'd want for this effect isn't just bump mapping. It's normal mapping. With bump mapping you'll only get different absolute height offsets, but no information on the actual surface orientation (important for proper lighting). \$\endgroup\$ – Mario Mar 24 '14 at 8:46
  • \$\begingroup\$ @Mario Quite so. I tend not to go into details about how exactly the OP should approach the mapping itself in questions like this, since the choice of whether to produce/use normal maps is something I think should be left up to the implementor. However in this case I agree with you -- a normal map would look good. \$\endgroup\$ – Engineer Mar 24 '14 at 8:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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