Search Unity

Volumetric Smoke Shader

Discussion in 'Works In Progress - Archive' started by jack-riddell, Sep 30, 2015.

  1. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    yep but not any screen space effects
     
  2. TheEndersWAR

    TheEndersWAR

    Joined:
    Jan 8, 2015
    Posts:
    58
    oh man that sucks.. Im using TENKOKU Dynamic Sky, and there fog effect is screen based''

     
  3. TheEndersWAR

    TheEndersWAR

    Joined:
    Jan 8, 2015
    Posts:
    58
    heres a example of my problem
    notice the red smoke'' is set to transparent(''Fade also doesn't work'') only cutout works for it''
     
  4. TheEndersWAR

    TheEndersWAR

    Joined:
    Jan 8, 2015
    Posts:
    58
    here's a few more old examples (''using transparent'')
    This one is with Cutout on''
     
  5. TheEndersWAR

    TheEndersWAR

    Joined:
    Jan 8, 2015
    Posts:
    58
    I know this doesnt deal with your product but it could be give you insight on how to approach the problem
     
  6. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    My existing smoke has a distance fade feature that fades out the smoke at a distance, that is your best chance for getting good looking smoke that fits with screen space fog effects like that.
     
  7. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,342
    Couldn't you use a curve for "size over time" to solve this issue?



    It looks good in stills but does draw attention too the low spritesheet framerate which otherwise would be barely noticable. Would it maybe be possible to avoid the flicker/pop/sort issues that a second particle system creates by using the "sorting fudge" (or whatever it is called) option in shuriken?



    Yeah, those are a royal pain to get right! Have you checked on blendswap, blender market place, blender cookie and blenderguru? There might either be good tutorials to copy or complete setups to download. I never really got the fire to look right myself. The firespritesheets I'm usually using are totally fake stuff created by animating noise textures in displacement modifiers of subsurfed meshes. That looks ok for pure fire but couldn't be made to transition gracefully to smoke. Your approach to pack it all in one spritesheet is quite interesting and looks promising. Keep up the great work!
     
  8. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    the issue is not the size of the particles its the number of particles and the amount of over draw they cause. if i use size over time i get a thin spot in the smoke trail and it becomes to narrow, if I leave them as is i get a spot that looks too thick / has too much smoke and if i use the colour over time to reduce the amount of smoke I end up with 4 + particles with 10 % alpha drawing over the top of each other creating blurred undefined smoke. Killing a percent of the particles is the best way i know of to thin out the smoke.

    the spark stuttering in that gif is mostly caused by me not using a fixed frame rate, i upped the frame rate of the smoke close to the flame go get a bit more detail / smoother effect but i didn't smooth out the frame rate for the tail end of the smoke leaving bits with a really low frame rate. if you look at the newer gifs you will see the sparks flowing a lot smoother.

    i have used multiple particle systems with fort fudge in the past, if you look at the crashed plane gif / video that's how i did the fire and smoke. using multiple particle system has several limitations.
    In a multi particle system you cant have the sparks be occluded by / light the smoke in any way.
    when 2 fire effects spawn close to each other you run the risk of the fire/sparks of the back particle effect jumping in front of the near particle effect.
    and most crucially if you use a 2 particle effect fire as a sub emitter you get incorrect ordering of effects.

    the crudely drawn image below shows a barrel explosion, the barrel chunks are made using a normal mapped alpha clipped particle effect and the fire is made using sub emitters.

    the fire/fragment chunks on the left are done using 2 sub emitters one for fire one for smoke, the fire/fragment chunks on the right are done using 1 fire / smoke / spark super emitter.

    ParticleSorting.png

    because all particles in a sub emitter are part of one effect if you use 2 effects you have to draw all the particles from one effect on top of the other.
    This causes all the fire and sparks to be drawn on top of all the smoke ruining the effect.
    if you use only one particle effect you can use unitys particle sort to make sure all the particles are in the correct order.

    anyway its 2:00 pm here and I'm drawing exploding barrels in MS Paint im going to call it a night.
     
    Martin_H likes this.
  9. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,342
    Ah I see, thanks a lot for the in-depth explanation! Then maybe upping the framerate of the spritesheet is the key. Do you know how much the size of the spritesheet texture affects rendering performance? I'd imagine not much, but I'm not sure.
     
  10. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    Ok so my current mobile shader is "Feature complete" it has all the functionality you could need, emission maps, soft particle settings, light scattering, vertex only lighting and distance fade support. Now I have to break apart my shader and add the ability to turn all these features on and off. So all the people that bought Advanced Normal Mapped Particles I need to know what setting you used, what things you found yourself turning on and off and what options you would like in the next generation of this package.

    ps did anyone use the height alpha setting? as I'm not sure i should included it in the next package.
     
    Martin_H likes this.
  11. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,342
    I tend to go for maximum visual quality until performance really becomes an issue. If you can pinpoint certain features that cost the most processing time in general, then I'd start with making those optional.

    I never used it and I doubt there is much demand for it. I'd suggest to just comment out the code and leave it there as an undocumented and unsupported bonus feature, in case someone wants to add it back in.
     
  12. John-G

    John-G

    Joined:
    Mar 21, 2013
    Posts:
    1,114
    Have an issue with particles not showing up in build, works perfect in editor and play mode.
    Also tried your example scenes by building and also the particles are not showing in standalone build.
    Building for Windows 10 64bit DX11, any ideas what may be the issue?
     
  13. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    I have some idea what it might be but I will have to double check my code before I'm certain. I should have an answer in 24 hours
     
    Martin_H and John-G like this.
  14. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    Ok so i think the issue with direct X 11 might stem from array declaration but I'm not 100 percent on that. unity has no documentation about how its shader internals work so it makes it hard to debug it. Unfortunately i have a few things I need to do over the weekend so the patch might not be ready until Monday or later sorry.
     
  15. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    what version of unity are you using?
    I don't have windows 10 but I built a scene using windows 7 + (86 & 86_64) + direct x 11 and it all seemed to work fine.
    Do you know if this issue is exclusive to windows 10?
     
  16. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    643
    Bought! Hope it adds to the mad profit. It's probably one of the few assets I've bought at full price! Roll on shadows and self-shadows!

    One request before those though:
    Knowing you wrote how to Blend-up our own smoke textures (excellent for later), is it possible to get textures/techniques mentioned in your recent posts, please?
    Specifically, from these which look lovely:

    http://forum.unity3d.com/threads/volumetric-smoke-shader.358315/page-5#post-2626617
    http://forum.unity3d.com/threads/volumetric-smoke-shader.358315/page-5#post-2625963

    (I, like many, am trying to get good looking performance-friendly fire & smoke (on desktop/console))
    Thanks, Rupert.
     
  17. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    Thanks for the purchase and I hope the package is living up to the hype. If you have time please rate and review it as the package still doesn't have enough ratings to get a star rating from unity :(

    The new techniques / blender files will be added in the next update in the next couple of weeks.
    The new technique requires a few more steps than the last and will require a bit more documentation which is why I haven't released it yet.
     
  18. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    643
    I'm having difficulties integrating ANMS with Particle Playground when using PP's code-based emission. I think this is likely due to PP rather than ANMS so I've posted my question on their forum thread. Obviously you might have input so I'll post a link to the question here.
    Thanks for any thoughts!
     
  19. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    643
    Solved! (a couple of PP settings I'd missed -- see there)
     
  20. John-G

    John-G

    Joined:
    Mar 21, 2013
    Posts:
    1,114
    jack-riddell, hippocoder and Arkade like this.
  21. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    643
    Woo! Thanks for highlighting this! I use the fantastic ”MAD Compile time optimiser” asset which does this automatically for you. I'd have been very confused to find particles not showing up!
     
    John-G likes this.
  22. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    That is a really strange bug considering the thing that does all the work is a couple of shader files with no real outside connections.
    I suspect the issue might be caused by breaking up the shader into 2 files.
    I split the files because one of them is over a thousand lines long and was making code writing a nightmare.

    The work on my mobile version of the shader is starting to wrap up, all the core code is finished and I'm just making the editor look good, adding help docs and making a few new smoke effects.
    Once the new version is done and released I will be reprogramming ANMP and hopefully I will fix this issue then.
     
  23. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    643
    Like you say, it does seem very odd. Could it be something to do with Unity's stripping facility (I.e. leaving files out of the build if it doesn't think they're being used). Maybe merely adding to that list that forces shaders into the build might suffice for now?

    (I can't reproduce or test these things atm but might be able to on Sunday.)
     
  24. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    my guess is its not stripping the main file only the file i split off, breaking the shader.
     
  25. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    An example of the particle sorting i was talking about
     
    John-G and Martin_H like this.
  26. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,342
    Something I forgot to ask earlier: does the shader have the ability to boost the emissive light effect into HDR brightness levels? That's an issue with the default unity additive particle shader. Some bloom post effects won't look as intended if you can't get certain particles bright enough.
     
  27. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    643
    FYI, here's my use of your shader so far. Although it doesn't look anywhere near as good as your effect (*1) and I'm not satisfied with it by a long shot but it does have a few interesting quirks:
    • It integrates with Particle Playground so all fires in my scene are a single Particle System (Shuriken and PP).
    • It does actual flame images (which I really want) as well as your beautiful clouds. I used a flat normal and full emission to achieve and put flame and cloud animation frames in the same sprite sheet. There's still much to do (including overlapping them) but it's a sufficient start as POC.
    I'd really like to get the flames using an additive effect but couldn't see any way to achieve. I don't suppose it's something you know how to do?

    *1: but maybe it will after your next update? ;-)

    (but maybe it will after your next update?)

     
    John-G likes this.
  28. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    My current mobile version has an emissive booster that will push the values up into HDR ranges but i think you would need an additional HDR clamp value to stop it going to high. I haven't tested HDR much.


    there is no way as far as i know to do both additive and alpha blend shading in a single pass without using direct X 11 voodo. all the effects you see me making are all alpha blended with a bit of camera bloom.

    when it comes to alpha blending vs additive blending I'm finding using a bit of bloom to get a good glowing effect looks kinda the same as using additive particles.

    My next release for mobile is almost ready for release (just needs documentation and a few more smoke effects) and has most of the features you need but will be limited to openGL. I'm not sure how far away the next update for the main package is.
     
    Arkade likes this.
  29. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    643
    Will the non-shader posts (smoke textures, etc) work with non-OpenGL?

    I assume updating wing break anything we currently have?
     
  30. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    The open gl shaders need a new texture format (rg is normal, b is an emissive map and alpha is alpha),
    when I upgrade the non mobile version I will try to include a legacy version that will work with the old shader formats
     
  31. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    Finished all the code for the next release just working on the art for the smoke effects.
    getting a good combination of smoke and fire is driving me insane, the blender smoke sim I am using is highly unstable and will often crash or cause the smoke effect to explode.

    anyway here is the progress so far.

    I am trying to get more detail into the initial flames as well as add more expressive sparks / burning debris
     
    zyzyx, Martin_H and Arkade like this.
  32. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    Below is a sequence of gifs I made of my smoke sim work in blender.
    the difference between each gif is ether me changing the rate the smoke burns by 0.5 or in some cases me just re running the same simulation again.

    increased fire burn rate by a tiny bit and everything broke


    re ran the simulation


    re re ran the simulation. fire is burning a little too fast


    turned down the fire burn rate and re ran the simulation a couple more times until it stopped breaking.


    each simulation run takes about 10 minutes to run on my computer and every time I change a setting I have to run 2 - 4 simulations until everything stops breaking.

    I'm hoping to release the mobile version of ANMP with a bunch of particle effects. once that's done I'll be porting them all to the base version of ANMP.

    Don't forget to review and rate ANMP here https://www.assetstore.unity3d.com/en/#!/content/60561
    I still haven't gotten enough rating to get a star rating yet which is not helping the package.
     
  33. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,342
    I know they are a real pain to deal with, but so far I hadn't encountered that particular problem. What are those keyframes that you have on the smoke domain object? Are all the seed values fixed?
     
  34. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    the key frames a just turning down the fire burn rate.
    As for the seed values I an not sure.
     
  35. John-G

    John-G

    Joined:
    Mar 21, 2013
    Posts:
    1,114
    Added a review, also noticed you don't have a link to the asset on initial post.
    Would be worth editing the first post with latest images, video and links to help with sales.
     
    jack-riddell likes this.
  36. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    Thanks for the review. I don't know about you guys but when I look at an asset if it has no star rating, reviews or a low star rating I am a lot less likely to buy. Good Idea about updating the first post
     
    Martin_H and John-G like this.
  37. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    Still not 100 percent on the flame and i think I went overboard with the sparks
     
    John-G and Martin_H like this.
  38. John-G

    John-G

    Joined:
    Mar 21, 2013
    Posts:
    1,114
    Nice, really like it including the sparks.
     
  39. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    643
    I agree with so Jack said but it's still good direction :)
     
  40. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    Final tweaks. still not 100% happy with it especially with the sparks. I think I need to release more sparks early and have most of them die off shortly after the flames finish.

    At some point in the future I will bake out a 4K version of the texture for release and I will make the final tweaks then.


    For now I'm moving on to explosions.

    If you have any Ideas for effects you would like too see post them below.
     
    John-G likes this.
  41. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,342
    I'm sure people would appreciate a collection of ready made prefabs that they can just drag and drop. Like single sprite explosions of different sizes, multi particle system explosions with flying debris that leaves a smoke trail, rocket trails, torches, campfires, mushroom clouds, etc..
    I'd be careful with the explosions rendered onto a single sprite, imho those will easily look too repetitive when copy pasted. I'd try to have at least 3 to 5 randomly rotated sprites overlayed in the particle system to get some variation on every instance.
     
  42. John-G

    John-G

    Joined:
    Mar 21, 2013
    Posts:
    1,114
    Gun smoke coming out of a gun barel would be nice.
     
    jack-riddell and Martin_H like this.
  43. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    643
    Still on the fire front, what about different scale fires? Torch vs. campfire vs. bonfire vs. oil rig vs. napalm, etc. They have rather different fire and smoke requirements.
     
    Martin_H likes this.
  44. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,342
    jack-riddell likes this.
  45. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    I worked with the guy who made that, its a top notch asset.
    my stuff doesn't quite work well with long thin trails unfortunately.
     
    Martin_H likes this.
  46. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    First explosion test looks ok but i think martin is right it does lack the dynamic effect of a multi particle system.
    now I need to work out how to add more complexity to it, I'm thinking i might spawn sparks and some lingering smoke.
     
    Haagndaaz and Martin_H like this.
  47. John-G

    John-G

    Joined:
    Mar 21, 2013
    Posts:
    1,114
    It was more this I had in mind



    So after the explosive smoke you have a lighter pre emission smoke pume too.
     
    Last edited: Jun 1, 2016
    jack-riddell likes this.
  48. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    I don't think i can do the light post shot smoke but the rest is possible
     
    John-G likes this.
  49. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    an early prototype, The way i did the normal mapping is not meant to work with non square particles but some how it is so that makes my work a lot easier.
     
    wetcircuit, John-G and Martin_H like this.
  50. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    Explosion Progress, still working on the sprite sheets but i think it shows promise
    ExplosionProgress.png
     
unityunity