Search Unity

Blured Mirror Reflection

Discussion in 'Shaders' started by TSUMIKISEISAKU, Aug 22, 2013.

  1. TSUMIKISEISAKU

    TSUMIKISEISAKU

    Joined:
    Jan 24, 2013
    Posts:
    31
    Hello. I'm having a puzzling question about [MirrorReflection2.cs] now.

    http://wiki.unity3d.com/index.php?title=MirrorReflection2


    I revisioned this script to blur render texture (reflection)
    with the use of Graphics.Blit before SetTexture to _ReflectionTex, and it works fine.:eek:


    [MirrorReflection.cs]
    Code (csharp):
    1.  
    2. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    3. //---Add Blur---
    4. Material mat2 = new Material(blurShader);
    5. RenderTexture buffer = RenderTexture.GetTemporary(m_TextureSize, m_TextureSize, 16, RenderTextureFormat.ARGBFloat);
    6.  
    7. mat2.SetFloat("_Blur", blurAmount);
    8.  
    9. Graphics.Blit(m_ReflectionTexture, buffer, mat2, 0);    //  Horizontal Blur
    10. Graphics.Blit(buffer, m_ReflectionTexture, mat2, 1);    //  Vertical Blur
    11.  
    12. RenderTexture.ReleaseTemporary(buffer);
    13. //------
    14.  
    15. foreach(Material mat in materials){
    16.     if(mat.HasProperty("_ReflectionTex")){
    17.         mat.SetTexture("_ReflectionTex", m_ReflectionTexture);
    18.     }
    19. }
    20. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    21.  

    However, the lighting of the scene will be strange for some reason.:-|


    [with Graphics.Blit] strange
    $img02.jpg

    [comment out Graphics.Blit] correct (original code)
    $img01.jpg

    I want to blur RenderTexture but when I tried it with the Graphics.Blit I wrote,
    I don't know why my lighting changes as well. I'm stuck...