[SOLVED] How to disable Cull?

tudou.com/programs/view/wFAV1ki-lrs/

The video is my game. I think Cull takes up too much CPU, but it unuseful. How to disable cull ?

#!/usr/bin/python
#coding:utf8

from direct.showbase.ShowBase import ShowBase
from panda3d.bullet import BulletWorld, BulletDebugNode, BulletPlaneShape, BulletRigidBodyNode
from pandac.PandaModules import Vec3
from pandac.PandaModules import LODNode
from pandac.PandaModules import NodePath
from pandac.PandaModules import TransparencyAttrib, Point3
import random

class Tropical():
	"""载入一个非洲风格的场景,重点在生成草坪。"""
	aX = 0
	aY = -165
	aZ = 0
	aH = 3.14
	cP = -3
	cZ = 3
	path = [[1,1,1,1,1,1,1,1,1,1,1,1,1, ... 1,1,1],
				[1,1,1,1,1,1,1,1,1,1,1,1,1, ... 1,1,1],
				[1,1,1,1,1,1,1,1,1,1,1,1,1, ... 1,1,1],
					...
					...
				[1,1,1,1,1,1,1,1,1,1,1,1,1, ... 1,1,1],
				[1,1,1,1,1,1,1,1,1,1,1,1,1, ... 1,1,1]]

	def __init__(self):
		m = loader.loadModel("tropical")
		m.reparentTo(render)
		
		# 加入草丛
		# Add grass with LOD
		for i in range(0,75):
			y = 150-i*4
			for j in range(0,75):
				if self.path[i][j]:
					x = j*4-150
					# 使用LOD
					lod = LODNode('grass LOD node')
					lod_np = NodePath(lod)
					lod_np.reparentTo(render)
					# close grass
					g = loader.loadModel("grass1")
					g.reparentTo(lod_np)
					lod.addSwitch(20,10)
					# normal grass
					g = loader.loadModel("grass2")
					g.reparentTo(lod_np)
					lod.addSwitch(30,20)
					# wires grass
					g = loader.loadModel("grass3")
					g.reparentTo(lod_np)
					lod.addSwitch(100,30)
					lod_np.setPos(x+random.uniform(-1,1),y+random.uniform(-1,1),0)
		
		shape = BulletPlaneShape(Vec3(0,0,1), 0)
		stage = BulletRigidBodyNode('stage')
		stage.addShape(shape)
		base.world.attachRigidBody(stage)

If you disable culling on this program you would be sending all objects in the scene to the GPU each frame, and the frame rate would be MUCH worse.

The most likely reason your program is slow is because you have too many objects. This code is creating over 5000 grass objects. Even with the LOD nodes hiding the far away ones you probably have hundreds of grass objects in view at one time. You can check this with the “Geoms” window in pstats. You should keep your Geoms under 200. The best thing you can do to improve the performance is find a better way to create the grass.

Also what shows as Cull in pstats is not just culling, it is also the time spent preparing all of the data for the GPU.

Thank you ! I use little grass objects and new .egg file that include more polygons. Now it’t faster.