ok
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
#version 120
|
||||
|
||||
varying vec2 uv;
|
||||
|
||||
uniform float TimeSeconds;
|
||||
|
||||
// https://github.com/hughsk/glsl-hsv2rgb/blob/master/index.glsl
|
||||
vec3 hsv2rgb(vec3 c) {
|
||||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
}
|
||||
|
||||
float remapX(float x) {
|
||||
return clamp(10.0/9.5 - 0.1 * abs(x - 11.5), 0.0, 1.0);
|
||||
}
|
||||
|
||||
vec3 _sample(vec2 xy) {
|
||||
float hue = mod(cos(TimeSeconds * 0.25) * 0.5 + xy.x + 0.1 * cos(TimeSeconds * 0.25 * 20.0 + xy.y * 20.0), 1.0);
|
||||
|
||||
return hsv2rgb(vec3(hue, 1.0, 1.0));
|
||||
}
|
||||
|
||||
void main() {
|
||||
float y = max(uv.y, 1.0/16.0);
|
||||
float x = remapX(uv.x * 22.0);
|
||||
|
||||
if (uv.x > 0.5 && uv.y < 1/17.0) {
|
||||
x = remapX((uv.x - 0.45) * 22.0);
|
||||
y = 1.0;
|
||||
}
|
||||
|
||||
gl_FragColor = vec4(_sample(vec2(x, y)), 1.0);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"blend": {
|
||||
"func": "add",
|
||||
"srcrgb": "one",
|
||||
"dstrgb": "zero"
|
||||
},
|
||||
"vertex": "chroma",
|
||||
"fragment": "chroma",
|
||||
"attributes": [ "Position" ],
|
||||
"uniforms": [
|
||||
{ "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
|
||||
{ "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
|
||||
{ "name": "TimeSeconds", "type": "float", "count": 1, "values": [ 0.0 ] }
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#version 120
|
||||
|
||||
attribute vec4 Position;
|
||||
|
||||
uniform mat4 ProjMat;
|
||||
uniform vec2 OutSize;
|
||||
|
||||
varying vec2 uv;
|
||||
|
||||
void main(){
|
||||
vec4 outPos = ProjMat * vec4(Position.xy, 0.0, 1.0);
|
||||
gl_Position = vec4(outPos.xy, 0.2, 1.0);
|
||||
|
||||
uv = Position.xy / OutSize;
|
||||
uv.y = 1.0 - uv.y;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#version 150
|
||||
|
||||
in vec2 uv;
|
||||
|
||||
uniform float TimeSeconds;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
// https://github.com/hughsk/glsl-hsv2rgb/blob/master/index.glsl
|
||||
vec3 hsv2rgb(vec3 c) {
|
||||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
}
|
||||
|
||||
float remapX(float x) {
|
||||
return clamp(10.0/9.5 - 0.1 * abs(x - 11.5), 0.0, 1.0);
|
||||
}
|
||||
|
||||
vec3 _sample(vec2 xy) {
|
||||
float hue = mod(cos(TimeSeconds * 0.25) * 0.5 + xy.x + 0.1 * cos(TimeSeconds * 0.25 * 20.0 + xy.y * 20.0), 1.0);
|
||||
|
||||
return hsv2rgb(vec3(hue, 1.0, 1.0));
|
||||
}
|
||||
|
||||
void main() {
|
||||
float y = max(uv.y, 1.0/16.0);
|
||||
float x = remapX(uv.x * 22.0);
|
||||
|
||||
if (uv.x > 0.5 && uv.y < 1/17.0) {
|
||||
x = remapX((uv.x - 0.45) * 22.0);
|
||||
y = 1.0;
|
||||
}
|
||||
|
||||
fragColor = vec4(_sample(vec2(x, y)), 1.0);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"blend": {
|
||||
"func": "add",
|
||||
"srcrgb": "one",
|
||||
"dstrgb": "zero"
|
||||
},
|
||||
"vertex": "chroma_core",
|
||||
"fragment": "chroma_core",
|
||||
"attributes": [ "Position" ],
|
||||
"uniforms": [
|
||||
{ "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
|
||||
{ "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
|
||||
{ "name": "TimeSeconds", "type": "float", "count": 1, "values": [ 0.0 ] }
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#version 150
|
||||
|
||||
in vec4 Position;
|
||||
|
||||
uniform mat4 ProjMat;
|
||||
uniform vec2 OutSize;
|
||||
|
||||
out vec2 uv;
|
||||
|
||||
void main(){
|
||||
vec4 outPos = ProjMat * vec4(Position.xy, 0.0, 1.0);
|
||||
gl_Position = vec4(outPos.xy, 0.2, 1.0);
|
||||
|
||||
uv = Position.xy / OutSize;
|
||||
uv.y = 1.0 - uv.y;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#version 120
|
||||
|
||||
uniform sampler2D DiffuseSampler;
|
||||
|
||||
varying vec2 texCoord;
|
||||
varying vec2 oneTexel;
|
||||
|
||||
uniform vec2 InSize;
|
||||
|
||||
uniform vec2 BlurDir;
|
||||
uniform float Radius;
|
||||
|
||||
void main() {
|
||||
vec4 blurred = vec4(0.0);
|
||||
float totalStrength = 0.0;
|
||||
float totalAlpha = 0.0;
|
||||
float totalSamples = 0.0;
|
||||
for(float r = -Radius; r <= Radius; r += 1.0) {
|
||||
vec4 sample = texture2D(DiffuseSampler, texCoord + oneTexel * r * BlurDir);
|
||||
|
||||
// Accumulate average alpha
|
||||
totalAlpha = totalAlpha + sample.a;
|
||||
totalSamples = totalSamples + 1.0;
|
||||
|
||||
// Accumulate smoothed blur
|
||||
float strength = 1.0 - abs(r / Radius);
|
||||
totalStrength = totalStrength + strength;
|
||||
blurred = blurred + sample;
|
||||
}
|
||||
gl_FragColor = vec4(blurred.rgb / (Radius * 2.0 + 1.0), totalAlpha);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"blend": {
|
||||
"func": "add",
|
||||
"srcrgb": "one",
|
||||
"dstrgb": "zero"
|
||||
},
|
||||
"vertex": "sobel",
|
||||
"fragment": "lunar_blur",
|
||||
"attributes": [ "Position" ],
|
||||
"samplers": [
|
||||
{ "name": "DiffuseSampler" }
|
||||
],
|
||||
"uniforms": [
|
||||
{ "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
|
||||
{ "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
|
||||
{ "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
|
||||
{ "name": "BlurDir", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
|
||||
{ "name": "Radius", "type": "float", "count": 1, "values": [ 5.0 ] }
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
#version 120
|
||||
|
||||
uniform sampler2D DiffuseSampler;
|
||||
|
||||
varying vec2 texCoord;
|
||||
varying vec2 oneTexel;
|
||||
|
||||
uniform vec2 InSize;
|
||||
|
||||
uniform float hue = 0.0;
|
||||
uniform float Brightness = 0.5;
|
||||
uniform float Contrast = 0.8;
|
||||
uniform float Saturation = 0.8;
|
||||
|
||||
// See https://forum.unity.com/threads/hue-saturation-brightness-contrast-shader.260649/ for inspiration.
|
||||
|
||||
void applyHue(inout vec4 color, float hue) {
|
||||
float angle = radians(hue);
|
||||
vec3 k = vec3(0.57735, 0.57735, 0.57735);
|
||||
float cosAngle = cos(angle);
|
||||
//Rodrigues' rotation formula
|
||||
color.rgb = color.rgb * cosAngle + cross(k, color.rgb) * sin(angle) + k * dot(k, color.rgb) * (1.0 - cosAngle);
|
||||
}
|
||||
|
||||
void applySaturation(inout vec4 color, float saturation) {
|
||||
// I couldn't get dotproduct and lerp to work, so I manually added it :(
|
||||
float dot = sqrt(color.r * color.r * 0.299 + color.g * color.g * 0.587 + color.b * color.b * 0.114);
|
||||
color.r = dot + (color.r - dot) * saturation;
|
||||
color.g = dot + (color.g - dot) * saturation;
|
||||
color.b = dot + (color.b - dot) * saturation;
|
||||
}
|
||||
|
||||
vec4 applyHSBCEffect(vec4 startColor, vec4 hsbc) {
|
||||
float _Hue = 360 * hsbc.r;
|
||||
float _Brightness = hsbc.b * 2 - 1;
|
||||
float _Contrast = hsbc.a * 2;
|
||||
float _Saturation = hsbc.g * 2;
|
||||
|
||||
vec4 outputColor = startColor;
|
||||
applyHue(outputColor, _Hue);
|
||||
// Contrast
|
||||
outputColor.rgb = (outputColor.rgb - 0.5) * _Contrast + 0.5;
|
||||
// Brightness
|
||||
outputColor.rgb = outputColor.rgb + vec3(_Brightness, _Brightness, _Brightness);
|
||||
// Saturation
|
||||
applySaturation(outputColor, _Saturation);
|
||||
|
||||
outputColor = vec4(outputColor.rgb, 1.0);
|
||||
|
||||
return outputColor;
|
||||
}
|
||||
|
||||
void main() {
|
||||
gl_FragColor = applyHSBCEffect(texture2D(DiffuseSampler, texCoord), vec4(hue, Saturation, Brightness, Contrast));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"blend": {
|
||||
"func": "add",
|
||||
"srcrgb": "one",
|
||||
"dstrgb": "zero"
|
||||
},
|
||||
"vertex": "sobel",
|
||||
"fragment": "lunar_colorsaturation",
|
||||
"attributes": [ "Position" ],
|
||||
"samplers": [
|
||||
{ "name": "DiffuseSampler" }
|
||||
],
|
||||
"uniforms": [
|
||||
{ "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
|
||||
{ "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
|
||||
{ "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
|
||||
{ "name": "Saturation", "type": "float", "count": 1, "values": [ 0.9 ] },
|
||||
{ "name": "hue", "type": "float", "count": 1, "values": [ 0.0 ] },
|
||||
{ "name": "Brightness", "type": "float", "count": 1, "values": [ 0.5 ] },
|
||||
{ "name": "Contrast", "type": "float", "count": 1, "values": [ 0.5 ] }
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
#version 150
|
||||
|
||||
uniform sampler2D DiffuseSampler;
|
||||
|
||||
in vec2 texCoord;
|
||||
in vec2 oneTexel;
|
||||
|
||||
uniform vec2 InSize;
|
||||
|
||||
uniform float hue = 0.0;
|
||||
uniform float Brightness = 0.5;
|
||||
uniform float Contrast = 0.8;
|
||||
uniform float Saturation = 0.8;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
// See https://forum.unity.com/threads/hue-saturation-brightness-contrast-shader.260649/ for inspiration.
|
||||
|
||||
void applyHue(inout vec4 color, float hue) {
|
||||
float angle = radians(hue);
|
||||
vec3 k = vec3(0.57735, 0.57735, 0.57735);
|
||||
float cosAngle = cos(angle);
|
||||
//Rodrigues' rotation formula
|
||||
color.rgb = color.rgb * cosAngle + cross(k, color.rgb) * sin(angle) + k * dot(k, color.rgb) * (1.0 - cosAngle);
|
||||
}
|
||||
|
||||
void applySaturation(inout vec4 color, float saturation) {
|
||||
// I couldn't get dotproduct and lerp to work, so I manually added it :(
|
||||
float dot = sqrt(color.r * color.r * 0.299 + color.g * color.g * 0.587 + color.b * color.b * 0.114);
|
||||
color.r = dot + (color.r - dot) * saturation;
|
||||
color.g = dot + (color.g - dot) * saturation;
|
||||
color.b = dot + (color.b - dot) * saturation;
|
||||
}
|
||||
|
||||
vec4 applyHSBCEffect(vec4 startColor, vec4 hsbc) {
|
||||
float _Hue = 360 * hsbc.r;
|
||||
float _Brightness = hsbc.b * 2 - 1;
|
||||
float _Contrast = hsbc.a * 2;
|
||||
float _Saturation = hsbc.g * 2;
|
||||
|
||||
vec4 outputColor = startColor;
|
||||
applyHue(outputColor, _Hue);
|
||||
// Contrast
|
||||
outputColor.rgb = (outputColor.rgb - 0.5) * _Contrast + 0.5;
|
||||
// Brightness
|
||||
outputColor.rgb = outputColor.rgb + vec3(_Brightness, _Brightness, _Brightness);
|
||||
// Saturation
|
||||
applySaturation(outputColor, _Saturation);
|
||||
|
||||
outputColor = vec4(outputColor.rgb, 1.0);
|
||||
|
||||
return outputColor;
|
||||
}
|
||||
|
||||
void main() {
|
||||
fragColor = applyHSBCEffect(texture(DiffuseSampler, texCoord), vec4(hue, Saturation, Brightness, Contrast));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"blend": {
|
||||
"func": "add",
|
||||
"srcrgb": "one",
|
||||
"dstrgb": "zero"
|
||||
},
|
||||
"vertex": "sobel",
|
||||
"fragment": "lunar_colorsaturation_core",
|
||||
"attributes": [ "Position" ],
|
||||
"samplers": [
|
||||
{ "name": "DiffuseSampler" }
|
||||
],
|
||||
"uniforms": [
|
||||
{ "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
|
||||
{ "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
|
||||
{ "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
|
||||
{ "name": "Saturation", "type": "float", "count": 1, "values": [ 0.9 ] },
|
||||
{ "name": "hue", "type": "float", "count": 1, "values": [ 0.0 ] },
|
||||
{ "name": "Brightness", "type": "float", "count": 1, "values": [ 0.5 ] },
|
||||
{ "name": "Contrast", "type": "float", "count": 1, "values": [ 0.5 ] }
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"blend": {
|
||||
"func": "add",
|
||||
"srcrgb": "one",
|
||||
"dstrgb": "zero"
|
||||
},
|
||||
"vertex": "sobel",
|
||||
"fragment": "lunar_entity_sobel_1_7",
|
||||
"attributes": [ "Position" ],
|
||||
"samplers": [
|
||||
{ "name": "DiffuseSampler" }
|
||||
],
|
||||
"uniforms": [
|
||||
{ "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
|
||||
{ "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
|
||||
{ "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#version 120
|
||||
|
||||
uniform sampler2D DiffuseSampler;
|
||||
|
||||
varying vec2 texCoord;
|
||||
varying vec2 oneTexel;
|
||||
|
||||
void main(){
|
||||
vec4 center = texture2D(DiffuseSampler, texCoord);
|
||||
vec4 left = texture2D(DiffuseSampler, texCoord - vec2(oneTexel.x, 0.0));
|
||||
vec4 right = texture2D(DiffuseSampler, texCoord + vec2(oneTexel.x, 0.0));
|
||||
vec4 up = texture2D(DiffuseSampler, texCoord - vec2(0.0, oneTexel.y));
|
||||
vec4 down = texture2D(DiffuseSampler, texCoord + vec2(0.0, oneTexel.y));
|
||||
float leftDiff = abs(center.a - left.a);
|
||||
float rightDiff = abs(center.a - right.a);
|
||||
float upDiff = abs(center.a - up.a);
|
||||
float downDiff = abs(center.a - down.a);
|
||||
float total = clamp(leftDiff + rightDiff + upDiff + downDiff, 0.0, 1.0);
|
||||
vec3 outColor = center.rgb * center.a + left.rgb * left.a + right.rgb * right.a + up.rgb * up.a + down.rgb * down.a;
|
||||
gl_FragColor = vec4(outColor * 0.2, total);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#version 120
|
||||
|
||||
uniform sampler2D DiffuseSampler;
|
||||
uniform sampler2D PrevSampler;
|
||||
|
||||
varying vec2 texCoord;
|
||||
varying vec2 oneTexel;
|
||||
|
||||
uniform vec2 InSize;
|
||||
|
||||
uniform vec3 Phosphor = vec3(0.7, 0.0, 0.0);
|
||||
uniform float LerpFactor = 1.0;
|
||||
|
||||
void main() {
|
||||
vec4 CurrTexel = texture2D(DiffuseSampler, texCoord);
|
||||
vec4 PrevTexel = texture2D(PrevSampler, texCoord);
|
||||
float factor = Phosphor.r;
|
||||
|
||||
if (Phosphor.g == 1) {
|
||||
gl_FragColor = vec4(max(PrevTexel.rgb * vec3(factor), CurrTexel.rgb), 1.0);
|
||||
} else {
|
||||
gl_FragColor = vec4(mix(PrevTexel.rgb, CurrTexel.rgb, factor), 1.0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"blend": {
|
||||
"func": "add",
|
||||
"srcrgb": "one",
|
||||
"dstrgb": "zero"
|
||||
},
|
||||
"vertex": "sobel",
|
||||
"fragment": "lunar_motionblur",
|
||||
"attributes": [ "Position" ],
|
||||
"samplers": [
|
||||
{ "name": "DiffuseSampler" },
|
||||
{ "name": "PrevSampler" }
|
||||
],
|
||||
"uniforms": [
|
||||
{ "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
|
||||
{ "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
|
||||
{ "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
|
||||
{ "name": "Phosphor", "type": "float", "count": 3, "values": [ 0.3, 0.3, 0.3 ] }
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#version 150
|
||||
|
||||
uniform sampler2D DiffuseSampler;
|
||||
uniform sampler2D PrevSampler;
|
||||
|
||||
in vec2 texCoord;
|
||||
in vec2 oneTexel;
|
||||
|
||||
uniform vec2 InSize;
|
||||
|
||||
uniform vec3 Phosphor = vec3(0.7, 0.0, 0.0);
|
||||
uniform float LerpFactor = 1.0;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec4 CurrTexel = texture(DiffuseSampler, texCoord);
|
||||
vec4 PrevTexel = texture(PrevSampler, texCoord);
|
||||
float factor = Phosphor.r;
|
||||
|
||||
if (Phosphor.g == 1) {
|
||||
fragColor = vec4(max(PrevTexel.rgb * vec3(factor), CurrTexel.rgb), 1.0);
|
||||
} else {
|
||||
fragColor = vec4(mix(PrevTexel.rgb, CurrTexel.rgb, factor), 1.0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"blend": {
|
||||
"func": "add",
|
||||
"srcrgb": "one",
|
||||
"dstrgb": "zero"
|
||||
},
|
||||
"vertex": "sobel",
|
||||
"fragment": "lunar_motionblur_core",
|
||||
"attributes": [ "Position" ],
|
||||
"samplers": [
|
||||
{ "name": "DiffuseSampler" },
|
||||
{ "name": "PrevSampler" }
|
||||
],
|
||||
"uniforms": [
|
||||
{ "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
|
||||
{ "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
|
||||
{ "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
|
||||
{ "name": "Phosphor", "type": "float", "count": 3, "values": [ 0.3, 0.3, 0.3 ] }
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#version 120
|
||||
|
||||
uniform sampler2D DiffuseSampler;
|
||||
|
||||
varying vec2 texCoord;
|
||||
varying vec2 oneTexel;
|
||||
|
||||
uniform vec2 InSize;
|
||||
|
||||
uniform vec2 BlurDir;
|
||||
uniform float Radius;
|
||||
uniform float Progress;
|
||||
|
||||
void main() {
|
||||
vec4 blurred = vec4(0.0);
|
||||
float totalStrength = 0.0;
|
||||
float totalAlpha = 0.0;
|
||||
float totalSamples = 0.0;
|
||||
float progRadius = floor(Radius * Progress);
|
||||
for (float r = -progRadius; r <= progRadius; r += 1.0) {
|
||||
vec4 texel = texture2D(DiffuseSampler, texCoord + oneTexel * r * BlurDir);
|
||||
totalAlpha = totalAlpha + texel.a;
|
||||
totalSamples = totalSamples + 1.0;
|
||||
float strength = 1.0 - abs(r / progRadius);
|
||||
totalStrength = totalStrength + strength;
|
||||
blurred = blurred + texel;
|
||||
}
|
||||
gl_FragColor = vec4(blurred.rgb / (progRadius * 2.0 + 1.0), totalAlpha);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"blend": {
|
||||
"func": "add",
|
||||
"srcrgb": "one",
|
||||
"dstrgb": "zero"
|
||||
},
|
||||
"vertex": "sobel",
|
||||
"fragment": "menu_blur",
|
||||
"attributes": [ "Position" ],
|
||||
"samplers": [
|
||||
{ "name": "DiffuseSampler" }
|
||||
],
|
||||
"uniforms": [
|
||||
{ "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
|
||||
{ "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
|
||||
{ "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
|
||||
{ "name": "BlurDir", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
|
||||
{ "name": "Radius", "type": "float", "count": 1, "values": [ 5.0 ] },
|
||||
{ "name": "Progress", "type": "float", "count": 1, "values": [ 0.0 ] }
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#version 150 core
|
||||
|
||||
uniform sampler2D DiffuseSampler;
|
||||
|
||||
in vec2 texCoord;
|
||||
in vec2 oneTexel;
|
||||
|
||||
uniform vec2 InSize;
|
||||
|
||||
uniform vec2 BlurDir;
|
||||
uniform float Radius;
|
||||
uniform float Progress;
|
||||
|
||||
out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
vec4 blurred = vec4(0.0);
|
||||
float progRadius = floor(Radius * Progress);
|
||||
for (float r = -progRadius; r <= progRadius; r += 1.0) {
|
||||
blurred += texture(DiffuseSampler, texCoord + oneTexel * r * BlurDir);
|
||||
}
|
||||
// force alpha to be 1.0 since otherwise areas with zero alpha turn black?
|
||||
outColor = vec4(blurred.rgb / (progRadius * 2.0 + 1.0), 1.0);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"blend": {
|
||||
"func": "add",
|
||||
"srcrgb": "one",
|
||||
"dstrgb": "zero"
|
||||
},
|
||||
"vertex": "sobel",
|
||||
"fragment": "menu_blur_core",
|
||||
"attributes": [ "Position" ],
|
||||
"samplers": [
|
||||
{ "name": "DiffuseSampler" }
|
||||
],
|
||||
"uniforms": [
|
||||
{ "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
|
||||
{ "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
|
||||
{ "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
|
||||
{ "name": "BlurDir", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
|
||||
{ "name": "Radius", "type": "float", "count": 1, "values": [ 5.0 ] },
|
||||
{ "name": "Progress", "type": "float", "count": 1, "values": [ 0.0 ] }
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user