Search Unity

  1. The 2022.1 beta is now available for testing. To find out what's new, have a look at our 2022.1 beta blog post.
    Dismiss Notice

Volumetric Smoke Shader

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

  1. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,342
    Looks very promising! Will the normal shader (without shadows) work without any other scripts? That in itself could be very usefull already.
     
  2. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    just works like any other shader,it is limited to square particles that are bill boarded to the camera though. in the future i plan on adding support for fixed rectangular particles but i cant do any particles that don't directly face the camera or change there height/width ratio (stretch)
     
    Martin_H likes this.
  3. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    Just tested out the shader with some non smoke related effects, looking good. i might try to change the shader to work with a mix of solid objects and smoke in the one image.
    ShellTest.gif ShellTest2.gif
     
    Martin_H and John-G like this.
  4. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    particles have a much lower physics and rendering cost which makes things like this a lot more doable. while in your average shooter you wouldn't expect a single unit to spit out that many casings but a squad of 10 soldiers or a boss with a mini gun could easily need that many casings
    ShellTest4.gif
     
    hippocoder, Martin_H, eskovas and 2 others like this.
  5. John-G

    John-G

    Joined:
    Mar 21, 2013
    Posts:
    1,114
  6. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    Multiple per pixel normal mapped lights are in.
    the particle shader has 1 light, 2 lights and 4 light options. the shader also has support for per pixel or per vertex spotlights
    ShellTest7.gif
     
    FPires, eskovas, elbows and 3 others like this.
  7. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,342
    That's looking really good and I could see this being a big improvement for pre-rendered and animated debris particles! Keep up the great work!
     
  8. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    Thanks to Martin_H I finally have some decent normal maps to play around with and they are looking good. I don't have a lot of experience in smoke sims so his help saved me a lot of blood sweat and tears
    ShellTest8.gif
     
    eskovas, Seneral, hopeful and 2 others like this.
  9. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    More amazing smoke from Martin_H.
    Martin_H_SmokeTest2.gif
     
    John-G, Seneral and Martin_H like this.
  10. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    Im still playing around with the lighting settings, i don't think i have all the correct options in the shader for lighting so thats on the top of my todo list.
     
    Martin_H likes this.
  11. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,342
    Wow, that's a night and day difference to what it looked like with the default particle shader that I tested it with!
     
    jack-riddell likes this.
  12. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    i should have run the old and the new one at the same time to show the difference
     
    Martin_H likes this.
  13. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    Tweaked the way the shader handles the lighting to fake translucency,looks a lot less sharp now Martin_H_SmokeTest3.gif
     
    ZJP and Seneral like this.
  14. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    Added soft particle support, soft particles come in 2 flavors true soft particles (first gif) and height clipped soft particles (second gif). height clipped soft particles only fade out as they go below a fixed height while true soft particles fade out the closer they get to geometry. When rendering true soft particles a depth map is needed which can be quite costly on mobile platforms, height clipped soft particles don't need a depth map giving them better performance especially on mobile where depth maps require the entire scene to be re-rendered with a special shader.

    (True Soft Particles)
    SoftParticle1.gif

    (Height Clipped)
    SoftParticle2.gif

    (Hard Particles)
    SoftParticle3.gif
     
  15. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,342
    If there was a way to blend between this and the old way it would make the shader quite flexible to handle different real world sizes of smoke.
    Like this:
    http://www.telegraph.co.uk/news/pic...volcano-Mount-Sinabung-erupts-in-Sumatra.html
    compared to this:
    https://upload.wikimedia.org/wikipedia/commons/f/f3/Ognisko_ubt_0126.jpeg

    Also please take a look at how the color shifts across the shape of a single round "smoke puff". I was thinking that maybe a 1 x 256px color gradient texture could be used to create that shift in color based on the normal mapped lighting. Does that make sense? Would this be hard/costly to implement? I don't want to feature creep you too much ^^.
     
  16. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    I'm trying to avoid adding too many texture calls in the fragment shader especially dependent texture calls (texture calls that rely on a previous texture call) and generally keep it as simple as possible to avoid getting fill rate limited, that said your idea isn't to crazy and when i get around to optimizing it ill see how costly your idea is.

    at the moment you have 2 key controls, first is light wrap around (how far the light wraps around to the dark side of the normals) second is shadow effect multiplier (how much light is blocked by the normals). both these variables are on sliders and both can be disabled for performance so there is nothing stopping you making smoke like the 2 examples you provided.

    Light wrap around
    LightOptionsDemonstration1.gif

    shadow effect multiplier
    LightOptionsDemonstration2.gif
     
    Martin_H likes this.
  17. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    one texture cord away from squeezing this entire thing into shader mode 2.0, if successful this should run on everything
     
    Seneral, Martin_H and John-G like this.
  18. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    ok so i have worked out what needs to be done but my code is a mess of #defines so i need to go through it all and sort out what is actually happening and streamline it all so # macros don't make up half my code. once that is done then its finished and all that's left is cleaning up, documenting and sorting out things like logos and names. if you have any ideas on the logo and name front it would be much appreciated.
     
  19. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,342
    Awesome! Looking forward to it!

    How about "Volumetric Smoke Shader and Shadow Casting Particles"? That'd be something with a high likelyhood of me actually finding it on the assetstore, if I were to look for something like this.
     
  20. IronDuke

    IronDuke

    Joined:
    May 13, 2014
    Posts:
    132
    Just use this from page 2 of this thread:
    Smoke Renderer Icon Test 8.png
    In my mind at least, it shows off everything perfectly. Shadows, volumetric, the works. It's also eye-catching while remaining simple.
    As for a name, "Volumetric Particle Shader" seems right. Anyone looking for either smoke or shadows will be attracted by the word "volumetric," as that usually has good smoke and shadows.

    --IronDuke
     
    Seith and John-G like this.
  21. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    the issue is im splitting the asset into 2 parts, I'm releasing the normal mapped particles without volumetrics separately first then combining it with the much larger volumetric package and releasing that later later, so i need a new name and logo for the normal mapped particles that hopefully fits with my name and logo (smoke sandwich) for the final volumetrics package.
     
    IronDuke likes this.
  22. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    very early mock up of an idea for the icon

    NormalMappedIconV1.png
     
  23. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    685
    looking forward to the release of this(been watching this thread for a while now!). anyway the three boxes is cool, the shape looks n shaped(for normal) and you could easily flip it to make a v shape for the subsequent volumetric release.
     
  24. CaptainKirby

    CaptainKirby

    Joined:
    Dec 12, 2011
    Posts:
    35
    This looks very promising, and seems to fill a big gap in the unity particle system compared to unreal!
     
    Martin_H likes this.
  25. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    28,364
    Jack's Particle Stuff
    It's great!
     
    Martin_H likes this.
  26. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    1. I'm setting up a hackintosh to test the shader on an iphone because there are some functions i am using that are not supported in stock opengl_es 2.0 but iPhones have an extension on opengl_es that adds the functionality. I'm not sure how all this works with unity's shader targets and CG cross compilation and there is scant documentation on the web so I'm going to have to do some testing. bad news is the shader is not going to fit into shader model 2.0 but with some luck it will work on iphone which is all that really counts.
     
  27. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    the more research i do the less likely it looks that i will be able to get this onto iphone devices older than the iphone 5. its not that the hardware does not support what i want to do, its that unity doesn't fully support the hardware.
     
  28. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    added in some updated textures, still fiddling around with a shader model 2.0 version, hoping to get at least a vertex mapped version available on lower end devices
    NormalMappedSmoke1.gif
     
    John-G and Seneral like this.
  29. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,405
    Looks great, how do you generate your animated smoke textures?
     
  30. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    Martin_H made them for me to test with. I think they are done using blender
     
  31. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    Updated Version of the logo, still not 100 % on the bullet shell colour and style
    LogoMK3.png
     
    Haagndaaz likes this.
  32. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    Looking for another round of volunteers to test out my package, if your interested I will message you a link to a package with the latest version
     
  33. popMark

    popMark

    Joined:
    Apr 14, 2013
    Posts:
    111
    I think on your logo you could add a similar gradient from the cloud to the bullet, since that bullet refers to normal maps it's looking pretty flat
     
  34. Haagndaaz

    Haagndaaz

    Joined:
    Feb 20, 2013
    Posts:
    232
    Hey I would be interested in testing this out for you, it would add a huge amount of dimensionality to our current project :)
     
  35. gurayg

    gurayg

    Joined:
    Nov 28, 2013
    Posts:
    247
    Count me in as well!
    I can take a look on both Win and Mac platforms if you like
     
  36. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    685
    I'd also love to give this a go, if you're still looking for testers.
     
  37. moure

    moure

    Joined:
    Aug 18, 2013
    Posts:
    184
    Extending on this idea i would go with something like this:

     
    hippocoder likes this.
  38. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    395
    Hi, can you control shadow strenght based on particle's transparency? And how about performance compared to Unity's built in particle shader?
     
  39. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    Shadow strength is adjustable but is not connected to particle alpha although that is something i want to look into in the future.
    Performance is obviously going to be worse than unitys built in shaders because my shader has a lot more features but many of those features can be turned on or off depending on what performance you need. with everything turned up to max my shader will be around 10 times more expensive than unitys built in shaders, with the settings set to medium/low it should only be 3 times more costly.
    My shader adds a lot of detail to particles effects that in the past you had to fake by using more particles so while it costs more per particle some of that cost is regained by reducing the number of particles drawn.

    this is the normal mapped shader with only 20 particles
    NormalMappedSmoke3.gif

    this is a render from my volumetric lighting package using around 2000 particles from memory
    Smoke Renderer Icon Test 9.png
     
    macdude2, John-G, hippocoder and 2 others like this.
  40. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,034
  41. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    I am working on the release artwork at the moment and hope to get it on the store by the end of next week if all goes well.
    I don't have a price set in stone but i am planing to release it around the 20 - 30$ mark as it is a bit more complex than the asset you linked to. what are you going to use it for if you don't mind me asking?
     
  42. smnerat

    smnerat

    Joined:
    Sep 23, 2012
    Posts:
    35
    It looks like you've been developing this for use with Unity's particle system, and I thought I saw somewhere that it was mentioned it could be used with third party particle systems? How about GPU particle systems?

    I've been using TC Particles for quite a while, but unfortunately the asset is all but abandoned and the shaders are okay, but leave a lot of room for improvement. How difficult would it be to implement your shaders instead? Honestly, my shader knowledge is pretty sub par for having been working with Unity for so long and I really have no way to gauge the difficulty of doing something like that.
     
  43. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    i haven't played around with TC Particles so i cant say for sure but its not impossible to do its just a matter of time and money like everything else
     
  44. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    just to expand on that, particle system modifiers like particle playground should work provided they give my shader billboarded particles in the same quad format as shuriken, Third party gpu particles do a lot of the particle simulation in the shader and do not use the same format as shuriken so i would have to merge the gpu particle shader with my shader to get it to work.
     
  45. John-G

    John-G

    Joined:
    Mar 21, 2013
    Posts:
    1,114
    Would love to test.
     
  46. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    sorry full up for this round of testing but there will be another one in the future you can be a part of
     
  47. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    so i did some very basic performance testing and it looks like my shader with a single normal mapped light and 3 per vertex lights is slightly faster than unity's vertex lit shader for particles for a single light, and when 4 lights are enabled its faster than everything else i could find on the store by 20% +. my shader has a fixed overhead for each light so if you set it to 4 lights but are only using one your still computing lighting for all 4 lights which means in some cases other shaders will be slightly faster but if the number of lights in the scene is equal to or greater than the number of lights the shader is set to nothing can beat it :).
     
    hopeful and Seneral like this.
  48. smnerat

    smnerat

    Joined:
    Sep 23, 2012
    Posts:
    35

    Well, I guess it's a toss up then. Everything is pretty separate in TC, the particle system itself is run in a compute shader while (what I consider) the traditional shading and coloring is done with a simple shader and vertex functions in a CGInc file. There is a built in method of hooking into to the shader and vertex functions, my biggest problem is just what you mentioned, getting the different data structures between the particle system and the shaders to work together.

    I suppose I'll have to try it out once you release, but it doesn't sound like it should be any more difficult than implementing other shader packs, which I have at least made some headway on. Looking forward to the release!
     
  49. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    Working on a demonstration scene
    SmokeDemoScene.png
     
  50. jack-riddell

    jack-riddell

    Joined:
    Feb 11, 2014
    Posts:
    326
    new version with added snow and falling rocks
    PlaneV3.gif
     
    IronDuke, Seneral, ZJP and 1 other person like this.
unityunity