Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Resources/Shaders/Camera.meta

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

Binary file not shown.
69 changes: 69 additions & 0 deletions Resources/Shaders/Camera/Bloom.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
Shader "JANOARG/Effects/Bloom"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Radius ("Blur Radius", Range(1, 100)) = 50
_Sigma ("Blur Sigma", Range(0.1, 100)) = 50
_BlurDirection ("Blur Direction", Vector) = (1, 0, 0, 0)
}
SubShader
{
Cull Off
ZWrite Off
ZTest Always

Pass
{
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"

sampler2D _MainTex;
float4 _MainTex_TexelSize;
int _Radius;
float _Sigma;
float2 _BlurDirection;

#define INV_SQRT_2PI 0.39894

float computeGauss(float x, float sigma)
{
return INV_SQRT_2PI * exp(-0.5 * x * x / (sigma * sigma)) / sigma;
}

float4 blur(int radius, float2 direction, float2 texCoord, float2 texSize, float sigma)
{
float factor = computeGauss(0.0, sigma);
float4 sum = tex2D(_MainTex, texCoord) * factor;

float totalFactor = factor;

for (int i = 2; i <= 200; i += 2)
{
float x = float(i) - 0.5;
factor = computeGauss(x, sigma) * 2.0;
totalFactor += 2.0 * factor;

sum += tex2D(_MainTex, texCoord + direction * x / texSize) * factor;
sum += tex2D(_MainTex, texCoord - direction * x / texSize) * factor;

if (i >= radius) break;
}

return sum / totalFactor;
}

fixed4 frag (v2f_img i) : SV_Target
{
float2 texSize = _MainTex_TexelSize.zw; // .zw contains width and height

float4 blurColour = blur(_Radius, _BlurDirection, i.uv, texSize, _Sigma);

return blurColour;
}
ENDCG
}
}
}
9 changes: 9 additions & 0 deletions Resources/Shaders/Camera/Bloom.shader.meta

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

38 changes: 38 additions & 0 deletions Resources/Shaders/Camera/Chromatic Aberration.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Shader "JANOARG/Effects/ChromaticAberration"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Strength ("Chromatic Aberration Strength", Range(0, 10)) = 1.0
}
SubShader
{
Cull Off
ZWrite Off
ZTest Always

Pass
{
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"

sampler2D _MainTex;
float _Strength;

fixed4 frag (v2f_img i) : SV_Target
{
float2 uv = i.uv;
fixed4 colour = tex2D(_MainTex, uv);

float2 offset = float2(0.001, 0.0) * _Strength;
colour.r = tex2D(_MainTex, uv + offset).r;
colour.b = tex2D(_MainTex, uv - offset).b;

return colour;
}
ENDCG
}
}
}
9 changes: 9 additions & 0 deletions Resources/Shaders/Camera/Chromatic Aberration.shader.meta

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

58 changes: 58 additions & 0 deletions Resources/Shaders/Camera/Fish Eye.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Shader "JANOARG/Effects/FishEye"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Strength ("Fish Eye Strength", Range(-1, 1)) = 0.5
}
SubShader
{
Cull Off
ZWrite Off
ZTest Always

Pass
{
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"

sampler2D _MainTex;
float _Strength;

#ifndef PI
#define PI 3.141593
#endif

float2 FishEyeUV(float2 uv)
{
float2 center = float2(0.5, 0.5);
float corner = length(center);
float2 d = uv - 0.5;
float r = length(d);

if (_Strength > 0.0)
{
float fac = _Strength * PI * 0.5;
uv = float2(0.5, 0.5) + normalize(d) * tan(r * fac) * corner / tan(corner * fac);
}
else
{
float fac = tan(_Strength) * PI * 2.0;
uv = float2(0.5, 0.5) + normalize(d) * atan(r * -fac) * 0.5 / atan(0.5 * -fac);
}
return uv;
}

fixed4 frag (v2f_img i) : SV_Target
{
float2 fisheyeUV = FishEyeUV(i.uv);
fixed4 colour = tex2D(_MainTex, fisheyeUV);

return colour;
}
ENDCG
}
}
}
9 changes: 9 additions & 0 deletions Resources/Shaders/Camera/Fish Eye.shader.meta

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

56 changes: 56 additions & 0 deletions Resources/Shaders/Camera/Glitch.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
Shader "JANOARG/Effects/Glitch"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_StrengthX ("Glitch Strength X", Range(0, 1)) = 0.1
_StrengthY ("Glitch Strength Y", Range(0, 1)) = 0.1
_BlockSize ("Block Size", Range(0, 1)) = 0.5
}
SubShader
{
Cull Off
ZWrite Off
ZTest Always

Pass
{
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"

sampler2D _MainTex;
float4 _MainTex_TexelSize;
float _StrengthX;
float _StrengthY;
float _BlockSize;

float random(float2 st, float seed)
{
return frac(sin(dot(st.xy, float2(12.9898, 78.233) + seed)) * 43758.5453123);
}

fixed4 frag (v2f_img i) : SV_Target
{
float2 texSize = _MainTex_TexelSize.zw;

float blockSizeInPixels = lerp(1.0, min(texSize.x, texSize.y), _BlockSize);

float2 blockUV = floor(i.uv * blockSizeInPixels) / blockSizeInPixels;

float randomShiftX = (random(blockUV, _Time.y) - 0.5) * _StrengthX;
float randomShiftY = (random(blockUV + float2(5.0, 5.0), _Time.y) - 0.5) * _StrengthY;

float2 fixedUV = i.uv;
fixedUV.x += randomShiftX;
fixedUV.y += randomShiftY;

fixed4 pixelColor = tex2Dlod(_MainTex, float4(fixedUV, 0, 0));

return pixelColor;
}
ENDCG
}
}
}
9 changes: 9 additions & 0 deletions Resources/Shaders/Camera/Glitch.shader.meta

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

36 changes: 36 additions & 0 deletions Resources/Shaders/Camera/Greyscale.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Shader "JANOARG/Effects/Greyscale"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Strength ("Greyscale Strength", Range(0, 1)) = 1.0
}
SubShader
{
Cull Off
ZWrite Off
ZTest Always

Pass
{
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"

sampler2D _MainTex;
float _Strength;

fixed4 frag (v2f_img i) : SV_Target
{
fixed4 colour = tex2D(_MainTex, i.uv);

float grey = dot(colour.rgb, float3(0.299, 0.587, 0.114));
float3 greyColour = float3(grey, grey, grey);

return lerp(colour, fixed4(greyColour, colour.a), _Strength);
}
ENDCG
}
}
}
9 changes: 9 additions & 0 deletions Resources/Shaders/Camera/Greyscale.shader.meta

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

66 changes: 66 additions & 0 deletions Resources/Shaders/Camera/Hue Shift.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
Shader "JANOARG/Effects/HueShift"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Strength ("Hue Shift", Range(0, 1)) = 0.5
}
SubShader
{
Cull Off
ZWrite Off
ZTest Always

Pass
{
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"

sampler2D _MainTex;
float _Strength;

float3 hueShift(float3 color, float hueAdjust)
{
const float3 kRGBToYPrime = float3(0.299, 0.587, 0.114);
const float3 kRGBToI = float3(0.596, -0.275, -0.321);
const float3 kRGBToQ = float3(0.212, -0.523, 0.311);

const float3 kYIQToR = float3(1.0, 0.956, 0.621);
const float3 kYIQToG = float3(1.0, -0.272, -0.647);
const float3 kYIQToB = float3(1.0, -1.107, 1.704);

float YPrime = dot(color, kRGBToYPrime);
float I = dot(color, kRGBToI);
float Q = dot(color, kRGBToQ);
float chroma = sqrt(I * I + Q * Q);

if (chroma < 1e-5)
{
return color;
}

float hue = atan2(Q, I);
hue += hueAdjust;

Q = chroma * sin(hue);
I = chroma * cos(hue);

float3 yIQ = float3(YPrime, I, Q);

return float3(dot(yIQ, kYIQToR), dot(yIQ, kYIQToG), dot(yIQ, kYIQToB));
}

fixed4 frag (v2f_img i) : SV_Target
{
fixed4 colour = tex2D(_MainTex, i.uv);

float3 shiftedColour = hueShift(colour.rgb, radians(_Strength * 360.0));

return fixed4(shiftedColour, colour.a);
}
ENDCG
}
}
}
9 changes: 9 additions & 0 deletions Resources/Shaders/Camera/Hue Shift.shader.meta

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

Loading