diff --git a/SCHIZO/Creatures/Hiyorifish/ILookAtYouLookingAtMe.cs b/SCHIZO/Creatures/Hiyorifish/ILookAtYouLookingAtMe.cs index 2f87a4a5..94f03881 100644 --- a/SCHIZO/Creatures/Hiyorifish/ILookAtYouLookingAtMe.cs +++ b/SCHIZO/Creatures/Hiyorifish/ILookAtYouLookingAtMe.cs @@ -184,6 +184,7 @@ private IEnumerator TeleportsBehindYou() bool didHit = Physics.Raycast(transform.position, line.normalized, out RaycastHit hit, line.magnitude, layerMask, QueryTriggerInteraction.Ignore); Vector3 closestPoint = didHit ? hit.point : targetPos; + vanish.Play(); // TODO: some sort of vfx const float moveDuration = 0.1f; Vector3 oldPos = transform.position; diff --git a/Unity/Assets/Mod/Hiyorifish/Hiyorifish.prefab b/Unity/Assets/Mod/Hiyorifish/Hiyorifish.prefab index 7a36c7bd..ce5d9db7 100644 --- a/Unity/Assets/Mod/Hiyorifish/Hiyorifish.prefab +++ b/Unity/Assets/Mod/Hiyorifish/Hiyorifish.prefab @@ -23,6 +23,7 @@ MonoBehaviour: teleportDelay: 2 attackDamage: 10 attackCooldown: 5 + vanish: {fileID: 3242919605542676494} --- !u!114 &4987332174112196998 MonoBehaviour: m_ObjectHideFlags: 0 @@ -47,6 +48,7 @@ GameObject: m_Component: - component: {fileID: 4864560752399926567} - component: {fileID: 3352353848001060605} + - component: {fileID: 3242919605542676494} m_Layer: 0 m_Name: ARG censor effect holder m_TagString: Untagged @@ -84,6 +86,60 @@ MonoBehaviour: fadeOutStartDistance: 35 scale: 1.3 frameChangeInterval: 0.08 +--- !u!114 &3242919605542676494 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9000506824905469698} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ab295fd9edc803847899e6a45b19b8d7, type: 3} + m_Name: + m_EditorClassIdentifier: + material: {fileID: 2100000, guid: 90d68bd5b93283548afcede3360eed2a, type: 2} + previewImage: {fileID: 2800000, guid: 8d9a0b0a0c76afd47b6dd21873f45558, type: 3} + previewResult: {fileID: 0} + image: {fileID: 2800000, guid: c067febdd5239af44952245c405a4e1e, type: 3} + wrapMode: 0 + curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: -0.49856365 + value: -0.0020976663 + inSlope: 3.8164005 + outSlope: 3.8164005 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0.11409956 + - serializedVersion: 3 + time: -0.23037523 + value: 0.9432476 + inSlope: -0.15380536 + outSlope: 0.09137419 + tangentMode: 1 + weightedMode: 3 + inWeight: 0.4085686 + outWeight: 0.10359245 + - serializedVersion: 3 + time: 0.9874878 + value: 0 + inSlope: -0.12003079 + outSlope: -0.12003079 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.6338688 + outWeight: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + displacementStrength: 2 + effectDuration: 1 + scale: 4 + fadeoutDist: 35 --- !u!1001 &915920292816743419 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Unity/Assets/Mod/VFX/vanish splash.meta b/Unity/Assets/Mod/VFX/vanish splash.meta new file mode 100644 index 00000000..0aca7202 --- /dev/null +++ b/Unity/Assets/Mod/VFX/vanish splash.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e72a42e5e8c02ec4db12b2872661959d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Mod/VFX/vanish splash/VanishSplash.mat b/Unity/Assets/Mod/VFX/vanish splash/VanishSplash.mat new file mode 100644 index 00000000..65fec465 --- /dev/null +++ b/Unity/Assets/Mod/VFX/vanish splash/VanishSplash.mat @@ -0,0 +1,44 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: VanishSplash + m_Shader: {fileID: 4800000, guid: 57cbbb69b0cc9e34d9c511988eee5f21, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _Disp: + m_Texture: {fileID: 2800000, guid: 2d1f222c31e4d374b985748e539464b6, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Image: + m_Texture: {fileID: 2800000, guid: c067febdd5239af44952245c405a4e1e, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Noise: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _DispStr: 2 + - _Phase: 0 + - _Scale: 4 + - _Strength: 0 + m_Colors: + - _ScreenPosition: {r: 0, g: 0, b: 0, a: 0} diff --git a/Unity/Assets/Mod/VFX/vanish splash/VanishSplash.mat.meta b/Unity/Assets/Mod/VFX/vanish splash/VanishSplash.mat.meta new file mode 100644 index 00000000..db878289 --- /dev/null +++ b/Unity/Assets/Mod/VFX/vanish splash/VanishSplash.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 90d68bd5b93283548afcede3360eed2a +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Mod/VFX/vanish splash/VansihSpalsh_shader.shader b/Unity/Assets/Mod/VFX/vanish splash/VansihSpalsh_shader.shader new file mode 100644 index 00000000..aba3c025 --- /dev/null +++ b/Unity/Assets/Mod/VFX/vanish splash/VansihSpalsh_shader.shader @@ -0,0 +1,90 @@ +Shader "Hidden/VanishSplash_shader" +{ + Properties + { + [HideInInspector] + _MainTex ("MainTex", 2D) = "gray" {} + [NoScaleOffset] + _Image ("image", 2D) = "gray" {} + [HideInInspector] + _ScreenPosition ("Position" , Vector) = (0,0,0,0) + _Strength ("Strength", float) = 1 + _Scale ("Scale", float) = 2 + _Phase("Phase", float) = 0 + _DispStr("Displacement Strength", float) = 1 + } + SubShader + { + Tags {"Queue" = "AlphaTest" "PreviewType" = "Plane" } + // No culling or depth + Cull Off ZWrite Off ZTest Always + + Pass + { + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + + #pragma require 2darray + #include "UnityCG.cginc" + + struct appdata + { + float4 vertex : POSITION; + float2 uv : TEXCOORD0; + }; + + struct v2f + { + float2 uv : TEXCOORD0; + float4 vertex : SV_POSITION; + }; + + v2f vert (appdata v) + { + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.uv = v.uv; + return o; + } + + + sampler2D _CameraDepthTexture; + sampler2D _MainTex; + sampler2D _Image; + float4 _ScreenPosition; + float _Strength; + float _Scale; + float _Phase; + float4 _Image_TexelSize; + float _DispStr; + + float2 FixUV(float2 iuv, float2 tex) + { + float2 asp = float2(_ScreenParams.x / _ScreenParams.y, 1); + float2 imAsp = float2(tex.x / tex.y, 1); + return iuv * ( asp / imAsp); + } + + fixed4 frag (v2f i) : SV_Target + { + _ScreenPosition.xy /= _ScreenParams.xy; + + float depth = LinearEyeDepth(tex2D(_CameraDepthTexture, i.uv)); + float depthDist = saturate((depth - _ScreenPosition.z) * 100) ; + + _Scale = (1 / _Scale) * _ScreenPosition.z; + + float2 straightUV = FixUV(i.uv * _Scale, _Image_TexelSize.zw) + 0.5; + float2 straightPos = FixUV(_ScreenPosition.xy * _Scale, _Image_TexelSize.zw); + + float2 distFactor = (_ScreenPosition.xy - i.uv) * _DispStr * distance(i.uv, _ScreenPosition.xy) * _Phase; + fixed4 col = tex2D(_MainTex, i.uv + distFactor); + fixed4 image = tex2D(_Image, straightUV - straightPos); + image.w = (distFactor.x + distFactor.y) ; + return col + (image * image.w * depthDist * _Strength * _Phase); + } + ENDCG + } + } +} diff --git a/Unity/Assets/Mod/VFX/vanish splash/VansihSpalsh_shader.shader.meta b/Unity/Assets/Mod/VFX/vanish splash/VansihSpalsh_shader.shader.meta new file mode 100644 index 00000000..e909361c --- /dev/null +++ b/Unity/Assets/Mod/VFX/vanish splash/VansihSpalsh_shader.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 57cbbb69b0cc9e34d9c511988eee5f21 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/SCHIZO/Creatures/Hiyorifish/ILookAtYouLookingAtMe.cs b/Unity/Assets/Scripts/SCHIZO/Creatures/Hiyorifish/ILookAtYouLookingAtMe.cs index 9b7a280c..3ce1dd3e 100644 --- a/Unity/Assets/Scripts/SCHIZO/Creatures/Hiyorifish/ILookAtYouLookingAtMe.cs +++ b/Unity/Assets/Scripts/SCHIZO/Creatures/Hiyorifish/ILookAtYouLookingAtMe.cs @@ -1,4 +1,5 @@ using SCHIZO.Attributes; +using SCHIZO.VFX; using TriInspector; using UnityEngine; @@ -33,5 +34,6 @@ public partial class ILookAtYouLookingAtMe : MonoBehaviour public float attackDamage = 10f; [Tooltip("After attack, idles for this long")] public float attackCooldown = 5f; + public VanishSplash vanish; } } diff --git a/Unity/Assets/Scripts/SCHIZO/VFX/VanishSplash.cs b/Unity/Assets/Scripts/SCHIZO/VFX/VanishSplash.cs new file mode 100644 index 00000000..1cc8564c --- /dev/null +++ b/Unity/Assets/Scripts/SCHIZO/VFX/VanishSplash.cs @@ -0,0 +1,54 @@ +using System.Collections; +using UnityEngine; + +namespace SCHIZO.VFX +{ + [AddComponentMenu("SCHIZO/VFX/Vanish")] + public class VanishSplash : VFXComponent + { + public Texture2D image; + public TextureWrapMode wrapMode = TextureWrapMode.Clamp; + public AnimationCurve curve; + public float displacementStrength = 1f; + public float effectDuration = 1f; + + [Range(0f, 10f)] + public float scale = 1; + + public float fadeoutDist = 35f; + private float opacity; + + private Vector3 pos; + private float phase = 0; + + public override void SetProperties() + { + base.SetProperties(); + image.wrapMode = wrapMode; + propBlock.SetTexture("_Image", image); + propBlock.SetVector("_ScreenPosition", new Vector4(pos.x, pos.y, pos.z, 0f)); + propBlock.SetFloat("_Strength", opacity); + propBlock.SetFloat("_Scale", scale); + propBlock.SetFloat("_Phase", phase); + propBlock.SetFloat("_DispStr", displacementStrength); + } + + public void Play() + { + StartCoroutine(Playing()); + } + + private IEnumerator Playing() + { + Vector3 dirToCam = (Camera.main.transform.position - transform.position).normalized; + pos = Camera.main.WorldToScreenPoint(transform.position + dirToCam); + opacity = Mathf.Clamp01((1f / pos.z) * fadeoutDist); + + for (float t = 0; t < effectDuration; t += Time.deltaTime) + { + phase = curve.Evaluate(t); + yield return null; + } + } + } +} diff --git a/Unity/Assets/Scripts/SCHIZO/VFX/VanishSplash.cs.meta b/Unity/Assets/Scripts/SCHIZO/VFX/VanishSplash.cs.meta new file mode 100644 index 00000000..47824673 --- /dev/null +++ b/Unity/Assets/Scripts/SCHIZO/VFX/VanishSplash.cs.meta @@ -0,0 +1,15 @@ +fileFormatVersion: 2 +guid: ab295fd9edc803847899e6a45b19b8d7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: + - material: {fileID: 2100000, guid: 90d68bd5b93283548afcede3360eed2a, type: 2} + - previewImage: {fileID: 2800000, guid: 8d9a0b0a0c76afd47b6dd21873f45558, type: 3} + - previewResult: {instanceID: 0} + - image: {fileID: 2800000, guid: c067febdd5239af44952245c405a4e1e, type: 3} + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: