PDA

View Full Version : mdme_sadie's True DOF - COFFEE version


Pate
05-28-2003, 05:03 AM
Hi!

I have a need for a Depth Of Field effect in my animation project, and since I have reflective and transparent objects in the scene I need to use a better DOF than the inbuilt C4D one. Luckily, mdme_sadie has created an XPresso setup that seemed to be just what I needed. However, after some testing I noticed that this setup is not perfectly suited for animation, so I decided to see if I can use mdme_sadie's ideas and create a similar system but geared towards animation. Here is the result, in case anyone else has a need for this.

First of, many thanks to mdme_sadie for the original innovation!

The problems I noticed in his setup are:
- If the camera moves around the scene, the rotation of the pivot object does not follow the movement properly.
- The setup requires 100% Scene Motion Blur strength, which might not be optimal for other aspects of the animation.
This COFFEE setup attempts to address these problems.

---------------- THE COFFEE EXPRESSION START ------------------
main(doc,op)
{
var radius = 0.2; /* Radius of the camera blur movement */
var strength = 0.25; /* Scene Motion Blur strenght (0.25 = 25%) */

var time = doc->GetTime()->GetSecond() * doc->GetFps();
time = (time+0.0001 - int(time+0.0001))/strength;
var rotation = time * PI2 * 7;
radius = radius*(1.0 - time);
var position = vector(sin(rotation)*radius, cos(rotation)*radius, 0);
// println(position);
op->SetPosition( position );
}
---------------- THE COFFEE EXPRESSION END ------------------

See the attached image to see where to put this expression in the scene.

Okay, so how does this work?

The first two lines set up a couple of variables, "radius" sets the radius of the camera rotation (experimentation is required for optimum values), and "strength" tells the Scene Motion Blur strength in the current render settings.

The next two lines take the absolute time of the (sub)frame, and convert it to range 0.0 <= X < 1.0.

Next, we calculate the "rotation" angle, which will rotate the camera 7 full circles over the subframes, and we make the "radius" start with the largest value and spiral towards the centre.

Then we just simply set the camera position using simple trigonometry. This will work if both the camera and the camera's parent have a Target expression pointing to the same object, which will be the focus point. The expression evaluation order should be:
1. parent's Target expression
2. This COFFEE expression of the camera
3. Target expression of the camera

This should be all there is to it, you can freely animate the Target object and the camera's parent object.

I guess I should eventually create a "tips & tricks" section on my web pages...

Pate

manlio
05-28-2003, 11:34 AM
Great Pate, thanks for sharing!
I will try it very soon. :thumbsup:

flingster
05-28-2003, 10:34 PM
hey pate top job thanks for sharing.


(why don't you just set it in a cinema file for download off your website...i think paul used to do things like this when he had coffee examples...that way people can see it working and play about with it a bit....and you also get visitors to you webspace...keeping it sticky...just a thought of course)

thanks again...i'm sure people are gonna find this very useful...btw hows your project coming along?

Pate
05-29-2003, 04:17 AM
Thanks flingster!

Yeah, I've been meaning to do a page on my 3D web site for things like this, but have always found something more interesting to do with the time. I promise I will eventually get it done!

My project is progressing slowly, but that is to be expected. Actually, I am already in the process of rendering the first final scene! :bounce: (Looks like the movie will be around 15 minutes in total length, the first scene is a whopping 8 seconds and will take a couple of weeks to render) :)

I still have some modeling to do, but looks like I will be able to concentrate on animating and rendering (instead of modeling and texturing as during the past year) from now on!

Still now idea when it will be finished, could be a year from now or five years from now. :)

Pate

knight42
05-29-2003, 12:17 PM
Call me dozey, but are you rotating the camera slightly on the spot to get the DOF effect?

J

Pate
05-29-2003, 01:55 PM
Originally posted by knight42
Call me dozey, but are you rotating the camera slightly on the spot to get the DOF effect?

J

Well, I am rotating the position of the camera around the original camera (parent) position. I do not rotate the camera itself (that might create an interesting tunnel vision effect, though :) ).

Pate

knight42
05-30-2003, 01:25 PM
I see. I was just wondering how it worked!

J

CGTalk Moderation
01-15-2006, 06:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.