Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
4
Question by soundwav_ · May 07, 2013 at 08:33 PM · textureplanemaskoffsetclipping

Masking a plane object (which has an animated texture offset)

Hello, I have a plane with a material that has an animated texture offset, and I would like to mask out part of that plane.

  • I tried different shaders, but the invisible area seems to move along with the offset...

  • I tried with an additional camera (ortho) + culling mask, but the mask gets resized in different aspect ratios and it looks wrong...

Is there a way that I'm missing to clip the plane so the result will be something like the image below?

Imagine the black screen as the entire game view, and the Plane is just a normal plane with a repeating texture and animated offset... the Visible Area is what is actually being rendered, and the darker area of the plane is not being rendered at all. I made it darker here just for illustration purposes.

Thanks for any help and insights!

alt text

unityissue.gif (34.5 kB)
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
3
Best Answer

Answer by kilgore · May 07, 2013 at 11:34 PM

You need a shader that uses one texture to display the image and uses one texture as an alpha. Below is an Unlit example. "Base" is used for the image you want to animate and BaseA is your alpha.

  Shader "Unlit/TransparentSeperateAlpha" 
     {
         Properties 
         {
             _MainTex ("Base", 2D) = "white" {}
             _MainTexA("BaseA", 2D) = "white" {}
         }
     
         SubShader 
         {
             Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
             LOD 100
         
             ZWrite Off
             Blend SrcAlpha OneMinusSrcAlpha 
     
             Pass 
             {
                 Lighting Off
                 SetTexture [_MainTex] 
                 { 
                     Combine texture
                 }
                 SetTexture [_MainTexA]
                 {
                     Combine texture * previous
                 
                 }
             }
         }
     }
Comment
Add comment · Show 4 · 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 soundwav_ · May 08, 2013 at 01:00 AM 0
Share

Thanks, kilgore! You're awesome. Works like a charm!

Just out of curiosity, are there any optimization for mobile for that shader? Because I did notice that Unity has $$anonymous$$obile-Unlit and regular Unlit shaders (for example).

I do get 55-60fps on my scene on iPhone4/iPad2, still haven't checked on 3GS. Thanks!

avatar image kilgore · May 08, 2013 at 01:23 AM 0
Share

To be honest I know little about shader optimization. This comes from a source I had searched a good while ago to solve the same issue. If someone on Answers is willing to post a 'mobile' optimized version of the above script I'd be more than happy to give some karma.

avatar image kilgore · May 08, 2013 at 01:26 AM 0
Share

By the way sounwav_, really nice use of a gif to explain your question! I appreciate the effort in putting that together to pinpoint your problem.

avatar image soundwav_ · May 08, 2013 at 01:28 AM 0
Share

Yeah, I thought it would explain the issue best :) Thanks!

Hopefully I won't be needing an optimization for the 3GS, but I will try to read-up on shader optimizations in the near future.

And thanks for the great answer!

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

15 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

Related Questions

X-raying plane to see underneath 1 Answer

How can I make a scratch card type of effect in unity 1 Answer

mainTextureOffset not updating via script 1 Answer

Reading a masked texture? 0 Answers

SkinnedMeshRenderer offset UVs to match texture atlas? 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