Good day everyone,
I'm currently programming a fluid simulation through use of metaballs and I have a very specific problem/question.
The steps I use for metaball simulation: 1. Simulate particles' positions 2. Create billboards that always face the camera with the particles' positions at its center 3. Cast a ray from camera to every fragment/pixel and determine the value of every particles' contribution along the ray.
Currently, I have nice looking metaballs with lighting, however, when you look closely you can see the edges of a billboard that is infront of another metaball because the colors are slightly off. The fragments that fail the raycasting test get discarded, but they are obviously still somehow interfering and I just don't know how or why.
Want I want to know, because I have thought about it and didn't come to a conclusion: since the actual fragments of the billboards where there is no implicit surface are discarded, that means that not the color value of the "obstructing" discarded billboard gets changed, but instead that of the actual goal billboard. where are possible points of conflicts that may create this behaviour?
Thanks in advance!
EDIT: I think I am wrong about my earlier assumption: the raycast used to determine the implicit surface most likely hits a metaball BEHIND the billboard, so it actually doesn't get discarded... it then takes the normal of the actual intersection, but uses the light direction vector that is made by using the fragment's position, not the actual intersection. So, my guess is that I need a better condition to let the raycast know it didn't hit anything instead of continuing and hitting a ball that is a little further away.