Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
12
Question by noflyzone · Sep 19, 2011 at 06:07 AM · screen

Screen VS Viewport What is the difference

In unity3d, what is the "Screen", "Viewport"? "Screen" image is not on the "Viewport" is a Camera on it? Learn unity3d friends, to explain, in unity3d in, "Screen", "Viewport", respectively, what is meant by the concept? "Screen Point", "Viewport Point", "World Point", What is the difference? Camera.ViewportToScreenPoint (), Camera.WorldToScreenPoint () What is the difference (in my opinion is the same, all the points in 3D space projected on the Screen, oh no difference?)

Screen VS Viewport What is the difference

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
39

Answer by Paulius-Liekis · Sep 19, 2011 at 07:58 AM

Screen and Viewport represent same area - on screen, but they have different coordinate systems (IIRC):

  • Screen: from [0,0] to [Screen.width, Screen.height]

  • Viewport: from [0,0] to [1,1]

World point is a point in world space.

edit(Bunny83)
I just fixed the Viewport coordinates. It's [0,0] to [1,1] and not [-1,-1] to [1,1]. The latter are homogeneous device coordinates. This is the space where the GPU actually clips the geometry against the frustum. The result of the projection matrix outputs homogeneous coordinates.

A simplified version of the pipeline is:

 local space   [-inf, -inf] to [+inf, +inf]
     \/                                     -- localToWorld (Model)
 world space   [-inf, -inf] to [+inf, +inf]
     \/                                     -- worldToCamera (View)
 camera space  [-inf, -inf] to [+inf, +inf]
     \/                                     -- projectionMatrix (Projection)
 clip space    [  -1,   -1] to [   1,    1]
     \/                                     
 view space    [   0,    0] to [   1,    1] \
     \/                                      -- handled by GPU / driver
 screen space  [   0,    0] to [   W,    H] /

In all cases [0,0] is the bottom left. This only handles normal geometry. The GUI space is a special case where the camera space has to invert the y axis, hence it starts at the top left.

Comment
Add comment · Show 7 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image noflyzone · Sep 19, 2011 at 09:19 AM 0
Share

In unity3d, why this design? Viewport In what circumstances is used?

avatar image Paulius-Liekis · Sep 19, 2011 at 11:29 AM 1
Share

I don't think it's Unity specific design - these are common terms in 3d graphics. Viewport might be useful if you want to check if something is on-screen (you don't care about Screen size), but I'm sure there are better exampled.

avatar image syclamoth · Sep 19, 2011 at 11:49 AM 1
Share

Viewport is used when you need to be sure something will show up the same on all different screen sizes and shapes. It is independent of the pixel width and height of the exact screen in question.

avatar image RedRival · Dec 19, 2012 at 03:44 AM 7
Share

Correction Viewport: from [0,0] to [1,1] Quote: Viewport space is normalized and relative to the camera. The bottom-left of the camera is (0,0); the top-right is (1,1). The z position is in world units from the camera. http://docs.unity3d.com/Documentation/ScriptReference/Camera.ViewportToWorldPoint.html

avatar image Jonathan-Bro · Dec 08, 2016 at 04:58 AM 1
Share

Hoping that people also check the comments. Just to reiterate what @redrival said.

The bottom-left of the camera is (0,0); the top-right is (1,1)

See Link for image

Show more comments
avatar image
3

Answer by Priyanka-Rajwanshi · Mar 03, 2020 at 06:05 PM

Screen point is defined in pixels. The bottom-left of the screen is (0,0); bottom-right of the screen is (Screen.width,0), left-top is (0, Screen.height) and the right-top is (Screen.width,Screen.height).

A viewport space point is normalized and relative to the Camera. The points on the screen range between 0 and 1. You can determine the the x-coordinate by dividing the screenPoint.x by Screen.width and the y-coordinate by dividing the screenPoint.y by Screen.height.

For more information, check out the link http://codesaying.com/understanding-screen-point-world-point-and-viewport-point-in-unity3d/

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Raycasting Accurately with gun 2 Answers

RenderTexture to capture an area bigger than Screen on IOS 0 Answers

How do you clamp a camera by mobile width? 2 Answers

Get the borders of screen 1 Answer

instantiate object at the edge of screen 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges