Spanning textures

I’m working on an addition for GeoMipTerrain that allows use of non power of two heightmaps. I’m using geomipterrains parented to a root node. The problem is applying a texture. The geomipterrain (left) spans the texture across the child nodes, but my addition does not span across geomipterrains. I’m looking at geomipterrain.cxx to see if I am missing a step, butI can’t seem to find it.

Basically, the texture coordinates should be in the range 0…1. This line of code achieves that:

        twriter.add_data2f((mx * _block_size + x) / double(_xsize - 1),
                           (my * _block_size + y) / double(_ysize - 1));

This means that it uses the position of the current vertex and divides it by the total terrain size, to get the texture coordinates.

Or did I misunderstand your question?

You answered it :slight_smile:

So to span the texture over a bunch of geomipterrains I need to:

  1. Chop it up into chunks and pass each chunk to each geomipterrain.
  2. Reiterate through each vertex to redefine the uv coordinates
  3. Learn c++ and add nonpower of two to geomipterrain itself.

I have a texture on the terrain which follows the mouse cursor by using texture scale and texture offset, so unless there is a better way to do so #1 is out of the question. I am lazy so (re)learning c++ isn’t that likely, so looks like it is a for-loop party time!

Ah, now I get what you mean. You can simply use texture transforms to achieve this:
panda3d.org/manual/index.php/T … Transforms
Set the scale to the amount of terrains, and use offsets to indicate which terrain should show which piece of the puzzle.