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 LoneWolf155 · Sep 13, 2012 at 02:12 AM · 2dlightingshaders

2D Lighting With Unity Free

I am currently working on making a 2D game where I want to "simulate" lighting effects that are capable of having multiple light sources in a scene. Now, I'm not looking to create real-time 2D lighting as it doesn't need to be that advanced. What I would like to do is create what appears to be lighting effects using shaders.

I'm wondering if its possible to overlay the screen with a black texture and then place images of a certain color on the screen that alter the alpha of the black overlay based on the use of color in that image. This way, I could not only place multiple lights but also I would be able to alter the black overlay to simulate different areas being darker than others.

I have basically no experience with shaders in Unity, so if this is a silly question then I apologize :D Also, I am using the free edition of Unity for all of this if that affects the answer.

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
0

Answer by PuppyPunch · Oct 08, 2012 at 05:51 PM

If you use a texture targa of a white dot on a black background with an alpha channel the following shader will give you a spotlight effect. Unfortunately, I'm not able to get it to gradient the transparency. However if you change the blend to the one I have commented out, it will go from transparent to black in a gradient, this means that lights cannot overlap though.

If you or anyone knows how to make this go from cutting transparency to just being opaque (i.e. showing the black texture behind it) that'd be awesome.

 Shader "bitmask"
 
 {
 
    Properties
 
    {
 
       _Mask ("Culling Mask", 2D) = "white" {}
 
    }
 
    SubShader
 
    {
 
         Tags {"Queue" = "Geometry"} 
     
         //Blend SrcAlpha OneMinusSrcAlpha
         Blend One One
 
         Pass {
             AlphaTest LEqual 0.9
             SetTexture [_Mask] { combine 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
avatar image
0

Answer by reveriejake · Jun 02, 2013 at 08:19 AM

2D Volumetric Lights on the Asset Store.

And I sell it for only $15. It should be exactly what you need. You can check the light as "Static" to make it non-dynamic.

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

12 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

Related Questions

2D ligting, light cone 2 Answers

2D Sptite Shader Character in 3D World 0 Answers

Multiple lights disable additive intensity for Sprites-Diffuse? 0 Answers

URP Lit 2D Sprite Shader Texture 0 Answers

Limit Amount of Light Applied to Sprite 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