Lighting and Rendering: A Beginner-Friendly Guide
Lighting and Rendering settings can have a major effect on the games visual aesthetics.
Learning about them is crucial even if you are not a visual artist.
In this article, we will see an overview of Lighting and Rendering in Unity, focusing on their role in both 2D and 3D environments, and exploring advanced techniques like post-processing, skybox, and fog to enhance a game’s atmosphere.
Overview of Rendering
Rendering in Unity is the process of generating an image from a 2D or 3D model to display it on the final output device like a monitor or a phone.
It’s the final step in the graphics pipeline, where the game translates data into the images that players see. Rendering is significantly influenced by lighting.
The way light interacts with objects, surfaces, and the game environment determines the final look of your scene. Without lighting, even the most detailed models appear flat and lifeless.
Overview of Unity Lighting in 2D and 3D
Lighting adds depth, mood, and realism to your game. Whether working in 2D or 3D, understanding how to effectively utilize lighting is essential.
Lighting in 2D Games
In 2D games, lighting can be used to create mood, highlight important elements, or suggest a time of day. Unity offers various light sources, which can be used to simulate sunlight or other light sources. The challenge in 2D is to use these lights to create depth and dimensionality in a flat world. A Unity URP project is required to use the special 2D lights listed below.
- Freeform
- Sprite
- Parametric
- Point
- Global
Lighting in 3D Games
For 3D environments, lighting becomes even more complex. Here, you deal with aspects like shadows, reflections, and light scattering. Unity’s lighting system allows for dynamic lighting scenarios, where lights can interact with the game’s physics to create realistic shadows and reflections, adding to the immersive experience.
Unity also allows you to bake the lighting in case of large world scenarios which reduces the workload during gameplay and improves performance. Whether to use realtime or baked light is totally dependent on your game.
📄 Resources:
Post-processing for lighting effects
Post-processing is a powerful tool for enhancing or altering the look of your game through filters and effects applied after the scene has been rendered. It’s similar to adding a layer of polish, where you can adjust colors, add bloom, or create depth-of-field effects. This is particularly useful for creating specific moods or atmospheres, like a dreamy haze or a gritty, high-contrast look.
Unity requires a URP or a HDRP project to use the post processing effect. Keep in mind that post processing takes up a lot of computational resources and should be used wisely.
Skybox and lighting
The skybox is a large, encompassing background image or set of images that enclose the game world. It plays a significant role in setting a game’s overall atmosphere.
In Unity, a well-designed skybox can simulate vast open skies, deep space, or a panoramic landscape.
The skybox contributes to the environmental lighting, affecting how the game world is illuminated and is generally additive to the effects by other light sources. The effect of skybox can be seen by disabling all the other light sources in your scene and can be disabled under the scene lighting settings.
📄 Resources:
Using Fog to affect lighting
Fog is another tool in Unity’s arsenal for enhancing atmosphere. It can be used to create a sense of depth, mystery, or foreboding in a game.
Fog affects the overall color and visibility of the scene, making distant objects appear hazy, which adds a layer of realism, especially in large open-world games.
Fog can be generated using multiple ways in Unity. Here are some commonly used options
- Fog setting in the lighting window.
- Particle system for built in render pipeline.
- VFX graph for URP and HDRP
📄 Resources:
Conclusion
Lighting, whether in 2D or 3D, combined with post-processing, skybox, and fog, can elevate the rendering experience of a game world.
Each element, from the subtle glow of a streetlamp in a 2D platformer to the dynamic shadows in a 3D landscape, plays a crucial role in storytelling and gameplay. Your skills in lighting and rendering will pave the way for you to create a visually stunning game.