[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: landscape and footsteps

Ritesh Bansal wrote:

> 1. Suppose I have to map texture on a flat piece of big land which is
> basically at some parts grassy and at others we have soil as if the grass
> has eroded due to continuosus usage of a path(trail) or something similar
> ie. a mixture of grass and sand(soil). My *question* is what is an easy
> method to do that so that it does not seem repetitive.
>         One way I could think of is blending the two texture maps(of grass
> and soil) in different degrees and in fact we have n no. of grass patches
> and m no. of sand patches and can have various combinations of them.
> havenot tried it yet, so no results, but would try on this weekend.

This is a *huge* question because it depends on so many other thing:

  * Is your terrain densely triangulated?

  * Can you afford the fill rate to apply multiple textures (or multiple
    layers) ?

  * How much texture memory are you prepared to devote to this?

One way is to have a fairly uniform monochrome 'noise' map and colour
the vertices of your (dense) triangle mesh to make brown areas and green
areas.  Another way is just to paint one gigantic map containing all the
information you need...but that only works over relatively small areas...
one way to increase that area is to add a second layer of 'noise' texture
onto a lower resolution 'background' map.

You could also use a dense texture map close to the eye and lower resolution
maps further away - paging in higher resolution maps as you traverse the
terrain to keep a high res area near to the eye.

You could even generate the texture algorithmically as you go along.

You could make the pathways with a polygon with 'pathway' texture and
the grassy areas with 'grass' texture - then use a third texture that
blends between the two and fades out to either side using alpha - apply
that to a polygon strip that overlays all the boundaries between paths
and grass polygons.

TuxRacer has regularly gridded terrain - and for them they just overlay
the two textures on different polygons and have one fade out to transparent
as it crosses the other.  It looks *great* - but only on a dense, regular
triangle mesh.

There are dozens and dozens of ways to attack this problem - but which
one you choose depends critially on the other parameters of your game

> 2. Do we have something like 3d polygon subtract in openGl, or a method to
> do it. For example we have a small patch of muddy region in it(not
> marshy), and as I walk on it, my footsteps would mark on it.

So you want to make a dent in an existing polygon skin?

Well, if the dent needs to be genuinely 3D then there are really two options:

 * Cut a hole in the polygon(s) that the footprint landed on and insert your
   footprint model into that hole (much retesselation needed - lots of nasty
   special cases to take account of - a LOT of programming effort)

 * Cheat:
      0) Start of frame - clear the Z buffer as usual.
      1) Draw the footprints as a 3D objects.
      2) Draw all the rest of opaque objects in the 3D
         scene...except the ground.
      3) Over the top of each print, at just above ground
         level (but not by much) draw a 100% transparent polygon.
         (Make sure you don't have alphafunc set to discard transparent
      4) Draw the terrain.
      5) Draw the translucent objects in the scene.

      The transparent polygon will cause the terrain in the region of the
      footprint to be Z-buffered out - leaving a nicely visible print.

      Actually, this isn't going to work well for footprints - but I've
      used it to make craters.  For footprints, it's gonna be hard to get
      the transparent polygon high enough above the terrain polygon to
      cleanly cut it out without Z-flimmering - yet not so high that when
      you see them kinda edge on,they cut out terrain pixels outside the
      area that the footprint polygons fill in.

      In the case of the craters, they had raised side-walls and the 100%
      transparent polygon could be drawn near to the top of the crater
      rim - making it much higher than the ground.  I still had to be
      careful when placing craters on very rough ground - and there are
      nasty things to worry about when two craters (or footprints) overlap.

      This algorithm is not without problems though...translucent objects
      that are down inside the crater (or footprint!) don't show up.
Steve Baker   HomeEmail: <sjbaker1@airmail.net>
              WorkEmail: <sjbaker@link.com>
              HomePage : http://web2.airmail.net/sjbaker1
              Projects : http://plib.sourceforge.net

To unsubscribe, e-mail: linuxgames-unsubscribe@sunsite.dk
For additional commands, e-mail: linuxgames-help@sunsite.dk