• 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
Question by Thevet · Jun 03, 2012 at 12:59 PM · lightinglightspotlightpoint light

Is it possible to create a torus-/ring-shaped light? If so, how?

As the title says. I've been searching Google, but I can't get my head around it. Thanks in advance!

Comment
Fattie
BiG

People who like this

2 Show 2
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 kolban · Jun 03, 2012 at 01:07 PM 0
Share

What is your goal? How large relative to the scene do you want the light? You can create a torus and give it an "emit" texture. This won't cast any new light but it will "appear" that the torus is a source of light. You can then place a point light in the center of the torus to actually cast a light. This will be a "close" notion.

avatar image Thevet · Jun 03, 2012 at 04:34 PM 0
Share

I'm looking to create a ring of light inside a very dark scene that keeps expanding around the player, but also travels across any mesh it touches. Prototype 2's ping function is a good represenation of what I'm trying to achieve. I've been advised to use lighting, but if you have any other suggestions, please tell. Sorry for the unclear question.

3 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Fattie · Jun 03, 2012 at 04:43 PM

It sounds like what you want is not "A LIGHT FITTING" (like "a chandelier")

What you want is like "SOME LIGHT FALLING ON STUFF"

In other words if I pointed a spotlight on a floor, that would be a "circle of light" on the floor -- what you want is a "donut of light"

Is that correct?

If so, I have your answer. You have to learn about "Projectors"

If you look at blob shadows, that is exactly what a projector is.

In your project, look around for the free standard assets that unity gives you.

Add a projector, blob shadow. In fact, ther eis indeed one that is a "shadow" (it's dark) and there is one that is a "light blob" .... which is exactly what you are asking for, I believe.

the only difference is you want a particular shape (a donut) rather than just a circle.

From here, you will have to do the work to figure out how to make it your own custom shape! I hope, that helps!


FTR earlier answer,

Just use a "self-illuminated shader"

http://unity3d.com/support/documentation/Components/Built-in%20Shader%20Guide.html http://unity3d.com/support/documentation/Components/shader-SelfIllumFamily

Comment
Thevet
Wolfram
whydoidoit
BiG

People who like this

4 Show 2 · 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 Thevet · Jun 03, 2012 at 04:51 PM 0
Share

Then looking into projectors it is. Thank you very much.

avatar image Wolfram · Jun 03, 2012 at 06:48 PM 2
Share

Nice catch, none of us understood what he was trying to do ^^

Actually, for light sources, there is already a Unity feature dedicated to this, called "Light Cookie". It's an alpha texture that's applied directly to the light source, so there's no need to fiddle around with Projectors: http://unity3d.com/support/documentation/Components/class-Light.html

avatar image

Answer by Mortoc · Jun 03, 2012 at 01:29 PM

If you don't need the light to move in the scene, make a mesh torus, give it a light emitting material and bake it with the lightmapper. If you do need the light to change in the scene, give it a point light in the middle. An area based light is too complicated to run at runtime (at the very least without some complicated shader-fu)

Comment
whydoidoit
Thevet

People who like this

2 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 Thevet · Jun 03, 2012 at 04:36 PM 0
Share

My light is supposed to expand around the player, but also travel across any mesh it touches, much like Prototype 2's ping function. Would a similar approach work for this? Sorry for the unclear question.

avatar image

Answer by MonolithBR · Oct 20, 2022 at 08:30 PM

alt text

Is this what you want? If so, you can add a circle cookie to the point light 2D, that makes a ring light. The cookie is a texture I generated with R script.

 library(png)
 
 N = 128
 Nhalf = N/2
 InnerRadius = 8
 OuterRadius = 32
 
 
 tab <- array(0, c(N, N, 2))
 
 f <- function(i, j) {
   return(clamp((sqrt((i - Nhalf + 0.5)^2 + (j - Nhalf + 0.5)^2) - InnerRadius)/OuterRadius, lower=0, upper=1))
 }
 
 for(x in (1:N)){
   for(y in (1:N)){
     tab[x, y, 1] = f(x, y)
     tab[x, y, 2] = 1 - f(x, y)
   }
 }
 
 png::writePNG(image = tab, target="C:\\Users\\YOUR_USER_HERE\\Desktop\\image.png")

Set N to be the size of your sprite, then InnerRadius to be the radius of the no-light ring in the center, and OuterRadius where unity's point light takes full effect. Both in pixels as well.,alt text

Is what you want something like this? If so, it can be achieved in 2D by using a Point Light with a cookie. The cookie will be a grayscale image with alpha, which I generated via an R script.

Here is the following R code. You want N to be the size of your sprite, and InnerRadius and OuterRadius also in pixels. Try a few different values until you find one to your liking.

 library(png)
 
 N = 128
 Nhalf = N/2
 InnerRadius = 8
 OuterRadius = 32
 
 
 tab <- array(0, c(N, N, 2))
 
 f <- function(i, j) {
   return(clamp((sqrt((i - Nhalf + 0.5)^2 + (j - Nhalf + 0.5)^2) - InnerRadius)/OuterRadius, lower=0, upper=1))
 }
 
 for(x in (1:N)){
   for(y in (1:N)){
     tab[x, y, 1] = f(x, y)
     tab[x, y, 2] = 1 - f(x, y)
   }
 }
 
 png::writePNG(image = tab, target="C:\\PATH\\TO\\SOMETHING\\image.png")

Also make sure the png package is installed: install.packages(png)

Not really sure how you'd achieve the same thing in 3d.


capturar.png (254.2 kB)
capturar.png (254.2 kB)
Comment

People who like this

0 Show 0 · 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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Spot light creates squares instead of round spot 2 Answers

Attenuation of point and spotlight 0 Answers

What is causing Terrain to improperly respond to point lights? 0 Answers

Multiple Point Light Issue 1 Answer

2D game spotlight issue with floor tiles,2D game spotlight floor tiles get different brightness 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