Search Unity

Assets [NEW RELEASE] Physics-Based Flames: The best gosh darned realtime flames reaction engine ever

Discussion in 'Works In Progress' started by fallingfrog, Apr 7, 2017.

  1. fallingfrog

    fallingfrog

    Joined:
    Mar 25, 2017
    Posts:
    15
    Hey, check this out:


    So here is my question: does it catch your eye? Granted, I'm a total geek for procedural/algorithmic effects.. but I'm willing to bet your players eyes would pop out if they saw this stuff in a game. You just drag a "flames" prefab onto *any* game object, and bam, it's on fire. It detects the texture and form of the object automatically and the flames wrap and lick around it in a completely organic way.

    I want some feedback: what do you see about it that you like or don't like- and, any feature requests? And, what are you really looking for in an effect like this one? I want to hear your ideas! Give me some love!

    https://assetstore.unity.com/packages/vfx/particles/fire-explosions/physics-based-flames-63488

    The Falling Frog
     
    Last edited: Aug 22, 2019
    DrOcto and Arkade like this.
  2. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    604
    Looks cool! (Irony)
    • Would have been nice to see the tree being hit. (Lots of green fire in video and asset store down atm so can't check other bids/pics.)
    • Is it all at once or can it spread along from impact point?
    • Also, most importantly, what's performance like? Is it limited by world space or screen space covered? Does it cull nicely? Does it LOD?
    I've built a simple dynamic fire system for my game that spreads and damages things but my visuals are not anywhere near so awesome (just using particle system for visuals). I wonder if I can integrate yours / replace mine if...?

    Thx
     
  3. fallingfrog

    fallingfrog

    Joined:
    Mar 25, 2017
    Posts:
    15
    Hey thanks for the feedback! Here are some answers:
    Good idea! I'll upload a video of that tonight.
    It can spread from the impact point, but the whole flame uses the same color ("spectrum") map, so a green fireball would make green flames. If people want multicolor flames I can add that as a feature.

    It auto-adjusts LOD up to some maximum you can specify. I usually leave the max at 1024x1024. The flames still looks good close to the camera at 256x256, so if you have any issues you can turn down the max lod.
    The performance has been tweaked and re tweaked and by now it runs like butter! My gpu is from 2010 and when a flaming object is right up close to the camera where the level of detail is at maximum (1024x1024) the flames takes about 2ms to render, ymmv though. I haven't tested this on mobile but it should work as long as the mobile gpu supports shader level 3.5.
    As far as culling: the flames effect writes to the z buffer, so the clipping is per pixel, and it renders onto a transparent texture so it behaves that way to the culling engine.
     
    Arkade likes this.
  4. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    604
    Same colour = fine. (Don't want other).
    Was more meaning: player holds a flaming brand/torch, waves at middle of a tree. It initially covers end of nearest branch them spreads incrementally and in realistic fashion along then up, slightly down, etc.
    I've done that with mine but ended up using ray/spherecasts to get nice spreading.

    Also I'd like to see smoke produced in some configurable situations. Say something related to your lovely realistic properties? (E.g. low oxygen / certain fuel type = more / darker smoke?)

    > Is it limited by world space?

    Not sure you answered this? Specifically what are the performance implications of having a field burning vs a torch?

    Thx
     
  5. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    604
    P.s, would I be close guessing it's rendering the source shape into a buffer then doing an old style 2d demo scene effect to generate the flame? So is there cost associated with source geometry quantity / complexity? (Obviously also helps me understand the performance and possibility implications.)
    Thx
     
  6. fallingfrog

    fallingfrog

    Joined:
    Mar 25, 2017
    Posts:
    15
    Ok, I see what you're asking! Yes, you guessed right about how it renders the object geometry into a pane and then there's a demo scene type effect that runs. It also grabs the z coordinate of the fuel source and propogates that over the flames pane along with the fuel and heat, that's how I get the per pixel clipping. So it depends on screen space rather than world space. If the object is far away, it might pick 128x128 for the background geometry and also the vector fields etc. It also handles gracefully the case where you are in the middle of the object on fire. But you might still want to break up your burning field into some largeish tiles, if you were walking through it. It knows which direction is up in world space so it can handle the case where you are looking down at the flames from above. It's definitely possible to have flames that spread from branch to branch in a tree- hmm now that I think of it though I think there's a feature I can add to make that look a bit nicer! Right now I hardcoded it so that a fuel source also acts as a minor heat source so you don't have to worry about ignition, but if I split the fuel rate into fuel rate/heat rate, then yes you could define your torch object as supplying ignition heat and the tree only fuel then it would work like you expect. Right now I'm DEFINITELY accepting feature requests so that's something I could add.

    As far as smoke goes- it woukd be pretty easy to add smoke right close to the flaming object but probably if you wanted a pillar of smoke floating way up into sky.. well let me try it when I get home tonight and I'll upload a YouTube clip and see what that looks like, it might actually work fine..
     
    Arkade likes this.
  7. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    604
    Awesome. Also a webgl demo where we can walk around the flame, through it, jump over it, please?
     
  8. fallingfrog

    fallingfrog

    Joined:
    Mar 25, 2017
    Posts:
    15
    Hi Arkade - I just wanted to let you know where I'm at.. to get the tree to start burning from a single spot is trickier than I thought- I need to define a growing "ignition area" rather than just marking game objects as a fuel source. So that's 3 or 4 days.
    I'm playing around with WebGL and boy the CPU performance is pretty rough. Maybe 15% as fast as native. Firefox is much better than Chrome. GPU performance seems about the same. I'll get a demo up at some point in the next couple days!
     
    Arkade likes this.
  9. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    694
    Hi fallingfrog,
    I'm looking for a realistic moving (in the hand of my character) torch effect for my project and i'm wondering if this system is capable to do it.
    Did you have any sample of this behaviour?
    Thanks
    Max
     
    Last edited: Feb 2, 2018
  10. HenryChinaski

    HenryChinaski

    Joined:
    Jul 9, 2013
    Posts:
    97
    I suppose this asset is discontinued?
    If not, any comment on that review stating, that performance is bad and the flames not rendered in HDR?
     
  11. fallingfrog

    fallingfrog

    Joined:
    Mar 25, 2017
    Posts:
    15
    It’s been a little while since the last update.. but it’s not discontinued. It’s just that I have 2 kids and not much time:)

    I actually put a ton of time into getting it to run fast, the effect was a very ambitious project and I ended up getting it to do things that should have been impossible with current technology by using various complicated tricks. For example the flames buffer is actually 2 dimensional with a depth buffer not 3D, but then when the object or camera moves you have to anti-rotate and reproject the flames buffer.. then there’s the case where the user is inside the virtual flames volume.. it gets real nasty :). But the effect is magical. So many corner cases. But I’ll go back in and see if I can find any memory leaks at some point.
     
    HenryChinaski and manpower13 like this.
  12. HenryChinaski

    HenryChinaski

    Joined:
    Jul 9, 2013
    Posts:
    97
    Thank you very much for the fast reply and I am glad to hear that the reason for the lack of recent updates is something positive!

    I bought the asset and really do like the effect. It also is very performant in my desktop application. What I love especially is that you are able to set complex shapes really easy on fire.

    I just have two "problems", I thought you could maybe help me with.
    I think I understand how the fire is procedurally generated. You use a mask to scan the camera view for objects that have the fuel component attached. This leads to the seemingly unavoidable problem, that if I have a burning barrel and the user knocks it over - away from the camera -, that the fire stops spawning because the fuel plane is not longer visible. Am I right that this is unavoidable? I tried to duplicate the fuel plane on top of the barrel, rotated it 180 degrees and the fire spawned even if the fuel plane was obstructed by the barrel mesh itself. Am I right that you need to consider this when using your technique?

    The other problem I am facing before we can integrate your asset in our project is that your assigned shader does not seem to render in HDR. We are using HDR effects in Unity heavily and this leads to your fire being visually "less bright" than some lamps in the environment. I thought that I could easily swap the shader with some particle shader that supports HDR but it seems to be more complicated than that since you're using very special shaders I suppose? Any idea on that?

    Thanks for your help!
     
  13. fallingfrog

    fallingfrog

    Joined:
    Mar 25, 2017
    Posts:
    15
    Ok, I see your problem. I’ll try and take a shot at it soon but.. off the top of my head- the last step in the rendering process is that it reads the temperature off the flames buffer (which has channels for: oxygen, fuel, heat, depth, they are all already floating point) and then indexes into a preset color spectrum map where temperature is mapped onto color. To do the effect in hdr you’d need the spectrum map to be in hdr (easy but you’ll have to make one). and you’d want the display buffer to be in hdr (might be a few lines of code to change but less than a dozen).

    As for visibility: it doesn’t animate flames buffers that it thinks are not visible to the camera- which are outside the view frustum. That’s just an optimization. You can probably turn that off by commenting out a line of code somewhere.

    I’ll try and get more exact answers to these questions, my next opportunity will be I think next Tuesday.
     
  14. HenryChinaski

    HenryChinaski

    Joined:
    Jul 9, 2013
    Posts:
    97
    Thanks again for your quick answer and thanks for the explanation. If you could look into the HDR I would be very grateful, especially if it does not seem to be too much work for you. I also believe that it could be a nice update for the asset, which is seemingly still the best of its kind on the store. I played a little with it and the effect I am achieving now fits our art style perfectly and looks incredibly unique. Amazing work.
     
  15. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    906
    This asset looks really nice, well done! Would love to give it a try before I buy, e.g. is there a demo I can download?
     
  16. HenryChinaski

    HenryChinaski

    Joined:
    Jul 9, 2013
    Posts:
    97
    Coming back to the HDR compatibility. I assume you did not find time to look into it?
    Because, if it is not possible to adapt the code from your side, I would need to contract someone to do it.
    I really like the flame effect and want to use it, but it would look so much better if the flames would be actually glowing.
     
  17. HenryChinaski

    HenryChinaski

    Joined:
    Jul 9, 2013
    Posts:
    97
    Just a last try to bump the HDR compatibility. I would gladly pay for it good money.
    This asset is without alternative and the effects we created are so cool, I am not even sure if you are aware of the possibilities. The only problem is sometimes the draw order. If you optimize it well performance also is pretty good for a desktop application.

    If you don't have the time, could you at least point us to the exact location of code you described in your previous post?
    If it is not too much work we will surely find someone to contract to do it since none of us has ANY idea of shader programming.

    Hope this message reaches you well.
     
  18. fallingfrog

    fallingfrog

    Joined:
    Mar 25, 2017
    Posts:
    15
    Hi, I’m sorry I haven’t taken care of implementing HDR yet! ..I tell you what, are you serious about paying for the feature? Because my development computer got rained on and is out of service and I could use a new one for developing the feature.. or just make me an offer.. I tell you what, make an offer and I’ll set myself a hard deadline of 2 weeks or so, is that fair? But I’ll try and get it done either way. Can you send me an email at fallingfrog@gmail.com ?
     
  19. fallingfrog

    fallingfrog

    Joined:
    Mar 25, 2017
    Posts:
    15
    Well, you didn't give me any money, but oh well, it's worth the effort to maintain my assets anyway. As it so happens I'm all set with HDR rendering now, I'm double checking that it works in older versions of Unity but it should be uploaded in a couple days. Cheers!
     
  20. fallingfrog

    fallingfrog

    Joined:
    Mar 25, 2017
    Posts:
    15
    HDR rendering is working, I'll be uploading it in a couple days.
     
    manpower13 likes this.
  21. fallingfrog

    fallingfrog

    Joined:
    Mar 25, 2017
    Posts:
    15
    Version 1.4 supporting HDR rendering is now up in the Unity Asset Store! I made a bunch of other little improvements too, such as the light source now moves around a little bit so that the shadows move when you turn the flicker up. I also renamed "pressure force" to "turbulence" to more accurately reflect what that slider does. I also made a bunch of bugfixes for corner cases that were not behaving quite exactly the way I wanted them to.
     
  22. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,414
    fallingfrog likes this.
  23. fallingfrog

    fallingfrog

    Joined:
    Mar 25, 2017
    Posts:
    15