Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Particle colour while breaking blocks #209

Open
vuolen opened this issue Apr 27, 2015 · 4 comments
Open

Particle colour while breaking blocks #209

vuolen opened this issue Apr 27, 2015 · 4 comments

Comments

@vuolen
Copy link
Contributor

vuolen commented Apr 27, 2015

Currently the particles are a boring gray when you break or blow up blocks. Maybe it would give a nice effect if the particles were actually the color of the block being destroyed?

@fkaa
Copy link
Collaborator

fkaa commented Apr 27, 2015

I attempted this a while ago. Some notes about how they are implemented now (mostly from memory, might be incorrect):

  • All particle instances share the same mesh
  • All particles are drawn in one call

So we end up with a few problems. For example if we want to scale particles with age, all particles are scaled equally. Same goes for colors.

A few solutions:

  • Make each block emit particles which they have ownership of (One draw call per block's particles. This still means only color would be mutable, which is kind of what we want anyway?)
  • Get rid of the single mesh and stream vertices instead (Most flexible, but also most expensive. Note that speed is relative here, and uploading ~100 vertices per frame is nothing for the GPU)

@vuolen
Copy link
Contributor Author

vuolen commented Apr 29, 2015

I wouldn't think having different meshes per block would be that expensive. We could even have a modifiable limit for particles, for example forbidding the creation of more, when there are over 100 being rendered.

Particles could still share the same mesh by block for optimization, but that shouldn't be a restriction, I would say particles have to be really flexible for future modders.

@rakiru
Copy link
Collaborator

rakiru commented Apr 29, 2015

In case someone changes particles:

I was considering adding a gravity multiplier to particles. Right now, all particles are affected by gravity regularly (so, 1x multiplier). Some things don't make sense to do that, like fire or smoke. A multiplier would allow this to be set per-particle (hopefully isn't noticeably performance degrading) while still respecting the actual gravity.

@iamgreaser
Copy link
Owner

Could've sworn I said something here, maybe I forgot to click Comment.

We used to have this, but in the blur of trying to find out what was making Iceball get progressively slower and slower, I ended up forcing blocks to use the same static mesh (it was using a different mesh for every particle).

Reverting to the old behaviour puts it at risk of fragmenting the GPU memory and making other things slow, so for this to work we'd ideally want to limit it to one static mesh per broken block.

If we want this to go faster, we'd probably want several points in a mesh, as there's a somewhat notable delay every time you call glDrawArrays, and calling it about 3000 times a frame makes things slow.

We are not streaming vertices to the GPU just so we can make block breakage look fancier. We could possibly invest in a shader, though...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants