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 radonthetyrant · Mar 14, 2015 at 03:30 PM · c#heightmapblurblurryalpha-channel

Blurring a generated alpha mask

I tried all day to get this work.

So instead of using tilemaps, I want to generate a layer mask for every texture layer which then gets put onto the ground. I managed to generate those layer masks based on the state of a tileGrid (which can change any moment in the game, therefore I want to generate the ground texture on demand)

Problem is, that I can't manage to blur the layermasks. I tried different approaches. I put all my alpha values (8bit) in a 2d-byte field and tried applying various blur algorithms myself, but apparently I lack the skills to implement/copypaste box or gaussian blur myself, because the layermasks always turned black or didn't change at all.

Next, I tried to save the layermasks into a Texture2D. I red somewhere that you can use the mip map technique to blur a texture. But that didn't work either. All attempts to resize and scale back up a layermask turned it to a black texture with 50% alpha channel and I can't track down the error.

Is there any cheap way I didn't find yet which can generate me a blurred version of a heightmap/alphachannel?

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 meat5000 ♦ · Mar 14, 2015 at 03:32 PM 0
Share

You may want to pastebin and link some code. Easier to help.

avatar image radonthetyrant · Mar 15, 2015 at 03:08 PM 0
Share

That was the problem, thanks. I reordered the code and it works with box blur. I had to implement it myself, blurring a Texture2D Source into a Texture2D target. Sad that there is no out-of-the-box mechanism available because it seems rather slow the way I did it :(

avatar image Glurth · Mar 15, 2015 at 05:13 PM 0
Share

slow the way I did it :(

Hmm, do you need to recompute it every time? Perhaps you could generate a dozen or so alpha textures, at startup only, and randomly select one of those when needed.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Glurth · Mar 14, 2015 at 03:39 PM

I put all my alpha values (8bit) in a 2d-byte field and tried applying various blur algorithms...copypaste ... the layermasks always turned black or didn't change at all.

regarding copy/pasting the code for the blur: I suspect/guess the algorithm uses a float value between 0 and 1 to represent the alpha. If you are using 0-255 (8bit), this is going to yield incorrect results. You will need to scale the 8bit number down to 0-1: float alpha= ((float)Alpha8bit)/255.0f;

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

How to procedurally generate a super simple terrain 1 Answer

Renderer on object disabled after level reload 1 Answer

MipMapBias alternative for Android? 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