You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
145 lines
3.8 KiB
Plaintext
145 lines
3.8 KiB
Plaintext
2 months ago
|
//////////////////////////////////////////////
|
||
|
/// 2DxFX v3 - by VETASOFT 2018 //
|
||
|
//////////////////////////////////////////////
|
||
|
|
||
|
|
||
|
//////////////////////////////////////////////
|
||
|
|
||
|
Shader "2DxFX_Extra_Shaders/SymbioseDistortion"
|
||
|
{
|
||
|
Properties
|
||
|
{
|
||
|
[PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
|
||
|
Symbiose_Distance("Symbiose_Distance", Range(-0.3, 0.3)) = 0.215
|
||
|
Symbiose_Position("Symbiose_Position", Range(-1, 1)) = -0.249
|
||
|
Effect_Fading("Effect_Fading", Range(0, 1)) = 1
|
||
|
_SpriteFade("SpriteFade", Range(0, 1)) = 1.0
|
||
|
|
||
|
// required for UI.Mask
|
||
|
[HideInInspector]_StencilComp("Stencil Comparison", Float) = 8
|
||
|
[HideInInspector]_Stencil("Stencil ID", Float) = 0
|
||
|
[HideInInspector]_StencilOp("Stencil Operation", Float) = 0
|
||
|
[HideInInspector]_StencilWriteMask("Stencil Write Mask", Float) = 255
|
||
|
[HideInInspector]_StencilReadMask("Stencil Read Mask", Float) = 255
|
||
|
[HideInInspector]_ColorMask("Color Mask", Float) = 15
|
||
|
|
||
|
}
|
||
|
|
||
|
SubShader
|
||
|
{
|
||
|
|
||
|
Tags {"Queue" = "Transparent" "IgnoreProjector" = "true" "RenderType" = "Transparent" "PreviewType"="Plane" "CanUseSpriteAtlas"="True" }
|
||
|
ZWrite Off Blend SrcAlpha OneMinusSrcAlpha Cull Off
|
||
|
|
||
|
// required for UI.Mask
|
||
|
Stencil
|
||
|
{
|
||
|
Ref [_Stencil]
|
||
|
Comp [_StencilComp]
|
||
|
Pass [_StencilOp]
|
||
|
ReadMask [_StencilReadMask]
|
||
|
WriteMask [_StencilWriteMask]
|
||
|
}
|
||
|
|
||
|
Pass
|
||
|
{
|
||
|
|
||
|
CGPROGRAM
|
||
|
#pragma vertex vert
|
||
|
#pragma fragment frag
|
||
|
#pragma fragmentoption ARB_precision_hint_fastest
|
||
|
#include "UnityCG.cginc"
|
||
|
|
||
|
struct appdata_t{
|
||
|
float4 vertex : POSITION;
|
||
|
float4 color : COLOR;
|
||
|
float2 texcoord : TEXCOORD0;
|
||
|
};
|
||
|
|
||
|
struct v2f
|
||
|
{
|
||
|
float2 texcoord : TEXCOORD0;
|
||
|
float4 vertex : SV_POSITION;
|
||
|
float4 color : COLOR;
|
||
|
};
|
||
|
|
||
|
sampler2D _MainTex;
|
||
|
float _SpriteFade;
|
||
|
float Symbiose_Distance;
|
||
|
float Symbiose_Position;
|
||
|
float Effect_Fading;
|
||
|
|
||
|
v2f vert(appdata_t IN)
|
||
|
{
|
||
|
v2f OUT;
|
||
|
OUT.vertex = UnityObjectToClipPos(IN.vertex);
|
||
|
OUT.texcoord = IN.texcoord;
|
||
|
OUT.color = IN.color;
|
||
|
return OUT;
|
||
|
}
|
||
|
|
||
|
|
||
|
float2 SimpleDisplacementRotativeUV(float2 uv, float4 rgba, float value, float value2)
|
||
|
{
|
||
|
float angle = value2 * 3.1415926;
|
||
|
float dist = rgba.r;
|
||
|
#define rot(n) mul(n, float2x2(cos(angle), -sin(angle), sin(angle), cos(angle)))
|
||
|
float2 uv2 = uv+rot(float2(dist-0.5, dist-0.5));
|
||
|
return lerp(uv, uv2, value);
|
||
|
}
|
||
|
float Generate_Fire_hash2D(float2 x)
|
||
|
{
|
||
|
return frac(sin(dot(x, float2(13.454, 7.405)))*12.3043);
|
||
|
}
|
||
|
|
||
|
float Generate_Fire_voronoi2D(float2 uv, float precision)
|
||
|
{
|
||
|
float2 fl = floor(uv);
|
||
|
float2 fr = frac(uv);
|
||
|
float res = 1.0;
|
||
|
for (int j = -1; j <= 1; j++)
|
||
|
{
|
||
|
for (int i = -1; i <= 1; i++)
|
||
|
{
|
||
|
float2 p = float2(i, j);
|
||
|
float h = Generate_Fire_hash2D(fl + p);
|
||
|
float2 vp = p - fr + h;
|
||
|
float d = dot(vp, vp);
|
||
|
res += 1.0 / pow(d, 8.0);
|
||
|
}
|
||
|
}
|
||
|
return pow(1.0 / res, precision);
|
||
|
}
|
||
|
|
||
|
float4 Generate_Fire(float2 uv, float posX, float posY, float precision, float smooth, float speed, float black)
|
||
|
{
|
||
|
uv += float2(posX, posY);
|
||
|
float t = 1;
|
||
|
float up0 = Generate_Fire_voronoi2D(uv * float2(6.0, 4.0) + float2(0, -t), precision);
|
||
|
float up1 = 0.5 + Generate_Fire_voronoi2D(uv * float2(6.0, 4.0) + float2(42, -t ) + 30.0, precision);
|
||
|
float finalMask = up0 * up1 + (1.0 - uv.y);
|
||
|
finalMask += (1.0 - uv.y)* 0.5;
|
||
|
finalMask *= 0.7 - abs(uv.x - 0.5);
|
||
|
float4 result = smoothstep(smooth, 0.95, finalMask);
|
||
|
result.a = saturate(result.a + black);
|
||
|
return result;
|
||
|
}
|
||
|
float4 frag (v2f i) : COLOR
|
||
|
{
|
||
|
float4 _Generate_Fire_1 = Generate_Fire(i.texcoord,-0.024,0.052,0.05,0.5,1,0);
|
||
|
float2 _Simple_Displacement_Rotative_1 = SimpleDisplacementRotativeUV(i.texcoord,_Generate_Fire_1,Symbiose_Distance,Symbiose_Position);
|
||
|
i.texcoord = lerp(i.texcoord,_Simple_Displacement_Rotative_1,Effect_Fading);
|
||
|
float4 SourceRGBA_1 = tex2D(_MainTex, i.texcoord);
|
||
|
SourceRGBA_1.a = lerp(float4(1,1,0,1).a * SourceRGBA_1.a, (1 - float4(1,1,0,1).a) * SourceRGBA_1.a,0);
|
||
|
float4 FinalResult = SourceRGBA_1;
|
||
|
FinalResult.rgb *= i.color.rgb;
|
||
|
FinalResult.a = FinalResult.a * _SpriteFade * i.color.a;
|
||
|
return FinalResult;
|
||
|
}
|
||
|
|
||
|
ENDCG
|
||
|
}
|
||
|
}
|
||
|
Fallback "Sprites/Default"
|
||
|
}
|