Mirror too dark

Hi everyone,
I’m very new to unity, and I’m amazed by the work done. Big applause! :slight_smile:

Having said that, my problem is that the mirror I’m using gets me a pretty dark reflection. It is the same shader and script from the characterCustomization tutorial (not a single line changed, and the example works perfectly). The funny thing is that while I’m in “Play mode” the mirror is dark, but when I’m in the editor the reflection is fine. My scene has 10 lights, could it have something to do?

Thanks!

I've just reduced the number of lights and tried to play with the light intensities, but it has no effect on the mirror.

1 Answer

1

Solved!

Adding camera.renderingPath = RenderingPath.Forward; in CreateMirrorObjects:

private void CreateMirrorObjects( Camera currentCamera, out Camera reflectionCamera )
{
    reflectionCamera = null;
    
    // Reflection render texture
    if( !m_ReflectionTexture || m_OldReflectionTextureSize != m_TextureSize )
    {
        if( m_ReflectionTexture )
            DestroyImmediate( m_ReflectionTexture );
        m_ReflectionTexture = new RenderTexture( m_TextureSize, m_TextureSize, 16 );
        m_ReflectionTexture.name = "__MirrorReflection" + GetInstanceID();
        m_ReflectionTexture.isPowerOfTwo = true;
        m_ReflectionTexture.hideFlags = HideFlags.DontSave;
        m_OldReflectionTextureSize = m_TextureSize;
    }
    
    // Camera for reflection
    reflectionCamera = m_ReflectionCameras[currentCamera] as Camera;
    if( !reflectionCamera ) // catch both not-in-dictionary and in-dictionary-but-deleted-GO
    {
        GameObject go = new GameObject( "Mirror Refl Camera id" + GetInstanceID() + " for " + currentCamera.GetInstanceID(), typeof(Camera), typeof(Skybox) );
        reflectionCamera = go.camera;
        reflectionCamera.enabled = false;
        reflectionCamera.transform.position = transform.position;
        reflectionCamera.transform.rotation = transform.rotation;
		//better lighting
		reflectionCamera.renderingPath = RenderingPath.Forward;
        
		reflectionCamera.gameObject.AddComponent("FlareLayer");
        go.hideFlags = HideFlags.HideAndDontSave;
        m_ReflectionCameras[currentCamera] = reflectionCamera;
    }        
}

It’d be nice to have shadows in the mirror, but it looks good anyway