diff options
Diffstat (limited to 'Assets/Scripts/Unit')
-rw-r--r-- | Assets/Scripts/Unit/AI/Actions.meta | 8 | ||||
-rw-r--r-- | Assets/Scripts/Unit/AI/Conditionals.meta | 8 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Components/UnitPreprocessing.cs | 77 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Components/UnitState/PCState.cs | 2 | ||||
-rw-r--r-- | Assets/Scripts/Unit/LensEffect/LensEffect_Buzz.cs | 6 | ||||
-rw-r--r-- | Assets/Scripts/Unit/LensEffect/LensEffect_Dash.cs | 96 |
6 files changed, 91 insertions, 106 deletions
diff --git a/Assets/Scripts/Unit/AI/Actions.meta b/Assets/Scripts/Unit/AI/Actions.meta deleted file mode 100644 index 9b4ad463..00000000 --- a/Assets/Scripts/Unit/AI/Actions.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 971e9d55b8bc0894eb6a110fb962000b -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Unit/AI/Conditionals.meta b/Assets/Scripts/Unit/AI/Conditionals.meta deleted file mode 100644 index 70a86da5..00000000 --- a/Assets/Scripts/Unit/AI/Conditionals.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 85b7e0c7ed1d12f42a5178bfbf3d934c -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: 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 diff --git a/Assets/Scripts/Unit/Components/UnitState/PCState.cs b/Assets/Scripts/Unit/Components/UnitState/PCState.cs index 7e766455..1bdd355f 100644 --- a/Assets/Scripts/Unit/Components/UnitState/PCState.cs +++ b/Assets/Scripts/Unit/Components/UnitState/PCState.cs @@ -144,7 +144,7 @@ public partial class PCState : UnitState UnitSnapshotInfo info = owner.TakeSnapshot();
Vector2 dir = TestErika.Instance.monster.owner.center + new Vector3(offset, -0.5f, 0) - owner.center;
- LensEffect_Dash dash = new LensEffect_Dash(Color.white, 0.05f, Mathf.Atan2(dir.y, dir.x), info);
+ LensEffect_Dash dash = new LensEffect_Dash(Color.white, 0.1f, Mathf.Atan2(dir.y, dir.x), info);
owner.unitLensEffect.AddEffect(dash);
owner.center = TestErika.Instance.monster.owner.center + new Vector3(offset, -0.5f, 0);
diff --git a/Assets/Scripts/Unit/LensEffect/LensEffect_Buzz.cs b/Assets/Scripts/Unit/LensEffect/LensEffect_Buzz.cs index 55e8c772..6aa06d01 100644 --- a/Assets/Scripts/Unit/LensEffect/LensEffect_Buzz.cs +++ b/Assets/Scripts/Unit/LensEffect/LensEffect_Buzz.cs @@ -15,11 +15,11 @@ public class LensEffect_Buzz : LensEffectBase public override void AfterForwardAlpha(EStage stage, CommandBuffer cb) { - if(stage == EStage.Before) + if (stage == EStage.Before) { Before(cb); } - else if(stage == EStage.After) + else if (stage == EStage.After) { After(cb); } @@ -28,7 +28,7 @@ public class LensEffect_Buzz : LensEffectBase void Before(CommandBuffer cb) { MaterialEntry buzz = ClaimMaterial(StaticDefine.shaders[EShader.Buzz].name); - + cb.SetGlobalTexture("_UnitDepthTexture", owner.unitPreprocessing.unitDepthTexture); cb.Blit(BuiltinRenderTextureType.CameraTarget, BuiltinRenderTextureType.CameraTarget, buzz.material); } diff --git a/Assets/Scripts/Unit/LensEffect/LensEffect_Dash.cs b/Assets/Scripts/Unit/LensEffect/LensEffect_Dash.cs index 6cce6b4c..dc14cf09 100644 --- a/Assets/Scripts/Unit/LensEffect/LensEffect_Dash.cs +++ b/Assets/Scripts/Unit/LensEffect/LensEffect_Dash.cs @@ -9,22 +9,22 @@ public class LensEffect_Dash : LensEffectBase Color rimColor; int tempID; - float lifeTime; - UnitSnapshot snapshot; - TRS trs;
- float angle;
+ float lifeTime;
+ UnitSnapshot snapshot;
+ TRS trs;
+ float angle;
- float curTime = 0;
+ float curTime = 0;
- public LensEffect_Dash(Color color, float lifeTime, float angle, UnitSnapshotInfo snapshot) : base() + public LensEffect_Dash(Color color, float lifeTime, float angle, UnitSnapshotInfo snapshot) : base() { rimColor = color; tempID = Shader.PropertyToID("RT_Dash"); - this.lifeTime = lifeTime; - trs = snapshot.trs; - this.snapshot = UnitManager.Instance.ClaimSnapshotSolo(snapshot); - this.angle = angle; - } + this.lifeTime = lifeTime;
+ trs = snapshot.trs;
+ this.snapshot = UnitManager.Instance.ClaimSnapshotSolo(snapshot);
+ this.angle = angle;
+ } public override void AfterForwardOpaque(EStage stage, CommandBuffer cb) { @@ -42,53 +42,53 @@ public class LensEffect_Dash : LensEffectBase } void Before(CommandBuffer cb) - { - cb.GetTemporaryRT(tempID, -1, -1, 24, FilterMode.Bilinear); + {
+ cb.GetTemporaryRT(tempID, -1, -1, 24, FilterMode.Bilinear); cb.SetRenderTarget(tempID); - cb.ClearRenderTarget(true, true, new Color(0, 0, 0, 0)); - - // renderer - snapshot.transform.position = trs.position; - snapshot.transform.rotation = trs.rotation; - snapshot.transform.localScale = trs.scale;
+ cb.ClearRenderTarget(true, true, new Color(0, 0, 0, 0));
- Matrix4x4 obj2Wod = Matrix4x4.identity;
- SkinnedMeshRenderer smr = snapshot.renderers[0] as SkinnedMeshRenderer;
- Vector3 pos = smr.rootBone.transform.position;
- Quaternion rot = smr.rootBone.transform.rotation;
- obj2Wod = MatrixUtility.RotateAndTranslate(pos, rot);
+ // renderer
+ snapshot.transform.position = trs.position;
+ snapshot.transform.rotation = trs.rotation;
+ snapshot.transform.localScale = trs.scale;
- MaterialEntry mat = ClaimMaterial(StaticDefine.shaders[EShader.SolidColor].name);
- mat.material.SetColor("_Color", rimColor);
- mat.material.SetMatrix("_ObjectToWorld", obj2Wod);
- mat.material.SetTexture("_MainTex", snapshot.renderers[0].sharedMaterial.GetTexture("_MainTex"));
+ Matrix4x4 obj2Wod = Matrix4x4.identity;
+ SkinnedMeshRenderer smr = snapshot.renderers[0] as SkinnedMeshRenderer;
+ Vector3 pos = smr.rootBone.transform.position;
+ Quaternion rot = smr.rootBone.transform.rotation;
+ obj2Wod = MatrixUtility.RotateAndTranslate(pos, rot);
- cb.DrawRenderer(snapshot.renderers[0], mat.material);
- } + MaterialEntry mat = ClaimMaterial(StaticDefine.shaders[EShader.SolidColor].name);
+ mat.material.SetColor("_Color", rimColor);
+ mat.material.SetMatrix("_ObjectToWorld", obj2Wod);
+ mat.material.SetTexture("_MainTex", snapshot.renderers[0].sharedMaterial.GetTexture("_MainTex"));
+
+ cb.DrawRenderer(snapshot.renderers[0], mat.material);
+ } void After(CommandBuffer cb) {
- curTime += Time.deltaTime;
+ curTime += Time.deltaTime;
- MaterialEntry blur = ClaimMaterial(StaticDefine.shaders[EShader.MotionBlur].name); + MaterialEntry blur = ClaimMaterial(StaticDefine.shaders[EShader.MotionBlur].name); - Vector4 tileOffset = RenderingUtility.GetTillingOffset(MainCamera.Instance.camera, owner.center, owner.unitDetail.snapshotBound);
- blur.material.SetVector("_UnitTileOffset", tileOffset);
- blur.material.SetFloat("_Angle", Mathf.Rad2Deg * angle);
- blur.material.SetFloat("_AlphaMultiplier", Mathf.Clamp(1 - curTime / lifeTime, 0, 1));
+ Vector4 tileOffset = RenderingUtility.GetTillingOffset(MainCamera.Instance.camera, trs.position, owner.unitDetail.snapshotBound);
+ blur.material.SetVector("_UnitTileOffset", tileOffset);
+ blur.material.SetFloat("_Angle", Mathf.Rad2Deg * angle);
+ blur.material.SetFloat("_AlphaMultiplier", Mathf.Clamp(1 - curTime / lifeTime, 0, 1));
- cb.Blit(tempID, BuiltinRenderTextureType.CameraTarget, blur.material); + cb.Blit(tempID, BuiltinRenderTextureType.CameraTarget, blur.material); cb.ReleaseTemporaryRT(tempID); - } - - public override bool CanDestroy()
- {
- return curTime > lifeTime;
- } - - public override void OnDestroy()
- {
- UnitManager.Instance.ReleaseSnapshot(ref snapshot);
- }
+ }
+
+ public override bool CanDestroy()
+ {
+ return curTime > lifeTime;
+ }
+
+ public override void OnDestroy()
+ {
+ UnitManager.Instance.ReleaseSnapshot(ref snapshot);
+ }
}
\ No newline at end of file |