-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from w1n7er87/warp
poof warp effect
- Loading branch information
Showing
10 changed files
with
287 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
90 changes: 90 additions & 0 deletions
90
Unity/Assets/Mod/VFX/vanish splash/VansihSpalsh_shader.shader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
Unity/Assets/Mod/VFX/vanish splash/VansihSpalsh_shader.shader.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.