internal void SetViewport(CommandBuffer commandBuffer, IPostProcess nextProcess) { if (commandBuffer == commandBufferPostProcesses && nextProcess == null) { commandBuffer.SetViewport(new Rect(0, 0, Screen.width, Screen.height)); } }
public void Disconnected() { this.postProcesser = null; if (this.Character != null) { UserService.Instance.CharacterLeave(Character); } }
/// <summary> /// Removes the specified post processing effect from the collection. /// </summary> /// <param name="postEffect">The post effect to remove.</param> public void RemovePostProcessEffect(IPostProcess postEffect) { if (postEffect is SimulatedPostProcess) { this.simulatedPostProcessEffects.Remove((SimulatedPostProcess)postEffect); } else { this.postProcessingEffects.Remove(postEffect); } }
/// <summary> /// Adds the specified post processing effect to the collection. /// </summary> /// <param name="postEffect">The post effect to add.</param> public void AddPostProcessEffect(IPostProcess postEffect) { postEffect.LoadContent(this.parentGame.Content); if (postEffect is SimulatedPostProcess) { this.simulatedPostProcessEffects.Add((SimulatedPostProcess)postEffect); } else { this.postProcessingEffects.Add(postEffect); } }
public override bool BuildCommandBuffer(RenderPipeline pipeline, CommandBuffer commandBuffer, TargetContext context, IPostProcess nextProcess) { return(false); }
public override bool BuildCommandBuffer(RenderPipeline pipeline, CommandBuffer commandBuffer, TargetContext context, IPostProcess nextProcess) { if (context.CompareSource0ToTarget0() != false) { int temporary = pipeline.GetTemporaryRT(); if (nextProcess == null) { commandBuffer.Blit(context.source0, temporary); context.SetSource0(temporary); } else { context.SetTarget0(temporary); } } commandBuffer.SetRenderTarget( context.target0, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare); commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0); pipeline.SetViewport(commandBuffer, nextProcess); pipeline.DrawFill(commandBuffer, material, 0); context.duplicated = false; return(true); }
public override bool BuildCommandBuffer(RenderPipeline pipeline, CommandBuffer commandBuffer, TargetContext context, IPostProcess nextProcess) { if (context.CompareSource0ToTarget0() != false && nextProcess != null) { int temporary = pipeline.GetTemporaryRT(); context.SetTarget0(temporary); } if (Properties.visualizeFocus != false) { commandBuffer.SetRenderTarget( context.target0, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare); pipeline.DrawFill(commandBuffer, material, 7); } else { var alphaDepthTarget = new RenderTargetIdentifier(kShaderPropertyAlphaDepthTarget); commandBuffer.GetTemporaryRT(kShaderPropertyAlphaDepthTarget, -1, -1, 0, FilterMode.Bilinear, RenderTextureFormat.ARGB32); commandBuffer.SetRenderTarget( alphaDepthTarget, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare); commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0); pipeline.DrawFill(commandBuffer, material, 0); int pass = (Properties.blurQuality == BlurQuality.kLow)? 2 : 3; if (Properties.highResolution != false) { commandBuffer.SetRenderTarget( context.target0, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare); commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, alphaDepthTarget); pipeline.SetViewport(commandBuffer, nextProcess); pipeline.DrawFill(commandBuffer, material, pass); } else { int lowWidth = pipeline.ScreenWidth >> 1; int lowHeight = pipeline.ScreenHeight >> 1; var lowBlurTarget = new RenderTargetIdentifier(kShaderPropertyLowBlurTarget); var lowDiscTarget = new RenderTargetIdentifier(kShaderPropertyLowDiscTarget); commandBuffer.GetTemporaryRT(kShaderPropertyLowBlurTarget, lowWidth, lowHeight, 0, FilterMode.Bilinear, RenderTextureFormat.ARGB32); commandBuffer.GetTemporaryRT(kShaderPropertyLowDiscTarget, lowWidth, lowHeight, 0, FilterMode.Bilinear, RenderTextureFormat.ARGB32); commandBuffer.SetRenderTarget( lowBlurTarget, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare); commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, alphaDepthTarget); pipeline.DrawFill(commandBuffer, material, 1); commandBuffer.SetRenderTarget( lowDiscTarget, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare); commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, lowBlurTarget); pipeline.DrawFill(commandBuffer, material, pass); switch (Properties.blurQuality) { case BlurQuality.kMedium: { pass = 5; break; } case BlurQuality.kHigh: { pass = 6; break; } default: { pass = 4; break; } } commandBuffer.SetRenderTarget( context.target0, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare); commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, alphaDepthTarget); commandBuffer.SetGlobalTexture(kShaderPropertyLowRez, lowDiscTarget); pipeline.SetViewport(commandBuffer, nextProcess); pipeline.DrawFill(commandBuffer, material, pass); commandBuffer.ReleaseTemporaryRT(kShaderPropertyLowBlurTarget); commandBuffer.ReleaseTemporaryRT(kShaderPropertyLowDiscTarget); } commandBuffer.ReleaseTemporaryRT(kShaderPropertyAlphaDepthTarget); } context.duplicated = false; return(true); }
public override bool BuildCommandBuffer(RenderPipeline pipeline, CommandBuffer commandBuffer, TargetContext context, IPostProcess nextProcess) { if (context.CompareSource0ToTarget0() != false) { int temporary = pipeline.GetTemporaryRT(); if (nextProcess == null) { commandBuffer.SetRenderTarget( new RenderTargetIdentifier(temporary), RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare); commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0); pipeline.SetViewport(commandBuffer, nextProcess); pipeline.DrawCopy(commandBuffer); context.SetSource0(temporary); } else { commandBuffer.SetRenderTarget( new RenderTargetIdentifier(temporary), RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare); commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.target0); pipeline.SetViewport(commandBuffer, nextProcess); pipeline.DrawCopy(commandBuffer); context.SetTarget0(temporary); } } else { commandBuffer.SetRenderTarget( context.target0, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare); commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0); pipeline.SetViewport(commandBuffer, nextProcess); pipeline.DrawCopy(commandBuffer); } commandBuffer.SetRenderTarget( context.target0, (Properties.StencilCompare != CompareFunction.Always)? RenderBufferLoadAction.Load : RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, pipeline.DepthStencilBuffer, RenderBufferLoadAction.Load, RenderBufferStoreAction.DontCare); commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0); pipeline.SetViewport(commandBuffer, nextProcess); pipeline.DrawFill(commandBuffer, material, 0); context.duplicated = false; return(true); }
public override bool BuildCommandBuffer(RenderPipeline pipeline, CommandBuffer commandBuffer, TargetContext context, IPostProcess nextProcess) { if (context.CompareSource0ToTarget0() != false) { int temporary = pipeline.GetTemporaryRT(); if (nextProcess == null) { commandBuffer.Blit(context.source0, temporary); context.SetSource0(temporary); } else { context.SetTarget0(temporary); } } var brightnessExtractionTarget = new RenderTargetIdentifier(kShaderPropertyBrightnessExtractionTarget); commandBuffer.GetTemporaryRT(kShaderPropertyBrightnessExtractionTarget, brightnessExtractionDescriptor, FilterMode.Bilinear); commandBuffer.SetRenderTarget( brightnessExtractionTarget, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare); #if WITH_CLEARRENDERTARGET commandBuffer.ClearRenderTarget(false, true, Color.clear, 0); #endif commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0); commandBuffer.DrawMesh(brightnessExtractionMesh, Matrix4x4.identity, material, 0, 0); var gaussianBlurHorizontalTarget = new RenderTargetIdentifier(kShaderPropertyGaussianBlurHorizontalTarget); commandBuffer.GetTemporaryRT(kShaderPropertyGaussianBlurHorizontalTarget, blurDescriptor, FilterMode.Bilinear); commandBuffer.SetRenderTarget( kShaderPropertyGaussianBlurHorizontalTarget, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare); #if WITH_CLEARRENDERTARGET commandBuffer.ClearRenderTarget(false, true, Color.clear, 0); #endif commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, brightnessExtractionTarget); commandBuffer.DrawMesh(blurHorizontalMesh, Matrix4x4.identity, material, 0, 1); var gaussianBlurVerticalTarget = new RenderTargetIdentifier(kShaderPropertyGaussianBlurVerticalTarget); commandBuffer.GetTemporaryRT(kShaderPropertyGaussianBlurVerticalTarget, blurDescriptor, FilterMode.Bilinear); commandBuffer.SetRenderTarget( gaussianBlurVerticalTarget, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare); #if WITH_CLEARRENDERTARGET commandBuffer.ClearRenderTarget(false, true, Color.clear, 0); #endif commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, kShaderPropertyGaussianBlurHorizontalTarget); commandBuffer.DrawMesh(blurVerticalMesh, Matrix4x4.identity, material, 0, 1); if (combinePassCount > 1) { commandBuffer.SetRenderTarget( gaussianBlurHorizontalTarget, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare); #if WITH_CLEARRENDERTARGET commandBuffer.ClearRenderTarget(false, true, Color.clear, 0); #endif commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, gaussianBlurVerticalTarget); commandBuffer.DrawMesh(combineMesh, Matrix4x4.identity, material, 0, 2); commandBuffer.SetGlobalTexture(kShaderPropertyBloomTex, gaussianBlurVerticalTarget); commandBuffer.SetGlobalTexture(kShaderPropertyBloomCombinedTex, kShaderPropertyGaussianBlurHorizontalTarget); } else { commandBuffer.SetGlobalTexture(kShaderPropertyBloomCombinedTex, gaussianBlurVerticalTarget); } commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0); if (((nextProcess as PostProcess)?.DuplicateMRT() ?? false) != false) { int temporary = pipeline.GetTemporaryRT(); context.SetTarget1(temporary); commandBuffer.SetRenderTarget( new RenderTargetBinding( new [] { context.target0, context.target1 }, new [] { RenderBufferLoadAction.DontCare, RenderBufferLoadAction.DontCare }, new [] { RenderBufferStoreAction.Store, RenderBufferStoreAction.Store }, context.depthBuffer, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare)); pipeline.SetViewport(commandBuffer, nextProcess); pipeline.DrawFill(commandBuffer, material, 4); context.duplicated = true; } else { commandBuffer.SetRenderTarget( context.target0, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare); pipeline.SetViewport(commandBuffer, nextProcess); pipeline.DrawFill(commandBuffer, material, 3); context.duplicated = false; } commandBuffer.ReleaseTemporaryRT(kShaderPropertyGaussianBlurVerticalTarget); commandBuffer.ReleaseTemporaryRT(kShaderPropertyGaussianBlurHorizontalTarget); commandBuffer.ReleaseTemporaryRT(kShaderPropertyBrightnessExtractionTarget); return(true); }
public override bool BuildCommandBuffer(RenderPipeline pipeline, CommandBuffer commandBuffer, TargetContext context, IPostProcess nextProcess) { if (context.CompareSource0ToTarget0() != false) { int temporary = pipeline.GetTemporaryRT(); if (nextProcess == null) { commandBuffer.Blit(context.source0, temporary); context.SetSource0(temporary); } else { context.SetTarget0(temporary); } } /**/ var blurTarget = new RenderTargetIdentifier(kShaderTargetBlur); commandBuffer.GetTemporaryRT(kShaderTargetBlur, descriptor, FilterMode.Point); commandBuffer.SetRenderTarget( blurTarget, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare); commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0); pipeline.DrawFill(commandBuffer, material, 0); /**/ commandBuffer.SetRenderTarget( context.target0, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare); commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0); commandBuffer.SetGlobalTexture(kShaderPropertyBlurTex, blurTarget); pipeline.SetViewport(commandBuffer, nextProcess); pipeline.DrawFill(commandBuffer, material, 1); commandBuffer.ReleaseTemporaryRT(kShaderTargetBlur); context.duplicated = false; return(true); }
public override bool BuildCommandBuffer(RenderPipeline pipeline, CommandBuffer commandBuffer, TargetContext context, IPostProcess nextProcess) { commandBuffer.ClearRenderTarget( Properties.ClearDepth, Properties.ClearColor, Properties.Color, Properties.Depth); context.duplicated = false; return(false); }
public static void agregarPostProcessObject(IPostProcess objeto) { postProcessObjects.Add(objeto); }
public abstract bool BuildCommandBuffer(RenderPipeline pipeline, CommandBuffer commandBuffer, TargetContext context, IPostProcess nextProcess);
public void AgregarElemento(IPostProcess elem) { PostProcessElements.Add(elem); }
public override bool BuildCommandBuffer(RenderPipeline pipeline, CommandBuffer commandBuffer, TargetContext context, IPostProcess nextProcess) { if (context.CompareSource0ToTarget0() != false) { int temporary = pipeline.GetTemporaryRT(); if (nextProcess == null) { commandBuffer.Blit(context.source0, temporary); context.SetSource0(temporary); } else { context.SetTarget0(temporary); } } if (Properties.DebugMode != false) { commandBuffer.SetRenderTarget( context.target0, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare); commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0); pipeline.SetViewport(commandBuffer, nextProcess); pipeline.DrawFill(commandBuffer, material, 0); } else { /**/ var shadeTarget = new RenderTargetIdentifier(kShaderTargetShade); commandBuffer.GetTemporaryRT(kShaderTargetShade, shadeDescriptor, FilterMode.Bilinear); commandBuffer.SetRenderTarget( shadeTarget, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare); if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Metal) { commandBuffer.ClearRenderTarget(false, true, Color.black, 0); } commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0); pipeline.DrawFill(commandBuffer, material, 0); /**/ var halfTarget = new RenderTargetIdentifier(kShaderTargetHalf); commandBuffer.GetTemporaryRT(kShaderTargetHalf, halfDescriptor, FilterMode.Bilinear); commandBuffer.SetRenderTarget( halfTarget, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare); if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Metal) { commandBuffer.ClearRenderTarget(false, true, Color.black, 0); } commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, shadeTarget); pipeline.DrawFill(commandBuffer, material, 1); /**/ var quarterTarget = new RenderTargetIdentifier(kShaderTargetQuarter); commandBuffer.GetTemporaryRT(kShaderTargetQuarter, quarterDescriptor, FilterMode.Bilinear); commandBuffer.SetRenderTarget( quarterTarget, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare); if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Metal) { commandBuffer.ClearRenderTarget(false, true, Color.black, 0); } commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, halfTarget); pipeline.DrawFill(commandBuffer, material, 1); /**/ commandBuffer.SetRenderTarget( context.target0, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare); commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0); commandBuffer.SetGlobalTexture(kShaderPropertyBlurTex, quarterTarget); pipeline.DrawFill(commandBuffer, material, 2); commandBuffer.ReleaseTemporaryRT(kShaderTargetShade); commandBuffer.ReleaseTemporaryRT(kShaderTargetHalf); commandBuffer.ReleaseTemporaryRT(kShaderTargetQuarter); } context.duplicated = false; return(true); }
public override bool BuildCommandBuffer(RenderPipeline pipeline, CommandBuffer commandBuffer, TargetContext context, IPostProcess nextProcess) { commandBuffer.SetRenderTarget( Properties.GetInternalStripLut(), RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare); commandBuffer.SetGlobalTexture("_Curves", Properties.GetCurveTexture(false)); pipeline.SetViewport(commandBuffer, nextProcess); pipeline.DrawFill(commandBuffer, material, 0); context.duplicated = false; return(true); }
/// <summary> /// Compares the current object with another object of the same type. /// </summary> /// <param name="other">An object to compare with this object.</param> /// <returns> /// A 32-bit signed integer that indicates the relative order of the objects being compared. The return value has the following meanings: Value Meaning Less than zero This object is less than the <paramref name="other"/> parameter.Zero This object is equal to <paramref name="other"/>. Greater than zero This object is greater than <paramref name="other"/>. /// </returns> public int CompareTo(IPostProcess other) { return(PostProcessComparer.CompareIPostProcess(this, other)); }
void OnPreRender() { bool fourceCacheClear = false; #if UNITY_EDITOR if (Application.isPlaying == false && enabled == false) { return; } if (CollectionProcesses() != false) { isRebuildCommandBuffers = true; fourceCacheClear = true; } if (cacheOverrideTargetBuffers != OverrideTargetBuffers) { cacheOverrideTargetBuffers = OverrideTargetBuffers; isRebuildCommandBuffers = true; } if (cacheOverrideCameraDepthTexture != OverrideCameraDepthTexture) { cacheOverrideCameraDepthTexture = OverrideCameraDepthTexture; isRebuildCommandBuffers = true; } if (cacheDefaultDepthTextureMode != defaultDepthTextureMode) { cacheDefaultDepthTextureMode = defaultDepthTextureMode; isRebuildCommandBuffers = true; } if (copyShader != null && copyMaterial == null) { copyMaterial = new Material(copyShader); } #endif if (OverrideTargetBuffers != false) { if (cacheScreenWidth != Screen.width || cacheScreenHeight != Screen.height || cacheResolutionScale != resolutionScale) { isRebuildCommandBuffers = true; } } if (cacheCamera.allowMSAA != false) { cacheCamera.allowMSAA = false; isRebuildCommandBuffers = true; } if (cacheDisplayWidth != Screen.width || cacheDisplayHeight != Screen.height) { isRebuildCommandBuffers = true; cacheDisplayWidth = Screen.width; cacheDisplayHeight = Screen.height; } for (int i0 = 0; i0 < caches.Length; ++i0) { IPostProcess process = caches[i0]; bool cacheClear = fourceCacheClear; if (process != null) { if (process is IUbarProcess ubarProcess) { if (ubarProcess.PreProcess() == false && ubarProcess.HasIndependent(ref isRebuildCommandBuffers) == false) { continue; } } #if UNITY_EDITOR if (process.RestoreMaterials() != false) { cacheClear = true; } #endif if (process.UpdateProperties(this, cacheClear) != false) { isRebuildCommandBuffers = true; } } } if (isRebuildCommandBuffers != false) { RebuildCommandBuffers(); } RebuildScreenShotCommandBuffer("CameraPipeline::OpaqueScreenShot", ref phaseOpaqueScreenShot, ref opaqueScreenShot, CameraEvent.BeforeImageEffectsOpaque, ref commandBufferOpaqueScreenShot, ref onOpaqueScreenShot); RebuildScreenShotCommandBuffer("CameraPipeline::PostScreenShot", ref phasePostScreenShot, ref postScreenShot, CameraEvent.BeforeImageEffects, ref commandBufferPostScreenShot, ref onPostScreenShot); }