Hi,
I was wondering if there was a way to access / modify the Viewport 2.0 Depth of Field effect. There is very little documentation about it. My first goal would be to make it more physically correct. ( Adjust blur amount to match an off-lline renderer ) Second make it work with transparent objects like in the attached image.
I have some OpenMaya 2 experience, though I assume this would be more a cpp override because of performance issues. Help This is what I found in the documentation. If any one has any tips / guides / articles how to approach this I would be really grateful.
Thanks!
Hi,
Kind of, I wrote a tool in python that picks up dof and jprototyped a physical dof node that recalculates the dof properly. I also found where maya stores the CoC values. I leanred some cpp so i`m rewriting it now since python sucks for viewport stuff Also maya has the near and close focus values totally off. They’re accessible thourh the api though. Regarding the per pixel dof - its a shader feature and maya straight-foward renderer is also quite limited in terms of post so the dof effect is… yeah at least you can make it more responsive and physically accurate.
You can check my last reel: https://vimeo.com/manage/videos/511273466
Hi MineClever,
Thank you for the kind words. I am not sure I am ready to release the source code yet since I did spent some time on this one - sorry.
But I can compile for maya 2019 - 2018 if there is need for it.
Thanks
Hey, this is great. We’ve been trying to work out a good solution to viewport DOF ourselves and the documentation is pretty sparse. Can I clarify the current functionality of your plugin? I’ve downloaded it and tried it out and the depthOfFieldContext works as expected. I can click and set the focus distance for the camera, etc. But the plugin doesn’t appear to produce a visible difference in the viewport DOF compared Maya’s default DOF. Is this the expected functionality, or am I setting something incorrectly?
Hi Will,
So firstly yes, the difference is very subtle.
To work with dof you would need to have a textured scene with good lights to see it. Flat geo will not work well with this dof effect.
I`m recalculating the fStop value based on the simplified dof formula and coc setting.
You can find the math online. Also very important you need to work in cm so an average person will have around 185 maya units.
Then the math is a bit tricky since the dof equation has mm and cm you need to convert the distance to mm and afterwards back to cm when you want to set the values on the camera.
Then its just calculate the closes distance with MFnMesh.closestIntersection - check Chad’s APi videos for that (MPxContext).
Lastly I`m setting the MFnCamera setNearFocus and farFocusDistance which will change the camera fStop values to something like 0.238 which is below the GUI’s allowed values.
This was the easiest and most secure solution for my v.1.0.0 becasue I`m not messing with any internal settings - if you delete the keyframes on the camera everything will go back to stock settings.
Now from what I have researched maya viewport 2.0 is a straight - foward renderer so we will never have access to all the fancy stuff like render buffers so we have to stick to something like this:
This is what is happening and what I believe why the devs limitted the dof effect to what we have.
Yeah, that is really helpful, thanks. We’re really looking for a solution whereby the viewport DOF is reasonably representative of the final render DOF to allow previs/layout to set up cameras with some confidence. The limit on the DOF effect that you mention is, I think, what really gets in our way. We’re probably going to have to dig into Viewport 2 shader overrides. The “limitations” from the NVidia article aren’t really problems for use. We accept that the viewport doesn’t handle transparency well when it comes to DOF, also that extreme settings might cause the whole thing to fall apart.