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 Ceraph · May 16, 2013 at 09:42 PM · 2dlightingtextures

Multiple alpha maps / moving alpha maps

Hello, I'm fairly new to Unity so I'm not even sure if what I want to do is even possible but here goes.

I am making a 2D game and the effect I want to create is to have a black overlay slowly fade in across the screen except for where the player is. The player is able to move horizontally across the screen while the background constantly scrolls down. I had previously achieved this affect by making a static cutout with a transparent gradient in the overlay image and moving it with the player, but it looks like we want to have multiple light sources on the screen at once and this method does not work for that.

My next approach was to create an alpha map for the black overlay and use that for each light source, but I'm not sure how to go about doing that or if it's even possible. The two things I need to be able to do are dynamically create an alpha map and add it to the overlay's material and also move the alpha map independently of the object.

Also if anyone has a better idea of how to accomplish this affect please let me know!

Thank you in advance.

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 DESTRUKTORR · May 16, 2013 at 11:23 PM

You'll need to look into shaders. More specifically you'll want to look into alpha masks. Take a look at unity's documentation for ShaderLab and HLSL (high level shader language). Specifically, take a look at this tutorial. What you need to do is called "alpha masking," or using an alpha channel to clip out sections of the viewport that would otherwise be rendered.

Unity supports alpha masking, but only in cutouts. If you want to have a gradiented effect, you'll need to make a texture and attach it where the cutout occurs. Alternatively, you could just use a standard black-to-transparent gradient texture in front of the camera, which would probably be a lot simpler.

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 Ceraph · May 21, 2013 at 09:01 PM 0
Share

I got the alpha masking to work easily enough, but I've been having a lot of issues getting the gradiented effect to work on top of it. Using a 2D overlay on top of the cutout creates some pixelation around the border where the overlay doesn't match up to the polygons of the sphere. I've been looking into creating a radial transparent gradient with shaders with little success, but I had another thought on creating the effect I want:

Is it possible to have a light affect the alpha of a material ins$$anonymous$$d of the RGB? I'm fairly new to shaders so I'm not entirely sure if that's possible or what that would look like.

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

14 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

Related Questions

Making a sprite totally dark without lighting 1 Answer

Flickering circle of light around character 0 Answers

Why do 2D Lights render past shadowcasters. 1 Answer

ShadowCaster2D not working when Light2D is too close 0 Answers

2D Lantern Lighting Effects/Fog of War 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