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 codejoy · Jul 22, 2014 at 05:39 PM · spritetexturesmask

Dynamically building sprite by using masks in unity

There is this tutorial in imagemagick

http://www.imagemagick.org/Usage/masking/#masks

I was wondering if there was some way to mimic the behavior (like cutting the image up based on a black image mask that turns image parts transparent... )

and then trim that image in game...

trying to hack around with the webcam feature and reproduce some of the imagemagick opencv stuff in it in Unity but I am sadly unequipped with masks, shaders etc in unity skill/knowledge. Not even sure where to start.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by robertbu · Jul 22, 2014 at 05:45 PM

I was wondering if there was some way to mimic the behavior (like cutting the image up based on a black image mask that turns image parts transparent... )

Typically this is done with a shader, but it can be done procedurally. Here is one shader to get you started:

http://wiki.unity3d.com/index.php/TextureMask

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 codejoy · Jul 22, 2014 at 09:07 PM 0
Share

Ahhh, I Actually rolled some code using the texture set/get pixels and got it mostly "working", though I realized I think I am in trouble with this approach not being variant resolution friendly.

$$anonymous$$ostly it is to template a face with a picture you provide, then save the cut out face as a texture to use all over on planes again. Getting the picture you provide to match the face template requires image scaling and that, that where im running into trouble. Scaling a texture to line things up is not trivial it seems. If I could just smack the textures onto a plane and scale those that would be awesome but then I cannot build up the final cutout face texture that way (As scaling the plane with a texture does not scale the texture that I am cutting the pixels from).

I am still researching all this, I have to seriously dive into shaders too...the above code while readable Id have no idea how to implement with little to no shader experience.

Shane

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

Sprite Mask Render Issue 1 Answer

(2D) Rendering only the parts of a sprite that are within specific bounds 3 Answers

Sprite pixels problem on Android with mask 0 Answers

Mask a sprite mask?,Is there anyway to use a sprite mask under a rect mask? 0 Answers

How to mask sprites/animations using alpha channel 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