From 61d6e9bf192ffa54abc57bab69b1bd88c3b8d62b Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 29 Sep 2021 19:55:57 +0800 Subject: *misc --- Assets/Scripts/Unit/LensEffect/LensEffect_Dash.cs | 38 +++++++++++++++++------ 1 file changed, 28 insertions(+), 10 deletions(-) (limited to 'Assets/Scripts/Unit/LensEffect/LensEffect_Dash.cs') diff --git a/Assets/Scripts/Unit/LensEffect/LensEffect_Dash.cs b/Assets/Scripts/Unit/LensEffect/LensEffect_Dash.cs index 24a62264..935a7286 100644 --- a/Assets/Scripts/Unit/LensEffect/LensEffect_Dash.cs +++ b/Assets/Scripts/Unit/LensEffect/LensEffect_Dash.cs @@ -12,15 +12,17 @@ public class LensEffect_Dash : LensEffectBase float lifeTime; UnitSnapshot snapshot; TRS trs; + float angle; - public LensEffect_Dash(TRS trs, Color color, float lifeTime, UnitSnapshotInfo snapshot) : base() + public LensEffect_Dash(Color color, float lifeTime, float angle, UnitSnapshotInfo snapshot) : base() { rimColor = color; tempID = Shader.PropertyToID("_BlurRim_RT0"); this.lifeTime = lifeTime; + trs = snapshot.trs; this.snapshot = UnitManager.Instance.ClaimSnapshotSolo(snapshot); - this.trs = trs; - } + this.angle = angle; + } public override void AfterForwardOpaque(EStage stage, CommandBuffer cb) { @@ -44,17 +46,33 @@ public class LensEffect_Dash : LensEffectBase 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; + + 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); + + 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) { - MaterialEntry blur = ClaimMaterial(StaticDefine.shaders[EShader.Blur].name); + MaterialEntry blur = ClaimMaterial(StaticDefine.shaders[EShader.MotionBlur].name); - Vector4 tileOffset = RenderingUtility.GetTillingOffset(MainCamera.Instance.camera, owner.center, owner.unitDetail.snapshotBound); - blur.material.SetVector("_TileOffset", tileOffset); - - cb.Blit(tempID, BuiltinRenderTextureType.CameraTarget, blur.material); + Vector4 tileOffset = RenderingUtility.GetTillingOffset(MainCamera.Instance.camera, owner.center, owner.unitDetail.snapshotBound); + blur.material.SetVector("_TileOffset", tileOffset); + blur.material.SetFloat("_Angle", Mathf.Rad2Deg * angle); + + cb.Blit(tempID, BuiltinRenderTextureType.CameraTarget, blur.material); cb.ReleaseTemporaryRT(tempID); } -- cgit v1.1-26-g67d0