doyubkim / fluid-engine-dev

Fluid simulation engine for computer graphics applications
https://fluidenginedevelopment.org/
MIT License
1.89k stars 264 forks source link

Colored mesh #238

Open PavelBlend opened 5 years ago

PavelBlend commented 5 years ago

Hello.

I have particles that have color: 01 Is it possible to transfer these colors to the mesh of a liquid?

doyubkim commented 5 years ago

This feature is not available at the moment but sounds like a good addition. Will add to the feature list!

PavelBlend commented 5 years ago

It turned out to blender means to implement the painting of the mesh: rend_colored_mesh

PavelBlend commented 5 years ago

I implemented the mesh color using Vertex Colors. Because of this, the transition between colors looks stepwise. Perhaps the color of the mesh can be realized using textures and UV coordinates? Each particle source will have texture coordinates that will be transmitted to the particles.

doyubkim commented 5 years ago

Thanks for the experiment! Yes, I think that’s a good idea. Let me try letting particles to sample texture coordinates from an input mesh and carry the values throughout simulations.

kentbarber commented 5 years ago

I would also like to be able to set the color of particles and also grid cells. Have the colors of cells advected throughout the domain. I am happy to set the colours myself, I don't need any sampling from textures done by the framework itself.

It would also be nice to set the color for the emitted particles as a parameter to the emitters, just set a Vector3D(red, green, blue) between 1-0.

The emitters could also have a callback to let us set the sample colors ourselves. Similar to the way addTarget works, but let us specify the color of each particle based on its location. I could then sample volumes and textures within Cinema 4D to set the colors myself.

utilForever commented 5 years ago

I'll take a look this weekend.

utilForever commented 5 years ago

Are you want to add feature for setting the color of particles and grid cells?

kentbarber commented 5 years ago

Only particles are really required.

kentbarber commented 4 years ago

Hi @utilForever, just wondering if you have added color support for particles yet? If not then I may start on it myself. I won't be worrying about LevelSetSolver for now and will just add support throughout for setting a color for particle emitters and having that data stored for each individual particle in the ParticleSystemData.

kentbarber commented 4 years ago

@utilForever I decided to start with this. Looks simple enough to add. So if your not working on this yet then do let me know, otherwise I could submit my own changes for a pull request.

kentbarber commented 4 years ago

Actually I think what I am doing is not part of this particular Issue. Since what I am doing is adding colors directly to the Jet Framework and this issue is about using particle colors to set the vertex colors of a mesh, these are two different topics although they are related. I am going to open a new issue for this.

doyubkim commented 4 years ago

@kentbarber @utilForever Here's what I was envisioning for this feature:

For the particle-based solvers, add additional channel (color channel) to ParticleSystemData3. After performing mesh generation using marching cubes, enumerate over the mesh vertices, "interpolate" colors around the vertices using SPH-style interapolation and/or nearest neighbor approach (maybe have an option to pick one). Then the colored mesh could be achieved.

For the grid-based solvers, add color channel to GridSystemData3, make them "advectable", and when performing marching cubes, directly interpolate color values from the grid which now has color channel.

@kentbarber if you are already working on the particles, then please feel free to post a PR! We can discuss from there.

utilForever commented 4 years ago

@kentbarber Oh, I'm sorry. I've been very busy with my company. Are you started implementation? If you not working on this yet, I'd like to start next week. p.s. I'm working on many projects such as RosettaStone. Thank you for reminding me.

kentbarber commented 4 years ago

@utilForever Yes I have started adding support for particles, but it is still under discussion. I have opened a new issue for adding color information to particles: https://github.com/doyubkim/fluid-engine-dev/issues/277#issuecomment-562773481

I haven't touched GridSystemData3 yet, so if you would like to do that then feel free. I would consider it to be a separate task and perhaps could be its own issue as well.

Then once color has been added to both of the above, this particular issue could be used to track the interpolation task for creating the color for the generated mesh.

utilForever commented 4 years ago

@kentbarber Hmm... If you haven't started implementing the code yet, I'd like to work on both. I think that since color data is not essential, it would be good to provide additional data as an extension such as std::optional or new design.

kentbarber commented 4 years ago

@utilForever That is ok with me. I will hold off on any further work in the Jet Framework itself and will instead get my code ready to create and use the color data once it is in place. I would prefer the ability to add arbitrary data to the system, with color being one of them, so a more general case system that is usable throughout Jet would be a better solution. Thanks.

utilForever commented 4 years ago

@kentbarber Thank you for your consideration. I'll discuss this design on #277.