Search Unity

Camera Perspective Editor [RELEASED]

Discussion in 'Assets and Asset Store' started by deram_scholzara, Apr 3, 2014.

  1. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043

    Get it now on the Unity Asset Store!
    Click Here

    Expand Your Camera’s Versatility!


    Visit the Website



    Powerful Easy
    • Fully scriptable animatable
    • Shows modified frustum
    • Easy to use inspector with descriptions
    • Comes with prefabs for common setups
    • Easily tweaked for your specific needs
    • Works in Orthographic and Perspective modes
    • Doesn’t break standard Camera component or controls
    • Dolly Zoom (Trombone Effect) without moving the camera
    • Smoothly transition between Perspective and Orthographic projections

    Wide Range of Perspectives
    • Isometric Projections
    • Oblique Projections
    • Oblique Perspectives
    • Tilt-Shift Lens
    • Classic 2.5D FPS perspective
    • Skewed Views

    Also Included
    • Full C# code for customization purposes
    • City diorama seen in screenshots
    • Classic 2.5D Character/Camera controller script








    Updates:

    1.2.0 - 2014-04-30: Feature release Feature Replacement.
    - Added "Dolly Zoom" section, which allows for simulation of "Trombone" camera zooms without actually moving or zooming the camera at all.
    * As the "Dolly Zoom" variable approaches 1, the Dolly Zoom effect approaches an orthographic perspective.
    * The "Focal Distance" variable defines the depth/distance at which objects should maintain the same screen-relative size throughout the dolly zoom adjustment.
    * The "Focal Target" variable, if set, will automatically update the "Focal Distance" based on its distance from the camera.
    * Note: "Dolly Zoom" does not work with Orthographic Cameras, but it can be used to create orthographic perspectives by setting the "Dolly Zoom" variable to 1.​
    - Replaced "Aspect Offset" with "Aspect Scale", as it provides more accurate and useful functionality and does not distort with viewport ratio changes.
    * Upgrade Note: If you were using "Aspect Offset" previously, you will need to adjust the new "Aspect Scale" settings such that you get the same results as your old settings. The numbers will not match.​

    1.1.1 - 2014-04-02: Feature Bugfix release.
    - Added "Proportional To Aspect" option to Lens Shift.
    * When inactive, the offset distance of the horizontal matches the offset of the vertical.
    * When active, it behaves as previously set up, where the wider/taller axis will move proportionally more than the other.​
    - Also fixed aspect ratio updating by using OnPreCull() instead of LateUpdate().

    1.0.0 - 2014-03-25: Initial release.
     
    Last edited: Jul 5, 2014
    Gozdek likes this.
  2. gamescorpion

    gamescorpion

    Joined:
    Feb 15, 2014
    Posts:
    132
    This looks pretty neat! :)

    Great work!
     
  3. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Hi everybody! Just checking in to see if any of you have any questions about the tool.

    Also, thank you to all those who purchased already!
     
    gsammbunny likes this.
  4. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Camera Perspective Editor 1.2.0 has just been released!

    Now with CPE, you can simulate Dolly Zoom (Trombone Effect) without actually moving your camera or changing its field of view! This effect is commonly used for accentuating intense actions like sprinting or falling from dangerous heights. It can also be used to smoothly transition between perspective and orthographic projection modes.




    1.2.0 - 2014-04-30: Feature release Feature Replacement.
    - Added "Dolly Zoom" section, which allows for simulation of "Trombone" camera zooms without actually moving or zooming the camera at all.
    * As the "Dolly Zoom" variable approaches 1, the Dolly Zoom effect approaches an orthographic perspective.
    * The "Focal Distance" variable defines the depth/distance at which objects should maintain the same screen-relative size throughout the dolly zoom adjustment.
    * The "Focal Target" variable, if set, will automatically update the "Focal Distance" based on its distance from the camera.
    * Note: "Dolly Zoom" does not work with Orthographic Cameras, but it can be used to create orthographic perspectives by setting the "Dolly Zoom" variable to 1.​
    - Replaced "Aspect Offset" with "Aspect Scale", as it provides more accurate and useful functionality and does not distort with viewport ratio changes.
    * Upgrade Note: If you were using "Aspect Offset" previously, you will need to adjust the new "Aspect Scale" settings such that you get the same results as your old settings. The numbers will not match.​
     
    Last edited: Jul 5, 2014
  5. icone-conception

    icone-conception

    Joined:
    Nov 9, 2012
    Posts:
    1
    @deram_scholzara

    Hi!
    I've bought your plugin, it works well but in deferred rendering with shadows I've got some issue
    as the shadow become glitchy. is there a way to still use your plugin with real time shadows?

    regards.
     
  6. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    Hello, I have a question. I've been using a script to apply custom matrix(oblique projection) to camera, but it seems the custom matrix breaks stuff like Unity's OnMouse events and raycasting. I haven't tested yet but likely NGUI's UI Camera won't work either. Does your project have a workaround this?
     
  7. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Hi there, sorry about the delay, this new forum system has me subscribed to everything, so it's hard to tell when something important pops up.

    I haven't noticed any issues like this in my testing. What kind of lights are you using? Can you provide screenshots or video of the issue?

    It would appear that Orthographic projections which are oblique will break both OnMouse events, as well as Raycasting that uses Camera.ScreenPointToRay(). This seems like a bug with Unity's Camera.ScreenPointToRay() method. Unity seems to have had an interest in giving us the ability to modify camera projection matrices, but they don't seem to have put any effort into making sure the engine doesn't break when doing so.

    That said, OnMouse and Raycasting do both work with Oblique non-orghographic projections (perspectives), such as the Classic FPS example in Camera Perspective Editor.

    It should also be noted that while you cannot use Camera.ScreenPointToRay() to come up with the Ray for your Raycast, you can still build the world-space Ray on your own using the mouse position and the current projection matrix generated by Camera Perspective Editor. I will try to add something like CameraPerspectiveEditor.ScreenPointToRay() to an update when I get the chance. It won't fix OnMouse events, but it will allow you to build your own custom cursor raycasting solution that does work. I'll try to include a simple example scene for this as well.

    In the meantime, I would greatly appreciate it if you could report this as a bug to Unity so it gets some attention.
     
  8. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    Thanks for your reply and the detail. I've submitted a feedback on the Unity website. Custom ScreenPointToRay() sounds great, looking forward to that. Do you have screenshot or video showing "Oblique non-orghographic projections (perspectives)"? I don't have slightest idea what it looks like :p
     
  9. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Thank you for doing the feedback submission =-)

    Oblique non-orthographic projection is done by setting the camera to perspective mode and then adjusting the Lens Shift in Camera Perspective Editor. It looks like the video links in my posts above were broken when the forums were upgraded; they're fixed now, but here's the main demonstration video for the initial launch of CPE:

    Lens Shift is demonstrated at about 2 minutes in. It shifts the back plane of the view frustum, thereby making an "oblique" perspective projection - this is the same way oblique orthographic projections are made.
     
  10. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    I've watched the entire vid :p Thanks!
     
  11. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Hey again!

    So I've just finished implementing the custom CameraPerspectiveEditor.ScreenPointToRay() and CameraPerspectiveEditor.ViewportPointToRay() methods. They will be included in Camera Perspective Editor version 1.3.0, which has just been submitted to the asset store for review. Should be available within the next week or so.
     
  12. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    Nice to see an update coming so soon. I will be definitely trying your solution.
     
  13. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,145
    Can this do two-point perspective?
     
  14. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    There are no attributes specifically for setting up two-point perspective, on top of there being many different two-point setups, but there are three ways I'm aware of that Camera Perspective Editor can currently create two point perspectives.
    1. You can adjust Aspect Offset to remove either the vertical or horizontal perspective by making a dimension of the back clip plane the same as the corresponding dimension of the front clip plane. This probably ends up looking pretty weird though.
    2. You can make sure that the camera's forward axis is pointing at one of the "vanishing points" and then adjust Lens Shift to offset that vanishing point from screen-center without rotating the camera.
    3. You can use Lens Tilt to remove vertical or horizontal perspective at a given camera angle. If your camera is fixed, this is easy. If your camera can rotate, you'll need to write a script to adjust the Lens Tilt according to the current horizontal or vertical angle.
    Can you provide an image of the kind of two-point perspective you're going for? That way I can let you know if that particular setup is possible.
     
  15. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,145
    Basically, I'm trying to emulate the 3D Studio Max camera correction modifier for the planet rendering camera in my game. It sounds like option three with a script attached to it would be the best option for this. I'm basically trying to eliminate the distortion around the edge of the screen without having to rely on a very narrow FOV or orthographic cameras, which cause issues with my shader.
     
  16. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    I think that either 2 or 3 may correct this effect when combined with a script. For option 2, there is an example of a Classic FPS Camera script included which demonstrates Lens Shift control for vertical looking. There's also footage of this script in action at the end of the demonstration video in the first post of this thread. I think going this route would be easier than figuring out the math to adjust the Lens Tilt, and the end result is identical.
     
  17. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,145
    Well, I'll give it a shot then. The asset is only $15 and even if it doesn't work perfectly for this, I know of a lot of other uses I can get out of it. I'll pick it up later tonight.
     
  18. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Wonderful! Thanks a bunch. If you have any questions of suggestions, let me know =-)
     
  19. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Well, it looks like 1.3.0 was finally released, but I didn't receive the usual notification email, so I'm not sure when it happened. Either way, it's there and hopefully it can help to resolve the issues you've encountered with oblique orthographic projections and raycasting.
     
  20. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    Very neat! Bookmarked!
     
  21. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    Thanks for the notice. Uh.. I was too excited to try out and didn't notice the "it requires unity4.5.1" warning before purchasing. Are you able to send me the old&new version of the asset by any chance? I will send you an email with invoice.
     
    Last edited: Jul 22, 2014
  22. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    What version of Unity are you using? I keep forgetting to release it with the oldest possible Unity version. I'm submitting an update now with an older Unity version.
     
  23. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    Thanks, that helps. I'm using Unity Version 4.3.4 right now.
     
  24. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Ok, I have just resubmitted using Unity 4.0.0 and will send you the unity package as soon as I've verified your invoice number =-)
     
  25. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Camera Perspective Editor 1.3.1 has just been released. It is now be available to anybody who uses any 4.x version of Unity.
     
  26. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Hi everybody!

    I'm just posting to let you know that version 1.3.2 has been submitted to the Asset Store for approval.

    A few people have contacted me about issues with zooming by changing the Camera component's orthographic size while Camera Perspective Editor is applying a Lens Shift (creating an oblique perspective). This issue has been resolved in the new version of CPE by changing Lens Shift so that it is applied in world-units when using an orthographic camera.

    This may require some minor adjustments to existing Lens Shifted orthographic cameras, but I feel that the tweaks can be resolved quickly and that the new setup will make it much easier to get the exact oblique orthographic view you're going for in the future.

    Thanks again to all those who have helped me build this tool!
     
  27. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    And it's been approved! This is the fastest review I've ever received from for the Asset Store. Thank you Unity!

    Here are the release notes from version 1.3.2:

    1.3.2 - 2014-07-07: Feature Improvement.
    • When the Camera component is set to Orthographic mode, "Lens Shift" offsets will no be applied in world-units instead of frustum-units.
      • This change allows Orthographic cameras to properly zoom by changing the Orthographic Size on the Camera component.
      • Upgrade Note: If you were previously using "Lens Shift" with an Orthographic Camera component, you will need to adjust the offset values unless your Orthographic Size was previously set to 1.
      • Upgrade Note: All preconfigured camera prefabs and example scenes have been updated to accomodate for this change.
     
  28. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,123
    Just a bug I found, when I have 2 perspective camera editors on the same camera, the 'focus distance' for the dolly zoom will default to the value of the first script. I can't give the scripts different values.

    Right now, my workaround is adding a empty child object to the camera per 'Camera Perspective Editor' script, and telling the scripts to look at different children with different Z values (Where Z = my desired 'Focus Distance').

    Great work other than this problem :)

    PS: I am doing this because I need to toggle between different perspective settings! Only one is enabled at a time
     
  29. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Hi Prodigga, sorry about the issue, but thank you for pointing it out.

    I'll be fixing this soon, along with some updates to the screen-space conversion functions.
     
  30. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,123
    No problem :) Great plugin dude
     
    deram_scholzara likes this.
  31. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    I'm having problems setting the Dolly Zoom focal distance and having it remain set after entering Play mode. I've fixed it for my needs, but just a heads-up in case anyone else has problems with it.
     
  32. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Hi everybody!

    Just letting you know that I've submitted an update for Camera Perspective Editor which should go live within the next week. This update fixes a few issues that have been brought up, including fixes for the ScreenPointToRay() and ViewportPointToRay() methods, as well as adding their complimentary methods WorldToScreenPoint() and WorldToViewportPoint().

    @Prodigga Your specific issue with multiple CPE components on the same object should be fixed. If it's still an issue, I'll need more information about your specific case so I can come up with a specific solution.

    @IFL This issue has been resolved - the Focal Distance value should now only set to the default midpoint value when the CPE script is first initialized/added.

    Thanks to all of you who helped me find these issues, I'm very happy have your help in improving Camera Perspective Editor.

    Here are the release notes from the latest update:

    1.3.3 - 2014-10-12: Feature & Fix Release.
    • Added the methods "WorldToScreenPoint()" and "WorldToViewportPoint()" to the CameraPerspectiveEditor class.
      • The standard "WorldToScreenPoint()" and "WorldToViewportPoint()" methods in the Camera class do not work with orthographic cameras that have been modified by Camera Perspective Editor, so these new methods act as replacements and will work with both Perspective and Orthographic camera setups.
    • Fixed the methods "ScreenPointToRay()" and "ViewportPointToRay()" in the CameraPerspectiveEditor class when working with orthographic cameras. They will now create properly-directed rays.
    • Fixed an issue causing the "Dolly Zoom" "Focal Distance" to revert to default values while no "Focal Target" is selected.
     
    IFL likes this.
  33. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    And 1.3.3 has now been approved! Get it while it's hot =-)
     
    IFL likes this.
  34. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Hi everybody! Just a minor update for a major bug that affected those few who used the ScreenPointToRay() or ViewportPointToRay() methods in CameraPerspectiveEditor. Previously they were producing scaled up ray origins which did not line up with the input position.

    This issue has now been fixed and will be available on the asset store as soon as Unity approves it.

    Thanks for your patience!
     
    OnePxl likes this.
  35. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Camera Perspective Editor 1.3.5 is now released! It fixes the issue mentioned above.

    Here are the release notes:

    1.3.5 - 2014-12-07: Bugfix.
    • Fixed a really stupid mistake in the "ViewportPointToRay()" method which previously caused the returned ray origin to be inaccurate - really sorry about that!
     
  36. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    @deram_scholzara, Do you think this would currently be possible to implement by using your plugin?

     
  37. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Hi Ben BearFish,

    I think the only thing you'd need for that is a way to track the viewer's position (kinect in that example). Once you have that, you'd just need to make the virtual camera in Unity emulate the physical camera's position (and maybe some sort of calibration system beforehand as well).

    No Camera Perspective Editor necessary as far as I can tell.
     
  38. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    Hmmm..in the comments he specifically mentions modifying the projection matrix in Unity to achieve the effect with Kinect. I thought since your plugin modifies the camera matrices, that it might help with this. I believe he mentions skewing the frustum to achieve the effect with Kinect head tracking.
     
  39. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Ben BearFish,

    Camera Perspective Editor will definitely allow you to skew the perspective as described in the video - I guess they're doing more of a parallax effect than actually rotating+moving the camera (like I was originally thinking). Sorry about the confusion.
     
  40. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    No problem. Could I ask when you say parallax effect, are you referring to the skewing of the frustum?
     
  41. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Exactly
     
  42. CampioneDev

    CampioneDev

    Joined:
    Feb 9, 2015
    Posts:
    4
    Hi, I would like to point out a fairly big issue in Unity 5.

    Lens Tilt, Clipping Plane Skew and Dolly Effect produce a misalignment between the shadows and the actual geometry. Something wrong happens to fog as well.

    I LOVE this asset and my project's graphics totally relies on it, hence I really hope this is trivial to fix :)

    BTW: previously (Unity 4.x) I experienced the very same problem using the asset called "Sunshine!" by Punk Labs (volumetric scattering and custom shadow maps). It would be great if the same fix would work even for Sunshine because it's a beautiful plugin.
     
  43. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    First off, some people have had luck with switching the shadow mapping mode between close fit and stable fit - but it doesn't work for everybody.

    As for fixing the issue:
    So, as far as I can tell, this issue is on Unity's end. They have documentation on how to modify camera projection matrices, yet a lot of their features don't seem to support these modifications. Occlusion Culling has some similar issues, unfortunately.

    For now, I'm sad to say that the best solution is to bug Unity about it - the more squeaky wheels, the better (others have already submitted bug reports, but don't let that stop you).
     
  44. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    You can upvote this bug, which is already marked on the Issue Tracker here. That bug is caused by the same issue mentioned in this forum thread.
     
  45. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Hi,

    Can we adjust the Tilt Shift in game (RunTime)?
    and, works on Unity 5?
     
  46. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Tilt-Shift adjustments at runtime are absolutely possible, along with all the other features.

    The only outstanding issue is with Unity's support for modified projection matrices, which, in some cases, causes issues with shadows and/or occlusion culling. That issue is described in more detail in the post just above yours. This affects both Unity 4 and 5, but in different ways for each version.
     
    ZJP likes this.
  47. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Thanks. That said, i bought the product before your answer : 15$ is not a big risk. :p:D
     
  48. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Thank you for the purchase ZJP!

    How is it working out for you so far?
     
  49. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    You're welcome. :)
    Not yet tested. I'm not on the 'right' machine. I will keep you informed.
     
  50. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    UP.

    Does not solve directly my pb, but pointing me in the good direction. I've learned a lot with yours scripts. Thanks :cool:
     
    deram_scholzara likes this.