Results 1 to 12 of 12

Thread: Setting FOV values via LScript ...

  1. #1
    A.K.A "The Silver Fox" Gungho3D's Avatar
    Join Date
    Aug 2009
    Location
    Oztralia
    Posts
    416

    Setting FOV values via LScript ...

    Look, I know this is "LW-Community" but ... I'm actually keen for an answer.

    Is there a way of specifying FOV values specifically via LScript?

    Yep, I can slice this another way via CommandInput("ZoomFactor " + string(ZoomFactorVariableName)) ...
    ... and I can convert that to focal length mm, but it is not the same as directly saying "having set the camera's final width x height, NOW I want to specify an exact horizontal FOV angle value."

    In other words going via ZoomFactor -> FocalLength mm is not giving me the same FOV which an "identical" camera (same focal mm & same render final width x height) from Terragen is showing ...

    Anyone with any clue as to how to specify a hFOV via LScript?

  2. #2
    Goes bump in the night RebelHill's Avatar
    Join Date
    Nov 2003
    Location
    jersey
    Posts
    5,766
    Dont think so. FOV isn't simply another term for focal length, its a function of both focal length and the frame aspect ratio.
    LSR Surface and Rendering Tuts.
    RHiggit Rigging and Animation Tools
    RHA Animation Tutorials
    RHR Rigging Tutorials
    RHN Nodal Tutorials
    YT Vids Tuts for all

  3. #3
    TrueArt Support
    Join Date
    Feb 2003
    Location
    Poland
    Posts
    7,897
    [never mind]
    Last edited by Sensei; 05-24-2019 at 07:38 AM.

  4. #4
    A.K.A "The Silver Fox" Gungho3D's Avatar
    Join Date
    Aug 2009
    Location
    Oztralia
    Posts
    416
    Quote Originally Posted by RebelHill View Post
    Dont think so. FOV isn't simply another term for focal length, its a function of both focal length and the frame aspect ratio.
    Thanks RH - yes, very aware of that, but just the same here is the dilemma:

    I am scripting up a means of importing TG cameras directly into LW from TG project files. This is working well, I am able to get a starting position and rotation (no animation yet), plus the aspect ratio is based off TG's default 800x450px render resolution. I'm just stuck on finding a formula to force LW to use the FOV it's reading from TG. Using TG's Focal Length mm values is not giving me the same FOV value as I'm seeing in TG.


    Years ago I coded all this going the other way, exporting to a .chan file - in that case TG was forced to use the exported FOV values from LW and all was well.

    I have put in hours of digging around the likes of https://stackoverflow.com/ … seems to be more on calculating FOV than the other way around.


    Any ideas?

  5. #5
    TrueArt Support
    Join Date
    Feb 2003
    Location
    Poland
    Posts
    7,897
    You can create your own perspective Camera plugin class where you will be able to create rays in direction that you want. It's relatively easy. But requires C/C++ code.
    Last edited by Sensei; 05-24-2019 at 07:40 AM.

  6. #6
    A.K.A "The Silver Fox" Gungho3D's Avatar
    Join Date
    Aug 2009
    Location
    Oztralia
    Posts
    416
    Quote Originally Posted by Sensei View Post
    You can create your own perspective Camera plugin class where you will have be able to create rays from origin and toward direction that you want. It's relatively easy. But requires C/C++ code.
    Hey Sensei thanks.

    I hadn't thought about the brute force method of saving out a scene, parsing to the point of physically changing camera FOV values, and then invoking a load from scene … although I do wonder if the FOV value is stored in that format in the .lws file … possibly it's stored as a Zoom Factor value? ...

    … in which case i'm still looking for a formula to give me a Focal Length value based on FOV and render aspect ratio as RH was saying.

    PS I wish I was a black belt in coding C++ like yourself but alas I am not

  7. #7
    Goes bump in the night RebelHill's Avatar
    Join Date
    Nov 2003
    Location
    jersey
    Posts
    5,766
    personally... Id just look for a formula for the discrepancy... Take a few focal lengths in TG (10mm,20mm,... 100mm), note down the FOV values. Do the same in LW, find the difference function, and just send over the focal length and then apply the offset.
    LSR Surface and Rendering Tuts.
    RHiggit Rigging and Animation Tools
    RHA Animation Tutorials
    RHR Rigging Tutorials
    RHN Nodal Tutorials
    YT Vids Tuts for all

  8. #8
    A.K.A "The Silver Fox" Gungho3D's Avatar
    Join Date
    Aug 2009
    Location
    Oztralia
    Posts
    416
    Quote Originally Posted by RebelHill View Post
    personally... Id just look for a formula for the discrepancy... Take a few focal lengths in TG (10mm,20mm,... 100mm), note down the FOV values. Do the same in LW, find the difference function, and just send over the focal length and then apply the offset.
    Ok, I've got it working by first manually setting the "Frame:" value on the camera settings tab to the magic number of "0.7972" (I just dialled it up from "0.5906" until I got a FOV matching value to what was in TG). This retains the Focal Length mm value in LW but changes the Zoom Factor value. All I did was note the new Zoom Factor value and simply got my script to get that Zoom Factor based on the new ZF/FL valuie.

    As the relationship between ZF and FL seems linear, the above *appears to be* working across a range of TG camera values … but I suspect that if someone messes with the "Film aperture in mm" settings in TG, all of the above will come unstuck


    To be continued …


    Ed: spoke too soon, just broke it … going to bed
    Last edited by Gungho3D; 05-24-2019 at 09:22 AM.

  9. #9
    TrueArt Support
    Join Date
    Feb 2003
    Location
    Poland
    Posts
    7,897
    Quote Originally Posted by Gungho3D View Post
    I hadn't thought about the brute force method of saving out a scene, parsing to the point of physically changing camera FOV values, and then invoking a load from scene … although I do wonder if the FOV value is stored in that format in the .lws file … possibly it's stored as a Zoom Factor value? ...
    That's why I removed that message from this thread..

    ZoomFactor is controlling the all 4 (ZoomFactor,LensFocalLength,H FOV,V FOV).

    Did you use correct Aspect Ratio?
    Are you calculating it from resolution or it's stored somewhere?

    If you adjust Aspect Ratio slider, H FOV is changed, but Zoom Factor, Lens Focal Length and V FOV remain the same as they used to be (because the same Zoom Factor).
    Last edited by Sensei; 05-24-2019 at 09:33 AM.

  10. #10
    TrueArt Support
    Join Date
    Feb 2003
    Location
    Poland
    Posts
    7,897
    1) make screen-shot or render in 3rd party app.
    2) put it in background of Layout.
    3) start adjusting Aspect Ratio till they match (bg image and LW scene).
    Last edited by Sensei; 05-24-2019 at 09:42 AM.

  11. #11
    Quote Originally Posted by Gungho3D View Post
    Ok, I've got it working by first manually setting the "Frame:" value on the camera settings tab to the magic number of "0.7972" (I just dialled it up from "0.5906" until I got a FOV matching value to what was in TG). This retains the Focal Length mm value in LW but changes the Zoom Factor value. All I did was note the new Zoom Factor value and simply got my script to get that Zoom Factor based on the new ZF/FL valuie.

    As the relationship between ZF and FL seems linear, the above *appears to be* working across a range of TG camera values … but I suspect that if someone messes with the "Film aperture in mm" settings in TG, all of the above will come unstuck


    To be continued …


    Ed: spoke too soon, just broke it … going to bed
    Hi,
    to match the FOV (field of view) you need the same focal length and sensor size, resolution does not matter (frame aspect ratio does, of course).
    In Lightwave you can set the sensor/frame height with the "Frame" settings. In Terragen it seems to be "Film aperture in mm" (according to the planetside wiki).
    As seen in the planetside wiki you also can set the HFOV (horizontal field of view) or the VFOV (vertical) in TG, same in LW. Because the FOV is measured in degrees is independent from sensor size.

    Hope this helps.
    ciao
    Thomas
    Web: www.dieleinwandhelden.com

    I use two pieces of the three-piece application with mocap module.

  12. #12
    A.K.A "The Silver Fox" Gungho3D's Avatar
    Join Date
    Aug 2009
    Location
    Oztralia
    Posts
    416
    Success!


    The goal has been to implement a one-click "Import Cameras from TG" without further user intervention and for the result to be as close to pixel-perfect as possible (in other words no "near enough" outcomes).

    The renders below carry an FOV tolerance of .001 degree max either side of the originating TG specified FOV.


    To the guys who wrote (above) - thanks heaps!



    Below: a first proof of concept / work in progress render comparison ...




    Click image for larger version. 

Name:	LWTG_Link__CameraTest__02B__CompareTGCam&LW-Import-TGCam__Small.png 
Views:	47 
Size:	1.72 MB 
ID:	145071

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •