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 tonycoculuzzi · Jun 13, 2012 at 06:49 PM · imagememoryblurimage effect

How to blur an image in memory?

Is there a way to blur an image in memory? What I'm doing is capturing the screen, and I'm trying to blur this image, in order to overlay it for a pause screen. The image is only going to be blurred once when pause is hit, not once per frame.

I've tried applying a gaussian blur algorithm but it's very slow. Is there a better way to do this? For example, any libraries or addons I can use? If not, does anyone know of the best way to do this?

Comment
Add comment · Show 9
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 Eric5h5 · Jun 13, 2012 at 07:14 PM 0
Share

You just need to optimize your algorithm; there's no reason why it should be slow. You can do fast, real-time image blurs in web Javascript, so in Unity it should be even faster.

avatar image tonycoculuzzi · Jun 13, 2012 at 07:28 PM 0
Share

That doesn't exactly help me, at all. I've tried multiple different iterations and it's still extremely slow with processing image information. If you know of any solutions or the best practices for doing so, I'd love to hear.

avatar image Eric5h5 · Jun 13, 2012 at 07:34 PM 0
Share

I posted that as a comment rather than an answer for a reason, but you can just google for "fast blur algorithm" or similar.

avatar image Julien-Lynge · Jun 13, 2012 at 07:38 PM 1
Share

Your problem may be in how you're accessing the image information - Are you using GetPixel or GetPixels, and SetPixel or SetPixels? Ideally you want to pull the image information into a large array, apply your filter, and then call SetPixels once to apply the change. If you work with Color32 ins$$anonymous$$d of Color it should be even faster.

avatar image tonycoculuzzi · Jun 13, 2012 at 07:39 PM 0
Share

Ah, I didn't realize SetPixel and GetPixel had much overhead. I'll try this out and post my findings. Thanks! :)

Show more comments

1 Reply

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

Answer by tonycoculuzzi · Jun 13, 2012 at 10:14 PM

To answer my own question:

I got it working by using GetPixels to get all the pixels into a single array. I then turned that array into a 2D array based on the height and width of the input image.

I then processed this array, instead of the image. I found that using GetPixel every iteration had HUGE amounts of overhead, as it was grabbing the info from the GPU every single time. Grabbing the info once and storing it in a 2D GREATLY improved speed.

I then reversed the 2D array into a single dimension array, and used SetImage once, after the loop, to set the image contents. Works great, though going over 20 tends to crash the editor.

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 Julien-Lynge · Jun 14, 2012 at 03:08 AM 0
Share

Great, glad you got it working! I'd definitely suggest trying to modify your blurring algorithm to work with a 1D array rather than copying the bits - ins$$anonymous$$d of using [x][y], you can just as easily use [x + y * width]. The reason for this is that $$anonymous$$ono / .NET is not always good about releasing large chunks of continuous memory when you're done with them - plus it's a potentially unnecessary overhead.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Stippled Shader? 2 Answers

Creating a Blur Effect on GUITexture 0 Answers

What is the best way to make clouds with png images? 1 Answer

Modifying an image effect component over time. 0 Answers

Add Motion Blur To Prefab - HELP 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