I want to display a single point sprite, with a given texture, at a given location.
I’ve looked through the tutorials and documentation, but they all seem to use a ParticleEmitter or ParticleFactory to generate many sprites - For what I want, I’ll be rendering many particles, but all at specific locations, and I’d like to add them one by one. Is there example code to create and render a single point sprite at a given location, and is it significantly slower than using an emitter?
Then give it a Particle.j3md material with the right texture, etc…
You can look at the code to the particle stuff to see how to setup the other mesh buffers that the particle material expects. (Or if you know how then you can write your own shader but it’s easier just to use the existing one).
As I recall, you will need Position, Size, TextureCoord (with a Vec4 to define two corners instead of the normal Vec2), and Color.
Oh, and you will have to set the Quadratic float on the Material to something. I think I set mine to 6. This somehow controls how fast the sprites scale with distance.
Thanks! That worked, and it looks great. One more problem, though: All the particles except one are red, and the one nearest the camera is green. I looked at Particle.jm3d and I don’t see how to edit the color if it’s not specified in the texture; the texture I’m using is grayscale, and I tried it both with a grayscale (8-bit) texture and a 24-bit texture.
So, another unrelated problem: can these sprites on a point mesh not be “picked”? And if not, how else will I determine what object the player is clicking on?
I’m using point sprites at the moment because, as far as I can tell, they’re the fastest way to display sprites at given locations constantly facing the player. If Ray.distanceSquared(Vector3f point) does what I think it does, I should be able to implement picking very easily, but I have no idea if it’ll be anywhere near as fast as OGL picking.
Given that I’ll have anywhere from 1000-10000 sprites to interact with, in terms of performance, should I use quads or just implement picking?
@ShivanHunter said:
I'm using point sprites at the moment because, as far as I can tell, they're the fastest way to display sprites at given locations constantly facing the player. If Ray.distanceSquared(Vector3f point) does what I think it does, I should be able to implement picking very easily, but I have no idea if it'll be anywhere near as fast as OGL picking.
Given that I’ll have anywhere from 1000-10000 sprites to interact with, in terms of performance, should I use quads or just implement picking?
btw, thanks!
You could batch the quads and it would be lighting fast… but you’d have to implement the billboarding in a .vert shader. You could do it in code on the CPU but it would be much slower.