Hello, I’ve a performance problem. I’ve this simple application: a quad with a texture on it, and the offset of the texture changes. This is the code:
from panda3d.core import TextureStage
from pandac.PandaModules import Spotlight
from panda3d.core import loadPrcFileData
loadPrcFileData( '', 'want-pstats 1' )
loadPrcFileData( '', 'show-frame-rate-meter #t' )
import direct.directbase.DirectStart
base.disableMouse()
camera.setPos( 0, -2.5, 2.5 )
camera.setHpr( 0, -48, 0)
model = loader.loadModel( 'quad' )
model.reparentTo( render )
ts = TextureStage('ts')
model.setTexture( ts, loader.loadTexture('img2.jpg') )
offset = 0
def update( task ):
global offset
offset += .001
model.setTexOffset( ts, offset, offset )
return task.cont
taskMgr.add( update, 'TextureUpdate' )
def setupLight():
light = render.attachNewNode( Spotlight( 'Spot' ) )
light.setPos( ( 20, 20, 20 ) )
light.lookAt( 0,0,0 )
light.node().setShadowCaster( True, 1024, 1024 )
render.setLight( light )
render.setShaderAuto()
# it costs 2 ms without the texture movement and 8 ms with that
setupLight()
# it costs 2 ms without the texture movement and 30 ms with that
run()
I would like to see these two effects: shadows and texture offset. Both cost few milliseconds if used separately, but, if I use them together then the performances drop (and I can’t use them in real contexts ).
For example, with render.setShaderAuto() and lighting each frame costs 28 ms more.
Here’s the complete code with resources.
Is my lighting setup wrong? Thank you!