Пример #1
0
 public static void RemoveBinding(Camera cam, string name)
 {
     if (DepthBufferGrabCommand.m_data == null || !DepthBufferGrabCommand.m_data.ContainsKey(cam))
     {
         return;
     }
     DepthBufferGrabCommand.CommandData commandData = DepthBufferGrabCommand.m_data[cam];
     if (!commandData.bindings.Contains(name))
     {
         return;
     }
     commandData.bindings.Remove(name);
     commandData.recreate = true;
 }
Пример #2
0
        private void CreateCommand()
        {
            if (DepthBufferGrabCommand.m_data == null || !DepthBufferGrabCommand.m_data.ContainsKey(this.m_camera))
            {
                return;
            }
            DepthBufferGrabCommand.CommandData commandData = DepthBufferGrabCommand.m_data[this.m_camera];
            if (commandData.command == null && commandData.bindings.Count == 0)
            {
                return;
            }
            if (commandData.command != null && commandData.bindings.Count == 0)
            {
                this.m_camera.RemoveCommandBuffer(CameraEvent.AfterSkybox, commandData.command);
                commandData.command = null;
                return;
            }
            if (!commandData.recreate && commandData.command != null && commandData.width == this.m_camera.pixelWidth && commandData.height == this.m_camera.pixelHeight)
            {
                return;
            }
            if (commandData.command != null)
            {
                this.m_camera.RemoveCommandBuffer(CameraEvent.AfterSkybox, commandData.command);
            }
            commandData.command      = new CommandBuffer();
            commandData.command.name = "Shared Depth Grab Cmd: " + this.m_camera.name;
            commandData.width        = this.m_camera.pixelWidth;
            commandData.height       = this.m_camera.pixelHeight;
            int nameID = Shader.PropertyToID("_DepthCopyTexture");

            commandData.command.GetTemporaryRT(nameID, commandData.width, commandData.height, 0, FilterMode.Point, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Linear);
            commandData.command.Blit(BuiltinRenderTextureType.CurrentActive, nameID, this.m_depthCopyMat, 0);
            HashSet <string> .Enumerator enumerator = commandData.bindings.GetEnumerator();
            while (enumerator.MoveNext())
            {
                commandData.command.SetGlobalTexture(enumerator.Current, nameID);
            }
            this.m_camera.AddCommandBuffer(CameraEvent.AfterSkybox, commandData.command);
            commandData.recreate = false;
        }