diff options
author | chai <chaifix@163.com> | 2021-10-01 10:04:00 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-10-01 10:04:00 +0800 |
commit | f0ae9393da021fe16af32f7ae1a3245f27050f92 (patch) | |
tree | eb3618a8661c6771098cdfe796bdff50b4e75328 /Assets/Scripts/Unit/Components/UnitPreprocessing.cs | |
parent | 5b19af7f51ad4504fc426b8387442f6b868b5f61 (diff) |
*misc
Diffstat (limited to 'Assets/Scripts/Unit/Components/UnitPreprocessing.cs')
-rw-r--r-- | Assets/Scripts/Unit/Components/UnitPreprocessing.cs | 77 |
1 files changed, 39 insertions, 38 deletions
diff --git a/Assets/Scripts/Unit/Components/UnitPreprocessing.cs b/Assets/Scripts/Unit/Components/UnitPreprocessing.cs index 44ab73b7..8c56f0b6 100644 --- a/Assets/Scripts/Unit/Components/UnitPreprocessing.cs +++ b/Assets/Scripts/Unit/Components/UnitPreprocessing.cs @@ -2,28 +2,28 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -using UnityEngine.Rendering; - -// 给每个角色准备一些特殊的前置渲染 +using UnityEngine.Rendering;
+
+// 给每个角色准备一些特殊的前置渲染
public class UnitPreprocessing : UnitComponent { [Flags] public enum EUnitPreprocessing { - None , - DepthTexture, // Unit Depth Texture - WorldNormalTexture, // Unit World Normal Texture + None, + DepthTexture, // Unit Depth Texture
+ WorldNormalTexture, // Unit World Normal Texture
} public EUnitPreprocessing preprocessing;
- #region render textures - public RenderTexture unitDepthTexture { get; private set; } + #region render textures + public RenderTexture unitDepthTexture { get; private set; } public RenderTexture unitWorldNormalTexture { get; private set; }
- public RenderTexture unitMotionVectorTexture { get; private set; }
- #endregion + public RenderTexture unitMotionVectorTexture { get; private set; }
+ #endregion - private CommandBuffer m_CBBeforeDepthTexture; + private CommandBuffer m_CommandBufferBeforeDepth; private Material m_MaterialDepth; @@ -39,7 +39,8 @@ public class UnitPreprocessing : UnitComponent MainCamera.Instance.customRenderingPipeline.onPreCull += OnWillRenderUnit; MainCamera.Instance.customRenderingPipeline.onPostRender += OnRenderUnit; - m_CBBeforeDepthTexture = new CommandBuffer(); + m_CommandBufferBeforeDepth = new CommandBuffer(); + m_CommandBufferBeforeDepth.name = "Unit Preprocessing(" + owner.unitObj.name + ")"; PrepareRenderTextures(); PrepareMaterials(); @@ -74,16 +75,16 @@ public class UnitPreprocessing : UnitComponent } private void OnWillRenderUnit() - { - RenderDepthTexture();
- //RenderWorldNormal();
- RenderMotionVector();
- MainCamera.Instance.camera.AddCommandBuffer(CameraEvent.BeforeDepthTexture, m_CBBeforeDepthTexture); - } + {
+ RenderDepthTexture();
+ //RenderWorldNormal();
+ RenderMotionVector();
+ MainCamera.Instance.camera.AddCommandBuffer(CameraEvent.BeforeDepthTexture, m_CommandBufferBeforeDepth);
+ } void RenderDepthTexture() { - var cb = m_CBBeforeDepthTexture; + var cb = m_CommandBufferBeforeDepth; cb.Clear(); cb.SetRenderTarget(unitDepthTexture); cb.ClearRenderTarget(true, true, new Color(0, 0, 0, 0)); @@ -100,21 +101,21 @@ public class UnitPreprocessing : UnitComponent continue; cb.DrawRenderer(renderer, m_MaterialDepth); } - } - - void RenderMotionVector()
- {
- } - - //void RenderWorldNormal() - //{ - // var cb = m_CBBeforeDepthTexture; - // cb.Clear(); - // cb.GetTemporaryRT(unitWorldNormalTextureID, -1, -1, 24, FilterMode.Point, RenderTextureFormat.RG16, RenderTextureReadWrite.Linear); - // cb.SetRenderTarget(unitWorldNormalTextureID); - // cb.ClearRenderTarget(true, true, new Color(0, 0, 0, 0)); - //} - + }
+
+ void RenderMotionVector()
+ {
+ }
+
+ //void RenderWorldNormal()
+ //{
+ // var cb = m_CommandBufferBeforeDepth;
+ // cb.Clear();
+ // cb.GetTemporaryRT(unitWorldNormalTextureID, -1, -1, 24, FilterMode.Point, RenderTextureFormat.RG16, RenderTextureReadWrite.Linear);
+ // cb.SetRenderTarget(unitWorldNormalTextureID);
+ // cb.ClearRenderTarget(true, true, new Color(0, 0, 0, 0));
+ //}
+
IEnumerable GetRenderers() { IBodyRendererAgent body = owner.unitRender.body; @@ -127,9 +128,9 @@ public class UnitPreprocessing : UnitComponent } private void OnRenderUnit() - { - //m_CBBeforeDepthTexture.ReleaseTemporaryRT(unitDepthTextureID); - - MainCamera.Instance.camera.RemoveCommandBuffer(CameraEvent.BeforeDepthTexture, m_CBBeforeDepthTexture); + {
+ //m_CommandBufferBeforeDepth.ReleaseTemporaryRT(unitDepthTextureID);
+
+ MainCamera.Instance.camera.RemoveCommandBuffer(CameraEvent.BeforeDepthTexture, m_CommandBufferBeforeDepth); } }
\ No newline at end of file |