Title: Better Pseudo-Depth of Field Post by: philovivero on November 18, 2012, 12:04:09 PM I'm using Mandelbulber. I turn on the depth of field post-processing, and it always looks wrong. I finally figured out why.
In actual lens blur, light wins over dark every time. Take a picture of a perfect checkerboard pattern of black/white, blurry, with a camera. The white squares bleed into the black, never the other way around, but Mandelbulber (and I assume other depth of field algorithms) just use gaussian blurring, whereby dark colours are simply smeared with light ones. If before blurring, you apply a convolution matrix of positive numbers, eg: [ 0.1 0.3 0.1 0.3 0.5 0.3 0.1 0.3 0.1 ] Then the entire image will be "light colours propogated" and if you then blur that, you will get something more closely approximating lens blur. It's still very imperfect, but should be more natural-looking than the gaussian-only method. I tested this out by pulling up GIMP and doing a generic convolve on my image before blurring. In that case, it's a 5x5 matrix rather than 3x3 as I've illustrated here, but the principle is the same: you put the highest value in the centre, and as you increase distance from centre of matrix, the values are proportionally smaller (probably on a quadratic basis, but I haven't completed my analysis that far yet). I think to do this 100% properly, you'd need the convolve matrix to be larger the further from the focal plane the voxel is. But again, as a first approximation, just doing it with a static matrix would be an improvement over what's there currently. Does anyone have opinions on this matter? Title: Re: Better Pseudo-Depth of Field Post by: kram1032 on November 18, 2012, 12:55:41 PM while you're right that bright values usually dominate over dark ones, this effect usually actually is called bloom.
DoF rather needs a bokeh-blur (convolve with a circular cutout matrix) instead of a gaußean. (http://upload.wikimedia.org/wikipedia/commons/a/ac/Faux-bokeh-comparison.jpg) http://en.wikipedia.org/wiki/Bokeh (http://upload.wikimedia.org/wikipedia/commons/9/9a/HrdiBloomExample.jpg) http://en.wikipedia.org/wiki/Light_bloom Ideally, for a perfect lens, you want to have an Airy-disk kernel: http://en.wikipedia.org/wiki/Airy_disk Title: Re: Better Pseudo-Depth of Field Post by: richardrosenman on November 22, 2012, 09:08:30 PM 90% of the time, users apply standard gaussian and box blurs to simulate depth of field. This couldn't be more incorrect. As a result, I spent a lot of time studying correct depth of field and them creating a Photoshop plugin that does it correctly.
You should check out the technical info as it's interesting, especially when you break down what a correct bokeh looks like: http://richardrosenman.com/shop/dof-pro/ Specular bloom, as you point it out, is something different though and coincidentally enough, I created a plugin for this too: http://www.lumierefilter.com Cheers, -Rich Title: Re: Better Pseudo-Depth of Field Post by: kram1032 on November 23, 2012, 01:29:37 AM Stuff like this always makes me wonder:
Do you have to apply DoF first, then bloom or the other way round or does it not matter? (that is, if you try to keep it realistic) Title: Re: Better Pseudo-Depth of Field Post by: richardrosenman on November 23, 2012, 05:57:55 AM Hi Kram;
That's a really good and important question. The order absolutely matters. For instance, in my field, we have to deal with motion blur and depth of field regularly. Rendering these in 3D is computationally exhaustive so we often rely on applying them as a post process. However, adding motion blur first and then depth of field yields incorrect results. Likewise, adding depth of field first and then motion blur is also incorrect. The bottom line is they both happen concurrently in the camera yet there's no tools out there that allow you to do both in one shot as a post process. Often enough, we can cheat it and you won't notice but the order is definitely an ongoing headache we deal with every day. With phenomena like blooms, I think it's easier to cheat because a bloom is equivalent to a gel or filter over the lens. As a result, it's ok to add motion blur and/or depth of field first and then add the bloom. Likewise for vignettes. At least, that's my opinion. ;) -Rich Title: Re: Better Pseudo-Depth of Field Post by: kram1032 on November 23, 2012, 05:55:57 PM heh, yeah I thought so...
Though couldn't you "just (:D)" write an algorithm that sort of does all two (or three if you add bloom) blurs at the same time in post-processing? Title: Re: Better Pseudo-Depth of Field Post by: lycium on November 23, 2012, 06:46:56 PM That's a really good and important question. The order absolutely matters. For instance, in my field, we have to deal with motion blur and depth of field regularly. Rendering these in 3D is computationally exhaustive so we often rely on applying them as a post process. However, adding motion blur first and then depth of field yields incorrect results. Likewise, adding depth of field first and then motion blur is also incorrect. The bottom line is they both happen concurrently in the camera yet there's no tools out there that allow you to do both in one shot as a post process. Often enough, we can cheat it and you won't notice but the order is definitely an ongoing headache we deal with every day. That's why, as computers get faster, physically correct renderers are increasingly attractive: human effort isn't getting any cheaper, but FLOPs most certainly are... Also, while you're taking extra samples, it doesn't really cost any more to incorporate depth of field, motion blur, area lights, etc. In other words, it's not like it takes twice as long to do DOF and motion blur, compared to just DOF alone. So that extra sampling effort to do things correctly is quite justifiable, since it covers all effects if you do it right. Title: Re: Better Pseudo-Depth of Field Post by: kram1032 on November 23, 2012, 06:56:21 PM The most exciting part of that, to my mind, is that basically full-quality raytracers become almost real-time usable...
Of course, having navigable scenes isn't strictly new anymore. But I wonder how much longer it takes until the first game engines start to pop up that do full-fledged real-time ray-tracing with basically no noise on by then basically "normal" hardware... Title: Re: Better Pseudo-Depth of Field Post by: richardrosenman on November 23, 2012, 07:08:56 PM Quote Also, while you're taking extra samples, it doesn't really cost any more to incorporate depth of field, motion blur, area lights, etc. In other words, it's not like it takes twice as long to do DOF and motion blur, compared to just DOF alone. So that extra sampling effort to do things correctly is quite justifiable, since it covers all effects if you do it right. Exactly. BUT, and there's always a but. Motion blur, dof, etc, is free in unbiased renderers (Maxwell, Octane, Arion, etc) and unfortunately, those are still not viable options. They still take waaaaaay too long when compared to biased renderers and those that utilize GPU processing, have some serious limitations which prohibit their use for any serious commercial production. For instance, depending on the project, it is not uncommon to have geometric scenes in excess of millions or billions of triangles. This is immediately impossible with GPUs. Likewise, using 4k textures, or many of them is also a limitations due to GPU ram. There's much more. So your standard commercial production renderer like VRay, Mental Ray, etc, do cheat and that makes turning on a features like depth of field, quite a bit more taxing. For this reason, I'd say about 80% of all projects still use post depth of field. VRay and Mental Ray do have GPU extensions (VRay RT GPU, IRay) but like I said, they are limited and more useful for single frame production than animation. It's also interesting to note that film production renderers weren't even raytracers up until recently. Renderman, 3Dlight, from what I know, didn't even do raytracing in order to be able to achieve the speeds required to render at film resolutions quickly and efficiently. I believe films like the Matrix were among the first that used commercial raytracers like Mental Ray to render with global illumination and such. Quote Though couldn't you "just ()" write an algorithm that sort of does all two (or three if you add bloom) blurs at the same time in post-processing? You probably could but it would be extremely complicated. For instance, you need to supply a depth map which is a frame that describes the distance of the scene to the camera: (http://www.dofpro.com/gallery/dofpro_chessRGB.jpg) (http://www.dofpro.com/gallery/dofpro_chessDM.jpg) With this you can effectively apply and modify the depth of field: (http://www.dofpro.com/gallery/dofpro_chessDOF.jpg) You would have to do the same to the motion blur: supply a vector map that would describe the direction and length of the motion vectors. This exists and you can do it with select apps. So imagine having to supply two frames of depth and motion information, both of which also have to be computationally derived, just to process one frame? And then imagine doing it for a sequence? Nahhhhhh.... ;) -Rich Title: Re: Better Pseudo-Depth of Field Post by: richardrosenman on November 23, 2012, 07:23:10 PM I have also created a motion blur plugin (ironically that the three topics that have come up I have created software for). It is called Motion Blur Lab PRO: http://www.mblpro.com
I'm posting it because it's a cool example of extending Photoshop's motion blur capabilities to production-environment requirements. Check out the gallery - some of the examples are pretty neat. (http://mblpro.com/gallery/mblpro_trainRGB.jpg) (http://mblpro.com/gallery/mblpro_trainMBL.jpg) (http://mblpro.com/gallery/mblpro_trainMBL2.jpg) But in order to make this plugin really powerful, you would want to implement the velocity maps I mentioned. This is what a velocity map looks like: (http://revisionfx.com/tutorials/AnimExpressTut/step_1.2.2.gif) Basically through using the RGB values you can describe motion vector x,y, length. -Rich Title: Re: Better Pseudo-Depth of Field Post by: cbuchner1 on November 23, 2012, 11:25:05 PM Richard, I am delighted that you are a member of fractal forums. Reading your postings really ups one's IQ ;) Title: Re: Better Pseudo-Depth of Field Post by: richardrosenman on November 24, 2012, 12:05:28 AM Richard, I am delighted that you are a member of fractal forums. Reading your postings really ups one's IQ ; Awwww - thanks! I just wish I could keep up with the fractal programming in here... Most of it is beyond me! ;) -Rich Title: Re: Better Pseudo-Depth of Field Post by: M Benesi on November 24, 2012, 05:42:26 AM Why'd you blur the sky so much? (joking)
So is a velocity map the same thing as a distance map used to taper motion blur on more distant objects? You could implement a linear map to decrease motion blur with distance- the mountains, farther down the track, the sky.... Title: Re: Better Pseudo-Depth of Field Post by: richardrosenman on November 24, 2012, 06:01:20 AM Quote You could implement a linear map to decrease motion blur with distance That's a pretty neat idea actually... My filter uses motion vectors which you can shorten or lengthen. This allows you to decrease the amount of motion blur in some areas and increase in others which is super-important in examples such as a vehicle turning around a corner and also allows you, as you pointed out, to vary motion blur depending on depth: (http://mblpro.com/gallery/mblpro_lamborghini_mountainMBL.jpg) I suppose the above train example isn't a good one as it's using radial blur but the custom motion blur gives you a ton of control: (http://mblpro.com/gallery/mblpro_flowfield.jpg) -Rich Title: Re: Better Pseudo-Depth of Field Post by: kram1032 on November 24, 2012, 02:55:00 PM Hmm.. The train map example seems to only take into account x-y-plane blurring, judging by the velocity map which apparently lacks a blue-channel which, I'd assume, stores z-velocities.
If that's "good enough", why don't you just store the z-depth information in the blue channel and apply DoF effects accordingly? Or am I incorrect in assuming lack of z-velocities? Title: Re: Better Pseudo-Depth of Field Post by: richardrosenman on November 24, 2012, 07:52:15 PM Hi Kram;
Truthfully, I never understood why the blue channel contained the velocity and not the depth. However, using only 2D values seems to be 'good enough' to mimic 3D motion blur. It seems to be slightly different per application. I use 3dsmax and this post explains that the blue channel isn't even used for velocity - it's discarded, which isn't how it used to work for me. So perhaps it really is variants based on different apps: http://www.timsportfolio.co.uk/tutorials/velocity-pass-3ds-max/ I can say one thing. We've tried all sorts of motion blur tricks and they rank in different spots on the totem pole: 3 - ReelSmart motion blur (frame analyzed and derived motion blur) - rarely works well and excels in slow moving frames only. Also, the higher the resolution, the better the results. 2 - Velocity map / 2D motion blur. Better than above but unfortunately tends to destroy and degrade the image. Often over-exaggerated. 1 - True 3D motion blur. Simply the best. ;) I remember doing this spot in 2005 for Diet Pepsi to be screened during the Academy Awards: http://richardrosenman.com/project/?cid=37 (http://richardrosenman.com/gallery/photo/originals/442b527b0e972.jpg) We had hundreds of bottles and cans stuck in a fridge, rendered with full global illumination, hybrid 2D/3D depth of field and 3D motion blur. Frames were averaging 12 hours each. There are 24 frames a second. And 30 seconds for that spot... -Rich Title: Re: Better Pseudo-Depth of Field Post by: kram1032 on November 24, 2012, 08:24:45 PM Yeah, true 3D motion blur should be the way to go.
Though what difference could it be, for computers of today, to change that into a 4D or 6D problem, using the full x,y,z-depth (or just z-depth) and x,y,z-velocity? Of course I do not have experience in this but it seems to me that this kind of convolution should be much easier than the reverse problem of deconvolution (e.g. DoF- and Motion-deblurring) Title: Re: Better Pseudo-Depth of Field Post by: lycium on November 24, 2012, 08:55:47 PM Exactly. BUT, and there's always a but. Motion blur, dof, etc, is free in unbiased renderers (Maxwell, Octane, Arion, etc) I have some issues with Octane's claims to being unbiased, and wonder why you don't include Indigo Renderer on that list ;)unfortunately, those are still not viable options. They still take waaaaaay too long when compared to biased renderers and those that utilize GPU processing, have some serious limitations which prohibit their use for any serious commercial production. For instance, depending on the project, it is not uncommon to have geometric scenes in excess of millions or billions of triangles. This is immediately impossible with GPUs. Likewise, using 4k textures, or many of them is also a limitations due to GPU ram. There's much more. That's a long list of nuanced claims, addressing them all would take ages :S Of course I'm biased from working on unbiased rendering software, but geometric detail seems fairly well addressed to me with instancing and 3GB or 6GB GPUs. Indigo's hybrid CPU+GPU acceleration only stores the geometry on the GPU, so you can really get a lot on there...In any case, if motion blur and DOF are your only concerns then something like stochastic rasterisation is probably the most efficient algorithm. However, some of us also want "perfect" global illumination and handling of light scattering events, so there's really nothing for it but Monte Carlo methods :) Title: Re: Better Pseudo-Depth of Field Post by: richardrosenman on November 24, 2012, 11:23:47 PM Doh! How could I have forgotten Indigo - it's AWESOME!
-Rich Title: Re: Better Pseudo-Depth of Field Post by: kram1032 on November 25, 2012, 02:08:52 AM Of course I'm biased from working on unbiased rendering software I see what you did there :DTitle: Re: Better Pseudo-Depth of Field Post by: lycium on November 25, 2012, 04:40:00 AM you should post some new indigo work sometime mark O0 haven't seen you on the forum in aaages!
Title: Re: Better Pseudo-Depth of Field Post by: kram1032 on November 25, 2012, 11:18:35 AM Yeah, I know... Haven't done any work with it in aaages either ^^ Or with Blender for the most part... It's a mixture of not knowing what I could do and not having time... - mostly the first part though. |