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

Add Particle Colors #277

Open
kentbarber opened this issue Dec 6, 2019 · 6 comments
Open

Add Particle Colors #277

kentbarber opened this issue Dec 6, 2019 · 6 comments

Comments

@kentbarber
Copy link
Contributor

kentbarber commented Dec 6, 2019

I would like to add color information to the particles. This would also involve adding an initial color to the emitters.

@doyubkim Are you in favour of this, or should I look for an alternative way of implementing it so that it is external to the Jet Framework? I don't want to break away from the main branch so any changes I make to the Jet Framework I would like to be integrated, if approved, otherwise I will look for an external approach.

@doyubkim
Copy link
Owner

doyubkim commented Dec 6, 2019

Original thinking behind the particle system data class is to have arbitrary channels like colors, vorticities, texture coordinates, etc, so that the particle system can be as compact as possible if all these channels are not needed (i.e. have positions and velocities only). However, I can see the value of color channel being there by default (or at least toggle-able).

Let's first add color channel to the system just like positions. Once we have something working that meets the need, we can then iterate on the design.

@kentbarber
Copy link
Contributor Author

Yes I also thought that having a system to attach arbitrary data to particles would be better. I am glad you brought this up. Since it felt wrong to add color as its own channel since it is not required data for the fluid simulation.

I have it almost implemented but have no objections removing it in favour of a generalised system, since I would also like to add additional information to particles as well.

Do you have part of this new system in place already in one of your other branches?

@utilForever
Copy link
Collaborator

@doyubkim I consider std::optional or rework code to support additional data such as color, vorticities and temperature. Do you have any preference?

@doyubkim
Copy link
Owner

doyubkim commented Dec 7, 2019

ParticleSystemData class already has full ability to add arbitrary/optional channel (see addScalarData/addVectorData). I would rather focus more how to make it interact with other modules such as the emitters and mesher

For example, a particle emitter will generate pairs of position and velocity and append it to a particle system. If that particle system has other channels, new particles will have zero values for such an non-position/velocity channels. So what should be added to the code is an API to specify default values of an arbitrary channels from emitters (and then particle system data which emitter should communicate with).

Mesher is actually more complicated and I don’t have good API design in my head yet. Ideally a mesher should take a particle system data with arbitrary channels, generate a mesh as well as interpolated channel values per vertices. That could be done by also making triangle mesh somewhat similar to a particle system data then we can not only handle colors, but also can handle any other channels that we couldn’t think of right now.

Lastly, the actual algorithm that interpolates color (or any values) from particles to mesh needs to be implemented which I think is quite straightforward if SPH style interpolation is used.

@utilForever
Copy link
Collaborator

utilForever commented Dec 7, 2019

@doyubkim Are you consider this way? These variables is declared in ParticleSystemData.
If this method is used, it will have to add a variable called _colorIdx.

_positionIdx = addVectorData();
_velocityIdx = addVectorData();
_forceIdx = addVectorData();

@doyubkim
Copy link
Owner

doyubkim commented Dec 8, 2019

@utilForever Yes, something like that. We can also make the color channel optional by taking a boolean parameter from the ctor. While having a dedicate color channel is useful for many cases, it also impacts memory cost if it's turned on by default.
I won't recommend using std::optional, though. I still would like to stick with C++11 for v1.x.

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

3 participants