• 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
Question by pelaezjorge · Sep 02, 2021 at 11:13 PM · graphicsrendertextureblitblitting

How Blit internally works?

I'm using Blit to resize a small RenderTexture into a bigger RenderTexture, and got good results. But I would like to know what is happening behind the scenes. Assuming both RT have same parameters but width and height...

Does Blit result in a nearest neighbor resize?
Or it interpolates somehow (bilinear, bicubic, etc)?
The resize method depends on RenderTexture/Graphics/Pipeline configuration?
It's behaviour is platform dependant?

I tried to research it online but I didn't get any useful information... Maybe I'm formulating the wrong questions.

Thank you!

Comment
andrew-lukasik

People who like this

1 Show 0
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

  • Sort: 
avatar image
Best Answer

Answer by renderist · May 27, 2022 at 01:39 PM

When you execute Blit() without a specified shader Unity will use one of its built in shaders, Internal-Blit*.shader.

You can find the built in shader package here under the Downloads popup for each platform: https://unity3d.com/get-unity/download/archive

The blit shaders are in the DefaultResourcesExtra folder.

For resizing operations Blit() will use bilinear interpolation - that is the default interpolation method used when sampling textures with tex2d().

Comment
pelaezjorge

People who like this

1 Show 0 · 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

Answer by Bunny83 · Sep 03, 2021 at 09:03 AM

The exact implementation is of course not know. However when you read the documentation you should get all the information you're looking for.

Copies source texture into destination render texture with a shader.

Blit sets dest as the render target, sets source _MainTex property on the material, and draws a full-screen quad.

So the result depends on the settings of the source texture as well as the used material / shader. We don't know what default material / shader is used when none is provided. Though it probably will do a usual bilinear interpolation.


I know your question was specifically about rendertextures. However if you want to rescale a Texture2d, I've written a CPU based bilinear texture sampler.for this question over here. Note that the TextureTools.cs on my dropbox now also contains a version that does apply a letterbox instead of cropping parts of the image.

Comment
andrew-lukasik

People who like this

1 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 pelaezjorge · Sep 05, 2021 at 01:34 AM 0
Share

Blit can be called without shader/material, so I suppose there is a default unknown material... There is also the possibility of Unity relying on GPU specific software or hardware for blitting. Thats why I asked...

May I ask why is probably a bilinear interpolation? Also, thank you for the script, but it would be too slow for our requirements, as it executes on CPU.

Thank you for your answer!

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

136 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 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

Rendering a screen aligned quad with Graphics.blit - not working? 0 Answers

dynamic hole in layer / texture / camera 0 Answers

Using Graphics.Blit with the same source and destination 1 Answer

Blitting a Texture once 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