Terrain Algorithm: PGMM / geoMipTerrain

EDIT: GeoMipTerrain is now included in Panda3D source of 1.5.1! For the latest 1.5.0 binary, see the last page of this forum topic.

Hi all :slight_smile:

I’ll post here soon my terrain algorithm called PGMM (Panda3D Geometrical MipMapping) on the forums, after I tested it some more, its beta atm.
It is written in C++, and uses the Geometrical MipMapping algorithm from this paper from Willem H. de Boer:
flipcode.com/articles/articl … maps.shtml

The algorithm is something like mipmapping, but then for terrain. The terrain is divided in multiple chunks, with the advantage that you don’t have to regenerate the terrain every frame, just the appropriate chunks will be automatically updated.
It will be released with linear LOD decision, and for at least Linux and Windows. Any help with OSX build is appreciated.

@Josh/Bigfoot, when I wanna release it, do I have to put it here or in Code Snippets then?

Well, to release something like that, I’d say the thing to do is to permanently integrate it into the panda source tree. We’d have to figure out where it belongs in the tree, and we’d have to tune it up to use the panda coding style rules. After that, it’s a simple question of checking it in to CVS.

I think it would belong in grutil, at the same place where the heightfieldTesselator resides.
I think it would be pretty much compatible with the rest of the code, because I also use the interrogate system, and because I was afraid of interrogate errors I tried to keep to the coding style of Panda3D as much as possible. :wink: So I think I made it pretty easy for you.

PGMM is almost done, I’m just doing some testing, there are still some texturing issues with the generated terrain for some weird reason :s
I will release a VC8 project as well.

hint pageing support /hint
i can offer some working but undocumented code which works on particularry anything,chunks too.
can also contribute some lod-decision stuff later on.
but would be great to have pro’s pgmm in the panda tree.
would be rewarding at least some part of all the efforts he spend :slight_smile:
big THX to you,pro-rsoft !

agreed ,- its amazing what happens when people work together toward common mutually inspired goals…and when those people you work with are nice and capable its all the more enjoyable…

so hats off not only to prorsoft but the rest of the amazing panda users and devs :wink:)

hip hip horrrrrrrrrray!! :wink:

can’t wait to start doing serious pipeline stuff heheh

cheers
nl

Just let me know when you feel it is ready to integrate, I’ll be ready to go.

I have already a beta version lying around here, but I’d like to wait until its fully tested and fully stable.
Question@Josh: If I make any improvements to the code AFTER you implemented it into the Panda tree, uhm, how do you think we’d do that? Do I need to give the changed code to you then?

pro-rsoft: We generally like to get to know somebody a bit before we give them write-access to the CVS server. So for your first few submissions, I think we’d like you to send me updates (ie, files to insert into the CVS tree, or diffs). I’m very serious about helping community members to contribute: I will give anything you send me high priority. After you’ve been contributing for a few months, it might become simpler to just give you write access.

@Josh: all right :wink: but plz dont integrate pgmm into the tree until the final version is released, that will save us some effort.

@ALL: Release Candidate 1 is finally released! Download it here:
pgmm.pro-rsoft.com/
It includes a dll for windows, a .so file for linux (compiled at 1.4.0, ubuntu edgy eft), a source package (./configure && make && make install) and a Microsoft Visual Studio 2005 project.
I believe Hypnos_ has been working on a OSX build (thanks very much Hypnos_, will you plz post it in this thread when you’re done?)

Oh, and to install, copy the library (.dll, .so) over to your python’s site-packages directory.
Something like:
Windows: c:\panda3d-1.4.0\python\lib\site-packages\libpgmm.dll
Linux: /usr/lib/python2.4/site-packages/libpgmm.so

Anyway, I’m leaving this week, for a little vacation, when I’m back I’ll look at your comments (if any), and release a Final, from that point on Josh is granted rights to implement it in the Panda3D CVS Tree :slight_smile:

I get a seg fault just after import, here is the strace output:

stat64("/usr/lib/python2.5/site-packages/libpgmm", 0xbff6c964) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/site-packages/libpgmm.so", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=2475859, ...}) = 0
open("/usr/lib/python2.5/site-packages/libpgmm.so", O_RDONLY) = 7
read(7, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\360\276"..., 512) = 512
fstat64(7, {st_mode=S_IFREG|0644, st_size=2475859, ...}) = 0
mmap2(NULL, 138712, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 7, 0) = 0xae6a5000
mmap2(0xae6c6000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 7, 0x20) = 0xae6c6000
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV (core dumped) +++
Process 6407 detached

That is odd. But I think I compiled it on python2.4 (but im not sure, sorry.)
Can you try to compile pgmm from scratch?
You need to edit the makefiles though that they point to 2.5 instead of 2.4… sorry for the inconvenience

Very nice! I compiled it myself on linux (Fedora Core 7) with panda3d 1.4.0. I had to make 2 changes so it would compile on my system:

  • in subdir.mk changed reference to python2.4 to python2.5
  • in objects.mk remove the reference to pandanspr4

Runs beautifully! I added a few lines to test.py so you can toggle between wireframe and textured using the “w” key:

from pandac.PandaModules import Texture

tex = Texture()
tex.load(terrain.heightfield())
terrain.setTexture(tex)

base.accept('w', base.toggleWireframe)

When you are back from your vacation, could you add setting the heightfield from a PNMImage directly, instead of a file?

That way you can for example generate random terrain.

Thanks for the good advice, Laurens!
You can now download a python2.4 and python2.5 source package at the website separately. And sorry about pandanspr4, I totally forgot about that, but I removed it as well now. :wink:

And yes, heightfield from PNMImage is def. on my todolist, ill do that right away after i come back. Until then, you can load an empty image instead in the desired size, and use the function pgmm.heightfield(), which returns a pointer to the PNMImage, which you can edit freely. Don’t forget to call generate() again after you altered the heightfield.

When you say beautifully what do you mean…I’m in windows xp home atm and am getting 4 fps ( and lines around each terrain tile as well ) so i’d be curious what your getting and what system specs you have…amd64 3200+ , one gig ram and nvidia 7600 GT pciE 256mb gpu…I have not tried in linux yet.

thx
nl

I get 15 to 40 fps, depending on view angle and wether I move a lot. I’m running linux on a 1.5 GHz AMD XP, 512 MB RAM, Geforce 7600 GS AGP with 256 MB RAM.

I am really curious what you get in linux.

There in part is our difference …I’m running a 1024 terrain with 4 detail textures setup…in texture mode are you seeing any lines as in my image here:

i-imagehost.com/uploads/5c4682d10c.png

thx
nl

After a lot of time i finally managed to get pgmm compiled under osx.

Here’s my build script:
http://public.nouser.org/~rspoerri/Development/python/panda3d/projects/pgmm-osx-build/my-build-script-v2.sh

And here’s the library:
http://public.nouser.org/~rspoerri/Development/python/panda3d/projects/pgmm-osx-build/libpgmm.so

Please note that the script might still contain some unnessecairy stuff, but it works for me…

@Hypnos: wow. Thanks very much for all your effort! I’ll upload it right now and it will be included next version as well.

@neighborlee: the main bottle-neck is probably your texturing shader. PGMM doesn’t do texturing at all - so switching off your shader would fix both the slow fps and the lines…

I’m using Panda3d 1.4.1, I put the .dll in Windows: c:\panda3d-1.4.1\python\Lib\site-packages\libpgmm.dll, but when I try to run test.py, I get a pop up message that says

Panda: ppython.exe - Entry Point Not Found
The procedure entry point ?update_type@MemoryUsage@@SAXPAVReferenceCount@@VTypeHandle@@@Z could not be located in the dynamic link library libpandaexpress.dll

And the console spits out

DirectStart: Starting the game.
Warning: DirectNotify: catagory 'Interval' already exists
Known pipe types:
  wglGraphicsPipe
(3 aux display modules not yet loaded.)
:util(warning): Adjusting global clock's real time by 0.658867 seconds.
Traceback (most recent call last):
  File "test.py", line 3, in ?
    from libpgmm import PGMM
ImportError: DLL load failed: The specified procedure could not be found.