private void CreateRenderPlane()
    {
        base.gameObject.AddComponent <MeshFilter>();
        base.gameObject.AddComponent <MeshRenderer>();
        Mesh mesh = new Mesh();

        mesh.vertices  = new Vector3[] { new Vector3(-10f, -10f, 0f), new Vector3(10f, -10f, 0f), new Vector3(-10f, 10f, 0f), new Vector3(10f, 10f, 0f) };
        mesh.colors    = new Color[] { Color.white, Color.white, Color.white, Color.white };
        mesh.uv        = new Vector2[] { new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(0f, 1f), new Vector2(1f, 1f) };
        mesh.normals   = new Vector3[] { Vector3.up, Vector3.up, Vector3.up, Vector3.up };
        mesh.triangles = new int[] { 3, 1, 2, 2, 1, 0 };
        base.GetComponent <Renderer>().GetComponent <MeshFilter>().mesh = mesh;
        this.m_Material = new Material(ShaderUtils.FindShader("Hidden/CameraFade"));
        base.GetComponent <Renderer>().sharedMaterial = this.m_Material;
    }
 protected void Start()
 {
     this.m_BloomShader = ShaderUtils.FindShader(this.BLOOM_SHADER_NAME);
     if (this.m_BloomShader == null)
     {
         Debug.LogError("Failed to load Local Rendering Effect Shader: " + this.BLOOM_SHADER_NAME);
     }
     this.m_BlurShader = ShaderUtils.FindShader(this.BLUR_SHADER_NAME);
     if (this.m_BlurShader == null)
     {
         Debug.LogError("Failed to load Local Rendering Effect Shader: " + this.BLUR_SHADER_NAME);
     }
     this.m_AdditiveShader = ShaderUtils.FindShader(this.ADDITIVE_SHADER_NAME);
     if (this.m_AdditiveShader == null)
     {
         Debug.LogError("Failed to load Local Rendering Effect Shader: " + this.ADDITIVE_SHADER_NAME);
     }
     this.CreateTexture();
     this.CreateCamera();
     this.CreateRenderPlane();
 }
    protected void Start()
    {
        CheatMgr mgr = CheatMgr.Get();

        if (mgr != null)
        {
            mgr.RegisterCheatHandler("wireframe", new CheatMgr.ProcessCheatCallback(this.OnProcessCheat_RenderWireframe), null, null, null);
        }
        base.gameObject.GetComponent <Camera>().clearFlags = CameraClearFlags.Color;
        if (!SystemInfo.supportsImageEffects)
        {
            Debug.LogError("Fullscreen Effects not supported");
            base.enabled = false;
        }
        else
        {
            if (this.m_BlurShader == null)
            {
                this.m_BlurShader = ShaderUtils.FindShader("Custom/FullScreen/Blur");
            }
            if (this.m_BlurShader == null)
            {
                Debug.LogError("Fullscreen Effect Failed to load Shader: Custom/FullScreen/Blur");
                base.enabled = false;
            }
            if ((this.m_BlurShader == null) || !this.blurMaterial.shader.isSupported)
            {
                Debug.LogError("Fullscreen Effect Shader not supported: Custom/FullScreen/Blur");
                base.enabled = false;
            }
            else
            {
                if (this.m_BlurVignettingShader == null)
                {
                    this.m_BlurVignettingShader = ShaderUtils.FindShader("Custom/FullScreen/BlurVignetting");
                }
                if (this.m_BlurVignettingShader == null)
                {
                    Debug.LogError("Fullscreen Effect Failed to load Shader: Custom/FullScreen/BlurVignetting");
                    base.enabled = false;
                }
                if (this.m_BlurDesaturationShader == null)
                {
                    this.m_BlurDesaturationShader = ShaderUtils.FindShader("Custom/FullScreen/DesaturationBlur");
                }
                if (this.m_BlurDesaturationShader == null)
                {
                    Debug.LogError("Fullscreen Effect Failed to load Shader: Custom/FullScreen/DesaturationBlur");
                    base.enabled = false;
                }
                if (this.m_BlendShader == null)
                {
                    this.m_BlendShader = ShaderUtils.FindShader("Custom/FullScreen/Blend");
                }
                if (this.m_BlendShader == null)
                {
                    Debug.LogError("Fullscreen Effect Failed to load Shader: Custom/FullScreen/Blend");
                    base.enabled = false;
                }
                if (this.m_VignettingShader == null)
                {
                    this.m_VignettingShader = ShaderUtils.FindShader("Custom/FullScreen/Vignetting");
                }
                if (this.m_VignettingShader == null)
                {
                    Debug.LogError("Fullscreen Effect Failed to load Shader: Custom/FullScreen/Vignetting");
                    base.enabled = false;
                }
                if (this.m_BlendToColorShader == null)
                {
                    this.m_BlendToColorShader = ShaderUtils.FindShader("Custom/FullScreen/BlendToColor");
                }
                if (this.m_BlendToColorShader == null)
                {
                    Debug.LogError("Fullscreen Effect Failed to load Shader: Custom/FullScreen/BlendToColor");
                    base.enabled = false;
                }
                if (this.m_DesaturationShader == null)
                {
                    this.m_DesaturationShader = ShaderUtils.FindShader("Custom/FullScreen/Desaturation");
                }
                if (this.m_DesaturationShader == null)
                {
                    Debug.LogError("Fullscreen Effect Failed to load Shader: Custom/FullScreen/Desaturation");
                    base.enabled = false;
                }
                if (this.m_DesaturationVignettingShader == null)
                {
                    this.m_DesaturationVignettingShader = ShaderUtils.FindShader("Custom/FullScreen/DesaturationVignetting");
                }
                if (this.m_DesaturationVignettingShader == null)
                {
                    Debug.LogError("Fullscreen Effect Failed to load Shader: Custom/FullScreen/DesaturationVignetting");
                    base.enabled = false;
                }
                if (this.m_BlurDesaturationVignettingShader == null)
                {
                    this.m_BlurDesaturationVignettingShader = ShaderUtils.FindShader("Custom/FullScreen/BlurDesaturationVignetting");
                }
                if (this.m_BlurDesaturationVignettingShader == null)
                {
                    Debug.LogError("Fullscreen Effect Failed to load Shader: Custom/FullScreen/BlurDesaturationVignetting");
                    base.enabled = false;
                }
            }
        }
    }
Exemple #4
0
 protected void Initialize()
 {
     if (!this.m_Initialized)
     {
         this.m_Initialized = true;
         if (this.m_HighlightShader == null)
         {
             this.m_HighlightShader = ShaderUtils.FindShader(this.HIGHLIGHT_SHADER_NAME);
         }
         if (this.m_HighlightShader == null)
         {
             Debug.LogError("Failed to load Highlight Shader: " + this.HIGHLIGHT_SHADER_NAME);
             base.enabled = false;
         }
         base.GetComponent <Renderer>().material.shader = this.m_HighlightShader;
         if (this.m_MultiSampleShader == null)
         {
             this.m_MultiSampleShader = ShaderUtils.FindShader(this.MULTISAMPLE_SHADER_NAME);
         }
         if (this.m_MultiSampleShader == null)
         {
             Debug.LogError("Failed to load Highlight Shader: " + this.MULTISAMPLE_SHADER_NAME);
             base.enabled = false;
         }
         if (this.m_MultiSampleBlendShader == null)
         {
             this.m_MultiSampleBlendShader = ShaderUtils.FindShader(this.MULTISAMPLE_BLEND_SHADER_NAME);
         }
         if (this.m_MultiSampleBlendShader == null)
         {
             Debug.LogError("Failed to load Highlight Shader: " + this.MULTISAMPLE_BLEND_SHADER_NAME);
             base.enabled = false;
         }
         if (this.m_BlendShader == null)
         {
             this.m_BlendShader = ShaderUtils.FindShader(this.BLEND_SHADER_NAME);
         }
         if (this.m_BlendShader == null)
         {
             Debug.LogError("Failed to load Highlight Shader: " + this.BLEND_SHADER_NAME);
             base.enabled = false;
         }
         if (this.m_RootTransform == null)
         {
             Transform parent = base.transform.parent.parent;
             if (parent.GetComponent <ActorStateMgr>() != null)
             {
                 this.m_RootTransform = parent.parent;
             }
             else
             {
                 this.m_RootTransform = parent;
             }
             if (this.m_RootTransform == null)
             {
                 Debug.LogError("m_RootTransform is null. Highlighting disabled!");
                 base.enabled = false;
             }
         }
         this.m_VisibilityStates = new Map <Renderer, bool>();
         HighlightSilhouetteInclude[] componentsInChildren = this.m_RootTransform.GetComponentsInChildren <HighlightSilhouetteInclude>();
         if (componentsInChildren != null)
         {
             foreach (HighlightSilhouetteInclude include in componentsInChildren)
             {
                 Renderer component = include.gameObject.GetComponent <Renderer>();
                 if (component != null)
                 {
                     this.m_VisibilityStates.Add(component, false);
                 }
             }
         }
         this.m_UnlitColorShader = ShaderUtils.FindShader(this.UNLIT_COLOR_SHADER_NAME);
         if (this.m_UnlitColorShader == null)
         {
             Debug.LogError("Failed to load Highlight Rendering Shader: " + this.UNLIT_COLOR_SHADER_NAME);
         }
         this.m_UnlitGreyShader = ShaderUtils.FindShader(this.UNLIT_GREY_SHADER_NAME);
         if (this.m_UnlitGreyShader == null)
         {
             Debug.LogError("Failed to load Highlight Rendering Shader: " + this.UNLIT_GREY_SHADER_NAME);
         }
         this.m_UnlitLightGreyShader = ShaderUtils.FindShader(this.UNLIT_LIGHTGREY_SHADER_NAME);
         if (this.m_UnlitLightGreyShader == null)
         {
             Debug.LogError("Failed to load Highlight Rendering Shader: " + this.UNLIT_LIGHTGREY_SHADER_NAME);
         }
         this.m_UnlitDarkGreyShader = ShaderUtils.FindShader(this.UNLIT_DARKGREY_SHADER_NAME);
         if (this.m_UnlitDarkGreyShader == null)
         {
             Debug.LogError("Failed to load Highlight Rendering Shader: " + this.UNLIT_DARKGREY_SHADER_NAME);
         }
         this.m_UnlitBlackShader = ShaderUtils.FindShader(this.UNLIT_BLACK_SHADER_NAME);
         if (this.m_UnlitBlackShader == null)
         {
             Debug.LogError("Failed to load Highlight Rendering Shader: " + this.UNLIT_BLACK_SHADER_NAME);
         }
         this.m_UnlitWhiteShader = ShaderUtils.FindShader(this.UNLIT_WHITE_SHADER_NAME);
         if (this.m_UnlitWhiteShader == null)
         {
             Debug.LogError("Failed to load Highlight Rendering Shader: " + this.UNLIT_WHITE_SHADER_NAME);
         }
     }
 }