Creating a static particle system with Panda3D

Hello all, I’m trying to create a static particle system with Panda3D (to be used for stars). I’ve seen the Particle Panel, and that looks great for moving particle systems, but I’m trying to create one where all the particles are static.

If anyone could point me in the right direction, it would be extremely helpful.

You can render vertex of a mesh as points using node.setRenderMode(RenderModeAttrib.MPoint, 1), but you may need to do some shader magic to scale the points with perspective on some(all?) hardware and even more magic to put star textures on them (if square points aren’t star-like enough for you).

To get a perspective scaling vert do in the vertex shader:

uniform vec2 screen_size; //size of the screen/window
uniform vec3 camera_pos; //position of the camera

float dist =distance(vert.xyz, camera_pos);
point_size= screen_size.y/ dist;
gl_PointSize = point_size;

To get uvs do in the vertex shader:

flat out vec2 center;
//void main() {  ...and so on
center = (gl_Position.xy / gl_Position.w * 0.5 + 0.5);

and in the fragment shader

flat in vec2 center;
//void main() {  ...and so on
vec2 uv = (gl_FragCoord.xy / screen_size - center) / (point_size / screen_size) + 0.5;

Making a model made out of point can be tricky using any modeling package (and more so when you try to export it) so it may be a good idea to let panda generate the geometry. Take a look at the ‘procedural-cube’ sample code, you will probably need to add a single GeomPoints primitive with all the vertex not multiple GeomTriangles with 3 verts each. Or so I think.