Turn off shadows for a specific camera?


I have two cameras in my scene. One is a top-down camera that is used to render a "radar" (2D) on the HUD. The other camera is the 3rd person gameplay camera that follows the player.

I also have a single directional light in my scene that generates shadows. For my top-down camera, I do not want shadows to be rendered. For the player camera I do want shadows to be rendered.

Is there a way to turn off shadows for a specific camera?

You can do what you describe using the Camera.OnPreRender () and Camera.OnPostRender () methods. So, you would attach a script to your minimap camera where, in OnPreRender, you store the current shadow distance in a class variable using QualitySettings.shadowDistance and set the shadow distance to 0. In OnPostRender, you simply restore the stored shadow distance.

var storedShadowDistance : float;

function OnPreRender () {
    storedShadowDistance = QualitySettings.shadowDistance;
    QualitySettings.shadowDistance = 0;

function OnPostRender () {
    QualitySettings.shadowDistance = storedShadowDistance;

I know this is old, but wanted to throw in an example that works based on Burnumd answer.

public class ShadowToggler : MonoBehaviour
    public Light[] SoftLights;
    public Light[] HardLights;
    void Start()
        if (gameObject.GetComponent<Camera>() == null) { Debug.Log("No Camera Found"); }

    void OnPreRender()
        foreach (Light l in SoftLights) { l.shadows = LightShadows.None; }
        foreach (Light l in HardLights) { l.shadows = LightShadows.None; }

    void OnPostRender()
        foreach (Light l in SoftLights) { l.shadows = LightShadows.Soft; }
        foreach (Light l in HardLights) { l.shadows = LightShadows.Hard; }

There is probably a better way than having to add your lights to the arrays, but this is the simple method that allows for multiple lights and shadow types.

I ended up turning off shadows on the scene's lights. This worked perfectly. The solution provided by 'burnumd' does not really work for some reason. It causes strange rendering artifacts as well as makes the scene very dark as if no lights exist at all.

From my experiemnce, using PreCull and PostRender methods are extremely resource intensive. There is a far easier way to do it: Just pass the Camera a replacement shader, one which doesn’t render shadows (Unlit/Texture, for example).

using UnityEngine;
using System.Collections;

public class MapCamera : MonoBehaviour {

	public Shader unlitShader;

	void Start() {
		//unlitShader = Shader.Find("Unlit/Texture");