Author Topic: Autofocus  (Read 19228 times)

2014-02-14, 23:16:07

DeadClown

  • Global Moderator
  • Active Users
  • ****
  • Posts: 1435
    • 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://corona-renderer.com/forum/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: 184
    • 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: 184
    • 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

DeadClown

  • Global Moderator
  • Active Users
  • ****
  • Posts: 1435
    • 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: 728
  • Corona is faster than diarrhea
    • View Profile
    • https://www.behance.net/Gringott
Did you reset xform?
Corona since 2014.06.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

DeadClown

  • Global Moderator
  • Active Users
  • ****
  • Posts: 1435
    • 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: 719
    • 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

DeadClown

  • Global Moderator
  • Active Users
  • ****
  • Posts: 1435
    • 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: 719
    • 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_Booth

  • Active Users
  • **
  • Posts: 525
    • 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_Booth

  • Active Users
  • **
  • Posts: 525
    • 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

DeadClown

  • Global Moderator
  • Active Users
  • ****
  • Posts: 1435
    • 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_Booth

  • Active Users
  • **
  • Posts: 525
    • 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 (;
« Last Edit: 2014-09-07, 17:00:19 by headoff »