Skip to content

Commit

Permalink
Merge pull request #61 from w1n7er87/warp
Browse files Browse the repository at this point in the history
poof warp effect
  • Loading branch information
Govorunb authored Apr 21, 2024
2 parents 5765b2a + fc100bc commit 1ff1530
Show file tree
Hide file tree
Showing 10 changed files with 287 additions and 0 deletions.
1 change: 1 addition & 0 deletions SCHIZO/Creatures/Hiyorifish/ILookAtYouLookingAtMe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
56 changes: 56 additions & 0 deletions Unity/Assets/Mod/Hiyorifish/Hiyorifish.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ MonoBehaviour:
teleportDelay: 2
attackDamage: 10
attackCooldown: 5
vanish: {fileID: 3242919605542676494}
--- !u!114 &4987332174112196998
MonoBehaviour:
m_ObjectHideFlags: 0
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions Unity/Assets/Mod/VFX/vanish splash.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions Unity/Assets/Mod/VFX/vanish splash/VanishSplash.mat
Original file line number Diff line number Diff line change
@@ -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}
8 changes: 8 additions & 0 deletions Unity/Assets/Mod/VFX/vanish splash/VanishSplash.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

90 changes: 90 additions & 0 deletions Unity/Assets/Mod/VFX/vanish splash/VansihSpalsh_shader.shader
Original file line number Diff line number Diff line change
@@ -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
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using SCHIZO.Attributes;
using SCHIZO.VFX;
using TriInspector;
using UnityEngine;

Expand Down Expand Up @@ -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;
}
}
54 changes: 54 additions & 0 deletions Unity/Assets/Scripts/SCHIZO/VFX/VanishSplash.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
}
15 changes: 15 additions & 0 deletions Unity/Assets/Scripts/SCHIZO/VFX/VanishSplash.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1ff1530

Please sign in to comment.