ArtOfIllusion / ArtOfIllusion

Art of Illusion modeling and rendering suite - core application and tools
http://www.artofillusion.org
GNU General Public License v2.0
71 stars 23 forks source link

SceneCamera revision #330

Open peteihis opened 3 months ago

peteihis commented 3 months ago

Hi.

I have recently had more time in my hands than I'd like. -- So, among many other things, I Ended up looking at the SceneCamera again.

The piece is a somewhat confusing thing to use but on the inside it is yet worse... I admit that some of that is my doing too, in the past attempt to separate the camera internal space from the scene space. What the code really needs is "pruning with big axe". There are parameters that overlap and contradict in their function etc... What I'd really want to do is to rethink the mathematical part, as in many cases the calculations could be a step or two step simpler than in the current implementation but more importantly the user interface needs a rethink.

The first things would be to

The change will of course break backward compatibility. The forward I got working already.

Issues #257, #169 and #145 seem to be about SceneCamera as well. Another edit: Add #331 to the list.

RE-EDIT:

A bit of a naming confusion above. I tried to google up the correct terms and this is how it looks:

I can not say if the parameters have always been used the way they are now, or if something has happened to them along the way. Anyway the refined plan now would be to do some renaming and add the option to set focus to working distance automatically.

EDITED .. a few times over..

peteihis commented 3 months ago

A little update:

Depth of field can not be set.

So I got an bit lost somewhere but not so bad I couldn't get back ... (And who did ever read the manual ... ??)

The Depth of Field setting is actually doing exactly what it is supposed to do but managing it in a natural manner is difficult: Say I render a picture with focus at 10 units and DoF at 5 the picture makes a nice detail close-up. Then if I pull the camera back by 40 units and focus to 50, I have effectively made the camera 5 times bigger than it was. To compensate the effect in depth blur, DoF needs to be set 45 or so.

My current plan would be to replace DoF by Lens diameter and Aperture. Lens diameter takes care that your camera is of appropriate size in relation to your scene. Aperture does what aperture does to focus (no effect on exposure in this case). Once, those are set you don't have to worry about them, unless you want play with depth blur in animation or something of that sort...

inside it is yet worse...

This was not exactly true either. The changes above induce some tweaks though...

The thing that keeps bothering and occasionally confusing me is the legacy of using Camera.DEFAULT_DISTANCE_TO_SCREEN to a lot of default settings. By function 'distance to screen' is actually the focal length of the Camera. That happens inside the camera, not in the scene space. I'd split that into two: Camera.DEFAULT_FOCAL_LENGTH and Camera.DEFAULT_WORKING_DISTANCE. And what then, remains to be seen, it would be a different project.

peastman commented 3 months ago

My current plan would be to replace DoF by Lens diameter and Aperture.

I'm not sure that's a good idea. Depth of field has a clear interpretation in terms of the scene: what range of distances should be in focus? Aperture may mean something to people who are into photography, but to anyone else it's an arbitrary, meaningless number.

peteihis commented 3 months ago

I'm not sure that's a good idea.

Okay -- I guess, I'll leave then...

It's just that myself, I have always found the effect of DoF-setting unnatural, when you focus the camera at a different distance. It's behavior does not mimic a real world camera at all, which a kind of is what I would expect.

peteihis commented 3 months ago

Depth of field has a clear interpretation in terms of the scene: what range of distances should be in focus? Aperture may mean something to people who are into photography, but to anyone else it's an arbitrary, meaningless number.

Coming to think of this, I'd, with all due respect, have to disagree.

As a matter of fact I already coded the lens so here's a little comparison. The cubes are 2×2×2 in size and focus distances 10, 50 and 1.24.

Lens and Aperture vs DoF

The last row is a sketch on how to automate the DoF to work much like a lens. The equation would be DoF = Max(focus - portion, focus × fraction). The idea of the formula is that DoF follows focus but stays always positive. You'd probably never have to touch the fraction parameter. It would seem to work well enough, though the effect is not exactly the same and I did not check what happens between the frames.

But then I had another idea: How about making the camera lens a plugin? The standard lens could be the DoF-control but you could change it to what ever special lens you need (and have available).

I was actually mapping out the options of rendering different perspective projections and it turns out that all you need is the response to getRayFromCamera(). The camera would pass the question to the lens. I'd also move all randomization from the renderer to the lens. (Just ask dof-blur or not.)

What would happen with animation pose tracks, I don't know yet. Probably each lens would have to produce their dedicated pose track under the camera pose track, as they'd have different parameters.

Anyway I'll have to drop this for a couple of days now and come back, when I can (no promises).

peteihis commented 3 months ago

all you need is the response to getRayFromCamera()

And the support to Raster renderer of course.

peteihis commented 3 months ago

When I started I did not exactly remember what it was that infuriated me about SceneCamera until I ran again into the worst possible SceneCamera bug: "Focal distance" was affecting magnification!

Calrification: That was the case in SceneCamera parallel mode.

So, when I had a framed a nice portion of the scene for an image, and wanted to focus on an object somewhere close to the camera, the image was rendered as if the camera had been moved almost to touch that object. Not as I had framed it. <---delete--->

peteihis commented 3 months ago

"Focal distance" was affecting magnification! ... parallel mode.

As I recall that was the original behavior of the SceneCamera before I started to work on view manipulation all those years ago. I got the ViewerCanvas to work right, but at the time I did not go into SceneCamera. Turned out to be an easy fix, when I found the spot.