GeoMipTerrain issue (Resolved)


I started learning Panda3D recently and hit a brick wall. Ive been following this tutorial : … MipMapping
to create terrain but the issue I get when I run the program is:
:grutil(error): Failed to load heightfield image heightfield.png!
:grutil(error): No valid heightfield image has been set!

I used L3DT to create a heightfield image and the image is in the /models folder. Ive had a look at different examples of GeoMipMapping on the forums and for this type of error but couldnt find a solution. If someone would point me in the right direction I would greatly appreciate it.

Thanks in advance

When I run the program i just see a gray screen while the command prompt shows the error.

How do you load the heightfield?
With setHeightfield(Filename(“models/heightfield.png”)) ?
Are you certain it even exists?


Yes the heightfield.png file exists, Ive also tried using some already made heightfield images but kept getting the same problem.

Here is the code i used:

import direct.directbase.DirectStart
from pandac.PandaModules import *

terrain = GeoMipTerrain("terrain")      
terrainRoot = terrain.getRoot()

terrainRoot.setColor(1, 0, 0)


AlexZ, i think i had this issue before.

Many high field programs save height field in 16bit grayscale PNG. Panda3d can only read 8bit gray scale PNG.

Huh? No, that’s not true. Panda can read 16-bits heightfields fine. I’ve tested 16-bits heightfields on my GeoMipTerrain and everything works fine.

Can you upload a heightfield png that doesn’t work?

EDIT: Hmm, you’re saying it’s in the models/ directory, but you’re simply referring to it as heightfield.png? Shouldn’t it be Filename(“models/heightfield.png”) then?
Try adding the full file path there, see if that works. If it doesn’t, upload the PNG so I can take a look at it.

Thanks for taking time to help me.

Ive made an 8bit heightfield image and used the whole path to the file and neither worked.

Here is the heightfield.png file:

I going to reinstall Panda just in case.

tested the png file. works fine for me. 16bit tiff images also work fine for me.
can you create a minimal-example which is able to reproduce the error?

Here is the .py file that i used for this example:

If it works for other people then I suppose its the issue with my computer / panda / or something else.


Upon reinstalling Panda and running the .py file the problem seems to be resolved as the heightfield is loaded and the terrain generated.

Again thanks to everyone who spent time trying to help me.

It must have been a version issue. I remember I rewrote the loading code in 1.5.4 to be fully 16-bits capable.