Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Camera Perspective Editor [RELEASED]

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

  1. NarkLord

    NarkLord

    Joined:
    Sep 24, 2013
    Posts:
    13
    Just purchased and it works great. The only problem is that realtime shadows break in oblique orthographic camera projections. The shadows seem to shift with the lens shift which offsets the shadows completely away from the casting object. Have you seen this and is there a fix on the way? Using Unity 5
     
  2. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    As mentioned earlier in the forum, 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.
     
    NarkLord likes this.
  3. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Hi NarkLord,

    Yes, as Ben pointed out, this is an issue with Unity's shadow & camera projection matrix implementation and is unfortunately not something I can fix in Camera Perspective Editor. The best way to help is indeed to vote on the bug (in Ben's post).

    Sorry I couldn't offer a more immediate solution.
     
  4. Kamilche_

    Kamilche_

    Joined:
    Jan 11, 2015
    Posts:
    75
    I just bought Camera Perspective Editor for one thing, the lens tilt. However, whenever I set the vertical lens tilt positive, it cuts off the bottom part of the scene; when I set it negative, it cuts off the top part of the scene.

    Do you know what causes this? I'm using Unity 5, and have a camera pointed at an object resting at 0,0,0.

     
  5. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Hi Kamilche_,

    My best guess from your image and description would be that you need to adjust the near and far clip planes. Would it be possible to get a screenshot of this scene from the side, with the camera selected so that I can see CPE's view frustum (the red lines) and how it envelops the boxes object?

    Is the object getting clipped a sprite or a 3D model?

    Thanks!
     
  6. sankalp22

    sankalp22

    Joined:
    Sep 3, 2012
    Posts:
    3
    Hi deram_scholzara ,
    I am facing issue in my project and come to your asset. I am using unity sprites with 3d terrain and my sprites changed as respect of base when moving camera as you can see in screenshots. While finding solution to this problem, i found that it occurs due to perspective distortion.
    So can you guide me if i solve this problem using your asset, if yes than i'll buy it from asset store.
    Thanks!
     

    Attached Files:

  7. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Hi sankalp22,

    First, you might be able to achieve the look you're going for simply by setting the standard Unity camera to Orthographic projection mode, and then rotating it to get the angle you want. For isometric perspectives though (which is what it looks like you're going for), this might cause some squashing of your sprites.

    If you have the squashing issue, you can use Camera Perspective Editor's Lens Shift feature to achieve a true isometric projection that will not squash your sprites. To do this, just rotate your camera to a 45 degree angle on the y-axis, zero out the x & z axes, raise the camera up above the terrain, and then use vertical Lens Shift to shift the frustum downwards.

    There is a sample of this setup included with CPE, and you may even be able to just drop the sample prefab into your scene.

    If you have any more questions, let me know!

    Thanks!
     
  8. sankalp22

    sankalp22

    Joined:
    Sep 3, 2012
    Posts:
    3
    Hi deram_scholzara,
    I can use orthographic camera but i am using 3d objects for environment. So i have to use perspective camera because an orthographic camera ruins advantage of using 3d environment. After some google search, i found that it can be done by change camera frustum like attached image. So is it possible ?
     

    Attached Files:

  9. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    You can do it, but most likely shadows will be incorrect due to a Unity 5 bug. You can vote on the bug below.
     
  10. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    The projection on that drawing is possible, but likely not what you want, as it would result in squashing/uneven foreshortening as things get further away. Try the true isometric approach I mentioned in my previous response.

    Good luck!
     
  11. sankalp22

    sankalp22

    Joined:
    Sep 3, 2012
    Posts:
    3
    @Ben BearFish .. currently i am using Unity 4.6. So may be 4.6 doesn't have that issue.
    @deram_scholzara ... is there any trial version of your asset, so i can try what you suggest me.
    Can you guys help me to get that projection of camera ?
     
  12. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    There is no trial version of Camera Perspective Editor, but I can certainly offer help with getting your perspective set up after purchase. There is also a demonstration video available which shows the perspective trick I believe you need based on your description - it's available here (specifically at 11:12):
     
  13. deram_scholzara

    deram_scholzara

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

    Just announcing that there's been a minor update to Camera Perspective Editor to provide better support for different versions of Unity. The new version is 1.3.7 and release notes are below:

     
  14. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    Regarding this behavior does that mean they now fixed the custom projection matrix issue, or not?
     
  15. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    I had hoped the same (I have my own projects that I'd like this fix for), but unfortunately the shadows still seems to assume an unmodified projection - implying that they only actually updated the Editor code for the Camera component, not any of the other code that uses the camera's projection matrix.
     
  16. spotd

    spotd

    Joined:
    Mar 12, 2014
    Posts:
    4
    I have a problem with using with Touchscript while using orthographic and lens shift. I assume this wont play nicely with Touchscript?
     
  17. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Hi Spotd,

    I havent used Touchscript myself, but my guess is that they implemented their touch hit-detection using Unity's built in raycasting functionality, which does not support modified camera projections. To help with cases like this, I implemented custom versions of the relevant functions in Camera Perspective Editor which are analogous to the built-in functions. These custom functions are intended to allow cases exactly like this one to be fixed :)

    To fix this, you or the developer of Touchscript would simply need to change all references to the following methods in Touchscript's scripts:
    Camera.ViewportPointToRay ---> CameraPerspectiveEditor.ViewportPointToRay
    Camera.ScreenPointToRay ---> CameraPerspectiveEditor.ScreenPointToRay
    Camera.WorldToScreenPoint---> CameraPerspectiveEditor.WorldToScreenPoint
    Camera.WorldToViewportPoint---> CameraPerspectiveEditor.WorldToViewportPoint

    If you need more help, feel free to ask!
     
  18. spotd

    spotd

    Joined:
    Mar 12, 2014
    Posts:
    4
    Thats great thanks I will give this a go soon!
     
    deram_scholzara likes this.
  19. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Great News Everybody!!!

    The issue that many of you have been encountering with shifting shadows when using atypical perspectives has been resolved with a patch for Unity 5.4.0 (tested with beta 8). It will unfortunately not be homogeneously integrated into the Editor until 5.5.0, nor does it sound like it will be resolved for 5.3.x or earlier. That said - it's finally fixed thanks to all the attention you've helped grab from Unity. More details here (note that the claim of a 5.0.x fix is inaccurate): https://issuetracker.unity3d.com/is...asts-it-when-using-a-custom-projection-matrix

    Patch Directions:
    1. You must install Unity 5.4.0 beta (b8 is the latest public release at the time of this writing).
    2. Download the patch: http://files.unity3d.com/florent/Fixes/FixFor686520_ScreenSpaceShadow.unitypackage
    3. Import the patch into your project (just open your project and double click the file, or import it from the Assets menu).
    4. The patch will include a folder named "ScreenSpaceShadows-ForCustomPerspectiveMat". From that folder, attach the script "ReplaceScreenSpaceShadowsShader.cs" to the camera you have Camera Perspective Editor on.
    5. Give it a go!
    6. Report bugs to Unity and here if you run into any.
    Next Steps:
    • I will be integrating this patch directly into a 5.4-only update for Camera Perspective Editor.
      • Since this patch relies on modifying Unity's shadow shader, people who are already modifying their shadows (with custom shaders or Shadow Softener, for example) will need to integrate the patch directly with those modifications.
      • For merging scenarios, I can provide minimal support - you're better off working with the developers of the other shadow-mod shaders.
    • As Unity is expecting to integrate this fix directly into Unity 5.5.0, I will be releasing another update once that version hits beta.
     
    Last edited: Mar 5, 2016
  20. Leeaux

    Leeaux

    Joined:
    Sep 26, 2015
    Posts:
    2
    Deram,

    Hey I love your camera plugin! I was wondering if (currently) there is a way to do what a lens shift does, but with a zoom, in your product? So that it locks the perspective of the shot, but you can zoom into it. Is that a feature it currently has?

    Appreciate any update on this!
     
  21. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Hi Leeaux, I'm not entirely clear on what you mean here, but what you're describing doesn't sound any different from adjusting the Field of View on Unity's Camera component - which is supported along side Camera Perspective Editor.

    If you're asking if you can zoom along with the lens shift, this is also supported, but you'd need to write a simple script that adjusts these values together (instead just just changing them independently).
     
  22. jmcguirk1

    jmcguirk1

    Joined:
    Dec 9, 2016
    Posts:
    1
    Howdy!

    Really a big fan of this package - I'm wondering if you could provide some assistance getting this to work with Unity's UI system - specifically with worldspace UI. What we're seeing is that the raycasts aren't aware of the transformation matrix being applied to the camera.

    We think this should theoretically be possible by creating an extension of GraphicRaycaster that calls into the handy Raycaster modifiers you've added - but are fighting with some of the details and could use some assistance

    Cheers!
     
    DanielLupascu likes this.
  23. Mico27

    Mico27

    Joined:
    Jul 21, 2014
    Posts:
    1
    Hi.
    I've been poking around with this package again recently. It seems there's a bug when I use an orthographic camera with some of the camera perspective editor presets as the OnMouseDown event doesnt seems to fire on my objects in the scene anymore. But if I switch it back to a perspective view or disable the camera perspective editor component, it works fine.
    Any idea why this would happen?

    Thanks.
     
  24. DanielLupascu

    DanielLupascu

    Joined:
    Oct 27, 2015
    Posts:
    5
    Hi,
    Is there any solution to this scenario ?
     
  25. Ced-Remix

    Ced-Remix

    Joined:
    May 2, 2013
    Posts:
    1
    Hey, great work on the package. Very well done!

    Did anyone manage to achieve this perspective? I looked at the video and did quite alot of experimenting but i just couln't get it. It should orthographic along one axis and perspective along the other. In the example in the image here, Moving the camera around would display the top and bottom of 3d objects but never the left and right.

    Anyone have any luck?
     
  26. ikazrima

    ikazrima

    Joined:
    Feb 11, 2014
    Posts:
    320
    I thought of making a purchase and found that it's been deprecated today. Any update?
     
  27. ozymandiax

    ozymandiax

    Joined:
    Nov 25, 2017
    Posts:
    12
    Would love to buy it but it is gone as ikazrima noted.
    Was it removed because of the problems with the UI mentioned above?
     
  28. ikazrima

    ikazrima

    Joined:
    Feb 11, 2014
    Posts:
    320
    Probably because it contains some unity scripts and the author didn't remove it from the package. Same thing happened to Stan's asset. He was last online on June 2017, you'd better off emailing him directly.
     
  29. rrahim

    rrahim

    Joined:
    Nov 30, 2015
    Posts:
    206
    I'm glad this asset was updated for 2019.3, I've always been a fan of what this does.
    I haven't tried using it recently, but how can it be used with Cinemachine? Or would it cause any issues if used with Cinemachine?
     
  30. MattDavis

    MattDavis

    Joined:
    Aug 11, 2013
    Posts:
    16
    Hi, this is for anyone else who had issues using ScreenPointToRay or ViewportPointToRay functions, which do not work correctly for perspective cameras. I don't know much about linear algebra, so there might be a more correct or conventional way to do this, but this seems to work.

    I added a few lines at the end of ViewportPointToRay. Basically rayOrigin is the screen point at the near plane, so I calculate rayEnd, which is the screen point at the far plane, and say that the direction is from near to far.

    Code (CSharp):
    1. public Ray ViewportPointToRay(Vector3 position)
    2.     {
    3.         position.x = (position.x - 0.5f) * 2f;
    4.         position.y = (position.y - 0.5f) * 2f;
    5.         position.z = -1f;
    6.  
    7.         var viewportToWorldMatrix = (customMatrix * thisCamera.worldToCameraMatrix).inverse;
    8.  
    9.         var rayOrigin = viewportToWorldMatrix.MultiplyPoint(position);
    10.  
    11.         // -- Original code, which is incorrect for perspective cameras
    12.         // return new Ray(rayOrigin, viewportToWorldMatrix.MultiplyVector(Vector3.forward));
    13.  
    14.         // -- New code to correct ray direction
    15.         var endPosition = position;
    16.         endPosition.z = 1f;
    17.         var rayEnd = viewportToWorldMatrix.MultiplyPoint(endPosition);
    18.  
    19.         return new Ray(rayOrigin, rayEnd - rayOrigin);
    20.     }
     
    rhys_vdw likes this.
  31. NigameKirabo

    NigameKirabo

    Joined:
    Jul 10, 2017
    Posts:
    1
    update two-point perspective please!!!!:)