I’m having performance problems on my simple program in both OGL and DirectX and I can’t pinpoint the cause. I have some basic geometry: Sky, moon, models/environment from panda tutorial a sphere modeled in 3ds max, one ambient light and one point light. None of the models are specially high poly. The sky and the moon are the same as the ones in the solar-system sample program.
I’m getting 20 or less fps and the only way to get it higher is to comment most of the geometry (ie only leave the sphere and the enviroment or only leave the sky and the moon). When I comment some of the geometry I get 60fps (I’m not getting 40 fps no matter what I remove from the scene for example). Using or not using shaders doesn’t affect my fps.
This is very odd considering I get 60fps on all the sample programs that come with panda.
from panda3d.core import loadPrcFileData
#loadPrcFileData('', 'load-display pandadx9')
loadPrcFileData('', 'show-frame-rate-meter 1')
import direct.directbase.DirectStart
from direct.interval.IntervalGlobal import *
from direct.showbase import DirectObject
from direct.interval.IntervalGlobal import *
from direct.showbase.DirectObject import DirectObject
from direct.actor.Actor import Actor
from pandac.PandaModules import Material, VBase4
from panda3d.core import AmbientLight, PointLight, TextureStage, Point3, Fog, AntialiasAttrib
class World(DirectObject):
def __init__(self):
base.setBackgroundColor(0, 0, 0)
base.disableMouse()
self.loadSky()
self.grass= loader.loadModel('models/environment')
self.grass.setPos(0,0,-10)
self.grass.setScale(0.07)
self.grass.reparentTo(render)
alight= AmbientLight('alight')
alight.setColor(VBase4(0.2, 0.2, 0.2, 1))
self.alight = render.attachNewNode(alight)
render.setLight(self.alight)
plight= PointLight('plight')
plight.setColor(VBase4(1,1,1, 1))
self.plight= self.moon.attachNewNode(plight)
render.setLight(self.plight)
self.sphere = loader.loadModel("sphere")
self.sphere.setShaderAuto()
self.sphere.reparentTo(render)
self.sphere.setScale(0.1)
self.sphere.setPos(0,-25,-9)
spin_sphere= self.sphere.hprInterval(6, Point3(360,0,0))
spin_sphere.loop()
dest= Point3(self.sphere.getX(), self.sphere.getY()+5, self.sphere.getZ())
walk_sphere = LerpPosInterval(
self.sphere,
duration=5,
pos= dest,
blendType= 'easeIn',
name= 'walk_sphere')
walk_sphere.start()
myFog = Fog("Fog Name")
myFog.setColor(0.3,0.3,0.3)
myFog.setExpDensity(0.01)
render.setFog(myFog)
camera.setPos(6, -45, -10)
camera.setPosHprScale(-15.00, -20.00, -9.00, 262.87, 10.30, 0.00, 1.00, 1.00, 1.00)
render.ls()
render.analyze()
def loadSky(self):
self.sky = loader.loadModel("solar_sky_sphere")
self.sky_tex = loader.loadTexture("stars_1k_tex.jpg")
self.sky.setTexture(self.sky_tex, 1)
self.sky.reparentTo(render)
self.sky.setScale(80)
self.moon= loader.loadModel("planet_sphere")
self.moon_tex= loader.loadTexture("moon_1k_tex.jpg")
ts = TextureStage('ts')
ts.setMode(TextureStage.MAdd)
self.moon.setTexture(ts, self.moon_tex, 1)
self.moon.setPos(50.00, -10.00, 10.00)
self.moon.setScale(6)
self.moon.reparentTo(render)
w = World()
run()
The result of my render.analyze with everything on:
95 total nodes (including 0 instances); 0 LODNodes.
5 transforms; 4% of nodes have some render attribute.
82 Geoms, with 82 GeomVertexDatas and 4 GeomVertexFormats, appear on 81 GeomNodes.
2369 vertices, 2369 normals, 0 colors, 2369 texture coordinates.
GeomVertexData arrays occupy 76K memory.
GeomPrimitive arrays occupy 15K memory.
108 GeomVertexArrayDatas are redundant, wasting 1K.
64 GeomPrimitive arrays are redundant, wasting 5K.
3542 triangles:
1910 of these are on 167 tristrips (11.4371 average tris per strip).
1632 of these are independent triangles.
15 textures, estimated minimum 5728K texture memory required.