Author Topic: Autofocus  (Read 30945 times)

2014-02-14, 23:16:07

racoonart

  • Active Users
  • **
  • Posts: 1446
    • View Profile
    • racoon-artworks
This little Script will help setting the camera focus very precisely. Just run the script and click in the viewport where you want the focus point to be. A little red helper will flash up for a short moment to show the exact position of your focus point (at least if your current active layer is not hidden ;) )

If you want to use this script as a macroscript you just need to uncomment the first 2 lines (remove the "--")
P.S. If you use this script in scenes with several thousand objects it may get slow (~4 seconds in a scene with 15k objects) since the intersectRayScene maxscript function I need to use is unfortunately quite slow.

Updated Script version v.04:
Updated the maxscript commands to work with the daily builds post-A7 and Corona 1.0


UPDATE BY FROOD
Please download an updated version by frood here (thanks frood! :) )
https://forum.corona-renderer.com/index.php?topic=2703.msg118309#msg118309
« Last Edit: 2018-01-15, 12:54:18 by DeadClown »
Any sufficiently advanced bug is indistinguishable from a feature.

2014-02-18, 11:43:02
Reply #1

kahein

  • Active Users
  • **
  • Posts: 181
    • View Profile
it work really well.
Thanks for sharing.
maybe a suggestion.
could it be possible to automatically add a CoronaCamMod on the selected camera when click on the script 
Asus Z10PE-D16 WS / Dual Xeon E5-2690 v4 @ 2.60GHz / RAM 64 Go - GTX 970
Win 10 / Max 2017 / Corona 1.4

2014-02-18, 11:50:25
Reply #2

kahein

  • Active Users
  • **
  • Posts: 181
    • View Profile
i have just a little unit size bug.
ex a box at 1.5m (the correct distance) in the override focus field it put 0.15m
Asus Z10PE-D16 WS / Dual Xeon E5-2690 v4 @ 2.60GHz / RAM 64 Go - GTX 970
Win 10 / Max 2017 / Corona 1.4

2014-02-18, 12:00:03
Reply #3

racoonart

  • Active Users
  • **
  • Posts: 1446
    • View Profile
    • racoon-artworks
could it be possible to automatically add a CoronaCamMod on the selected camera when click on the script
Done, will update the file soon.

i have just a little unit size bug.
ex a box at 1.5m (the correct distance) in the override focus field it put 0.15m
That's weird, it's working in world units, it shouldn't matter what you have for system and display units. I tested it here and it worked either for inches + meters or centimeters + meters etc. Which configuration did you use?
Any sufficiently advanced bug is indistinguishable from a feature.

2014-02-18, 21:18:56
Reply #4

Tanakov

  • Active Users
  • **
  • Posts: 831
  • Corona is faster than diarrhea
    • View Profile
    • https://www.behance.net/Gringott
Did you reset xform?
Using Corona since 2014-01-02
https://www.behance.net/Gringott

2014-02-19, 17:12:00
Reply #5

ukajali

  • Active Users
  • **
  • Posts: 12
    • View Profile
sweet tool :) works like a charm! thx very much

2014-02-20, 00:29:40
Reply #6

gekygoly

  • Users
  • *
  • Posts: 2
    • View Profile
Hi guys, can you please provide detailed instructions of all process to make this work?

Here's my problem: I've a camera with coronacameramod modifier applied on it(NOT coronacmameramodAdv), I have  the DoF in corona settings TURNED ON(with wrong focus), I run the script in the correct viewprt and camera selected, put the focus on the object I want(a little dialog windows tells me the right name of the object too), I click ok to the window in which the scripts tells me that targetdist setting is overridden, and I click render. But focus doesn't change.
Tell me where I'm wrong please!!

Thanks a lot in advance
Jack

2014-02-20, 16:15:42
Reply #7

racoonart

  • Active Users
  • **
  • Posts: 1446
    • View Profile
    • racoon-artworks
I click ok to the window in which the scripts tells me that targetdist setting is overridden, and I click render. But focus doesn't change.
I've no idea which script you're running but mine does not (yet!) open any dialogs ;)
If there is some window opening it's either not from my script or it's a maxscript error message - which would explain why the focus does not change at all. You can post the error message here with a description of what you did exactly.

To make it more clear: Your active viewport must have a camera assigned, not perspective, and this camera must have a CoronaCameraMod modifier. If that's true you just need to run the script and click somewhere in this viewport - a little red helper will pop up indicating where your focus is.
Any sufficiently advanced bug is indistinguishable from a feature.

2014-02-20, 16:25:15
Reply #8

johan belmans

  • Primary Certified Instructor
  • Active Users
  • ***
  • Posts: 761
    • View Profile
    • belly.be
Hi Martin

could it be the script is not working with A5?
I always receive the following error message (see attachment)

2014-02-20, 16:28:02
Reply #9

racoonart

  • Active Users
  • **
  • Posts: 1446
    • View Profile
    • racoon-artworks
Oooooh, yes, right. I totally forgot that the cameraMod did not have as much features in A5 as it has now. Thanks for reporting! Sorry, that means you will have to wait for A6 or use the daily builds :-/
Any sufficiently advanced bug is indistinguishable from a feature.

2014-02-20, 16:39:55
Reply #10

johan belmans

  • Primary Certified Instructor
  • Active Users
  • ***
  • Posts: 761
    • View Profile
    • belly.be
I first have to figured out how this is working

" have a separate external folder containing different builds with all plugin and dll files (A5, dailies, important steps etc). One of these subfolders is referenced in all the plugin inis over the network (or more precisely: they all include another ini which targets the plugin folder, easier to maintain that way). The important thing is to include the path where the dlls lie into the path environment variable on every machine - without that max will fail loading and complain about missing dlls.
So this way I don't need to have the files in my max folder and can just rename the build's folders which then load different files on each max start."


before I start with the Daily Builds ;-)

2014-04-24, 01:10:20
Reply #11

Stan_But

  • Active Users
  • **
  • Posts: 526
    • View Profile
    • https://www.behance.net/archdizs
Hi DeadClown!
Thank you for very usable scripts!
If it maybe to do that the script works with camera target?

2014-09-07, 14:51:33
Reply #12

Stan_But

  • Active Users
  • **
  • Posts: 526
    • View Profile
    • https://www.behance.net/archdizs
Hello, Martin!
Looks like autofocus doesn't work correctly through the cropped geometry((
It focuses the camera to the cropped geometry but not to the needed geometry(
I will try fix it myself but i not so good know the maxscript (;

2014-09-07, 15:16:44
Reply #13

racoonart

  • Active Users
  • **
  • Posts: 1446
    • View Profile
    • racoon-artworks
If it maybe to do that the script works with camera target?
Sorry, missed that one. Shouldn't be a problem but I'm currently a bit busy, will make a note for it :)

Looks like autofocus doesn't work correctly through the cropped geometry((
It focuses the camera to the cropped geometry but not to the needed geometry(
What is cropped geometry? If you mean "viewport clipping" then I doubt I can do anything about it. I'm using the exposed raycasting methods from maxscript, that limits my possibilities in that sense =/
Any sufficiently advanced bug is indistinguishable from a feature.

2014-09-07, 16:56:09
Reply #14

Stan_But

  • Active Users
  • **
  • Posts: 526
    • View Profile
    • https://www.behance.net/archdizs
If it maybe to do that the script works with camera target?
Sorry, missed that one. Shouldn't be a problem but I'm currently a bit busy, will make a note for it :)

When it may be done it would be more clearly to see where the focus
I will be waiting (;

Looks like autofocus doesn't work correctly through the cropped geometry((
It focuses the camera to the cropped geometry but not to the needed geometry(
What is cropped geometry? If you mean "viewport clipping" then I doubt I can do anything about it. I'm using the exposed raycasting methods from maxscript, that limits my possibilities in that sense =/

Oh. I'm sorry(
I mean the clipped geometry with the camera clipping planes.
Camera don't shows the clipped but script sees and focuses at this mesh
One more time sorry for mistake (;

2014-09-09, 10:11:40
Reply #15

racoonart

  • Active Users
  • **
  • Posts: 1446
    • View Profile
    • racoon-artworks
Oh. I'm sorry(
I mean the clipped geometry with the camera clipping planes.
Camera don't shows the clipped but script sees and focuses at this mesh
One more time sorry for mistake (;
Sorry, I fear I can't do anything about it =/
Any sufficiently advanced bug is indistinguishable from a feature.


2014-09-25, 20:37:51
Reply #17

Stan_But

  • Active Users
  • **
  • Posts: 526
    • View Profile
    • https://www.behance.net/archdizs
here i'm again (;
Hi, Martin!
Can you do in the perspective view will work autofocus too?
I mean to use "Perspective view focus distance"
Very comfortable for the tweaking

2014-09-25, 21:37:52
Reply #18

racoonart

  • Active Users
  • **
  • Posts: 1446
    • View Profile
    • racoon-artworks
If it maybe to do that the script works with camera target?
Done

Can you do in the perspective view will work autofocus too?
I mean to use "Perspective view focus distance"
...aaaand done :)

[UPDATE] Updated Script version v.03:
The Script has 3 modes now:
- CoronaCameraModifier
- Camera target
- Render settings: Perspective view focus distance
Any sufficiently advanced bug is indistinguishable from a feature.


2014-09-30, 14:45:17
Reply #20

kahein

  • Active Users
  • **
  • Posts: 181
    • View Profile
Great Job.
Work perfectly !
Asus Z10PE-D16 WS / Dual Xeon E5-2690 v4 @ 2.60GHz / RAM 64 Go - GTX 970
Win 10 / Max 2017 / Corona 1.4

2014-12-12, 18:44:24
Reply #21

form

  • Active Users
  • **
  • Posts: 70
    • View Profile
    • Plus Form
very handy script, thanks a lot. Unfortunately stopped working with latest DB. Your probably on top of it. Cheers

2014-12-12, 18:55:00
Reply #22

racoonart

  • Active Users
  • **
  • Posts: 1446
    • View Profile
    • racoon-artworks
Ah, yes. I've updated the maxscript commands but forgot to upload it.
New version is attached to the first post :)
Any sufficiently advanced bug is indistinguishable from a feature.

2014-12-17, 16:33:55
Reply #23

form

  • Active Users
  • **
  • Posts: 70
    • View Profile
    • Plus Form
Thanks DeadClown, it's really useful!

2016-08-11, 16:07:29
Reply #24

Frood

  • Active Users
  • **
  • Posts: 1903
    • View Profile
    • Rakete GmbH
Never tried this handy script before but at least with DB16-08-05 I get a "...got undefined" in "addmodifier theCamera(CoronaCamMod())" when there is none present.

Any chance to support physical cams?

Good Luck

Never underestimate the power of a well placed level one spell.

2016-08-11, 17:23:08
Reply #25

dubcat

  • Active Users
  • **
  • Posts: 425
  • ฅ^•ﻌ•^ฅ meow
    • View Profile
Here is my little mod with Physical Camera support, should do the trick until an official update. No reason to keep it to myself.
« Last Edit: 2016-08-11, 17:47:26 by dubcat »
             ___
    _] [__|OO|
   (____|___|     https://www.twitch.tv/dubca7 / https://soundcloud.com/dubca7 ( ͡° ͜ʖ ͡°) choo choo

2016-08-11, 17:34:52
Reply #26

Frood

  • Active Users
  • **
  • Posts: 1903
    • View Profile
    • Rakete GmbH
Damn. Meanwhile I also modded it to support Physical and fixed the CameraMod name. But I´d still like to use the "official" by Martin so maybe he has some time to extend it.

Good Luck

Edit: I see you added a new mode, I simplified it to "CameraMod", "Camera settings" and "Render settings". In case of Camera it set´s target distance (standard target cam and physical cam) and in case of physical cam additionally focus distance. This may be unwanted in some very rare cases but I´d like to have it simple. (physical cam target get set only if activated anyway).

Good Luck


« Last Edit: 2016-08-11, 18:28:28 by Frood »
Never underestimate the power of a well placed level one spell.

2018-01-15, 12:05:21
Reply #27

Frood

  • Active Users
  • **
  • Posts: 1903
    • View Profile
    • Rakete GmbH
(...) so maybe he has some time to extend it.

Nope :)

Due to this sad fact I changed it again,  here is a new version (v0.06):

  • added support for CoronaCamera
  • added support for standard free camera
  • added legacy mode for older Corona versions (affecting changing target distance of physical cam and availability of scene settings mode)
  • added versioning


Good Luck



Never underestimate the power of a well placed level one spell.

2018-01-17, 05:19:18
Reply #28

iacdxb

  • Active Users
  • **
  • Posts: 757
  • 3D Deisgner
    • View Profile
    • www.behance.net/iacdxb
Hi,
Is it for C4D also....?

Thanks.
Windows, Cinema 4D 2023.

2018-01-17, 08:45:00
Reply #29

Frood

  • Active Users
  • **
  • Posts: 1903
    • View Profile
    • Rakete GmbH
Sorry no, it's maxscript.


Good Luck


Never underestimate the power of a well placed level one spell.

2018-01-24, 10:50:12
Reply #30

Jpjapers

  • Active Users
  • **
  • Posts: 1644
    • View Profile
I wonder if something like this will be implemented in v2 onwards like in the Vray frame buffer where you can click to change focus.

2018-01-24, 11:02:45
Reply #31

NicolasC

  • Primary Certified Instructor
  • Active Users
  • ***
  • Posts: 539
  • CG supervisor / teacher / artist
    • View Profile
I wonder if something like this will be implemented in v2 onwards like in the Vray frame buffer where you can click to change focus.
Oh yes !!! like with VFB+ ...
However, AFAIR, with VRay it's only implemented with VRayRT for now.
Nicolas Caplat
CG supervisor / teacher / artist

2018-01-25, 16:39:47
Reply #32

Jpjapers

  • Active Users
  • **
  • Posts: 1644
    • View Profile

SNIP

Oh yes !!! like with VFB+ ...
However, AFAIR, with VRay it's only implemented with VRayRT for now.

Yeah in IR it would be great, Would be even better if that change in focal length could be reflected in the camera settings

2018-03-30, 07:03:09
Reply #33

Hozkr Mejia

  • Active Users
  • **
  • Posts: 8
    • View Profile
Thank you very much for sharing, I'll try it soon :)