Particle Shaders Vol. 1 - Including Lit Particles

Hi!

For past few weeks I have been working on particle shaders designed for Shuriken particle system. Now, I am ready to present you Particle Shaders Volume 1 for Unity 5. The package features:

  • shadow casting
  • adjustable self-shadowing
  • HDR light emission
  • alpha blend & alpha erosion fade modes
  • soft particles support
  • support for all Unity 5 ambient modes (skylight, tricolor, flat ambient)
  • multi-light support (maximum lights per-system is defined by pixel light count in Unity quality tab)

Screenshots

Download PC demo

Lit shader performance stats

// Stats for Vertex shader:
//       d3d11 : 50 avg math (30..72)
//    d3d11_9x : 50 avg math (30..72)
//        d3d9 : 50 avg math (27..78)
//        gles : 23 avg math (16..26), 1 avg texture (1..2)
//       gles3 : 23 avg math (16..26), 1 avg texture (1..2)
//       metal : 43 avg math (23..65)
//      opengl : 23 avg math (16..26), 1 avg texture (1..2)
// Stats for Fragment shader:
//       d3d11 : 17 avg math (12..20), 1 avg texture (1..2)
//    d3d11_9x : 17 avg math (12..20), 1 avg texture (1..2)
//        d3d9 : 21 avg math (16..24), 1 avg texture (1..2)
//       metal : 23 avg math (16..26), 1 avg texture (1..2)

Unlit shader performance stats

// Stats for Vertex shader:
//       d3d11 : 9 avg math (5..13)
//    d3d11_9x : 9 avg math (5..13)
//        d3d9 : 9 avg math (6..13)
//        gles : 11 avg math (6..16), 1 avg texture (1..2)
//       gles3 : 11 avg math (6..16), 1 avg texture (1..2)
//       metal : 5 avg math (3..8)
//      opengl : 11 avg math (6..16), 1 avg texture (1..2)
// Stats for Fragment shader:
//       d3d11 : 9 avg math (5..13), 1 avg texture (1..2)
//    d3d11_9x : 9 avg math (5..13), 1 avg texture (1..2)
//        d3d9 : 9 avg math (6..13), 1 avg texture (1..2)
//       metal : 11 avg math (6..16), 1 avg texture (1..2)

Current drawbacks:

  • particles donā€™t receive shadows
  • performance may be a problem for mobiles

Version 1.5.0 is now live!
Asset Store link: http://u3d.as/content/micha-pi-tek/particle-shaders-vol-1/

I hope that youā€™ll find this useful :slight_smile:
Cheers!

12 Likes

Great news!

If I may request an additional feature, it would be to add ā€œClip Safeā€ functionality in the shaders (or make a separate set of shaders with this feature). The effect would be that particles fade to completely transparent, based on distance to camera. It is similar to what happens if you walk through smoke or mist - the density appears less intense right in front of your eyes than at a distance. Can be especially useful in a Virtual Reality experience, where experiencing large particle billboards being clipped right in your face, so to speak, is not desirable.

4 Likes

I like the idea. I will definitely put this on my roadmap (maybe I should create public Trello board with features planned for this shader pack with voting options?).

2 Likes

Hey mate!

Saw your shaders pack and itā€™s exactly what Iā€™m looking for, great job there. Will get them when they arrive at the Asset Store.

2090605--136737--2015-04-29_16h24_07.png [quote=ā€œvarfare, post:1, topic: 577304, username:varfareā€]

  • particles donā€™t receive shadows
    [/quote]
    This is an ongoing issue with particles in general. For example debris from an explosion in shadowed areas would be full bright - entirely stupid. Light probes canā€™t detect realtime shadows either. Smoke in shadows will be full bright and so on. Any ideas how to fix it? I understand shadows are screen space now so perhaps sampling depth might be an option.

Of course cutout works but then weā€™re left with nasty edges.

Finally: mild bug: black bits if light is shining through.

Catching other objectsā€™ shadows is not the best idea. It is possible but the visual result wonā€™t be acceptable for professional use. The reason why transparent objects donā€™t receive shadows is that they are not taken into account in shadowing pipeline at all. And the reason behind this is really simple - performance. Proper transparent shadows are quite costly. There are a lot of approaches around the web so you can dig into this. But be warned - it is time consuming to get this thing working.

As for the bug - thanks for noticing. Iā€™ll have that fixed in upcoming update.

And finally - I am pleased to say that Particle Shaders volume 1 is live and ready to buy for 10$!
http://u3d.as/content/micha-pi-tek/particle-shaders-vol-1

Varfare, have you tested this in Unity 4? Does it work at all?

Thanks in advace!

Current package works only with Unity 5.0+. I am creating separate package for Unity 4 but it needs some more work. Stay tuned.

1.0.1 update has arrived and should be available within few days. Changelist:

  • Fixed black spots which were showing when looking at light source
  • Added EMLighting.cginc file which contains all lighting models. Now all shared functions and parameters will be handled inside this file

I have also created a public roadmap with voting options so that I can focus more on features you wish to be implemented. You can also check what Iā€™m currently working on (green indicates ā€œwork in progressā€, yellow is ā€œnext upā€ and red is ā€œsuspendedā€).

@ctp Next update should contain distance fade for Virtual Reality users.

1 Like

The webdemo seems to be down. I want to give this baby a look. :slight_smile:

I have just updated Web-player link. Please, try again. Also, if you are using Chrome, read this: http://twiik.net/articles/google-chrome-just-killed-the-unity-web-player

It works now. Looks great! Iā€™m going to buy it!!
Also:

It is in my best interest to ask you if shadow support would be possible? I know this wouldnā€™t be easy, but to have sunrays through the particles would look Fantastic!

(Also point and spotlight support would be nice)

Might I suggest adding a blur filter to the edges of the pre-rendered cutout shader? That would get rid of the nasty edges, yet still support shadows. It obviously wouldnā€™t look good with high detail textures, but at least it would give the option for use of shadows. Just an idea. All around, LOVE THE PRODUCT!

1 Like

Thank you! I really appreciate your kind words.

About shadow receiving. I have many ideas about the future of the package. Unity have already announced receiving shadows on transparent objects that should be available somewhere during Unity 5.x cycle. But I think that I should develop my own solution anyways. Reasons for this:
-particles are not regular ā€œtransparentā€ objects. They need special approach in order to be performant
-having own solution usually gives more possibilities
-there is no official release date for official transparent shadow receiving support

I have created public roadmap where Iā€™m putting all suggestions, bugs, features, you can even check what Iā€™m currently working on and vote for most wanted feature. Trello
There, you can see ā€œBetter shadowingā€ card where I have placed few links with known, working implementations that I am considering to use with the package, like:
http://www.roxlu.com/downloads/scholar/008.rendering.practical_particle_lighting.pdf
http://docs.nvidia.com/cuda/samples/5_Simulations/smokeParticles/doc/smokeParticles.pdf

But these ideas could take few month for me to implement. Transparent objects with shadow receivers were always a tricky part of realtime programming. But yea, I am definitely heading towards this direction.

As for now, I am going to do something about these cutout shadows. One way is to implement Unity 5 transparent shadows but they are really ugly when you donā€™t use soft shadows in your light.


They look quite nice when you have soft shadows turned on but I cannot take for granted that everyone is using it. Soft cutout shadows is an option. I have to dig in into how exactly Unity is casting shadows and then Iā€™ll start thinking about solving the problem in the best possible way.

1 Like

Iā€™m really happy that you, as a developer, are taking your customers suggestions for the future product! I havnā€™t seen too many others do that. Honestly, I like the product as it is. Iā€™ve tried to achieve lit particles on my own but failed, you sir, are brilliant! And I hope your product goes a long way!

1 Like

Iā€™m really not up on what can / canā€™t be done with particles, but letā€™s say you have rain occurring at night in a city with lots of lights (neon signs, car headlights, street lights). Can current falling rain particles be lit by a street light? My impression is they canā€™t, and no store plugin can help. With this plugin weā€™d have to wait until point and spot lights are enabled before it will work.

Is this correct?

You are right. My package currently support one, strongest directional light. I am going to work on point&spot light support next month.

1 Like

That will probably look really awesome once supported. Canā€™t wait! :smile:

I seem to have encountered a potential issue with my particular use-case for these particles.

Iā€™m trying to set up particles (particularly a pale grey fog in this instance) that work seamlessly throughout a day-night cycle, but Iā€™m finding that the ambient lighting does not update with the skybox, so the particles are still very bright at night (or dark during the day depending on the initial position of the sun). Initially the ambient lighting wasnā€™t updating for any object in the scene, but I solved that with one massive reflection probe that only renders the skybox. However it seems that the particles donā€™t react to the reflection probe, even when I can see that it is being detected under the ā€˜Rendererā€™ section of the particle system settings.

I may be wrong, but I assume this is something that would need to be taken into account in the shader itself. Is this something you would be able to support? Is this approach to ambient lighting for particles even remotely sensible?

Iā€™m aware I could just update the particle colours or ambient intensity manually, but it would be a lot more convenient and likely yield better results to have the more automated solution that draws directly from the procedural skybox.

Nice work with these assets by the way! They produce a far nicer look than the built in shaders. :slight_smile:

Hello Evil_Moo! I am happy that you like the shader pack, even though you have found some flaws.

I have to admit that I have not tested shaders with dynamic sky, my fault. Is it possible for you to send me a sample scene with dynamic sky that you are using? Or do you have any guidelines for recreating similar system? It would really help me determining whether it is possible for me to fix this problem in a reasonable way.

My set-up is fairly simple for the dynamic sky. Iā€™m just using the built in procedural skybox shader with the environment lighting options in the Lighting window set to use skybox for both ambient and reflection sources, and a directional light for the sun. This will automatically update the ambient light to match the sky as you move the sun outside of runtime, but while the game is running objects seem to require a reflection probe to update ambient lighting and reflections.

My reflection probe is set up as follows:

Which is basically just making it update in realtime, while only rendering the skybox and making the size big enough to cover everything in the scene that needs the ambient lighting to update.

Then just add a few objects (probably with the standard shader) to make sure the reflection probe is working at all and the particles to test (in my case Iā€™m mostly using the ā€˜Lit Alpha Blend Softā€™ shader). That should be everything you need to test this, as far as I can tell.

Again, Iā€™ve no idea if this is a feasible approach in general, but it looks like the simplest way to get dynamic ambient lighting from the procedural skybox at runtime.

Thanks for taking the time to look at this.