Terrain issue

I have been using geomip terrain and unforutnately I cant seem to get it working very well I have tried

self.terrain.setAutoFlatten(GeoMipTerrain.AFMLight)

and strong as well and all i get is white terrain with no height and my framerate drops to pretty much nill I beleive there might be something wrong with this call. shouldnt this make my framerate better? my terrain code is listed below.

Ive also tried setting near and far but have not gotten this to work satisfactorily yet either.

I need to load alot more terrain than you see here as this is 1024X1024 and i also want to tile it so if anyone can let me know hoe to fix the above issue or how to make it so i can load alot more terrain without killing my framerate that would be appreciated.

class TerrainClass(DirectObject):
    def __init__(self):
        
        #Load the first environment model
        self.terrain = GeoMipTerrain("ground")
        self.terrain.setHeightfield(Filename("Terrain/Level 1/terraintest.bmp")) #Terrain/game heightmap.bmp
        
        # Set terrain properties
        self.terrain.setBlockSize(32)
        self.terrain.getRoot().reparentTo(render)
#        self.terrain.setBruteforce(True)
        self.terrain_tex = loader.loadTexture('Terrain/Level 1/ground.jpg')
        self.terrain_tex.setMagfilter (Texture.FTLinear) 
        self.terrain_tex.setMinfilter(Texture.FTLinearMipmapLinear)
        self.terrain.setAutoFlatten(GeoMipTerrain.AFMLight)
        #self.terrain.setNear(40)
        #self.terrain.setFar(100)
        
        # Store root NodePath for convenience then set root settings for the terrain
        root = self.terrain.getRoot()
        #Set the terrain itself to be collide-able.
        root.setCollideMask(BitMask32.bit(0))
        root.reparentTo(render)
        ts = TextureStage('ts')
        root.setPos(0,0,0)
        root.setSz(50)
        root.setTexScale(ts.getDefault(),15,15)
        root.setTexture(self.terrain_tex,1)
        root.setTwoSided(True)
        #set global variable
            #there are currently no global variables

        #Updates the taskMgr
        taskMgr.add(self.updateTask, "update")

        #this updates the terrain when needed
    def updateTask(self, task): 
        self.terrain.update()
        self.terrain.getRoot().setCollideMask(BitMask32.bit(0)) 
        return task.cont 

Anybody got an answer for this? Can someone who works with Panda let me know if this code is doing what it is supposed to as i believe this maybe a bug but im not sure.

I am hoping someone will have an answer.

I played time ago with Geomipterrain and barely remember that performance is influenced by 2 parameters relationship: the heightmap texture size and the blocksize in a way that the bigger the texture the bigger the blocksize. Try to play with those and see how much the performance change.
I provided you code to be more elastic for tests - this setup is for an hf of 1024x1024 and runs @ 240fps on my rig:

# -*- coding: utf-8 -*-
from pandac.PandaModules import *
from direct.showbase.DirectObject import DirectObject
loadPrcFileData("", """#
win-origin 0 0
sync-video 0
show-frame-rate-meter #t
"""
)
import direct.directbase.DirectStart

#=================================================================
#
class TerrainClass(GeoMipTerrain):
  def __init__(self,
    name,
    geomap,
    blocksize=32,
    qfactor=100,
    elevation=30
  ):
    GeoMipTerrain.__init__(self, name)
    self.setHeightfield(Filename(geomap))
    self.setBlockSize(blocksize)
    self.setFactor(qfactor)
    ###self.setMinLevel(1)
    self.setFocalPoint(base.camera)
    self.root = self.getRoot()
    self.root.setSz(elevation)
    self.generate()

  def update(self, dummy):
    GeoMipTerrain.update(self)

  def setMonoTexture(self, texture):
    ts = TextureStage('ts')
    tex = loader.loadTexture(texture)
    self.root.setTexture(ts, tex)

  def reparentTo(self, target):
    self.getRoot().reparentTo(target)

#=================================================================
#
class world(DirectObject):
  def setup(self):
    self.ground=TerrainClass(
      name='scenario_ground',
      geomap='heightfield1025.png',
      blocksize=128,
      qfactor=100,
      elevation=15
    )
    self.ground.setMonoTexture('land01_tx_512.png')
    self.ground.reparentTo(render)

#=================================================================
#
w=world()
w.setup()
base.cam.setPos(512,512,50)
base.cam.lookAt(w.ground.root)

run()

Beautiful example astelix!!! Thanks a million

However, the camera position relative to the terrain never shows it completely and actually sees the terrain from below (resulting in the darker regions of the terrain map to look like holes instead of mountains).

Is there any way to position this terrain? the ‘setPos’ function did not work…

Thanks,
Adam

EDIT:
My bad. You need to set the position of the root of the terrain therefore:

ground.getRoot().setPos(0,0,0)

However, on a relatively unrelated topic (but something I faced with these terrains and I am pretty sure most people have) is that the camera is never at a perfect position so you always have to move it around to get a good look of the whole terrain.

So, is there a way in Panda for the camera to encompass all rendered objects? Something like a ‘fit objects to window’ or a ‘zoom to fit all’ kind of thing?

Thanks in advance,
Adam