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 gotys · Jan 20, 2014 at 05:48 AM · texture2dalphasetpixels

Texture2D setPixels Alpha merging

Hello everyone, I am trying to programmaticaly create a hexagon texture to be later projected onto a terrain. I am running into a problem when trying to tile the individual hex images (each hexagon is a loaded texture with GetPixels, and has alpha transparency) to create the grid. See the attached image for what I am talking about.

alt text

Is there an efficient way to solve the "overlap" problem without having to use SetPixel in a loop ? I really like the SetPixels because it's fast, and don't want to abandom my project because I can't figure out the alpha-overlay problem.

screen_hex.jpg (19.9 kB)
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 gotys · Jan 20, 2014 at 07:13 AM 0
Share

I have just learned that what I need is called "alphablending" and that I am looking for something like Lerp(text1,text2,X) ... anyone has any experience with this ? I don't want to lerp individual pixels - that would be slow I assume.

avatar image robertbu · Jan 20, 2014 at 07:28 AM 0
Share

You have to Lerp() individual pixels. You can be a bit more efficient by using GetPixels32() and deal with Color32 structures. There are both a Color32.Lerp() and a Color.Lerp() depending on the pixel representation you want to use. The algorithm for doing the Lerp() to a color should be pretty straight forward to figure out, but doing the code in-line vs. making the Lerp() calls probably won't buy you much. Try the Lerp() calls first.

avatar image gotys · Jan 20, 2014 at 07:49 AM 0
Share

Thanks a lot Robertbu for your ideas. I noticed there is $$anonymous$$aterial.render.Lerp function. What if I converted my Texture2D into a material, then lerp it, then convert it back to Texture ? Or .. can I somehow use Shaders to generate Texture2D ? I think shader-based Alphablends would be faster ?

0 Replies

· Add your reply
  • Sort: 

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

18 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

Related Questions

Painting stencil on a surface. 6 Answers

Setpixels creates gradient texture instead of raw colored pixels 1 Answer

SetPixels32 On A Sprite In Texture2D Atlas 0 Answers

Changing color of texture with transparency efficiently 0 Answers

SetPixels and ExportToPNG - Alpha value missing?, 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