OnRenderImage() 공개 메소드

public OnRenderImage ( RenderTexture source, RenderTexture destination ) : void
source RenderTexture
destination RenderTexture
리턴 void
예제 #1
0
    private void RenderHighlights2(RenderTexture rt)
    {
        bool didRender2             = false;
        RenderTargetIdentifier rtid = new RenderTargetIdentifier(rt);

        m_renderBuffer.SetRenderTarget(rtid);
        RenderTexture.active = rt;
        for (int i = glows.Count - 1; i >= 0; i -= 1)
        {
            if (glows[i].gameObject.activeInHierarchy && glows[i].enabled && glows[i].isVisible)
            {
                ClearCommandBuffers();
                m_highlightMaterial.SetColor("_Color", glows[i].GetComponent <ObjInfo>().glowColor);
                m_renderBuffer.DrawRenderer(glows[i], m_highlightMaterial, 0, 4);
                Graphics.ExecuteCommandBuffer(m_renderBuffer);
                didRender2 = true;
            }
            else
            {
                glows[i].GetComponent <ObjInfo>().addedToGlow = false;
                glows.Remove(glows[i]);
            }
        }
        if (didRender2)
        {
            m_blur.OnRenderImage(rt, rt);
            m_highlightMaterial.SetTexture("_OccludeMap", rt);
            Graphics.Blit(m_dest, m_dest, m_highlightMaterial, 5);
            didRender = true;
        }
    }
예제 #2
0
        //---------------------------------------------------------------------------------------------------
        void OnRenderImage(RenderTexture source, RenderTexture destination)
        {
            //create and allocate RenderTexture buffer
            RenderTexture highlightRT;

            highlightRT = RenderTexture.GetTemporary(Screen.width, Screen.height, 0, RenderTextureFormat.R8);

            //set active fill with black pixels and release
            RenderTexture.active = highlightRT;
            GL.Clear(true, true, Color.clear);
            RenderTexture.active = null;

            //clear and draw the mesh
            ClearRenderBuffer();
            RenderHighlightObjects(highlightRT);

            //blur image
            RenderTexture blurred = RenderTexture.GetTemporary(Screen.width, Screen.height, 0, RenderTextureFormat.R8);

            m_blur.OnRenderImage(highlightRT, blurred);

            //resolve shader
            this.m_highlightMaterial.SetTexture("_MaskTex", highlightRT);
            this.m_highlightMaterial.SetTexture("_ColorTex", blurred);
            Graphics.Blit(source, destination, this.m_highlightMaterial, 1);

            //release buffer
            RenderTexture.ReleaseTemporary(highlightRT);
            RenderTexture.ReleaseTemporary(blurred);
        }
예제 #3
0
    private void OnRenderImage(RenderTexture src, RenderTexture dst)
    {
        if (m_renderers.Count > 0)
        {
            var outputRT = RenderTexture.GetTemporary(m_rtWidth, m_rtHeight, 24);

            if (DrawStencilBuffer)
            {
                m_highlightMaterial.SetColor("_Color", Color.red);
                Graphics.Blit(src, outputRT, m_highlightMaterial, (int)HighlightPass.DebugStencil);
            }
            else
            {
                if (m_selectionType == HighlightType.Glow)
                {
                    m_blurImageEffect.OnRenderImage(m_colorRT, m_colorRT);
                }

                m_highlightMaterial.SetFloat("_Intensity", m_intensity);
                m_highlightMaterial.SetTexture("_SecondTex", m_colorRT);
                Graphics.Blit(src, outputRT, m_highlightMaterial, (int)HighlightPass.Overlay);
            }

            Graphics.Blit(outputRT, dst);
            RenderTexture.ReleaseTemporary(outputRT);
        }
        else
        {
            // nothing to draw
            Graphics.Blit(src, dst);
        }
    }
예제 #4
0
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        RenderTexture.active = cam2.targetTexture;
        GL.Clear(true, true, Color.clear);
        cam2.Render();

        /*cam.cullingMask = sightMask;
         * buffer.Clear ();*/

        /*RenderTargetIdentifier rtid = new RenderTargetIdentifier(rt);
         * buffer.SetRenderTarget( rtid );
         * buffer.DrawRenderer (mask, mat, 0, 0);
         * Graphics.ExecuteCommandBuffer(buffer);*/


        RenderTexture.active = cam3.targetTexture;
        GL.Clear(true, true, Color.clear);
        cam3.Render();
        m_blur.OnRenderImage(cam3.targetTexture, cam3.targetTexture);

        /*buffer.Clear();
         * buffer.SetRenderTarget (rtid1);
         * buffer.DrawRenderer (maskCircleRend, mat2, 0, 0);
         * buffer.DrawRenderer (maskPizzaRend, mat2, 0, 0);
         * Graphics.ExecuteCommandBuffer(buffer);*/

        /*RenderTexture.active = cam4.targetTexture;
         * GL.Clear (true, true, Color.clear);
         * cam4.Render ();*/
        /*buffer.Clear();
         * buffer.SetRenderTarget (rtid2);
         * buffer.DrawRenderer (maskCircleRend2, mat2, 0, 0);
         * buffer.DrawRenderer (maskPizzaRend2, mat2, 0, 0);
         * Graphics.ExecuteCommandBuffer(buffer);*/

        RenderTexture.active = cam6.targetTexture;
        GL.Clear(true, true, Color.clear);
        cam6.Render();

        mat.SetTexture("_ArenaTex", cam6.targetTexture);
        //mat.SetTexture ("_VisibleMask", cam4.targetTexture);
        mat.SetTexture("_Mask", cam3.targetTexture);
        mat.SetTexture("_VisibleTex", cam2.targetTexture);

        if (mist)
        {
            RenderTexture.active = cam5.targetTexture;
            GL.Clear(true, true, Color.clear);
            cam5.Render();

            mat.SetTexture("_Mist", cam5.targetTexture);
            Graphics.Blit(source, destination, mat, 2);
        }
        else
        {
            Graphics.Blit(source, destination, mat, 1);
        }
        RenderTexture.active = null;
    }
예제 #5
0
    /// Final image composing.
    /// 1. Renders all the highlight objects either with Overlay shader or DepthFilter
    /// 2. Downsamples and blurs the result image using standard BlurOptimized image effect
    /// 3. Renders occluders to the same render texture
    /// 4. Substracts the occlusion map from the blurred image, leaving the highlight area
    /// 5. Renders the result image over the main camera's G-Buffer
    private void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        RenderTexture highlightRT;

        #if UNITY_ANDROID
        RenderTexture.active = highlightRT = RenderTexture.GetTemporary(m_RTWidth, m_RTHeight, 0, RenderTextureFormat.ARGB32);
        #else
        RenderTexture.active = highlightRT = RenderTexture.GetTemporary(m_RTWidth, m_RTHeight, 0, RenderTextureFormat.R8);
        #endif
        GL.Clear(true, true, Color.clear);
        RenderTexture.active = null;

        ClearCommandBuffers();

        RenderHighlights(highlightRT);

        #if UNITY_ANDROID
        RenderTexture.active = highlightRT = RenderTexture.GetTemporary(m_RTWidth, m_RTHeight, 0, RenderTextureFormat.ARGB32);
        #else
        RenderTexture blurred = RenderTexture.GetTemporary(m_RTWidth, m_RTHeight, 0, RenderTextureFormat.R8);
        #endif

        m_blur.OnRenderImage(highlightRT, blurred);


        RenderOccluders(highlightRT);

        if (m_fillType == FillType.Outline)
        {
            #if UNITY_ANDROID
            RenderTexture.active = highlightRT = RenderTexture.GetTemporary(m_RTWidth, m_RTHeight, 0, RenderTextureFormat.ARGB32);
            #else
            RenderTexture occluded = RenderTexture.GetTemporary(m_RTWidth, m_RTHeight, 0, RenderTextureFormat.R8);
            #endif

            // Excluding the original image from the blurred image, leaving out the areal alone
            m_highlightMaterial.SetTexture("_OccludeMap", highlightRT);
            Graphics.Blit(blurred, occluded, m_highlightMaterial, 2);

            m_highlightMaterial.SetTexture("_OccludeMap", occluded);

            RenderTexture.ReleaseTemporary(occluded);
        }
        else
        {
            m_highlightMaterial.SetTexture("_OccludeMap", blurred);
        }

        m_highlightMaterial.SetColor("_Color", m_highlightColor);
        Graphics.Blit(source, destination, m_highlightMaterial, (int)m_selectionType);


        RenderTexture.ReleaseTemporary(blurred);
        RenderTexture.ReleaseTemporary(highlightRT);
    }
예제 #6
0
    private void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        ClearCommandBuffers();

        RenderHighlights();

        RenderTexture rt1 = RenderTexture.GetTemporary(Screen.width, Screen.height, 0);

        blur.OnRenderImage(hightlightRT, rt1);

        //antialiasing.OnRenderImage(rt1, rt1);

        HighlightMaterial.SetTexture("_OccludeMap", hightlightRT);
        Graphics.Blit(rt1, rt1, HighlightMaterial, 0);

        HighlightMaterial.SetTexture("_OccludeMap", rt1);
        Graphics.Blit(source, destination, HighlightMaterial, 1);

        RenderTexture.ReleaseTemporary(rt1);
    }