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 hd27 · Dec 09, 2014 at 03:18 PM · mergemerging

Merging 2 Textures Into 1

I am trying to merge two textures into one with little sucess. One texture is a border with a UI mask in the middle and the second texture is a picture of the user, taken with the camera of a mobile device. When the user takes the picture it is saved as a photo of him togther with the border. The problem is, I cant really understand who merging 2 textures work. I get an image but the colors are blurry. This is the code I am using:

 public class MergeTextures : MonoBehaviour {
     
     public RawImage image;
     public Texture2D tex1;
     public Texture2D tex2;
     
     public void Merge()
     {
         Color[] tex1Pix = tex1.GetPixels();
         Color[] tex2Pix = tex2.GetPixels();
         
         int width = (tex1.width >= tex2.width) ? tex1.width : tex2.width;
         int height = (tex1.height >= tex2.height) ? tex1.height : tex2.height;
         
         Color[] biggerArray = (tex1Pix.Length >= tex2Pix.Length) ? tex1Pix : tex2Pix;
         Color[] smallerArray = (biggerArray == tex1Pix) ? tex2Pix : tex1Pix;
                 
         for(int i = 0; i < smallerArray.Length; i++)
             biggerArray[i] += smallerArray[i];
         
         Texture2D photo = new Texture2D(width, height);
         photo.SetPixels(biggerArray);
         photo.Apply();
         
         image.texture = photo;
         image.SetNativeSize();
     }
 }

I will appreciate any help!

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 termway · Dec 10, 2014 at 05:45 PM 0
Share

I don't know what you really want to do but you should take at look at http://homepages.inf.ed.ac.uk/rbf/HIPR2/arthops.htm and http://wiki.unity3d.com/index.php/Blend_2_Textures

You should use texture of same size if you want to use 1D pixels array or loop on 2D array by using GetPixel(int x, int y)

PS : Images are worth 1000 words, especially here

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by thepenguinmaster · Dec 10, 2014 at 06:47 PM

Graphics.BlitMultiTap or Graphics.Blit will definately do the trick. You will want to take your materials and transparencies into consideration. For transparency possibly use a decal material when using Graphics.BlitMultiTap.

Just as a warning this will reuire pro.

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

27 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

Related Questions

Why are m_SizeDelta and m_AnchoredPosition values changing in scene file for no reason, complicating merge? 3 Answers

How can i merge mesh vertices using a script? 2 Answers

How to merge 2 projects into one 1 Answer

solve merge conflict in unity collab 1 Answer

When I merge 2 objects it spawns 2 objects 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