User avatar
By oz42
#342079
I've been meaning to do this for a while and finally found the time. Unfortunately, now I have the time, it seems I don't have the intelligence :lol:

I'd like to have spline rectangles displayed in the OpenGL viewport of the camera that show where the near and far focus points are.

I've used the equations from here http://www.dofmaster.com/equations.html (using a circle of confusion value of 0.019 for my Canon EOS 300D)

I've come across three stumbling blocks;

1. writing equations in Softimage's Equation editor is a nightmare if you can't create variables (which you can't - I did try rewriting the equations as a Scripted Operator but got even more lost!)

2. some of the Maxwell parameters are not accessible to the equation editor. I'm not sure if this a permanent issue but I was trying to use 'MaxwellCameraAttrs.FStop' in the equation editor but I kept getting errors and so had to type the value (5.6) in explicitly

3. I'm not very good at Math :oops: The equations seem to work (to a certain extent) but there is definitely something wrong.

H - I have created a green square as the Hyperfocal distance (H) (using the equation from above) and this seems to react well to camera (and interest) movements as well as changes to the focal length and F-Stop. I've had to make the whole equation negative as the camera's z positive value is out of the back of the camera, not the front! Although I'm not sure if this plane should always be at the same distance as the camera's interest??

Dn - I then created a blue square for the Near Distance (Dn), again using the equations (this is where variables would come in handy!) but this seems to move somewhat inversely to how I'd expect it.

Df - The red square is the Far Distance (Df) but this is actually behind the camera! (despite the making the whole equation negative)

And then the whole thing seem to melt down when moving the interest too close to the camera (under the Hyperfocal distance) with the red and blue squares inverting wildly!

Here's a Softimage 2012 scene with what I have so far;
http://www.richardosborn.com/maxwell/be ... 010511.zip

If anyone has the time (or inclination) to check through my math, I'd greatly appreciate it :D
Last edited by oz42 on Mon May 16, 2011 8:23 pm, edited 1 time in total.
User avatar
By Mihai
#342230
Just wondering if you couldn't do this in ICE....? I tried making the hyperfocal distance with an ICE tree attached to a plane. Btw, the focal length of the camera, is the "Camera.camera.projplanedist" property :P (just found out....)

But you want to attach the near/far formulas to planes, or curves....what happens when far distance is infinite?
User avatar
By oz42
#342232
Mihai,

thanks for the response. I did think of ICE but I'm a bit of a noob at this - I might give it a go...

Do you know whether Maxwell specific parameters like 'MaxwellCameraAttrs.FStop' are usable in expressions / ICE?

hmm, hadn't thought about the equation reaching infinity - I may have to rethink things!
User avatar
By oz42
#342739
I am a genius :D (not really but after wrestling with this problem again today, it feels like it!)

I finally managed to solve the DOF planes. It was a combination of the equations being too complex to even read using Softimage's standard Equation Editor, e.g. try getting your way through this and figuring what's gone wrong!
Code: Select all
Df = - ( ( ( ctr_dist ( Camera.kine.global.pos, Camera_Interest.kine.global.pos ) ) * ( ( ( ( ( Camera.camera.projplanedist * Camera.camera.projplanedist ) / ( ( Camera.MaxwellCameraAttrs.FStop ) * 0.019 ) ) + ( Camera.camera.projplanedist ) ) / 1000 ) - ( Camera.camera.projplanedist) ) ) / ( ( ( ( ( Camera.camera.projplanedist * Camera.camera.projplanedist ) / ( ( Camera.MaxwellCameraAttrs.FStop ) * 0.019 ) ) + ( Camera.camera.projplanedist ) ) / 1000 ) - ( ctr_dist ( Camera.kine.global.pos, Camera_Interest.kine.global.pos ) ) ) )
together with the fact that I was not using consistent units (e.g. m for camera-to-interest distance and mm for focal length etc.)

The answer was Custom Parameters attached to the camera, which effectively allowed me to set up variables that could be reused in other equations, vastly simplifying things and making bug tracking much easier.

In the attached scene, as you move the camera, the blue plane is the near focal distance, the red is the far focal distance and the green is the Hyperfocal distance (not sure you really need this?). They are all effected by changes in f/Stop and lens focal length as well as proximity of the camera to the interest. (Mihai - I got round the infinity issue by clipping the far plane to a maximum of 1,000,000mm, after which it is set to zero i.e. attached to the camera)

I'm going to run a few render test now to see how accurately these planes indicate the DOF (they should be pretty good as they already concur with some tables I found online)

If you want to play around with it, you may need to adjust the Custom Parameter 'c' which is the camera's circle of confusion (I've set it to 0.019mm, for my Canon EOS 300D) and please note that the lens focal length is for a 35mm camera and so you'll need to make adjustments if you're using another format.

Help youself;
http://www.richardosborn.com/maxwell/be ... Params.zip

I'll not be surprised to find that NL is done by n[…]

Haha, thanks.

Hello, I'm still waiting for a solution to the pro[…]