[SOLVED] How to disable Cull?


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


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")
		# 加入草丛
		# 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)
					# close grass
					g = loader.loadModel("grass1")
					# normal grass
					g = loader.loadModel("grass2")
					# wires grass
					g = loader.loadModel("grass3")
		shape = BulletPlaneShape(Vec3(0,0,1), 0)
		stage = BulletRigidBodyNode('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.