I’ve kind of been pulling my hair out with this the last couple of days. So I’ve decided to make a post to see if there isn’t some obvious solution that I am totally missing. (plus I am still a bit of a novice when it comes to unity and I’m not using unity pro)
I do not want to use unity’s in build lighting system for several reasons, first of all the lighting is too smooth for a pixel style game and secondly I’ve been having many problems with particles not receiving light properly.
I have found various shaders that can cutout shapes in to sprites rendered behind them behind them but these are solid shapes and as a result don’t achieve the right desired effect.
If anybody has any suggestions at all it’d be greatly appreciated!
“I do not want to use unity’s in build lighting system for several reasons, first of all the lighting is too smooth for a pixel style game and secondly I’ve been having many problems with particles not receiving light properly.”
You likely do want to use Unity’s inbuilt lighting system. You just mis-understand what is going on. Unity’s lights are by default smooth, but that is down to something else.
What you are seeing in your image is called a light cookie. It’s basically an image that goes from black to white, the black is unlit the white is the colour of the sprite/texture. The grey in between will affect the colour of the Sprite Texture.
The first image is what it looks like in engine, the second is the actual image. If you import it into Unity, set it’s type to cookie and choose spotlight, set alpha to greyscale, set filtering to point and size to 32 (or the size of your image). Then on your spotlight find the cookie option and choose spot light. Then you have the style of lighting you are looking for. To make your own cookie just make a black and white image. Black is unlit, white is fully lit any grey in between is shaded based on how dark the grey is. Don’t have anything other than black around the edges though or the cookie will create light in a straight line in that direction. You can make it as big as you like, I just made mine 32x32 to emphasize the pixels
Your sprites/textures will need to have a material that works with the lighting engine for this to work. The most popular one for 2d is to just use a standard diffuse shader.