I think I may be trying the impossible here - I’m trying to get pixel-lit particles that are transparent and soft-edged, but the camera is deferred rendering path.
I have made some headway (slow and painful headway) but the end result is very odd. Look and see:
There are a few issues here:
The lighting seems to be taken from the deferred light prepass, not the forward add.
The edges are not soft.
These particles are high-opacity when viewed using Particles/VertexLit Blended. So the alpha seems to be getting messed up too (although this might just be the way it looks due to the lighting).
I’ve been banging my head against this for ages now and have hit a dead end. Am I wasting my time, or have I misunderstood how to get forward lighting into the shader?
Thanks for the code. I can see it’s a huge undertaking getting lit particles into Unity.
Sadly, the code you have interferes with other shader code of mine. And when I try to fix one part to make them work together, something else breaks. I think I’m about ready to say screw it and just have mediocre particles. It’s not like anyone is going to complain that the particles aren’t amazing.
The key point is that you can’t get the world space particle position in a shader without the camera script to generate _Camera2World.
And all of the other lighting stuff relies on that (attenuation, shadows, light direction, etc) which is why I’ve had to duplicate a lot of code and put in the extra helper macros that use correct values.
Lulucifer; You don’t need a forwardbase pass to use forwardadd.
So I decided I wasn’t happy with mediocre particles after all, and have returned to working on this. I have lit particles working (mostly based off of Farfarer’s code, big thanks for that!). The only remaining issue is getting soft particles to work in it. I am completely stumped here - it should be virtually the same as normal soft particles. I compute the screen position, then the depth, then sample the camera depth to get the fade amount.
Yet it does not work. I tried changing it so that instead of fading it would color the results red, but it had no effect. So it seems the depth computations are either being ignored, or are not working at all. I checked, and soft particles are definitely on, so I can only assume something is wrong with how I’m determining the soft fade factor.
I could never get both lit particles and soft particles to work at the same time. In the end I gave up because it wasn’t vital that I have both, it was just a nice thing to have. So I ended up using hard pixel-lit in some cases, and soft vertex-lit in others.
noticed that on my project with one camera in forward and one camera in deferred when i fire my projectiles i do not see them ( particles) and after the screen freeze, i have to rescale my editor to unfreeze. if i set the second camera to forward and disable HDR, there is no bug.
That aside… what do you think is causing the screen to freeze? there are some issues with the new deferred renderer working properly atm, although that shouldn’t affect particles. Try turning the soft particles factor up if all else fails!