From 402bd202e40da369b93ea233886f3fdb1047f8e8 Mon Sep 17 00:00:00 2001 From: hdh Date: Tue, 20 Jun 2017 10:58:08 +0800 Subject: [PATCH 1/2] fix dx9 shader model 3 linear rendering DoF bug --- PostProcessing/Runtime/Components/DepthOfFieldComponent.cs | 3 ++- PostProcessing/Runtime/Utils/RenderTextureFactory.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/PostProcessing/Runtime/Components/DepthOfFieldComponent.cs b/PostProcessing/Runtime/Components/DepthOfFieldComponent.cs index 694888c4..18db28d6 100644 --- a/PostProcessing/Runtime/Components/DepthOfFieldComponent.cs +++ b/PostProcessing/Runtime/Components/DepthOfFieldComponent.cs @@ -105,7 +105,8 @@ public void Prepare(RenderTexture source, Material uberMaterial, bool antialiasC material.SetFloat(Uniforms._RcpAspect, 1f / aspect); // CoC calculation pass - var rtCoC = context.renderTextureFactory.Get(context.width, context.height, 0, cocFormat); + // HACK by hdh, add RenderTextureReadWrite.Linear setting. in DX9 shader model 3 Linear rendering, without this will have bug + var rtCoC = context.renderTextureFactory.Get(context.width, context.height, 0, cocFormat, RenderTextureReadWrite.Linear); Graphics.Blit(null, rtCoC, material, 0); if (antialiasCoC) diff --git a/PostProcessing/Runtime/Utils/RenderTextureFactory.cs b/PostProcessing/Runtime/Utils/RenderTextureFactory.cs index d51bf6c0..a3864732 100644 --- a/PostProcessing/Runtime/Utils/RenderTextureFactory.cs +++ b/PostProcessing/Runtime/Utils/RenderTextureFactory.cs @@ -27,7 +27,7 @@ public RenderTexture Get(RenderTexture baseRenderTexture) public RenderTexture Get(int width, int height, int depthBuffer = 0, RenderTextureFormat format = RenderTextureFormat.ARGBHalf, RenderTextureReadWrite rw = RenderTextureReadWrite.Default, FilterMode filterMode = FilterMode.Bilinear, TextureWrapMode wrapMode = TextureWrapMode.Clamp, string name = "FactoryTempTexture") { - var rt = RenderTexture.GetTemporary(width, height, depthBuffer, format); + var rt = RenderTexture.GetTemporary(width, height, depthBuffer, format, rw); // add forgotten param rw rt.filterMode = filterMode; rt.wrapMode = wrapMode; rt.name = name; From d0239ff2eb49e65fb92eae59599c4e5dbcb2cc5c Mon Sep 17 00:00:00 2001 From: hdhhuang Date: Thu, 22 Jun 2017 12:13:33 +0800 Subject: [PATCH 2/2] removed comment --- PostProcessing/Runtime/Components/DepthOfFieldComponent.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/PostProcessing/Runtime/Components/DepthOfFieldComponent.cs b/PostProcessing/Runtime/Components/DepthOfFieldComponent.cs index 18db28d6..d09643c8 100644 --- a/PostProcessing/Runtime/Components/DepthOfFieldComponent.cs +++ b/PostProcessing/Runtime/Components/DepthOfFieldComponent.cs @@ -105,7 +105,6 @@ public void Prepare(RenderTexture source, Material uberMaterial, bool antialiasC material.SetFloat(Uniforms._RcpAspect, 1f / aspect); // CoC calculation pass - // HACK by hdh, add RenderTextureReadWrite.Linear setting. in DX9 shader model 3 Linear rendering, without this will have bug var rtCoC = context.renderTextureFactory.Get(context.width, context.height, 0, cocFormat, RenderTextureReadWrite.Linear); Graphics.Blit(null, rtCoC, material, 0);