Last active
May 14, 2020 23:46
-
-
Save pardeike/851cd6a225b06a690016db2d14e71d88 to your computer and use it in GitHub Desktop.
PychoStripes Unity 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
Shader "Unlit/OffLimits" | |
{ | |
Properties { | |
_Color1 ("Color 1", Color) = (0,0,0,1) | |
_Color2 ("Color 2", Color) = (1,1,1,1) | |
_Size ("Size", Float) = 0 | |
_Tiling ("Tiling", Range(0.1, 10)) = 1 | |
_Direction ("Direction", Range(0, 1)) = 0 | |
_WarpScale ("Warp Scale", Range(0, 1)) = 0 | |
_WarpTiling ("Warp Tiling", Range(0.01, 20)) = 1 | |
_Speed("Speed", Range(-40, 40)) = 0 | |
_XPosition ("X Position", Range(0, 1000)) = 0 | |
_YPosition ("Y Position", Range(0, 1000)) = 0 | |
} | |
SubShader | |
{ | |
Blend SrcAlpha OneMinusSrcAlpha | |
Pass | |
{ | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
#include "UnityCG.cginc" | |
fixed4 _Color1; | |
fixed4 _Color2; | |
float _Size; | |
float _Tiling; | |
float _Direction; | |
float _WarpScale; | |
float _WarpTiling; | |
float _Speed; | |
float _XPosition; | |
float _YPosition; | |
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; | |
} | |
fixed4 frag (v2f i) : SV_Target | |
{ | |
const float PI = 3.14159; | |
// float x = lerp(i.vertex.x / _Size, i.vertex.y / _Size, _Direction); //lerp(i.uv.x, i.uv.y, _Direction); | |
// float y = lerp(i.vertex.y / _Size, (1 - i.vertex.x) / _Size, _Direction); //lerp(i.uv.y, 1 - i.uv.x, _Direction); | |
float x1 = i.uv.x - _XPosition; | |
float x2 = i.uv.y - _YPosition; | |
float y1 = i.uv.y - _YPosition; | |
float y2 = 1 - (i.uv.x - _XPosition); | |
float x = lerp(x1, x2, _Direction) * 2 / _Size; | |
float y = lerp(y1, y2, _Direction) * 2 / _Size; | |
fixed dx = _Speed * _Time; | |
float n = x + sin((y + sin(x)) * _WarpTiling * PI * 2 + sin(dx * 2)) * _WarpScale; | |
n = n * _Tiling + dx; | |
fixed v = smoothstep(0.45, 0.55, abs(frac(n) - 0.5) * 2); | |
return lerp(_Color1, _Color2, v); | |
} | |
ENDCG | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment