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
1
Question by Gentle-Troll · Oct 29, 2014 at 08:39 PM · 2ddynamicmasking

How to implement a movable (!) 2D mask?

Hi everyone,

we've been working on a little side project over the last years called "Die Brille" ("The Glasses"), which is a small interactive book app for kids. We've build a small Flash/AIR based prototype quite a while ago but since Flash has become mostly irrelevant for our daily work and we've picked up Unity, recently, we're currently evaluating to port the app over.

But we've already hit our first wall and I'm hoping some of you guys can point us to a good solution for what we're trying to do here, since the web didn't have much to offer for our apparently rather specific needs:

As you can see in the GIF above, we have a layer containing a background (the one with the lollipops) with 2D animations on top (the little helicopter thingy), covered by another image (the one with the roses). On top of that we have a PNG that's actually just a frame of a giant pair of glasses. This frame can be moved up and down with a slider.

Now, what we need to achieve in Unity is, that the image that covers the animations (the one with the roses) be masked away dynamically from the pair of glasses upward following the shape of the glasses and, thus, uncovering the animations behind it.

We've found some approaches on this forum all of which didn't seem to be doing exactly what we were looking for. Most of them involve shaders, but giving them a try we never managed to move the mask dynamically and keep the images in position (we're quite new to shaders, I admit).

Using two cameras doesn't seem to be an alternative, either. It was mentioned that this would cut down on performance tremendously.

We've found an approach that somewhat works with a simple line from left to right, but it seemed to dim down the whole image and we'd need something that works with a custom shape - the glasses (bitmap or polygon based).

So, if anyone has an idea how we could make this work we'd be very glad to hear about it!

Thanks a lot.

Michel

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by robertbu · Oct 29, 2014 at 10:19 PM

How about using an alpha cuttoff mask? The mask will be graduated from black to white and follow the shape of the glasses. You can get most of what you need by examining the answer and the package provided:

https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=unity3d%20circular%20progress%20bar

Also I would not be quick to discount a second camera.

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
avatar image
0

Answer by Gentle-Troll · Nov 03, 2014 at 10:31 AM

Thanks, @robertbu. We've evaluated the suggested solutions and build a small prototype. With the examples suggested in the links you listed, it all seems to boil down to a Photoshop problem, essentially. But I guess, we'll figure that out as well. I'll post an update once we've got it all working smoothly.

[UPDATE 6.11.:] So, once we knew what to look for, we came across this Unity Answers post, which links to a lifebar template. After analyzation of the template, we eventually managed to create the following image with illustrator and saved it as alpha mask within the covering image (the one with the roses). The final image with the mask needs to be in TIFF format:

Image used as alpha mask

It now works exactly as desired and performs pretty well even on iPad 1.

Thanks again @robertbu for pointing us into the right direction.


alphamask.png (24.9 kB)
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

2 People are following this question.

avatar image avatar image

Related Questions

Unity 2d Dynamic UI text not rendering on Canvas 0 Answers

Hiding a sprite partially (shader? masking?) 0 Answers

Deform sprite using SkinnedMeshRenderer 0 Answers

Sprite Mask that only affects child 0 Answers

Mask Component Missing 0 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