But I want to create them within a container at random x,y,z positions in this container. I don’t need to animate them as I will be moving the container while the camera stays still thus moving through the particles.
What would be the best way to achieve this?
I can’t seem to find any example of a particle system that sets the positions of the particles individually / directly.
Thanks for the links & replying, yes I’ve read that but it doesn’t detail what I need. I also tried BABYLON.SolidParticleSystem but I am unable to get particles to display like the ones in the BABYLON.ParticleSystem, transparency and light reflection issues.
I need the particles to be static, non moving and in a container which I will be moving a FirstPerson camera through, the particle container (cube/box) will be very large area, if I go this route then I will have to work out velocity of camera and match the velocity of the BABYLON.ParticleSystem and it’s direction based on camera direction and motion (which sounds like a nightmare to do).
I will try creating the particles as planes in BABYLON.SolidParticleSystem and see if I can get them to display correctly as the particles in the demo do and do a random x,y,z vector position on around 5,000 of them. Or sprites maybe…
Standard immobile particles should do the job for what you need.
A SPS can also do the job. Could you share your SPS attempt and your standard particle test in a playground so we could see what’s wrong with them ?
Something to fiddle-with. Lines 23-31… you see Jerome’s custom positioning function. He also has a simple custom updater function in lines 50-53. This has 200,000 triangle particles in a flattened box-shape… something to play-with. Reduce to 20,000 for more sanity.
The lights… you can’t shine lights on standard particles… but on these SPS… ya can, and so I did. Just fun stuff.
Line 34 radius sets particle size, line 19 particle count, line 20 box size, etc. (Wingy hugs Jerome for inventing SPS). Next gen of hardware, we’re going to “plow” SPS particles with Tonka toys… you know… MotorGrader Operator 1.0. FUN!!! Grain Elevator Tycoon! Gravel Pit Bull! heh.
Jerome already has basic particle collisions… working fine. Can ya smell the “Snow Plow Operator 1.0” on that demo? huh? I can.
As the particles don’t fade out with distance, I tried fog but that doesn’t work either. If there is a way in the render loop to check particle distance from camera and then set it’s alpha that might work but I’m betting this might start to get a bit heavy on the old cpu/gpu. Maybe if visiblility = false if alpha = 0 might lighten the render load? Maybe I could try to work out camera orientation / direction and match particle direction on BABYLON.ParticleSystem and eyeball velocity values of camera movement to particle / emitter speeds, however this would need to follow a FreeCamera. EG. It’s always raining on you, not the whole world
Particle texture, even with blendmode and alpha at 0.99 the particle plane texture is not trueley transparent and you can see that they are squares.
@jerome & @Wingnut
Love that particle collisions playground example! I’m already having ideas of sparks bouncing off a wall in some kind of metalic scene
3 you need to enable the alpha channel for the mesh vertices line 132
2 no need for fog, but you could add it for an extra effect, so commented out in my example : line 25
1 just add a computation of the particle/camera distance (squared distance is faster to compute) and set the particle alpha value according to this distance, line 121
https://playground.babylonjs.com/#0ZV4IX#2
the last factor in the multiplication at the line 131 (0.02 here) will increase or decrease the fading intensity according to the distance.
Is there a way distable render of the particle if it’s alpha is 0?
For this reason I may need to use BABYLON.ParticleSystem and work out how to move/rotate the ParticleSystem relative to camera rotation/direction and the ParticleSystem velocity relative to that of the FreeCamera’s velocity, while keeping the FreeCamera in the middle of the ParticleSystem (To make it rain on yourself and not the world/scene so to speak) .
I’ve done some adjustments to the original playground example, code clean up etc and I switched out the ArcRotateCamera with a FreeCamera, the SPS Particles dissapear at certain angles, I think this is because of the center registration point of the SPS mesh? As in that vector point is no longer in the render view and thus the whole SPS gets removed from the render engine?
line 232 to set compute the SPS Bbox once for all as its size doesn’t change then (or 233 if you want to skip the frustum test)
line 223 to set almost invisible particles as really invisble : invisible particles aren’t computed in the SPS particle loop, so it increases the global performance.
If you want 100 000 planar billboarded (2D) particles, you may consider using the standard particle system or the GPU particles instead of the SPS.
Is there a way to generate the standard particle system (BABYLON.ParticleSystem), so that it doesn’t animate and over a large cubed area as per the SPS example for the FreeCamera to move around in?
Hi again, guys. I recently did a LITTLE work on using camera.position as a standard PS emitter. (standard particle emitters can be mesh or a vector3… and camera.position is a vector3.)
I just barely started… mostly working in lines 120-125. It is quite easy to drive the camera fast-enough to exit its around-the-cam particle cloud. My goal was getting particles spraying from the entire edges of the render canvas… toward screen center. I started a thread about it… but few were interested or knew of solves. (yawn)
Also, Darcey… you might have noticed some problems with “depth sorting” and other alpha-related things… on standard particles. Expected behavior. Since standard particles are sort of like a single ground grid that has been divided-up into separate cells, the particles can only be depth-sorted IN-FRONT-OF, or BEHIND other mesh. I’m quite sure standard particles cannot be both behind and in-front-of other mesh… at the same time.
But maybe it can be done… using multiple particle systems. They are lightweight… no problems using many. Standard particles have an age (maxLifetime) that determines when they recycle… and they gentle-change from color1, to color2, to colorDead… across their lifetimes… so that gives you SOME fade-out features… time-based, not distance-from-emitter-based.
There are helpers nearby that are WAY smarter than I… on these subjects (such as Jerome). Generally, I am just a playground librarian. heh. I should just shut-up, really.
I don’t really know how to use the standard particle system, but I know that you can overwrite the emitter behavior and that you can set immobile particles at random locations.
You’re sort-of grappling-with the question: Is it better to move camera thru cloud of stationary particles, or parent-to-camera… an invislble emitter out in front of camera.direction, and set ps.gravity (and/or particle emit-directions) to move particles toward the camera? (in webGL particles, gravity can be sideways.)
9 Tile SBS particle system, moving past a certain limit of x,y or z will swap the x,y,z of the 9tile particles to ensure there’s more infront of you no matter where you go. Or maybe even try this with sprites or plain old planes.
or
Open up ParticleSystem.js and find how it generates the particle and see if I can do it myself and make my own generator.
I love your spirit. Keep in mind… the amount of power you can program-into custom startPosition and custom updateFunction on both types of particle systems. You can force the particles to act however you wish… just by fully exercising those two write-them-yourself functions. BUT… they could be complex… and they will definitely be monitoring camera values carefully, and morphing their functionality based-upon what the camera is doing. Both functions… run often and fast… often well-faster than human eyes.
Hmm, might be a good idea to watch fps and throttle this as the effect I need is going to be quite subbtle, its to give a better feel of motion so the alpha values will be 0 to 0.2 at most and a lower update polling rate should suffice which should lighten the load up again. hmm or even a web workers lol