x


Mirror too dark

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

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!

more ▼

asked Mar 06 '12 at 10:07 AM

Hannibalov gravatar image

Hannibalov
138 5 6 8

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

Mar 06 '12 at 09:54 AM Hannibalov
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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

more ▼

answered Mar 07 '12 at 11:48 PM

Hannibalov gravatar image

Hannibalov
138 5 6 8

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x215
x69
x53

asked: Mar 06 '12 at 10:07 AM

Seen: 959 times

Last Updated: Mar 07 '12 at 11:48 PM