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 EpikOwnage · May 10, 2010 at 11:28 AM · texturegraphicstexture2dprocedural

Procedurally combine (merge) two Texture2D

Hello Unity users,

I am currently trying to combine two textures into one, by script.

The main texture is a procedurally generated texture (makes random pixels at random position, some kind of colored perlin noise). I've got another texture, which is a grid (represented by white pixels) on a black background. Let's say they're both 256*256.

  • I through of getting every white pixels coordinate of the grid texture and reassigning them to the main texture, but It would be alot of work repeating 256 times an action, and I would like to chose the texture size as a variable. (maybe we could use "for"? but I really don't know how to use it so I gave up)

Another way I was thinking about was use of alpha maybe?

Could someone please help me? It would be great.

Regards -Alex

Examples:

Perlin Texture: alt text

Grid Texture: alt text

Comment
Add comment · Show 2
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 taoa · May 10, 2010 at 02:43 PM 0
Share

Are you sure you want to do this in a script? You could obtain the same result much faster using a RenderTexture (if you can, i.e. if you're on Pro) and your Graphics Card.

avatar image EpikOwnage · May 11, 2010 at 02:11 PM 0
Share

I have Indie so I can't. Anyway, speed is not a problem as it do this at loading, with alot of other calculatings :)

2 Replies

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

Answer by Mike 3 · May 10, 2010 at 12:28 PM

in js:


var cols1 = tex1.GetPixels();
var cols2 = tex2.GetPixels();
for(var i = 0; i < cols1.Length; ++i)
{
    cols1[i] += cols2[i];
}
tex1.SetPixels(cols1);
tex1.Apply();

that will do an additive sum of both images (so will be white where the grid is white), then put it back into the first texture

it should be pretty easy to adapt it to any other style you like

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 EpikOwnage · May 10, 2010 at 01:02 PM 0
Share

Thank you, works greatly! :D For those who would like to use this, remember to set textures to ARGB32 and "Is readable"

avatar image
1

Answer by golgauth · May 20, 2010 at 04:00 PM

Try this :

http://www.aforgenet.com/framework/features/

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 cupsster · Jan 10, 2011 at 12:15 AM 0
Share

works with Indie?

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

No one has followed this question yet.

Related Questions

Texture sampling - clamping to a border color 0 Answers

Alternative for Graphics.CopyTexture() ? 2 Answers

What are possible causes and solutions to randomly garbled textures on standalone builds? 1 Answer

background picture in my game 1 Answer

Change Material settings through script 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