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
2
Question by Kaji-Atsushi · Nov 14, 2013 at 07:17 AM · 2dspritesmask4.3

How to mask sprites in 4.3?

Hello, so lets say I have a scene with a few sprites. And I have a sprite wall on top of them. Is it possible to mask a portion of the wall out to...let's say make a window? This is just an example scenario. I was thinking I would have to use sorting layers and set a sprite with some special shader that overlaps the sprite and...does something.... Any guidance into this task would be great help. Thanks!

alt text

Comment
Add comment · Show 1
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 tkshredder · Dec 13, 2013 at 12:28 AM 0
Share

Hi $$anonymous$$aji, do you have a sample demo of this? I'm looking to accomplish something similar, although in my case, I just need 1 sprite per masking mesh. An example would be the "all-out attack" screens in Personas 3 and 4.

2 Replies

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

Answer by Kaji-Atsushi · Nov 25, 2013 at 11:55 PM

Well, the only way that I found so far is to procedurally create the Mesh Shape, and create the Mesh Shape Inverse, Apply a depth mask shader to the Inverse Mesh Shape, create a secondary over-lay camera that only sees the sprites and procedurally generated meshes. and set the z-depth accordingly, Sprite , Inverted Mesh on top.

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 bfowle · Jan 26, 2014 at 06:33 PM 0
Share

Hello, I was wondering if you would be willing to share how you achieved this a bit more in depth. Sprite masking (cutout) seems rather simple, but mask-showing is a bit more involved. Thanks, cheers~

avatar image
0

Answer by Bogotoff · Dec 18, 2013 at 02:35 PM

 Shader "Transparent/Mask" {
         // by moffatjason.
     Properties 
     {
         _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {}
         _Cutoff ("Base Alpha cutoff", Range (0,.9)) = .5
     }
     SubShader {
         // Render the mask after regular geometry, but before masked geometry and
         // transparent things. 
         Tags {"Queue" = "Geometry+10"}
         // Don't draw in the RGBA channels; just the depth buffer
         ColorMask 0
         ZWrite On
         Pass 
         {
             AlphaTest LEqual [_Cutoff]       
             SetTexture [_MainTex] {
                 combine texture * primary, texture
             }
         }
     }
 }
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

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

Related Questions

Alpha masking multiple 2D Sprite GameObjects with 1 Sprite GameObject 0 Answers

Sprite Masks not working in Build 0 Answers

Crop/Mask a Sprite on runtime 0 Answers

Sprites Mask with Custom Range not working after build 2 Answers

Deform sprite using SkinnedMeshRenderer 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