Release() public method

public Release ( ) : void
return void
 static public int Release(IntPtr l)
 {
     try {
         UnityEngine.Rendering.CommandBuffer self = (UnityEngine.Rendering.CommandBuffer)checkSelf(l);
         self.Release();
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static public int Release(IntPtr l)
 {
     try {
         UnityEngine.Rendering.CommandBuffer self = (UnityEngine.Rendering.CommandBuffer)checkSelf(l);
         self.Release();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 3
0
 void OnDestroy()
 {
     if (m_reflectionCamera)
     {
         Object.DestroyImmediate(m_reflectionCamera.gameObject);
     }
     m_reflectionCamera = null;
     if (m_copyDepthCB != null)
     {
         m_copyDepthCB.Release();
         m_copyDepthCB = null;
     }
     Object.DestroyImmediate(m_convolveMaterial);
     m_convolveMaterial = null;
     Object.DestroyImmediate(m_reflectionMap);
     Object.DestroyImmediate(m_reflectionDepthMap);
 }
Exemplo n.º 4
0
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        // intialize the post effect render camera
        effectCamera.CopyFrom(GetComponent <Camera>());
        effectCamera.clearFlags  = CameraClearFlags.Nothing;
        effectCamera.cullingMask = 0;
        effectCamera.enabled     = false;

        // initialize or resize linked list head buffer
        if (_headerBuffer != null && _headerBuffer.count != headerLength)
        {
            _headerBuffer.Release();
            _headerBuffer = null;
        }
        if (_headerBuffer == null)
        {
            _headerBuffer = new ComputeBuffer(headerLength, Marshal.SizeOf(typeof(int)));
        }

        // initialize or resize the fragment linked list / append buffer
        if (_linkedListBuffer != null && _linkedListBuffer.count != linkedListLength)
        {
            _linkedListBuffer.Release();
            _linkedListBuffer = null;
        }
        if (_linkedListBuffer == null)
        {
            _linkedListBuffer = new ComputeBuffer(linkedListLength, Marshal.SizeOf(typeof(LinkedListNode)), ComputeBufferType.Counter);
        }

        Graphics.SetRandomWriteTarget(1, _headerBuffer);
        Graphics.SetRandomWriteTarget(2, _linkedListBuffer);

        clearUtilities.SetBuffer(CLEAR_HEADER_KERNEL, HEAD_BUFFER_NAME, _headerBuffer);
        clearUtilities.Dispatch(CLEAR_HEADER_KERNEL, _headerBuffer.count, 1, 1);

        clearUtilities.SetBuffer(CLEAR_LINKEDLIST_KERNEL, LINKEDLIST_BUFFER_NAME, _linkedListBuffer);
        clearUtilities.Dispatch(CLEAR_LINKEDLIST_KERNEL, _linkedListBuffer.count, 1, 1);

        // Draw the meshes
        Shader.SetGlobalBuffer(HEAD_BUFFER_NAME, _headerBuffer);
        Shader.SetGlobalBuffer(LINKEDLIST_BUFFER_NAME, _linkedListBuffer);
        Shader.SetGlobalInt(LINKEDLIST_END_NAME, _linkedListBuffer.count);

        UnityEngine.Rendering.CommandBuffer commandBuffer = new UnityEngine.Rendering.CommandBuffer();
        for (int i = 0; i < _renderers.Count; i++)
        {
            FragmentSortedRenderer fsr = _renderers[i];

            // TODO: Support multiple materials?
            MeshFilter mf = fsr.GetComponent <MeshFilter>();
            if (fsr.material && mf)
            {
                commandBuffer.DrawMesh(mf.sharedMesh, fsr.transform.localToWorldMatrix, fsr.material);
            }
        }

        effectCamera.AddCommandBuffer(UnityEngine.Rendering.CameraEvent.AfterEverything, commandBuffer);
        effectCamera.Render();
        effectCamera.RemoveAllCommandBuffers();
        commandBuffer.Release();

        // Sort the fragments
        clearUtilities.SetBuffer(SORT_LINKEDLIST_KERNEL, HEAD_BUFFER_NAME, _headerBuffer);
        clearUtilities.SetBuffer(SORT_LINKEDLIST_KERNEL, LINKEDLIST_BUFFER_NAME, _linkedListBuffer);
        clearUtilities.Dispatch(SORT_LINKEDLIST_KERNEL, _headerBuffer.count, 1, 1);

        Graphics.ClearRandomWriteTargets();

        compositeMaterial.DisableKeyword("FRAGS_PER_PIXEL");
        if (drawFragmentCount)
        {
            compositeMaterial.EnableKeyword("FRAGS_PER_PIXEL");
            compositeMaterial.SetFloat("_FragmentCount", checkFragmentCount);
        }
        compositeMaterial.SetFloat("_DepthScale", effectCamera.farClipPlane - effectCamera.nearClipPlane);
        Graphics.Blit(source, destination, compositeMaterial);

        Shader.SetGlobalBuffer(HEAD_BUFFER_NAME, null);
        Shader.SetGlobalBuffer(LINKEDLIST_BUFFER_NAME, null);
        Shader.SetGlobalInt(LINKEDLIST_END_NAME, 0);
    }