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


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
		index += 1
	# create GeomNode and put it in NodePath
	geom = Geom(vdata)
	gnode = GeomNode('starfield')
	nodepath = NodePath(gnode)
	nodepath.setRenderMode(RenderModeAttrib.MPoint, pointsize)
	return nodepath

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



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.