-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Turbulence/Noise for ParticleMaterial (2D / 3D) #55387
Conversation
a7baafa
to
51cc4d6
Compare
0c47293
to
ef79491
Compare
What is the license of the noise? I couldn't find it |
The PR description says:
I would prefer if we were explicitly allowed to use the code under the MIT license, as CC BY is more restrictive than MIT overall (CC BY has stricter requirements for attribution). Feel free to contact Inigo Quilez about this 🙂 |
I used this shader code because it is compact and works well. As I tried different shaders in my research, I have a couple of alternatives if the license is not too great. A shader with MIT license that I tried and worked perfectly with some super small modifications is this one: I could swap it without a big problem - it's just more code - but with some space saving actions it can be reduced to a moderate level. I also just did a performance test and I couldn't make out any difference compared to the current code of this PR (tested with 12x1mio particle systems). |
Sorry for the oversight, I was looking for it into the code. Thanks a lot @RPicster for the work! My first observation is that I find this fairly complex to use. The knobs require a lot of tuning and there are a lot of configurations that won't work. I'd like to understand if we can reduce the knobs on turbulence to obtain something more "plug and play". Another issue that I had is that power and size behave in very counter intuitive ways. With power set to 0.07, my particles are still accelerated very very far, and I also observed a some flickering and I'm not sure if it's something I am doing wrong, or if there's some bugs? I'm happy to chat about this on rocket chat if you wish. Thanks again for looking into this!! |
@RPicster right now with these new systems we want to move towards giving more control through the visual particle shaders, and having the default one be tunable but not too advanced. I would perhaps remove a number of settings, specifically color, rotation influence (that could be achieved by using orient to velocity), scale influence. I didn't fully understand the difference between velocity influence and position influence (I didn't read the code yet). So perhaps
For all the complex behaviours like tying the turbulence value to a color ramp, I'd expect the user to use a visual shader. What do you think? |
I don't like taking power away and say: if you want cool stuff you have to use a more complicated tool. I rather hide the advanced settings behind a checkbox. Dumbing down tools often makes them borderline useless for many cases ending up in people going back to customized shaders - at least that's what people in my network do (fellow good Godot users). The difference between velocity and position is that position directly influences the particles position and velocity influences velocity (oh man that sounds dumb). Eg. With position you can theoretically build a lightning bolt because the particle will be forced to a certain position offset. My suggestions for simple settings would be:
When extending the settings, Speed is switched to a Vector3 (makes a lot of sense to e.g. make a fire that makes it look more like moving upwards). And the rest of the settings are shown. As said above, I want to empower the user and give a system that is flexible out of the box - saying "just use nodes" is really not a good solution imho as setting up a particle system with nodes is much more time consuming. |
Hey @RPicster, I understand where you're coming from but it is a current goal to expand more on what can be done with nodes rather than putting everything in the default particle system. I fully agree on the statement of dumbing down the system, but this isn't what I'm suggesting. I believe advanced users should be able to harness the potential of it, and i believe that newcomers shouldn't have too much on their plate. I'm not sure you've seen it, but I'm referencing this work: #42248 |
In my opinion, the particle system especially and (some) other shader effects are much easier and support advanced effects if used through visual shaders. If you cannot do it yourself - I can take and implement turbulence to them myself later (after merging) but saying that is not a good solution is a bit hastily. |
I think it is an absolute must have inside the visual shaders. I totally agree with you there. I love the idea, approach and power of the system. I just also have the opinion that a user wanting to create a good looking standard effect should not be reliant on visual shader nodes. It is much more complicated for a beginner and intermediate user compared to playing around with some sliders. Giving the user only the 3-4 parameters will create another set of options that are just quite not powerful enough to create high quality assets with that System. What is speaking against hiding advanced options behind a checkbox? It is not the same as having to use an entirely different setup. |
It's inconsistent with the rest: options that are deemed advanced are a target for the visual shader.
I'm confident that the standard can look good enough for most use cases ^^ I wanted to ask about something else: in my tests i noticed that there was a strong directional push, even with scrolling noise (most particles aligning on a tube along a diagonal on the zy plane). Is this intended? |
Then I would rather not hide / dumb options down and keep them in the way they are. Visual Shaders / Nodes have their use cases, but I think for such basic things (imho) it shouldn't be neccessary. About the directional push: I noticed that too and still try to find ways to reduce it / get rid of it. By the way - I totally disagree that Visual Shader Nodes should be considered the exclusive tool for advanced users and cool looking features should be limited to that. |
I think it's a powerfull feature! and will be a shame to not have it , it can be more simple, true, but you can easily just have some default and advanced options, in order to keep it simple and allow more advanced use at the same time. |
Who said it won't be merged? |
I don't think that this should be decided here, in this specific PR. If the design goal of the particle team is to move complexity and possible permutations to the visual shaders, then the new additions must adhere to the existing principles. Options can always be added later (new options with matching defaults don't break compat), but it's much harder to remove them (removing stuff always breaks compat). If you find the overall goals of the particle team to be misguided, it's worth a dedicated discussion, and likely a proposal suggesting an alternative. Do keep in mind, though, that node-based systems seem to be the most popular trend in the digital art these days, so visual shaders would probably come more natural to a lot of people. |
I would gladly take part in that discussion (I'm on the rocket chat) and I agree that node based systems are popular in certain software packages. A node system certainly does not come more natural, they require a lot of knowledge which nodes can be plugged where, which nodes exists to even start with etc. Learning a new node based system is a complex task. These people are not the typical Godot users - in my experience it's game devs. Anyway - my personal next step with this PR will be to
As said, we can gladly meet up and discuss Particle Systems in voice or in some channel! |
@RPicster I think you've made your point, but you can of course provide more examples if you think that they would swing the opinions of the particle team. However, if they don't, are you prepared to comply with the reviews and requirements from maintainers of the area even if you don't agree on the rationale? |
But parameters for rotation or scale influence can hardly be called "advanced options". They are no more advanced or complex than one for velocity. I would wager that most users using the turbulence at all would like to tune these as well. Therefore, to limit the influence to velocity only would be quite arbitrary, IMO. |
Oh well, that sounds to me like the pistol on the chest - I don't hope that's what you try to say 😉😘 |
c4389f7
to
d80de57
Compare
I looked into it and I also noticed the behaviour that you are describing as damping. I was very confused at first and checked the shader code... but if you think about it, it actually makes sense. I added a bit of code to compensate for it a bit... but I won't be able to "negate" it... as it would also make no sense from my understanding. At least this was my conclusion... if you add some linear acceleration it behaves very differently. Please also check it again as I said: I changed some shader code and it could also have been another bug I found with the noise scale. |
d80de57
to
9137ba7
Compare
Hey @RPicster , I don't know why it doesn't show in this page but I think that it would be enough to normalize the resulting normal vector of the velocity (I commented on the code) |
The current noise breaks down if positions are greater than ~100 units. So a particle system located 100 units away from the origin would start to show issues and one that is located 1000s of units away from origin will really start to break down. That being said, I can't figure out why Hash33 is causing problems in your case. It should be ideal for this situation and in my testing it is working fine. Unfortunately I won't have time anytime soon to really dig into this. Since you have tested very thoroughly and haven't run into any issues, I am fine merging with the hash function you have now. If the issues I anticipate arise we can easily switch out the hash function later. |
After testing it turns out that noise and turbulence actually looks better if particles lose velocity when changing directions harshly. rightmost is with "dampened" turbulence, left is my own "fix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work and really great addition for Godot.
Thank you so much and thanks for bearing with my whining.
I tested this again as it did keep me up at night... 🤯 So... I think in a practical application it still works with the slightly not-perfect noise. |
@RPicster nono, i was asking because you said there are discrepancies between your results and clay's. Perhaps it's a driver issue |
To be sure that we test the same way, we would need the same test first. |
Code looks good on my side, so if @QbieShay gives it the go, it should be fine. |
go gogogoogogogogoogo |
Thanks! Amazing work :) |
Now... The question of questions. Should I backport thisto 3.x? It's not too much work. |
I think there's no "you should". But if you can/want I think there's nothing against it. This PR looks like a pure enhacement. I don't see any breaking changes or usage of some new features not available in 3.x. So I'd say just give it a go. Also, don't you know the new motto? 😄 |
I think this is worth backporting for 3.6 🙂 |
Just seeing this now. Great idea and great work! It does seem like it could be done with significantly fewer noise calls, though. Right now it's using 12 (or 18 if the compiler doesn't optimize away the unused ones) plus one for time. Just two 4D simplex noise evaluations with gradient / partial derivative vector support (this with the output vector feature from this) should do the trick:
This would also reduce visible directional bias, because it's using more isotropic noise through a more isotropic formula. I'm currently working on a proof-of-concept for this, and perhaps making a follow-up PR. If such an update does get merged, I think it would be good to do so before including a backport in a 3.X release, so that there isn't a change in patterns in the official versions. |
It's a feature I miss a lot and brings much more life and interesting patterns to almost any Particle System.
I uploaded a longer demo video showing the features and parameters in action:
https://www.youtube.com/watch?v=oTsEaKpzseE
Here are some small examples:
godot.windows.opt.tools.64_sNd3QdukI7.mp4
godot.windows.opt.tools.64_TUfD4UlVNY.mp4
godot.windows.opt.tools.64_ZBGLjShgWi.mp4
godot.windows.tools.64_OEH3Ll39JA.mp4
godot.windows.tools.64_JYbgrKcvHO.mp4
It comes with the following parameters
(The original pull request also had rotation and scale influece, those were removed to reduce complexity)
I also took care that collisions look good and happen in a way that makes sense (no further turbulence gets applied after a collision).
The newly added code snippets for the noise in the shader have been checked with the original authors and both gave their (very friendly) approval to be included in the engine code.
TO DO: