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
0
Question by Khena_B · Jan 19, 2018 at 05:54 PM · scalerendertextureaspect-ratiopostprocessblit

Graphics.Blit scale

Hey,

Just learning about Blit and wondering if it's possible to scale it so that it doesn't stretch to fill the whole screen and stay at a fixed aspect ratio instead?

My game is rendered to a low res rendertexture and then blitted to screen, but i want it to stay 16:9 regardless of screen resolution.

Thanks

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

1 Reply

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

Answer by Bunny83 · Jan 19, 2018 at 06:40 PM

In short: No. Graphics.Blit will always draw a fullscreen rectangle. So it will always fill the entire screen / area of the destination. RenderTexture.


However you can scale the incoming texture by using the scale parameter. So you can render a part of the source texture to the full destination texture.

Comment
Add comment · Show 3 · 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 Khena_B · Jan 19, 2018 at 06:48 PM 0
Share

Thanks, could you provide a simple example of how to scale the inco$$anonymous$$g texture?

avatar image Khena_B · Jan 19, 2018 at 07:44 PM 0
Share

I think i deleted one of my comments at the same time you posted a reply, here's what you wrote:

Well, i haven't really used Blit that much. However to get the same result you currently get you have to pass a scale of (1, 1) and an offset of (0, 0). I'm not sure in which order the scale and offset are applied but usually the scale is applied first and the offset is added afterwards. I also don't know where the origin is located, but since we talk about UV coordinates 0,0 should be the bottom left, and 1, 1 should be the top right corner. In theory if you have a square source image and you want to cut the top and bottom to get a 16:9 ratio you would do something like: scale = new Vector2(1f, 9f/16f); offset = new Vector2(0f, -(1f-9f/16f) 0.5f) This is pure speculative. $$anonymous$$aybe the offset need to be positive, if the origin is the screen center the offset need to be 0, 0*

I messed around with the scaling and offset and the issue is that it stretches the borders to fill the empty space which doesn't look good, I played around with the camera's viewport rect settings ins$$anonymous$$d and it does the same thing and has nice black bars, I just need to figure out the equation and that should work.

Thanks!

avatar image Khena_B · Jan 19, 2018 at 07:51 PM 0
Share

For some reason Unity Answers is ignoring paragraphs and clumping everything together, i'm sorry about the mess.

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

76 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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

Where to Graphics.Blit()? 1 Answer

How would you efficiently access the last N rendered frames every frame? 2 Answers

fit spriterenderer image to screen after change aspect ratio 0 Answers

RenderTarget in scripts 0 Answers

how to make grid of buttons always fit parent? 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