Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by doukOmega · Feb 17, 2015 at 10:27 AM · render textureunitypro

Weird problem with render texture.

Hello there guys.

I just bought unity3d pro because i was in great need of the render texture effect.

My project at the moment needs to have 4 render textures that will be handled to create the content of the application.

I have 4 cameras that will pass the available data to be shown to those RTs.

Though i was in need to create the cameras fit in some specified aspect ratios.

So i applied this code to all of the cameras when the game is starting to initialize them.

 /// <summary>
     /// Determine the size of the camera depending on the aspect ratio that we need.
     /// </summary>    
     public static Rect CameraViewPortRect(Camera c, Vector2 pageSize)
     {
         Rect rect = c.rect;        
 
         // set the desired aspect ratio.
         float targetaspect = pageSize.x / pageSize.y;
 
         // determine the game window's current aspect ratio.
         float windowaspect = (float)Screen.width / (float)Screen.height;
 
         // current viewport height should be scaled by this amount
         float scaleheight = windowaspect / targetaspect;
 
 
         // if scaled height is less than current height, add letterbox
         if (scaleheight < 1.0f)
         {
             rect = c.rect;
 
             rect.width = 1.0f;
             rect.height = scaleheight;
             rect.x = 0;
             rect.y = (1.0f - scaleheight) / 2.0f;
 
             c.rect = rect;
         }
         else // add pillarbox
         {
             float scalewidth = 1.0f / scaleheight;
 
             rect = c.rect;
 
             rect.width = scalewidth;
             rect.height = 1.0f;
             rect.x = (1.0f - scalewidth) / 2.0f;
             rect.y = 0;
 
             c.rect = rect;
         }
         return rect;
     }


When i do so it means that i have the cameras that will pass the parameters to the render texture properly initialized. My cameras are orthographic with a size of 1.495 !

Those are the settings of all four RTs that will exist on my scene. alt text

The modifications on the camera lead to the following result: alt text

What i really cannot understand is the following result on the target geometry quad / plane that render texture is applied:

rt.jpg (17.1 kB)
cameraa.jpg (46.8 kB)
Comment
Add comment · Show 1
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 doukOmega · Feb 17, 2015 at 09:38 AM 0
Share

http://imageshack.com/a/img537/7224/4Qz9Hd.jpg

Sry for the comment like continuation of the post.

Well what i wanted though was to be able to have my render texture fit on the surface that is applied. And i cannot find a way that this can be done.

And secondly it behaves as if it ren renders a part of the camera that is applied onto. That means that this area in red that is in the center of the quad is a PART of the rescaled camera.

I cannot figure why it is behaving that way.

0 Replies

· Add your reply
  • Sort: 

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

2 People are following this question.

avatar image avatar image

Related Questions

Project collaboration between free and pro users? 0 Answers

how do you apply a render texture to an object? 1 Answer

Portal effect using render textures: how should I move the camera? 2 Answers

Converting textures to video or frames 0 Answers

Save RenderTarget (Color Format: Depth) into a png as a heightmap 0 Answers


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