Using Cookies to Create Realistic Lighting in Unity
It’s not the kind of cookies you are thinking of!
Cookies
It's a texture that is a mask projected from a light source. It can imitate real-world lighting like a lamp or a light fixture would depending on how the cookie texture is designed.
This is a cookie texture. If you can’t see it yet, it kind of looks like what a real flashlight would project on a surface. This is why cookies are so powerful! You can create different textures to imitate other types of light masks.
The image above has a spotlight casting light on the sphere with a cookie texture. Very powerful.
Setup
Let’s create a spotlight and place it in our scene.
You can grab the cookie texture above or search on Google for one. Once you have one, import it to your project folder. Select the texture to configure it.
Make sure Alpha Source is set to “From Gray Scale” and “Alpha is Transparency” is checked. Next, make sure “Wrap Mode” is on “Clamp.” Save and drag the texture to the cookie property in your spotlight. A message will appear underneath the property stating to Fix the texture. Click on the button to fix it.
We can now see the beauty of using cookies!
I managed to play around with the settings by adjusting the inner and outer angles of the spotlight.
Gabriel