Skip to content

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:

A night scene in the style of Octopath Traveler: pixel art characters on a cobbled square, lit warmly by street lamps and a glowing doorway

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:

The All In 1 Shader component with Change Shader Variant set to Lit, and the Create And Add Normal Map button with Normal Strength and Normal Blur below it

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

A material's Shader dropdown open on the AllIn1SpriteShader group, which lists AllIn1SpriteShaderLit and AllIn1SpriteShaderLitTransparent among its variants

A Transparent Lit shader also exists: pick Lit Transparent in the component’s dropdown, or AllIn1SpriteShaderLitTransparent in the Material Inspector.

The feature has its own Demo scene that you can find at: Assets\Plugins\AllIn1Assets\AllIn1SpriteShader\Demo\DemoLitShader

The DemoLitShader scene: three soldier sprites standing on a wooden floor, lit red and green by 3D lights and casting shadows behind them

If you switch to Lit with the component’s Change Shader Variant dropdown, the shadow configuration is done for you: Z Write on, the renderer casting and receiving shadows, and the render queue at 2000 (Geometry). Otherwise, you can manually configure it in the Material Advanced Configuration:

The material's Advanced Configuration with Enable Z Write ticked and an arrow pointing at Render Queue, set to Geometry 2000

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

The Inspector's tab menu with Debug selected, and an arrow from it to the Sprite Renderer's Cast Shadows field, set to On

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

The Light Effect section of the material with 1.Normal Map ticked, a blue normal map texture assigned and Normal Strength at 15

The asset component has a button, Create And Add Normal Map (in the component image above), that will activate the normal map effect, create a normal map texture, and add it to the material.

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\AllIn1SpriteShaderLit_BetterShader.surfshader (and AllIn1SpriteShaderLitTransparent_BetterShader.surfshader for the transparent one)

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 pipelines you get an error in any of the lit shaders please go into the asset Window (Tools → AllIn1 → Sprite Shader Window) and press Refresh Lit Shader at the bottom of its Others tab:

The Others tab of the Sprite Shader Window, with the Refresh Lit Shader button at the bottom