← Back to all addons

Lighting / Night Mode 💡

Posted by Mr.Titan on Jan 14, 2025 at 5:27 PM

ExperimentalFeature
💡 3 ❄️ 1

In preparation for day/night cycle, i give you a easy implementation of a night system. It does not uses lights because it’s a complex and time expensive process with no good results (Trust me, i’ve done it before).

Instead we use masking, a process of masking material using shader, very easy to implement.

Import Files

  • Create folder named “Shaders”, and add: LightCameraShader, LightShader
  • Add file LightingCamera.cs into Scripts/Runtime/Others.

Create Materials

  • Create a material called LightMaterial and on top in the inspector of the material, click the dropdown option Shader, go to Mythril2D/Light.
  • Create a material called LightCameraMaterial, do the same process as before for LightShader material.

Create Light Objects

  • Create a Sprite in the scene, 2D Objects/Sprites/Circle ( i recomend Circle but i’ve attached a sprite in this tutorial that has more style).
  • Assign the LightMaterial to the spriteRenderer.
  • In the inspector top right corner in the Layer, create a new layer called Lighting.

Setup Camera

  • Open prefab 0_Hero_Base and add a child camera called LightingCamera to the already present camera. One will presenting the scene, the other only handles lighting.
  • In the main camera, setup “Culling Mask” to evething EXCEPT Lighting. The LightingCamera, in Culling Mask select ONLY the Lighting. prints in attachment
  • Attach the LightingCamera.cs script to the main camera, and set it’s values.

Notes:

  • You can only see the light in play mode.
  • To make it better, add a light to the player, so that there is always a light wherever the player goes.

Have fun!

I’ll post the day/night cycle whenever i’m finished to upgrade your game to the next level!

Lighting / Night Mode 💡

💬 Comments (6)

Lee @ Raguthra Oct 02, 2025 at 08:12 AM
This is great - I’m using Pro Camera 2D and this worked with that pretty much out of the box - a life saver!
❤️ 1
Mr.Titan Oct 02, 2025 at 05:25 PM

Good to know that it still works in the latest version!

Thanks for the feedback!

❤️ 1
Zuko Oct 02, 2025 at 07:24 PM
You have followers in the demo video. How did u manage to do that? they are summons?
Mr.Titan Oct 02, 2025 at 08:39 PM
This is actually the first version of follower & summoner in m2d
Mr.Titan Oct 02, 2025 at 08:39 PM
Before 3.0
Mr.Titan Oct 02, 2025 at 08:40 PM
Currently should not be hard since we already have the summoners

Want to continue the conversation?