summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Unit/LensEffect/LensEffect_Dash.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-10-01 10:04:00 +0800
committerchai <chaifix@163.com>2021-10-01 10:04:00 +0800
commitf0ae9393da021fe16af32f7ae1a3245f27050f92 (patch)
treeeb3618a8661c6771098cdfe796bdff50b4e75328 /Assets/Scripts/Unit/LensEffect/LensEffect_Dash.cs
parent5b19af7f51ad4504fc426b8387442f6b868b5f61 (diff)
*misc
Diffstat (limited to 'Assets/Scripts/Unit/LensEffect/LensEffect_Dash.cs')
-rw-r--r--Assets/Scripts/Unit/LensEffect/LensEffect_Dash.cs96
1 files changed, 48 insertions, 48 deletions
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