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
2
Question by MestR · Jun 24, 2011 at 12:47 PM · camerarenderingrenderrect

How do I render only a part of the cameras view?

How can I render only a part of the camera? Like camera.rect but it only render the visible areas, and doesn't squeeze the remaining.

I have tried rotating the camera while using camera.rect, but it deforms the image.

Comment
Add comment · Show 3
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 aldonaletto · Jun 24, 2011 at 02:20 PM 1
Share

The camera renders everything is visible in its view angle (or fustrum, to be more precise). What exactly do you wanna do? Draw only selected objects? Zoom in some specific part of the screen?

avatar image SilverTabby · Jun 24, 2011 at 02:45 PM 1
Share

You can set the camera to only render certain layers by unchecking the layers you don't want rendered in the "culling mask" field , but I'm unsure if that is what you are looking for.

Some more details would be nice.

avatar image MestR · Jun 24, 2011 at 07:35 PM 0
Share

No that's not what I needed, but thanks anyways for the comments.

2 Replies

· Add your reply
  • Sort: 
avatar image
7
Best Answer

Answer by Jayde · Jun 24, 2011 at 07:50 PM

It sounds like what you're looking for is a scissor rect instead of a viewport rect. You can simulate a scissor rect using a viewport rect by multiplying a scale and offset matrix into your projection matrix.

scissor recting forum thread

 public static void SetScissorRect( Camera cam, Rect r )
     {        
         if ( r.x < 0 )
         {
             r.width += r.x;
             r.x = 0;
         }
         
         if ( r.y < 0 )
         {
             r.height += r.y;
             r.y = 0;
         }
         
         r.width = Mathf.Min( 1 - r.x, r.width );
         r.height = Mathf.Min( 1 - r.y, r.height );
              
         cam.rect = new Rect (0,0,1,1);
         cam.ResetProjectionMatrix ();
         Matrix4x4 m = cam.projectionMatrix;
         cam.rect = r;
         Matrix4x4 m1 = Matrix4x4.TRS( new Vector3( r.x, r.y, 0 ), Quaternion.identity, new Vector3( r.width, r.height, 1 ) );
         Matrix4x4 m2 = Matrix4x4.TRS (new Vector3 ( ( 1/r.width - 1), ( 1/r.height - 1 ), 0), Quaternion.identity, new Vector3 (1/r.width, 1/r.height, 1));
         Matrix4x4 m3 = Matrix4x4.TRS( new Vector3( -r.x  * 2 / r.width, -r.y * 2 / r.height, 0 ), Quaternion.identity, Vector3.one );
         cam.projectionMatrix = m3 * m2 * m; 
     }    


Comment
Add comment · Show 1 · 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 MestR · Jun 24, 2011 at 09:26 PM 0
Share

Thanks, I'll try it now! :)

avatar image
0

Answer by rohankad · Sep 15, 2015 at 05:36 AM

Ocullision Culling will help you out. It renders the objects which are available in the range of camera.

Comment
Add comment · Show 1 · 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 routitsm · Mar 28, 2018 at 09:49 AM 1
Share

Occlusion culling is something different. He wants part of the screen to render is sounds.

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

12 People are following this question.

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

Related Questions

Changing the Camera viewport rect results in resizing the objects rendered by the specific camera ? 1 Answer

Rendering players per camera 1 Answer

Render group of objects in front? 0 Answers

Can two cameras render at different speeds? 1 Answer

How do I force my cameras to render in a certain order in URP? 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