-
Notifications
You must be signed in to change notification settings - Fork 65
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
Cone distribution not uniform in all cases #95
Comments
Could you back those claims with resources or mathematical proofs? The 1/3 factor is derived mathematically from a half-cone. Maybe it doesn't extend to a truncated cone, I can't remember the details to be honest, but I find it hard to believe a simple |
After I changed some code so top_radius is the side facing Y+ it works fine for perfect cones. However, any cone without |
This is the distribution for a cone of height Distribution looks fairly uniform. Now with top radius We can start to guess some issue. With top radius Note that there's no "change the facing" involved here. The origin is at the top by design, which is the apex when So yes there's a bug in the distribution in case the cone is truncated at the top. But everything else is by design. In particular, there's no inversion of the top/base; the base is where particle are emitted, and is generally larger than the top as you most often want some kind of radial spread of particles rather than the particles converging toward the cone axis. And the "base" semantic comes from the mathematical definition of a cone, while the "top" one is just copied from Unity, and is arguable but is better than nothing. I'd maybe rename to "origin" if that makes it clearer. I do appreciate that Unity uses the opposite convention, but I don't really like it because what they end up calling the "top" is the mathematical base of the cone, while their "base" is the apex when |
By the way, the cone uniform distribution formula is from https://stackoverflow.com/a/41752481 |
Ah, if the design is supposed to have base always be bigger than top that eliminates the most obvious problem. Perhaps the library should somehow disallow setting it like that. I agree that flipping it would be a breaking change, and one that might be undesirable for particles as you'd want to emit them away from your origin and spread out. I also think hanabi doesn't currently rotate the effects, so users wouldn't be able to just flip it back either. As for the names, |
Note that in addition of the formula getting wronger and wronger as the base and top radii get closer to each other (which isn't fixed yet; I didn't find the proper formula so far), there was also another simpler bug where base and top were inverted in the distribution. The new |
To be clear on why this is not fixed yet: I have been unable so far too find a reliable formula to calculate the distribution over the surface or volume of a truncated cone. This is slightly tricky to derive mathematically. |
When creating a cone, particle distribution is not uniform. I think the problem comes from alpha_h being set to
pow(rand(), 1.0/3.0)
. This is not correct and performs even worse than setting it directly torand()
, which would at least behave correctly on a cylinder (top_radius == bottom_radius) and looks somewhat uniform on any cone without a sharp point.The text was updated successfully, but these errors were encountered: