public void CleanRT() { CommonSet.DeleteRenderTexture(ref colorRT); CommonSet.DeleteRenderTexture(ref normalRT); CommonSet.DeleteRenderTexture(ref specRT); CommonSet.DeleteRenderTexture(ref depthRT); CommonSet.DeleteRenderTexture(ref depthCopy); CommonSet.DeleteRenderTexture(ref depthBackUp); }
bool RefreshRT() { int width = EnvironmentManager.Instance.GetCurrentRTWidth(); int height = EnvironmentManager.Instance.GetCurrentRTHeight(); bool update = false; CommonSet.RefreshRT(ref colorRT, width, height, EnvironmentManager.Instance.isSupportDepthTex ? 0 : 24, EnvironmentManager.Instance.halfFormat, false, false, FilterMode.Bilinear, ref update, ref cam); if (NormalBufferEnable()) { CommonSet.RefreshRT(ref normalRT, width, height, 0, RenderTextureFormat.ARGBHalf, false, false, FilterMode.Bilinear, ref update, ref cam); CommonSet.RefreshRT(ref specRT, width, height, 0, RenderTextureFormat.ARGB32, false, false, FilterMode.Bilinear, ref update, ref cam); bufs[0] = colorRT.colorBuffer; bufs[1] = normalRT.colorBuffer; bufs[2] = specRT.colorBuffer; } else { CommonSet.DeleteRenderTexture(ref normalRT); CommonSet.DeleteRenderTexture(ref specRT); } if (EnvironmentManager.Instance.isSupportDepthTex) { CommonSet.RefreshRT(ref depthRT, width, height, 24, RenderTextureFormat.Depth, false, false, FilterMode.Bilinear, ref update, ref cam); RenderTextureFormat depthRawFormat = SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RFloat) ? RenderTextureFormat.RFloat : RenderTextureFormat.RHalf; CommonSet.RefreshRT(ref depthCopy, width, height, 0, depthRawFormat, true, true, FilterMode.Point, ref update, ref cam); } else { CommonSet.DeleteRenderTexture(ref depthRT); CommonSet.DeleteRenderTexture(ref depthCopy); } if (StochasticSSREnable()) { RenderTextureFormat depthRawFormat = SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RFloat) ? RenderTextureFormat.RFloat : RenderTextureFormat.RHalf; CommonSet.RefreshRT(ref depthBackUp, width, height, 0, depthRawFormat, true, false, FilterMode.Point, ref update, ref cam); CommonSet.RefreshRT(ref temporal[0], width / (int)mProperty.reflectionResolution, height / (int)mProperty.reflectionResolution, 0, RenderTextureFormat.ARGBHalf, false, false, FilterMode.Bilinear, ref update, ref cam); CommonSet.RefreshRT(ref temporal[1], width / (int)mProperty.reflectionResolution, height / (int)mProperty.reflectionResolution, 0, RenderTextureFormat.ARGBHalf, false, false, FilterMode.Bilinear, ref update, ref cam); } else { CommonSet.DeleteRenderTexture(ref depthBackUp); CommonSet.DeleteRenderTexture(ref temporal[0]); CommonSet.DeleteRenderTexture(ref temporal[1]); } return(update); }
void UpdateOpaqueCommandBuffer() { if (cam == null || opaqueCB == null) { return; } else if (initOpaqueCB) { CommonSet.ClearCommandBuffer(cam, ref opaqueCB, CameraEvent.BeforeForwardAlpha); cam.AddCommandBuffer(CameraEvent.BeforeForwardAlpha, opaqueCB); PrepareOpaqueCB(opaqueCB); initOpaqueCB = false; } }
void UpdateSimpleCommandBuffer() { if (cam == null || simpleCB == null) { return; } else if (initSimpleCB) { CommonSet.ClearCommandBuffer(cam, ref simpleCB, CameraEvent.BeforeImageEffects); cam.AddCommandBuffer(CameraEvent.BeforeImageEffects, simpleCB); PrepareSimpleCB(simpleCB); initSimpleCB = false; } }
public void UpdateDistortion(bool enable) { cam = GetComponent <Camera>(); if (enable) { InitDistortionBuffer(); cam.enabled = true; RefreshDistortionRT(); } else { ClearCommandBuffer(ref distortionCB, CameraEvent.BeforeForwardOpaque); cam.targetTexture = null; cam.enabled = false; CommonSet.DeleteRenderTexture(ref distortionRT); } }
public void Render(IRenderable renderable, CommonSet commonSet, IFramebufferHolder framebuffer, CommandList cl, GraphicsDevice device) { if (cl == null) { throw new ArgumentNullException(nameof(cl)); } if (device == null) { throw new ArgumentNullException(nameof(device)); } if (renderable is not DebugGuiRenderable) { throw new ArgumentException($"{GetType().Name} was passed renderable of unexpected type {renderable?.GetType().Name ?? "null"}", nameof(renderable)); } _imguiRenderer.Render(device, cl); cl.SetFullScissorRects(); }
void RefreshDistortionRT() { int width = EnvironmentManager.Instance.GetDistortionRTWidth(); int height = EnvironmentManager.Instance.GetDistortionRTHeight(); if (distortionRT) { if (width != distortionRT.width || height != distortionRT.height) { cam.targetTexture = null; CommonSet.DeleteRenderTexture(ref distortionRT); } } if (!distortionRT && EnvironmentManager.Instance.isSupportDepthTex) { distortionRT = new RenderTexture(width, height, 24, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear); distortionRT.autoGenerateMips = false; } }
public static void RefreshRT(ref RenderTexture rt, int width, int height, int depth, RenderTextureFormat format, bool useMipMap, bool autoGenerateMips, FilterMode filterMode, ref bool forceUpdate, ref Camera cam) { if (rt) { if (width != rt.width || height != rt.height || rt.format != format || rt.depth != depth) { cam.targetTexture = null; CommonSet.DeleteRenderTexture(ref rt); } } if (!rt) { rt = new RenderTexture(width, height, depth, format, RenderTextureReadWrite.Linear); rt.autoGenerateMips = autoGenerateMips; rt.useMipMap = useMipMap; rt.filterMode = filterMode; forceUpdate = true; } }
void RefreshAlphaRT() { int width = EnvironmentManager.Instance.GetCurrentRTWidth(); int height = EnvironmentManager.Instance.GetCurrentRTHeight(); if (alphaRT) { if (width != alphaRT.width || height != alphaRT.height || alphaRT.format != EnvironmentManager.Instance.halfFormat) { cam.targetTexture = null; CommonSet.DeleteRenderTexture(ref alphaRT); } } if (!alphaRT && EnvironmentManager.Instance.isSupportDepthTex) { alphaRT = new RenderTexture(width, height, 24, EnvironmentManager.Instance.halfFormat, RenderTextureReadWrite.Linear); alphaRT.autoGenerateMips = false; } }
void PrepareSimpleCB(CommandBuffer cb) { if (initLut) { GetLutTex(cb); forceUpdate = true; initLut = false; } RenderTextureFormat copyFormat = CommonSet.SelectFormat(RenderTextureFormat.ARGBHalf, RenderTextureFormat.ARGB32); RenderTargetIdentifier _SimpleCopyId = new RenderTargetIdentifier(CommonSet.ShaderProperties.simpleCopyTex); if (rt) { cb.GetTemporaryRT(CommonSet.ShaderProperties.simpleCopyTex, rt.width, rt.height, 0, FilterMode.Bilinear, copyFormat, RenderTextureReadWrite.Linear); RenderTargetIdentifier _RenderTexId = new RenderTargetIdentifier(rt); cb.Blit(_RenderTexId, _SimpleCopyId); if (SceneBloomEnable()) { PrepareBloom(cb, _SimpleCopyId, rt.width, rt.height); } cb.Blit(_SimpleCopyId, BuiltinRenderTextureType.CameraTarget, uberMaterial, (int)DragonPostProcess.MainPass.Simple); } else { cb.GetTemporaryRT(CommonSet.ShaderProperties.simpleCopyTex, cam.pixelWidth, cam.pixelHeight, 0, FilterMode.Bilinear, copyFormat, RenderTextureReadWrite.Linear); cb.Blit(BuiltinRenderTextureType.CameraTarget, _SimpleCopyId); if (SceneBloomEnable()) { PrepareBloom(cb, _SimpleCopyId, cam.pixelWidth, cam.pixelHeight); } cb.Blit(_SimpleCopyId, BuiltinRenderTextureType.CameraTarget, uberMaterial, (int)DragonPostProcess.MainPass.Simple); } cb.ReleaseTemporaryRT(CommonSet.ShaderProperties.simpleCopyTex); if (SceneBloomEnable()) { FinishBloom(cb, CommonSet.ShaderProperties.bloomTex); } }
public void Render(IRenderable renderable, CommonSet commonSet, IFramebufferHolder framebuffer, CommandList cl, GraphicsDevice device) { if (cl == null) { throw new ArgumentNullException(nameof(cl)); } if (commonSet == null) { throw new ArgumentNullException(nameof(commonSet)); } if (framebuffer == null) { throw new ArgumentNullException(nameof(framebuffer)); } if (renderable is not EtmWindow window) { throw new ArgumentException($"{GetType().Name} was passed renderable of unexpected type {renderable?.GetType().Name ?? "null"}", nameof(renderable)); } var tilemap = window.Tilemap; cl.PushDebugGroup($"Tiles3D:{tilemap.Name}"); cl.SetPipeline(tilemap.RendererId == DungeonTilemapPipeline.NoCulling ? _nonCullingPipeline.Pipeline : _normalPipeline.Pipeline); cl.SetGraphicsResourceSet(0, tilemap.ResourceSet.ResourceSet); cl.SetGraphicsResourceSet(1, commonSet.ResourceSet); cl.SetVertexBuffer(0, _vertexBuffer.DeviceBuffer); cl.SetVertexBuffer(1, tilemap.TileBuffer); cl.SetIndexBuffer(_indexBuffer.DeviceBuffer, IndexFormat.UInt16); cl.SetFramebuffer(framebuffer.Framebuffer); cl.DrawIndexed((uint)Cube.Indices.Length, (uint)tilemap.Tiles.Length, 0, 0, 0); cl.PopDebugGroup(); }
void OnDisable() { CommonSet.ClearCommandBuffer(cam, ref opaqueCB, CameraEvent.BeforeForwardAlpha); }
public void CleanRT() { CommonSet.DeleteRenderTexture(ref distortionRT); }
void OnDisable() { CommonSet.ClearCommandBuffer(cam, ref simpleCB, CameraEvent.BeforeImageEffects); }
public void CleanRT() { CommonSet.DeleteRenderTexture(ref alphaRT); }