// Command buffer setup private void SetupCB() { CopyCB = new CommandBuffer(); GrabCB = new CommandBuffer(); if ((new List <CommandBuffer>(Current.GetCommandBuffers(CameraEvent.AfterEverything))).Find(x => x.name == "SSAA_COMPOSITION") == null) { CopyCB.Clear(); GrabCB.Clear(); CopyCB.name = "SSAA_COMPOSITION"; CopyCB.SetRenderTarget(BuiltinRenderTextureType.CameraTarget); GrabCB.name = "SSAA_GRAB"; GrabCB.SetRenderTarget(BuiltinRenderTextureType.CurrentActive); RenderTargetIdentifier idBuff = new RenderTargetIdentifier(Main.targetTexture); RenderTargetIdentifier idBg = new RenderTargetIdentifier(baseRt); if (baseRt) { baseRt.Release(); } // fix unity editor startup errors baseRt = new RenderTexture(Screen.width == 0 ? 64 : Screen.width, Screen.height == 0 ? 64 : Screen.height, 24, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.sRGB); GrabCB.Blit(BuiltinRenderTextureType.CameraTarget, idBg); CopyCB.SetGlobalTexture("_BaseTex", idBg); CopyCB.Blit(idBuff, BuiltinRenderTextureType.CameraTarget, Material_current, 0); Current.AddCommandBuffer(CameraEvent.BeforeImageEffects, GrabCB); Current.AddCommandBuffer(CameraEvent.AfterEverything, CopyCB); } }
// Command buffer setup private void SetupCommand(CommandBuffer cb, CameraEvent evt) { // setup command cb.Clear(); cb.name = "SSAA_COMPOSITION"; // setup pass and blit RenderTargetIdentifier idBuff = new RenderTargetIdentifier(Main.targetTexture); cb.SetRenderTarget(BuiltinRenderTextureType.CameraTarget); cb.Blit(idBuff, BuiltinRenderTextureType.CameraTarget, MaterialCurrent, 0); // add to camera - todo hdrp var commands = new List <CommandBuffer>(Current.GetCommandBuffers(evt)); if (commands.Find(x => x.name == "SSAA_COMPOSITION") == null) { if (!MadGoatSSAA_Utils.DetectSRP()) { Current.AddCommandBuffer(evt, cb); } else { // --- Prep for v2 native HDRP support // Injection into render context goes here } } }