Jump to content

  • Log In with Google      Sign In   
  • Create Account


Particles with DOF


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 MajorTom   Members   -  Reputation: 715

Like
0Likes
Like

Posted 15 June 2012 - 02:37 PM

Good evening,

I'm just wondering how everyone else tackles the issue of integrating depth of field with particle systems. The usual method of using the depth buffer as input to the DOF effect won't work with transparency since only the nearest depth layer is stored (obviously) - resulting in distant transparent geometry being incorrect when behind closer transparent geometry.

It doesn't need to be perfect, it just needs to look "ok".

Unfortunately, in this scenario all of the particles are packed throughout the scene - and the focal range for the DOF is fairly small - so the transition between in-focus, and out-of-focus, must be smooth. (So I can't say: "These are out-of-focus, and these are in-focus")

Any suggestions? My google-fu isn't great today.

Cheers,
Tom

Saving the world, one semi-colon at a time.


Sponsor:

#2 ginkgo   Members   -  Reputation: 294

Like
4Likes
Like

Posted 15 June 2012 - 08:07 PM

If you have a way to sort the particles from back to front you can use the particle depth to scale and blur them according to their circle of confusion and mix them all together with alpha blending. You could do the scaling of the bilboards in the geometry shader.

The DoF particles wouldn't really interact with the DoF of the rest of the scene but this shouldn't be too apparent depending on how the particles are used.

#3 Promit   Moderators   -  Reputation: 6750

Like
1Likes
Like

Posted 16 June 2012 - 12:51 AM

Hmm. This is not something I've thought through clearly, but what if you scale the particles by their distance from the focal plane, and also bias the mip sample based on the distance? I'm thinking that if you deliberately sample a mipmap that is too small onto an expanded particle, you can create stretching that might make a reasonable fill-in for a blur.

#4 JimC1664   Members   -  Reputation: 179

Like
1Likes
Like

Posted 16 June 2012 - 01:44 AM

Possibly if, while rendering your particles, you take a secound copy of the depth buffer and output the particles depth but alpha blended. This may affect your DoF blur in just the right way. - Or it will look somewhat stupid, have not actually tested it.
Seems kind of excessive if you don't have much particles aswell.

#5 CukyDoh   Members   -  Reputation: 220

Like
4Likes
Like

Posted 16 June 2012 - 04:24 AM

I'll agree with everyone else and say the more interesting approaches would be:
  • Inferred-lighting style dithered depth
    • Only draw transparency to some pixels and then resolve after DoF.
    • Should "just work" and give particle lighting (See Volition's rain for an example), but likely low quality.
  • Draw particles after DoF and apply manually
    • I've played with this myself but never had the best results. This solves two issues though, one the DoF destroying your particles, and 2 your particles not getting the correct DoF.
    • Draw the particles and scale and blur them (or cheat with mips and pre-blurred textures) after your DoF pass.
    • You can have some fun putting e.g. a hexagon in the lower mips of a flame ember particle; Gives interesting results!
  • DoF pass per render batch
    • Another I've played with and had interesting (but expensive) results. This works well for larger and rare objects, e.g. a glass window.
    • When drawing the window, apply DoF on the background based on the window to previous depth distance. Allow the window to depth write and then apply post DoF as usual.
    • This will give a fairly correct layered DoF when the far original layer written will accumulate layers of DoF.
    • Using a layered depth buffer approach is likely much cheaper, correct and flexlible though! ;-)
For the most part this is still just an "unsolved" issue though in most major engines, e.g. CryEngine and Unity both exhibit the artifact. Even the latest Unreal 4 screenshots show this problem, which means they've haven't found a robust real-time solution yet.

Note how most of the below particles are actually in the foreground:

Posted Image

Posted Image

Edited by CukyDoh, 16 June 2012 - 04:36 AM.


#6 MajorTom   Members   -  Reputation: 715

Like
0Likes
Like

Posted 17 June 2012 - 03:10 PM

Thanks guys

ginkgo: Sorting is possible, but a pain since the particles are generated on the GPU. Though I like the idea Promit and yourself mentioned about scaling the quads and varying the mip-sample. This might work nicely, and if it merges well with the scene DOF, I'll go with that - since it's relatively cheap.

JimC1664: I'm not sure that will look right, something about it doesn't feel right - I could additively blend the depth, then use that to find centre of the particles for that pixel, but that feels wrong.

CukyDoh: Looking at those images, it looks like they just completely ignored the particles depth, and applied the DOF using the scene depth after drawing the particles.
I've seen inferred lighting, and if I were using it, then yes DOF using each layer's depth would be nice.
DOF pass per render batch doesn't seem feasible in this case; the individual particle systems can merge together, so this might introduce "popping" artefacts. Also, there are many systems visible at once - meaning many DOF passes, which is extremely expensive in this case.

I'll go ahead with applying the DoF manually, scaling the particles, and varying the mip level and see how it looks.

Cheers guys.

Saving the world, one semi-colon at a time.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS