weird GeomPoints perspective rendering issue

Try this code and tell me if it works on your machine:

from pandac.PandaModules import *
import direct.directbase.DirectStart
import random

base.setBackgroundColor(0,0,0,1)

def pointCube(amount, size, pointsize = 0.01):
	
	# create vertices
	format = GeomVertexFormat.getV3c4() # position and texcoord
	
	vdata = GeomVertexData('vdata', format, Geom.UHStatic)
	
	vwriter = GeomVertexWriter(vdata, 'vertex')
	colorwriter = GeomVertexWriter(vdata, 'color')
	
	# GeomPoints primitive
	geompoints = GeomPoints(Geom.UHStatic)
	
	index = 0
	for i in range(amount):
		# random positions in range (-1,1)
		vwriter.addData3f(random.uniform(-1.0, 1.0), random.uniform(-1.0, 1.0), random.uniform(-1.0, 1.0))
		# random UVs
		colorwriter.addData4f(random.random(), random.random(), random.random(), 1)
		
		# add to GeomPoints
		geompoints.addVertex(index)
		geompoints.closePrimitive()
		index += 1
		
	# create GeomNode and put it in NodePath
	geom = Geom(vdata)
	geom.addPrimitive(geompoints)
	gnode = GeomNode('starfield')
	gnode.addGeom(geom)
	nodepath = NodePath(gnode)
	nodepath.setRenderMode(RenderModeAttrib.MPoint, pointsize)
	
	return nodepath

pointcube1 = pointCube(2000,100, 0.05)
pointcube1.reparentTo(render)
pointcube2 = pointCube(1000,100, 4)
pointcube2.reparentTo(render)

#pointcube1.setRenderModePerspective(True)
#pointcube2.setRenderModePerspective(True)

run()

When I uncomment the first line of the last two lines, the vertices are rendered considerably bigger and in non-perspective, then after usually few seconds they change from persective to non-perpective in short intervals until they are finally rendered in persepctive. When I have two NodePaths like this (by uncommenting the second line as well), they are both rendered in non-perspective, alot bigger than they should be and after few seconds Panda freezes.

Tell me if you get this issue as well.

I don’t have any problems with it, but it seems that your points in pointcube2 are much larger than perhaps you meant them to be (they fill the entire window). Most graphics drivers won’t render perspective points larger that a hundred pixels on a side or so, and they may get weird if you try to draw bigger points than that.

You could try avoiding reliance on your graphics driver to handle the perspective computation, by putting “hardware-point-sprites 0” in your Config.prc. This will tell Panda to compute the perspective size of the points on the CPU first, and send the resulting quad to the graphics driver for rendering. It will tend to give more reliable results (since graphics drivers are often buggy), but it is a little bit slower.

David