using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Rendering; public class LensEffect_Dash : LensEffectBase { public override ERenderingEvent renderingEvents => ERenderingEvent.AfterForwardOpaque; Color rimColor; int tempID; float lifeTime; UnitSnapshot snapshot; TRS trs; public LensEffect_Dash(TRS trs, Color color, float lifeTime, UnitSnapshotInfo snapshot) : base() { rimColor = color; tempID = Shader.PropertyToID("_BlurRim_RT0"); this.lifeTime = lifeTime; this.snapshot = UnitManager.Instance.ClaimSnapshotSolo(snapshot); this.trs = trs; } public override void AfterForwardOpaque(EStage stage, CommandBuffer cb) { if (stage == EStage.Before) { Before(cb); } else if (stage == EStage.After) { After(cb); } else if (stage == EStage.Finished) { } } void Before(CommandBuffer cb) { cb.GetTemporaryRT(tempID, -1, -1, 24, FilterMode.Bilinear); cb.SetRenderTarget(tempID); cb.ClearRenderTarget(true, true, new Color(0, 0, 0, 0)); // renderer } void After(CommandBuffer cb) { MaterialEntry blur = ClaimMaterial(StaticDefine.shaders[EShader.Blur].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); cb.ReleaseTemporaryRT(tempID); } }