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 NinjaSquirrel · Jan 08, 2012 at 06:49 AM · texturearrayperlin

How do I add up Color Values of Textures with Different Resolutions?

How do I add up the black and white color values of textures with different resolutions?

Example:

alt text + alt text = alt text

NOTE: these textures are their apparent resolutions; I have just resized them for visualization.

We will need to find the color array of the first image, and somehow "add" it to the color array of the second image, and so on until complete. Then, store the final color values array.

The resolution of the highest resolution image will always be the resolution of the final product image, of course.

Does anyone know exactly how to do this?

Thanks.

Comment
Add comment · Show 3
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 syclamoth · Jan 08, 2012 at 07:05 AM 0
Share

I think what you're actually doing here is 'subtracting', but that's beside the point.

avatar image NinjaSquirrel · Jan 08, 2012 at 07:06 AM 0
Share

And how so?

avatar image syclamoth · Jan 08, 2012 at 07:11 AM 0
Share

Well, it's subtraction because white is (1, 1, 1) and black is (0, 0, 0). If you were doing addition, the last square would be entirely white, except for those few places where there are a black part on a grey part (which would be grey).

No wait, that's wrong. I'm not quite sure what operation is going on there! It's not addition, not subtraction, not even multiplication or division! I think what's going on there is

 image2 = image0 < image1

image 2 takes the darkest parts of each input image.

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by syclamoth · Jan 08, 2012 at 07:06 AM

Just out of interest, why are you doing this? In any case, I'd assume that the correct method would be to scale up the smaller images and then just add the images in whatever way you choose (shader, manual addition on every element of the color array, etc.).

To resample the texture, you could create a new texture, and then use

 newTexture.SetPixel(x, y, oldTexture.GetPixel(x / 2, y / 2));

for each pixel in the new texture. I'm pretty sure this would be quite slow.

Another option would be to use a shader for this. Is there any reason why you can't just use a subtractive shader that takes several texture inputs?

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 syclamoth · Jan 08, 2012 at 07:15 AM 0
Share

Basically, just use a shader. It's the graphics card's job to do this kind of work, so you may as well use it!

avatar image NinjaSquirrel · Jan 08, 2012 at 07:16 AM 0
Share

I am using this to add up multiple octaves for a perlin noise function.

EDIT: Oh, I see what you mean there ;)

I will be dealing relatively small resolutions (

As for using a shader, I may look into that. I am not very knowledgeable with shaders yet, however.

avatar image syclamoth · Jan 08, 2012 at 07:35 AM 0
Share

Nobody is very knowledgeable about shaders. (or at least, if someone is, they keep their knowledge to themselves!) If you learn them, they'll be very useful to you.

The reason I recommend using a shader is because as far as I know, shaders can automatically resample input textures.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Null Reference Exception After refering to an Array 1 Answer

Exception: not implemented? 2 Answers

Creating Perlin Noise 2 Answers

Why does Perlin-generated Texture lose gradient when with colour? 1 Answer

Link image sequence to an array 2 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