Creating and applying a cookie texture to a spotlight
Cookie Textures can work well with Unity Spotlights to simulate shadows coming from projectors, windows, and so on. An example of this would be for the bars of a prison window.
In this recipe, we'll create and apply a cookie Texture suitable to use with Unity Spotlights:

Getting ready
If you don't have access to an image editor, or prefer to skip the Texture map elaboration in order to focus on the implementation, we have provided the prepared cookie image file called spotCookie.tif
inside the 07_02
folder.
How to do it...
To create and apply a cookie texture to a spotlight, follow these steps:
- In your image editor, create a new
512 x 512
greyscale pixel image. - Ensure that the border is completely black by setting the brush tool color to black and drawing around the four edges of the image. Then, draw some criss-crossed lines. Save your image, naming it
spotCookie
:

- Import your image file to Unity and select it in the
Project
panel.
- From the Inspector...