# 3D Lights

The Lit shader variant supports all default 3D light components (Directional, Point, Spot, etc.) and allows you to create games in the style of Octopath Traveler:

<figure><img src="https://74615797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fvllr9Cp7qJRxWBqjDfzS%2Fuploads%2F95I4IGoEtOdBFKHMP8EU%2Fimage.png?alt=media&#x26;token=9489d9c6-9292-4462-9f2d-7b498b8b671b" alt=""><figcaption></figcaption></figure>

All pipelines are supported except the 2D Renderer. For 2D lighting in URP, use the dedicated 2D Renderer Lit variant instead (see the 2D Renderer URP Lights section).

As usual, you can add this shader variant by selecting the Lit option in the asset component:

<figure><img src="https://74615797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fvllr9Cp7qJRxWBqjDfzS%2Fuploads%2FSKfu8VyIzsbPuCy9BbEl%2Fimage.png?alt=media&#x26;token=5aaf7a8f-5f8d-4ee4-b7e6-06aa7a86d302" alt=""><figcaption></figcaption></figure>

Alternatively, you can manually select it in the Material Inspector:

<figure><img src="https://74615797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fvllr9Cp7qJRxWBqjDfzS%2Fuploads%2Fvf3Mb5WoylwtCtzIdSRb%2Fimage.png?alt=media&#x26;token=534ca679-0fb8-4bcc-be70-8dff89e863db" alt=""><figcaption></figcaption></figure>

A Transparent Lit shader also exists. To select it, you'll need to use the manual setup method described above.

The feature has its own Demo scene that you can find at: AllIn13DShader\Demo\DemoLitShader

<figure><img src="https://74615797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fvllr9Cp7qJRxWBqjDfzS%2Fuploads%2Faoh6UyeZoaXKoB5D2eZT%2Fimage.png?alt=media&#x26;token=1e9adb82-52ff-44db-a88c-685fa2948622" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
If you want to use Sprite Renderer Flip with this shader variant, please add the SpritePropertiesSync component

<img src="https://74615797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fvllr9Cp7qJRxWBqjDfzS%2Fuploads%2FMXRwSkAXCMBwoF9DeYe9%2Fimage.png?alt=media&#x26;token=e07fe2e1-56fe-41fb-9182-6b46073bed2a" alt="" data-size="original">
{% endhint %}

If the shader is added through the asset component, shadow configuration will be automatically done for you. Otherwise, you can manually configure it in the Material Advanced Configuration:

<figure><img src="https://74615797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fvllr9Cp7qJRxWBqjDfzS%2Fuploads%2FHhMgFb5I5h2Szipn84EU%2Fimage.png?alt=media&#x26;token=d4a16858-fbf8-49ac-beca-3bae3ef2842e" alt=""><figcaption></figcaption></figure>

And enable cast shadows in the sprite (it needs debug mode to be active):

<figure><img src="https://74615797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fvllr9Cp7qJRxWBqjDfzS%2Fuploads%2FOEBvlDYLIMhaekpwvGpa%2Fimage.png?alt=media&#x26;token=66320626-9e00-4260-96b8-2870460534e9" alt=""><figcaption></figcaption></figure>

If you want to add a Normal Map the shader variant has an effect for that:

<figure><img src="https://74615797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fvllr9Cp7qJRxWBqjDfzS%2Fuploads%2F3x4w6J6F367h19fp48OP%2Fimage.png?alt=media&#x26;token=5e05d189-f383-4b0b-8ce6-81fb83c8a50b" alt=""><figcaption></figcaption></figure>

The asset component has a button that will activate the normal map effect, create a normal map texture, and add it to the material:

<figure><img src="https://74615797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fvllr9Cp7qJRxWBqjDfzS%2Fuploads%2F7GJPA3pkllpc00ARNMth%2Fimage.png?alt=media&#x26;token=9b776dbe-d137-4570-ad09-7e40f7288cf3" alt=""><figcaption></figcaption></figure>

This lit shader was created using Better Shaders, a Unity Asset by Jason Booth that simplifies cross-pipeline shader development. This Better Shaders file can be found over at:

AllIn1SpriteShader\Shaders\LitShaders\BetterShaders\_AllIn1Sprite.surfshader

You can get Better Shaders here:

<https://assetstore.unity.com/packages/tools/visual-scripting/better-shaders-2022-standard-urp-hdrp-244057?aid=1101l52IjU>

If you do own Better Shaders, you are free to open the source file and change whatever you want.

If after an update or after changing render pipelies you get an error in any of the lit shaders please go into the asset Window (Tools/AllIn1/SpriteShaderWindow) and press the button at the very bottom:

<figure><img src="https://74615797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fvllr9Cp7qJRxWBqjDfzS%2Fuploads%2FDGwPsfkzQRXXntZLGvHC%2Fimage.png?alt=media&#x26;token=12b69757-1e70-4434-ae6d-de804ead037b" alt=""><figcaption></figcaption></figure>
