[orx-fx] convert to MPP
This commit is contained in:
111
orx-fx/src/shaders/glsl/antialias/fxaa.frag
Normal file
111
orx-fx/src/shaders/glsl/antialias/fxaa.frag
Normal file
@@ -0,0 +1,111 @@
|
||||
uniform float lumaThreshold;
|
||||
uniform float maxSpan;
|
||||
uniform float directionReduceMultiplier;
|
||||
uniform float directionReduceMinimum;
|
||||
|
||||
uniform sampler2D tex0;
|
||||
|
||||
in vec2 v_texCoord0;
|
||||
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
// see FXAA
|
||||
// http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf
|
||||
// http://iryoku.com/aacourse/downloads/09-FXAA-3.11-in-15-Slides.pdf
|
||||
// http://horde3d.org/wiki/index.php5?title=Shading_Technique_-_FXAA
|
||||
|
||||
void main(void) {
|
||||
const int u_showEdges = 0;
|
||||
const int u_fxaaOn = 1;
|
||||
|
||||
vec2 u_texelStep = 1.0 / textureSize(tex0, 0);
|
||||
vec3 rgbM = min(vec3(1), texture(tex0, v_texCoord0).rgb);
|
||||
|
||||
// Possibility to toggle FXAA on and off.
|
||||
if (u_fxaaOn == 0)
|
||||
{
|
||||
fragColor = vec4(rgbM, 1.0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Sampling neighbour texels. Offsets are adapted to OpenGL texture coordinates.
|
||||
vec3 rgbNW = min(vec3(1),textureOffset(tex0, v_texCoord0, ivec2(-1, 1)).rgb);
|
||||
vec3 rgbNE = min(vec3(1),textureOffset(tex0, v_texCoord0, ivec2(1, 1)).rgb);
|
||||
vec3 rgbSW = min(vec3(1),textureOffset(tex0, v_texCoord0, ivec2(-1, -1)).rgb);
|
||||
vec3 rgbSE = min(vec3(1),textureOffset(tex0, v_texCoord0, ivec2(1, -1)).rgb);
|
||||
|
||||
// see http://en.wikipedia.org/wiki/Grayscale
|
||||
const vec3 toLuma = vec3(0.299, 0.587, 0.114);
|
||||
|
||||
// Convert from RGB to luma.
|
||||
float lumaNW = dot(rgbNW, toLuma);
|
||||
float lumaNE = dot(rgbNE, toLuma);
|
||||
float lumaSW = dot(rgbSW, toLuma);
|
||||
float lumaSE = dot(rgbSE, toLuma);
|
||||
float lumaM = dot(rgbM, toLuma);
|
||||
|
||||
// Gather minimum and maximum luma.
|
||||
float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
|
||||
float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
|
||||
|
||||
// If contrast is lower than a maximum threshold ...
|
||||
if (lumaMax - lumaMin < lumaMax * lumaThreshold)
|
||||
{
|
||||
// ... do no AA and return.
|
||||
fragColor = vec4(rgbM, 1.0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Sampling is done along the gradient.
|
||||
vec2 samplingDirection;
|
||||
samplingDirection.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
|
||||
samplingDirection.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));
|
||||
|
||||
// Sampling step distance depends on the luma: The brighter the sampled texels, the smaller the final sampling step direction.
|
||||
// This results, that brighter areas are less blurred/more sharper than dark areas.
|
||||
float samplingDirectionReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * 0.25 * directionReduceMultiplier, directionReduceMinimum);
|
||||
|
||||
// Factor for norming the sampling direction plus adding the brightness influence.
|
||||
float minSamplingDirectionFactor = 1.0 / (min(abs(samplingDirection.x), abs(samplingDirection.y)) + samplingDirectionReduce);
|
||||
|
||||
// Calculate final sampling direction vector by reducing, clamping to a range and finally adapting to the texture size.
|
||||
samplingDirection = clamp(samplingDirection * minSamplingDirectionFactor, vec2(-maxSpan, -maxSpan), vec2(maxSpan, maxSpan)) * u_texelStep;
|
||||
|
||||
// Inner samples on the tab.
|
||||
vec3 rgbSampleNeg = min(vec3(1),texture(tex0, v_texCoord0 + samplingDirection * (1.0/3.0 - 0.5)).rgb);
|
||||
vec3 rgbSamplePos = min(vec3(1),texture(tex0, v_texCoord0 + samplingDirection * (2.0/3.0 - 0.5)).rgb);
|
||||
|
||||
vec3 rgbTwoTab = (rgbSamplePos + rgbSampleNeg) * 0.5;
|
||||
|
||||
// Outer samples on the tab.
|
||||
vec3 rgbSampleNegOuter = min(vec3(1),texture(tex0, v_texCoord0 + samplingDirection * (0.0/3.0 - 0.5)).rgb);
|
||||
vec3 rgbSamplePosOuter = min(vec3(1),texture(tex0, v_texCoord0 + samplingDirection * (3.0/3.0 - 0.5)).rgb);
|
||||
|
||||
vec3 rgbFourTab = (rgbSamplePosOuter + rgbSampleNegOuter) * 0.25 + rgbTwoTab * 0.5;
|
||||
|
||||
// Calculate luma for checking against the minimum and maximum value.
|
||||
float lumaFourTab = dot(rgbFourTab, toLuma);
|
||||
|
||||
// Are outer samples of the tab beyond the edge ...
|
||||
if (lumaFourTab < lumaMin || lumaFourTab > lumaMax)
|
||||
{
|
||||
// ... yes, so use only two samples.
|
||||
fragColor = vec4(rgbTwoTab, 1.0);
|
||||
// fragColor.r = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// ... no, so use four samples.
|
||||
fragColor = vec4(rgbFourTab, 1.0);
|
||||
// fragColor.g = 1.0;
|
||||
}
|
||||
|
||||
// Show edges for debug purposes.
|
||||
if (u_showEdges != 0)
|
||||
{
|
||||
fragColor.r = 1.0;
|
||||
}
|
||||
//fragColor.rgb = vec3(fragColor.rgb-rgbM)*40.0;
|
||||
}
|
||||
40
orx-fx/src/shaders/glsl/blend/add.frag
Normal file
40
orx-fx/src/shaders/glsl/blend/add.frag
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform bool clip;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 a = texture(tex0, v_texCoord0);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 a = texture2D(tex0, v_texCoord0);
|
||||
vec4 b = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
vec3 na = a.a > 0 ? a.rgb/a.a : vec3(0.0);
|
||||
vec3 nb = b.a > 0 ? b.rgb/b.a : vec3(0.0);
|
||||
|
||||
vec3 addColor = b.rgb;
|
||||
|
||||
vec4 result;
|
||||
if (clip) {
|
||||
result = vec4((na + addColor), 1) * a.a;
|
||||
} else {
|
||||
result = (1.0-a.a) * b + a.a * b.a * vec4(min(na + nb, vec3(1.0)), 1.0) + (1.0-b.a) * a;
|
||||
}
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
48
orx-fx/src/shaders/glsl/blend/color-burn.frag
Normal file
48
orx-fx/src/shaders/glsl/blend/color-burn.frag
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform bool clip;
|
||||
|
||||
float blendColorBurn(float base, float blend) {
|
||||
return (blend==0.0) ? blend : max((1.0 - ((1.0 - base) / blend)), 0.0);
|
||||
}
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 a = texture(tex0, v_texCoord0);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 a = texture2D(tex0, v_texCoord0);
|
||||
vec4 b = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
vec3 na = a.a == 0.0 ? vec3(0.0): a.rgb / a.a;
|
||||
vec3 nb = b.a == 0.0 ? vec3(0.0): b.rgb / b.a;
|
||||
|
||||
vec3 m = vec3(
|
||||
blendColorBurn(na.r, nb.r),
|
||||
blendColorBurn(na.g, nb.g),
|
||||
blendColorBurn(na.b, nb.b)
|
||||
);
|
||||
|
||||
vec4 result;
|
||||
if (clip) {
|
||||
result = vec4(na * (1.0 - b.a) + b.a * m, 1.0) * a.a;
|
||||
} else {
|
||||
result = (1.0-a.a) * b + a.a * b.a * vec4(m, 1.0) + (1.0-b.a) * a;
|
||||
}
|
||||
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
50
orx-fx/src/shaders/glsl/blend/color-dodge.frag
Normal file
50
orx-fx/src/shaders/glsl/blend/color-dodge.frag
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform bool clip;
|
||||
|
||||
float dodge(float base, float blend) {
|
||||
return (blend==1.0)?blend:min(base/(1.0-blend),1.0);
|
||||
}
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 a = texture(tex0, v_texCoord0);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 a = texture2D(tex0, v_texCoord0);
|
||||
vec4 b = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
vec3 na = a.a == 0.0 ? vec3(0.0): a.rgb / a.a;
|
||||
vec3 nb = b.a == 0.0 ? vec3(0.0): b.rgb / b.a;
|
||||
|
||||
vec3 m = vec3(
|
||||
dodge(na.r, nb.r),
|
||||
dodge(na.g, nb.g),
|
||||
dodge(na.b, nb.b)
|
||||
);
|
||||
|
||||
vec4 result;
|
||||
if (clip) {
|
||||
result = vec4(na * (1.0 - b.a) + b.a * m, 1.0) * a.a;
|
||||
} else {
|
||||
result = (1.0-a.a) * b + a.a * b.a * vec4(m, 1.0) + (1.0-b.a) * a;
|
||||
}
|
||||
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
|
||||
}
|
||||
43
orx-fx/src/shaders/glsl/blend/darken.frag
Normal file
43
orx-fx/src/shaders/glsl/blend/darken.frag
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform bool clip;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 a = texture(tex0, v_texCoord0);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 a = texture2D(tex0, v_texCoord0);
|
||||
vec4 b = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
vec3 na = a.a == 0.0 ? vec3(0.0): a.rgb / a.a;
|
||||
vec3 nb = b.a == 0.0 ? vec3(0.0): b.rgb / b.a;
|
||||
|
||||
vec3 m = vec3(
|
||||
nb.r <= na.r? nb.r : na.r,
|
||||
nb.g <= na.g? nb.g : na.g,
|
||||
nb.b <= na.b? nb.b : na.b);
|
||||
|
||||
vec4 result;
|
||||
if (clip) {
|
||||
result = vec4(na * (1.0 - b.a) + b.a * m, 1.0) * a.a;
|
||||
} else {
|
||||
result = (1.0-a.a) * b + a.a * b.a * vec4(m, 1.0) + (1.0-b.a) * a;
|
||||
}
|
||||
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
32
orx-fx/src/shaders/glsl/blend/destination-atop.frag
Normal file
32
orx-fx/src/shaders/glsl/blend/destination-atop.frag
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 src = texture(tex0, v_texCoord0);
|
||||
vec4 dest = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 src = texture2D(tex0, v_texCoord0);
|
||||
vec4 dest = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
float lsrc = src.a * (1.0 - dest.a);
|
||||
float lboth = src.a * dest.a;
|
||||
|
||||
vec4 result = src * lsrc + dest * 0.0 + dest * lboth;
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
30
orx-fx/src/shaders/glsl/blend/destination-in.frag
Normal file
30
orx-fx/src/shaders/glsl/blend/destination-in.frag
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 src = texture(tex0, v_texCoord0);
|
||||
vec4 dest = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 src = texture2D(tex0, v_texCoord0);
|
||||
vec4 dest = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
float lboth = src.a * dest.a;
|
||||
vec4 result = dest * lboth;
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
31
orx-fx/src/shaders/glsl/blend/destination-out.frag
Normal file
31
orx-fx/src/shaders/glsl/blend/destination-out.frag
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 src = texture(tex0, v_texCoord0);
|
||||
vec4 dest = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 src = texture2D(tex0, v_texCoord0);
|
||||
vec4 dest = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
float ldest = dest.a * (1.0 - src.a);
|
||||
|
||||
vec4 result = dest * ldest;
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
44
orx-fx/src/shaders/glsl/blend/hard-light.frag
Normal file
44
orx-fx/src/shaders/glsl/blend/hard-light.frag
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform bool clip;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 a = texture(tex0, v_texCoord0);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 a = texture2D(tex0, v_texCoord0);
|
||||
vec4 b = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
vec3 na = a.a == 0.0 ? vec3(0.0): a.rgb / a.a;
|
||||
vec3 nb = b.a == 0.0 ? vec3(0.0): b.rgb / b.a;
|
||||
|
||||
vec3 m = vec3(
|
||||
nb.r <= 0.5? 2*na.r * nb.r : 1.0 - 2.0*(1.0 - na.r)*(1.0 - nb.r),
|
||||
nb.g <= 0.5? 2*na.g * nb.g : 1.0 - 2.0*(1.0 - na.g)*(1.0 - nb.g),
|
||||
nb.b <= 0.5? 2*na.b * nb.b : 1.0 - 2.0*(1.0 - na.b)*(1.0 - nb.b)
|
||||
);
|
||||
|
||||
vec4 result;
|
||||
if (clip) {
|
||||
result = vec4(na * (1.0 - b.a) + b.a * m, 1.0) * a.a;
|
||||
} else {
|
||||
result = (1.0-a.a) * b + a.a * b.a * vec4(m, 1.0) + (1.0-b.a) * a;
|
||||
}
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
44
orx-fx/src/shaders/glsl/blend/lighten.frag
Normal file
44
orx-fx/src/shaders/glsl/blend/lighten.frag
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform bool clip;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 a = texture(tex0, v_texCoord0);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 a = texture2D(tex0, v_texCoord0);
|
||||
vec4 b = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
vec3 na = a.a == 0.0 ? vec3(0.0): a.rgb / a.a;
|
||||
vec3 nb = b.a == 0.0 ? vec3(0.0): b.rgb / b.a;
|
||||
|
||||
vec3 m = vec3(
|
||||
nb.r >= na.r? nb.r : na.r,
|
||||
nb.g >= na.g? nb.g : na.g,
|
||||
nb.b >= na.b? nb.b : na.b);
|
||||
|
||||
vec4 result;
|
||||
if (clip) {
|
||||
result = vec4(na * (1.0 - b.a) + b.a * m, 1.0) * a.a;
|
||||
} else {
|
||||
result = (1.0-a.a) * b + a.a * b.a * vec4(m, 1.0) + (1.0-b.a) * a;
|
||||
}
|
||||
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
37
orx-fx/src/shaders/glsl/blend/multiply-contrast.frag
Normal file
37
orx-fx/src/shaders/glsl/blend/multiply-contrast.frag
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 a = texture(tex0, v_texCoord0);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 a = texture2D(tex0, v_texCoord0);
|
||||
vec4 b = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
float ai = max(a.z, max(a.x, a.y));
|
||||
float bi = max(b.z, max(b.x, b.y));
|
||||
|
||||
vec3 f = a.rgb - (1.0-b.rgb)*2.0*b.a;
|
||||
|
||||
vec4 result;
|
||||
result.rgb = max(vec3(0.0), f) * (1.0) + b.rgb * (1.0-a.a);
|
||||
result.a = 1.0;
|
||||
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
46
orx-fx/src/shaders/glsl/blend/multiply.frag
Normal file
46
orx-fx/src/shaders/glsl/blend/multiply.frag
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
|
||||
uniform bool clip;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
vec3 u(vec4 x) {
|
||||
return x.a == 0.0? vec3(0.0) : x.rgb / x.a;
|
||||
}
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 a = texture(tex0, v_texCoord0);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 a = texture2D(tex0, v_texCoord0);
|
||||
vec4 b = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
vec3 na = u(a);
|
||||
vec3 nb = u(b);
|
||||
vec3 mulColor = mix(vec3(1.0), nb, b.a);
|
||||
|
||||
vec4 result;
|
||||
if (clip) {
|
||||
result = vec4(a.rgb * mulColor, a.a);
|
||||
} else {
|
||||
result = (1.0-a.a) * b + a.a * b.a * vec4(na * nb, 1.0) + (1.0-b.a) * a;
|
||||
}
|
||||
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
|
||||
39
orx-fx/src/shaders/glsl/blend/normal.frag
Normal file
39
orx-fx/src/shaders/glsl/blend/normal.frag
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform bool clip;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 a = texture(tex0, v_texCoord0);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 a = texture2D(tex0, v_texCoord0);
|
||||
vec4 b = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
float alpha = min(1,max(0, b.a));
|
||||
|
||||
vec4 result;
|
||||
if (!clip) {
|
||||
result = a * (1.0-alpha) + b;
|
||||
result.a = clamp(o_color.a, 0.0, 1.0);
|
||||
} else {
|
||||
result = a * (1.0-alpha) + b * a.a;
|
||||
}
|
||||
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
55
orx-fx/src/shaders/glsl/blend/overlay.frag
Normal file
55
orx-fx/src/shaders/glsl/blend/overlay.frag
Normal file
@@ -0,0 +1,55 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform bool clip;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
vec3 demul(vec4 c) {
|
||||
if (c.a == 0) {
|
||||
return vec3(0.0);
|
||||
} else {
|
||||
return c.rgb / c.a;
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 a = texture(tex0, v_texCoord0);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 a = texture2D(tex0, v_texCoord0);
|
||||
vec4 b = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
vec3 na = demul(a);
|
||||
vec3 nb = demul(b);
|
||||
|
||||
vec3 m = vec3(
|
||||
na.r <= 0.5? 2.0 * na.r * nb.r : (1.0 - 2.0 * (1.0 - na.r) * (1.0 - nb.r)),
|
||||
na.g <= 0.5? 2.0 * na.g * nb.g : (1.0 - 2.0 * (1.0 - na.g) * (1.0 - nb.g)),
|
||||
na.b <= 0.5? 2.0 * na.b * nb.b : (1.0 - 2.0 * (1.0 - na.b) * (1.0 - nb.b))
|
||||
);
|
||||
|
||||
vec4 result;
|
||||
if (clip) {
|
||||
vec3 fc = na * (1.0 - b.a) + m * b.a;
|
||||
result = vec4(fc, 1.0) * a.a;
|
||||
} else {
|
||||
result = (1.0-a.a) * b + a.a * b.a * vec4(m, 1.0) + (1.0-b.a) * a;
|
||||
}
|
||||
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
|
||||
}
|
||||
25
orx-fx/src/shaders/glsl/blend/passthrough.frag
Normal file
25
orx-fx/src/shaders/glsl/blend/passthrough.frag
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 result = texture(tex0, v_texCoord0);
|
||||
#else
|
||||
vec4 result = texture2D(tex0, v_texCoord0);
|
||||
#endif
|
||||
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
44
orx-fx/src/shaders/glsl/blend/screen.frag
Normal file
44
orx-fx/src/shaders/glsl/blend/screen.frag
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform bool clip;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 a = texture(tex0, v_texCoord0);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 a = texture2D(tex0, v_texCoord0);
|
||||
vec4 b = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
vec3 na = a.a == 0.0 ? vec3(0.0): a.rgb / a.a;
|
||||
vec3 nb = b.a == 0.0 ? vec3(0.0): b.rgb / b.a;
|
||||
|
||||
vec3 m = vec3(
|
||||
1.0-((1.0-na.r)*(1.0-nb.r)),
|
||||
1.0-((1.0-na.g)*(1.0-nb.g)),
|
||||
1.0-((1.0-na.b)*(1.0-nb.b)));
|
||||
|
||||
vec4 result;
|
||||
if (clip) {
|
||||
result = vec4(na * (1.0 - b.a) + b.a * m, 1.0) * a.a;
|
||||
} else {
|
||||
result = (1.0-a.a) * b + a.a * b.a * vec4(m, 1.0) + (1.0-b.a) * a;
|
||||
}
|
||||
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
32
orx-fx/src/shaders/glsl/blend/source-atop.frag
Normal file
32
orx-fx/src/shaders/glsl/blend/source-atop.frag
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 src = texture(tex0, v_texCoord0);
|
||||
vec4 dest = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 src = texture2D(tex0, v_texCoord0);
|
||||
vec4 dest = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
float ldest = dest.a * (1.0 - src.a);
|
||||
float lboth = src.a * dest.a;
|
||||
|
||||
vec4 result = dest * ldest + src * lboth;
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
31
orx-fx/src/shaders/glsl/blend/source-in.frag
Normal file
31
orx-fx/src/shaders/glsl/blend/source-in.frag
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 src = texture(tex0, v_texCoord0);
|
||||
vec4 dest = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 src = texture2D(tex0, v_texCoord0);
|
||||
vec4 dest = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
float lboth = src.a * dest.a;
|
||||
vec4 result = src * lboth;
|
||||
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
31
orx-fx/src/shaders/glsl/blend/source-out.frag
Normal file
31
orx-fx/src/shaders/glsl/blend/source-out.frag
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 src = texture(tex0, v_texCoord0);
|
||||
vec4 dest = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 src = texture2D(tex0, v_texCoord0);
|
||||
vec4 dest = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
float lsrc = src.a * (1.0 - dest.a);
|
||||
|
||||
vec4 result = src * lsrc;
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
39
orx-fx/src/shaders/glsl/blend/subtract.frag
Normal file
39
orx-fx/src/shaders/glsl/blend/subtract.frag
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform bool clip;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 a = texture(tex0, v_texCoord0);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 a = texture2D(tex0, v_texCoord0);
|
||||
vec4 b = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
vec3 na = a.a > 0 ? a.rgb/a.a : vec3(0.0);
|
||||
vec3 nb = b.a > 0 ? b.rgb/b.a : vec3(0.0);
|
||||
vec3 subColor = b.rgb;
|
||||
vec4 result;
|
||||
if (clip) {
|
||||
result = vec4(max(na - subColor, vec3(0.0)), 1) * a.a;
|
||||
} else {
|
||||
result = (1.0-a.a) * b + a.a * b.a * vec4(max(na - nb, vec3(0.0)), 1.0) + (1.0-b.a) * a;
|
||||
}
|
||||
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
32
orx-fx/src/shaders/glsl/blend/xor.frag
Normal file
32
orx-fx/src/shaders/glsl/blend/xor.frag
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef OR_GL_TEXTURE2D
|
||||
vec4 src = texture(tex0, v_texCoord0);
|
||||
vec4 dest = texture(tex1, v_texCoord0);
|
||||
#else
|
||||
vec4 src = texture2D(tex0, v_texCoord0);
|
||||
vec4 dest = texture2D(tex1, v_texCoord0);
|
||||
#endif
|
||||
|
||||
float lsrc = src.a * (1.0 - dest.a);
|
||||
float ldest = dest.a * (1.0 - src.a);
|
||||
|
||||
vec4 result = src * lsrc + dest * ldest;
|
||||
#ifdef OR_GL_FRAGCOLOR
|
||||
gl_FragColor = result;
|
||||
#else
|
||||
o_color = result;
|
||||
#endif
|
||||
}
|
||||
26
orx-fx/src/shaders/glsl/blur/approximate-gaussian-blur.frag
Normal file
26
orx-fx/src/shaders/glsl/blur/approximate-gaussian-blur.frag
Normal file
@@ -0,0 +1,26 @@
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0;
|
||||
uniform vec2 blurDirection;
|
||||
|
||||
uniform int window;
|
||||
uniform float sigma;
|
||||
uniform float spread;
|
||||
uniform float gain;
|
||||
|
||||
uniform int sourceLevel;
|
||||
|
||||
out vec4 o_color;
|
||||
void main() {
|
||||
vec2 s = 1.0 / textureSize(tex0, sourceLevel).xy;
|
||||
int w = window;
|
||||
|
||||
vec4 sum = vec4(0.0);
|
||||
float weight = 0;
|
||||
for (int x = -w; x <= w; ++x) {
|
||||
float lw = exp( -(x*x) / (2 * sigma * sigma) ) ;
|
||||
vec2 tc = v_texCoord0 + x * blurDirection * s;// * spread;
|
||||
sum += textureLod(tex0, tc, sourceLevel) * lw;
|
||||
weight += lw;
|
||||
}
|
||||
o_color = (sum / weight) * gain;
|
||||
}
|
||||
13
orx-fx/src/shaders/glsl/blur/bloom-combine.frag
Normal file
13
orx-fx/src/shaders/glsl/blur/bloom-combine.frag
Normal file
@@ -0,0 +1,13 @@
|
||||
out vec4 o_output;
|
||||
in vec2 v_texCoord0;
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
|
||||
uniform float gain;
|
||||
uniform vec4 bias;
|
||||
|
||||
void main() {
|
||||
o_output = texture(tex0, v_texCoord0) + texture(tex1, v_texCoord0)*gain;
|
||||
o_output.a = clamp(o_output.a, 0.0, 1.0);
|
||||
}
|
||||
19
orx-fx/src/shaders/glsl/blur/bloom-downscale.frag
Normal file
19
orx-fx/src/shaders/glsl/blur/bloom-downscale.frag
Normal file
@@ -0,0 +1,19 @@
|
||||
out vec4 o_output;
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0;
|
||||
|
||||
|
||||
// -- based on https://github.com/excess-demogroup/even-laster-engine/blob/a451a89f6bd6d3c6017d5890b92d9f72823bc742/src/shaders/bloom.fra
|
||||
void main()
|
||||
{
|
||||
float centerWeight = 0.16210282163712664;
|
||||
vec2 diagonalOffsets = vec2(0.3842896354828526, 1.2048616327242379);
|
||||
vec4 offsets = vec4(-diagonalOffsets.xy, +diagonalOffsets.xy) / textureSize(tex0, 0).xyxy;
|
||||
float diagonalWeight = 0.2085034734347498;
|
||||
|
||||
o_output = textureLod(tex0, v_texCoord0, 0) * centerWeight +
|
||||
textureLod(tex0, v_texCoord0 + offsets.xy, 0) * diagonalWeight +
|
||||
textureLod(tex0, v_texCoord0 + offsets.wx, 0) * diagonalWeight +
|
||||
textureLod(tex0, v_texCoord0 + offsets.zw, 0) * diagonalWeight +
|
||||
textureLod(tex0, v_texCoord0 + offsets.yz, 0) * diagonalWeight;
|
||||
}
|
||||
81
orx-fx/src/shaders/glsl/blur/bloom-upscale.frag
Normal file
81
orx-fx/src/shaders/glsl/blur/bloom-upscale.frag
Normal file
@@ -0,0 +1,81 @@
|
||||
float nrand(vec2 n) {
|
||||
return fract(sin(dot(n.xy, vec2(12.9898, 78.233))) * 43758.5453);
|
||||
}
|
||||
|
||||
// -- based on https://github.com/excess-demogroup/even-laster-engine/blob/a451a89f6bd6d3c6017d5890b92d9f72823bc742/src/shaders/bloom_upscale.frag
|
||||
uniform float noiseSeed;
|
||||
uniform float shape;
|
||||
uniform float gain;
|
||||
|
||||
uniform float noiseGain;
|
||||
|
||||
in vec2 v_texCoord0;
|
||||
out vec4 o_output;
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform sampler2D tex2;
|
||||
uniform sampler2D tex3;
|
||||
uniform sampler2D tex4;
|
||||
uniform sampler2D tex5;
|
||||
|
||||
vec4 sampleBloom(vec2 pos, float shape) {
|
||||
vec4 sum = vec4(0);
|
||||
float total = 0;
|
||||
|
||||
{
|
||||
float weight = pow(0.0, shape);
|
||||
vec2 rnd = vec2(nrand(3 + 0.0 + pos.xy + noiseSeed),
|
||||
nrand(5 + 0.0 + pos.yx - noiseSeed));
|
||||
rnd = (rnd * 2 - 1) / textureSize(tex0, 0);
|
||||
sum += textureLod(tex0, pos + rnd * noiseGain, 0.0) * weight;
|
||||
total += weight;
|
||||
}
|
||||
{
|
||||
float weight = pow(1.0, shape);
|
||||
vec2 rnd = vec2(nrand(3 + 0.0 + pos.xy + noiseSeed),
|
||||
nrand(5 + 0.0 + pos.yx - noiseSeed));
|
||||
rnd = (rnd * 2 - 1) / textureSize(tex1, 0);
|
||||
sum += textureLod(tex1, pos + rnd * noiseGain, 0.0) * weight;
|
||||
total += weight;
|
||||
}
|
||||
{
|
||||
float weight = pow(2.0, shape);
|
||||
vec2 rnd = vec2(nrand(3 + 0.0 + pos.xy + noiseSeed),
|
||||
nrand(5 + 0.0 + pos.yx - noiseSeed));
|
||||
rnd = (rnd * 2 - 1) / textureSize(tex2, 0);
|
||||
sum += textureLod(tex2, pos + rnd * noiseGain, 0.0) * weight;
|
||||
total += weight;
|
||||
}
|
||||
|
||||
{
|
||||
float weight = pow(3.0, shape);
|
||||
vec2 rnd = vec2(nrand(3 + 0.0 + pos.xy + noiseSeed),
|
||||
nrand(5 + 0.0 + pos.yx - noiseSeed));
|
||||
rnd = (rnd * 3 - 1) / textureSize(tex3, 0);
|
||||
sum += textureLod(tex3, pos + rnd * noiseGain, 0.0) * weight;
|
||||
total += weight;
|
||||
}
|
||||
{
|
||||
float weight = pow(4.0, shape);
|
||||
vec2 rnd = vec2(nrand(3 + 0.0 + pos.xy + noiseSeed),
|
||||
nrand(5 + 0.0 + pos.yx - noiseSeed));
|
||||
rnd = (rnd * 3 - 1) / textureSize(tex3, 0);
|
||||
sum += textureLod(tex4, pos + rnd * noiseGain, 0.0) * weight;
|
||||
total += weight;
|
||||
}
|
||||
{
|
||||
float weight = pow(5.0, shape);
|
||||
vec2 rnd = vec2(nrand(3 + 0.0 + pos.xy + noiseSeed),
|
||||
nrand(5 + 0.0 + pos.yx - noiseSeed));
|
||||
rnd = (rnd * 3 - 1) / textureSize(tex3, 0);
|
||||
sum += textureLod(tex5, pos + rnd * noiseGain, 0.0) * weight;
|
||||
total += weight;
|
||||
}
|
||||
|
||||
return sum / total;
|
||||
}
|
||||
|
||||
void main() {
|
||||
o_output = sampleBloom(v_texCoord0, shape) * gain;
|
||||
}
|
||||
18
orx-fx/src/shaders/glsl/blur/bloom.frag
Normal file
18
orx-fx/src/shaders/glsl/blur/bloom.frag
Normal file
@@ -0,0 +1,18 @@
|
||||
in vec2 v_texCoord0;
|
||||
out vec4 o_color;
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform float blendFactor;
|
||||
uniform float brightness;
|
||||
|
||||
void main() {
|
||||
vec3 original = texture(tex0, v_texCoord0).rgb;
|
||||
vec3 bloom = texture(tex1, v_texCoord0).rgb;
|
||||
|
||||
vec3 hdrColor = mix(original, bloom, blendFactor);
|
||||
|
||||
vec3 result = vec3(1.0) - exp(-hdrColor * brightness);
|
||||
|
||||
o_color = vec4(result, 1.0);
|
||||
}
|
||||
27
orx-fx/src/shaders/glsl/blur/box-blur.frag
Normal file
27
orx-fx/src/shaders/glsl/blur/box-blur.frag
Normal file
@@ -0,0 +1,27 @@
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0;
|
||||
uniform vec2 blurDirection;
|
||||
|
||||
uniform int window;
|
||||
uniform float sigma;
|
||||
uniform float gain;
|
||||
uniform vec4 subtract;
|
||||
uniform float spread;
|
||||
out vec4 o_color;
|
||||
void main() {
|
||||
vec2 s = textureSize(tex0, 0).xy;
|
||||
s = vec2(1.0/s.x, 1.0/s.y);
|
||||
|
||||
int w = window;
|
||||
|
||||
vec4 sum = vec4(0, 0, 0, 0);
|
||||
float weight = 0;
|
||||
for (int x = -w; x<= w; ++x) {
|
||||
float lw = 1.0;
|
||||
sum += texture(tex0, v_texCoord0 + x * blurDirection * s * spread);
|
||||
weight += lw;
|
||||
}
|
||||
|
||||
o_color = (sum / weight) * gain;
|
||||
// o_color.a = 1.0;
|
||||
}
|
||||
11
orx-fx/src/shaders/glsl/blur/frame-blur.frag
Normal file
11
orx-fx/src/shaders/glsl/blur/frame-blur.frag
Normal file
@@ -0,0 +1,11 @@
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0; // input image
|
||||
uniform sampler2D tex1; // accumulator image
|
||||
uniform float blend;
|
||||
out vec4 o_color;
|
||||
void main() {
|
||||
|
||||
vec4 inputColor = texture(tex0, v_texCoord0);
|
||||
vec4 accumulator = texture(tex1, v_texCoord0);
|
||||
o_color = accumulator * (1.0 - blend) + inputColor * blend;
|
||||
}
|
||||
29
orx-fx/src/shaders/glsl/blur/gaussian-blur.frag
Normal file
29
orx-fx/src/shaders/glsl/blur/gaussian-blur.frag
Normal file
@@ -0,0 +1,29 @@
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0;
|
||||
|
||||
uniform int window;
|
||||
uniform float sigma;
|
||||
uniform float spread;
|
||||
uniform float gain;
|
||||
|
||||
|
||||
out vec4 o_color;
|
||||
void main() {
|
||||
|
||||
vec2 s = textureSize(tex0, 0).xy;
|
||||
s = vec2(1.0/s.x, 1.0/s.y);
|
||||
|
||||
int w = window;
|
||||
|
||||
vec4 sum = vec4(0,0,0,0);
|
||||
float weight = 0;
|
||||
for (int y = -w; y<= w; ++y) {
|
||||
for (int x = -w; x<= w; ++x) {
|
||||
float lw = exp(-(x*x+y*y) / (2 * sigma * sigma));
|
||||
sum+=texture(tex0, v_texCoord0 + vec2(x,y) * s * spread) * lw;
|
||||
weight+=lw;
|
||||
}
|
||||
}
|
||||
|
||||
o_color = (sum / weight) * gain;
|
||||
}
|
||||
47
orx-fx/src/shaders/glsl/blur/hash-blur.frag
Normal file
47
orx-fx/src/shaders/glsl/blur/hash-blur.frag
Normal file
@@ -0,0 +1,47 @@
|
||||
// based on Hashed blur by David Hoskins.
|
||||
// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
|
||||
|
||||
uniform float radius;
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0;
|
||||
uniform float time;
|
||||
uniform int samples;
|
||||
uniform float gain;
|
||||
out vec4 o_color;
|
||||
|
||||
#define TAU 6.28318530718
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
#define HASHSCALE 443.8975
|
||||
vec2 hash22(vec2 p) {
|
||||
vec3 p3 = fract(vec3(p.xyx) * HASHSCALE);
|
||||
p3 += dot(p3, p3.yzx+19.19);
|
||||
return fract(vec2((p3.x + p3.y)*p3.z, (p3.x+p3.z)*p3.y));
|
||||
}
|
||||
|
||||
vec2 sampleTexture(inout vec2 r) {
|
||||
r = fract(r * vec2(33.3983, 43.4427));
|
||||
//return r-.5;
|
||||
return sqrt(r.x+.001) * vec2(sin(r.y * TAU), cos(r.y * TAU))*.5; // <<=== circular sampling.
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
vec4 blur(vec2 uv, float radius) {
|
||||
vec2 circle = vec2(radius) * (vec2(1.0) / textureSize(tex0, 0));
|
||||
vec2 random = hash22(uv + vec2(time));
|
||||
|
||||
vec4 acc = vec4(0.0);
|
||||
for (int i = 0; i < samples; i++) {
|
||||
acc += texture(tex0, uv + circle * sampleTexture(random));
|
||||
}
|
||||
return acc / float(samples);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
void main() {
|
||||
vec2 uv = v_texCoord0;
|
||||
float radiusSqr = pow(radius, 2.0);
|
||||
o_color = blur(uv, radiusSqr);
|
||||
o_color.rgb *= gain;
|
||||
}
|
||||
23
orx-fx/src/shaders/glsl/blur/kawase-blur.frag
Normal file
23
orx-fx/src/shaders/glsl/blur/kawase-blur.frag
Normal file
@@ -0,0 +1,23 @@
|
||||
out vec4 o_color;
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0;
|
||||
uniform int iteration;
|
||||
uniform float spread;
|
||||
|
||||
void main() {
|
||||
ivec2 size = textureSize(tex0, 0);
|
||||
vec2 pixelSize = vec2(1.0/size.x, 1.0/size.y);
|
||||
vec2 halfPixelSize = pixelSize / 2.0f;
|
||||
vec2 d = (pixelSize.xy * vec2(iteration, iteration)) + halfPixelSize.xy;
|
||||
d *= spread;
|
||||
|
||||
vec4 dec = vec4(2.2);
|
||||
vec4 enc = vec4(1.0/2.2);
|
||||
|
||||
vec4 cOut = pow(texture(tex0, v_texCoord0+ vec2(-1, 1)*d), dec);
|
||||
cOut += pow(texture(tex0, v_texCoord0 + vec2(1, 1)*d), dec);
|
||||
cOut += pow(texture(tex0, v_texCoord0 + vec2(1, -1)*d), dec);
|
||||
cOut += pow(texture(tex0, v_texCoord0+ vec2(-1, -1)*d), dec);
|
||||
|
||||
o_color = pow(cOut/4.0, enc);
|
||||
}
|
||||
49
orx-fx/src/shaders/glsl/blur/laser-blur.frag
Normal file
49
orx-fx/src/shaders/glsl/blur/laser-blur.frag
Normal file
@@ -0,0 +1,49 @@
|
||||
out vec4 o_output;
|
||||
uniform sampler2D tex0;
|
||||
in vec2 v_texCoord0;
|
||||
uniform float radius;
|
||||
uniform float amp0;
|
||||
uniform float amp1;
|
||||
uniform vec2 center;
|
||||
uniform float vignette;
|
||||
uniform float vignetteSize;
|
||||
uniform float aberration;
|
||||
uniform bool linearInput;
|
||||
uniform bool linearOutput;
|
||||
|
||||
void main() {
|
||||
vec4 i0 = texture(tex0, v_texCoord0);
|
||||
if (!linearInput) {
|
||||
i0.rgb = pow(i0.rgb, vec3(2.2));
|
||||
}
|
||||
vec2 vt = (v_texCoord0 - vec2(0.5, 0.5) + center) * radius + vec2(0.5, 0.5) - center;
|
||||
|
||||
vec2 size = textureSize(tex0, 0);
|
||||
vec2 l = (v_texCoord0 - vec2(0.5, 0.5) + center) * vec2(1.0, size.y/size.x);
|
||||
float d = length(l);
|
||||
|
||||
if (vt.x >= 0.0 && vt.y >= 0.0 && vt.x <= 1.0 && vt.y <= 1.0) {
|
||||
vec4 i1r = texture(tex0, (v_texCoord0 - vec2(0.5, 0.5) + center) * (radius*(1.0 + aberration)) + vec2(0.5, 0.5) - center);
|
||||
vec4 i1g = texture(tex0, (v_texCoord0 - vec2(0.5, 0.5) + center) * (radius*(1.0)) + vec2(0.5, 0.5) - center);
|
||||
vec4 i1b = texture(tex0, (v_texCoord0 - vec2(0.5, 0.5) + center) * (radius*(1.0 - aberration)) + vec2(0.5, 0.5) - center);
|
||||
|
||||
i1r.rgb = i1r.a > 0.0 ? i1r.rgb / i1r.a : vec3(0.0);
|
||||
i1g.rgb = i1g.a > 0.0 ? i1g.rgb / i1g.a : vec3(0.0);
|
||||
i1b.rgb = i1b.a > 0.0 ? i1b.rgb / i1b.a : vec3(0.0);
|
||||
|
||||
vec4 i1 = vec4(i1r.r, i1g.g, i1b.b, 1.0) * (i1r.a + i1g.a + i1b.a)/3.0;
|
||||
if (!linearInput) {
|
||||
i1.rgb = pow(i1.rgb, vec3(2.2));
|
||||
}
|
||||
o_output = i0 * amp0 + i1 * amp1;
|
||||
} else {
|
||||
o_output = i0 * 0.5;
|
||||
}
|
||||
|
||||
o_output.rgb *= mix(1.0, smoothstep(vignetteSize, 0.0, d), vignette);
|
||||
if (!linearOutput) {
|
||||
o_output.rgb = pow(o_output.rgb, vec3(1.0 / 2.2));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
39
orx-fx/src/shaders/glsl/blur/zoom-blur.frag
Normal file
39
orx-fx/src/shaders/glsl/blur/zoom-blur.frag
Normal file
@@ -0,0 +1,39 @@
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0; // input
|
||||
uniform vec2 center;
|
||||
uniform float strength;
|
||||
uniform vec2 dimensions;
|
||||
|
||||
out vec4 o_color;
|
||||
|
||||
float random(vec3 scale, float seed) {
|
||||
/* use the fragment position for a different seed per-pixel */
|
||||
return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);
|
||||
}
|
||||
|
||||
// Implementation by Evan Wallace (glfx.js)
|
||||
void main() {
|
||||
vec4 color = vec4(0.0);
|
||||
float total = 0.0;
|
||||
vec2 toCenter = center - v_texCoord0;
|
||||
|
||||
/* randomize the lookup values to hide the fixed number of samples */
|
||||
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
|
||||
|
||||
for (float t = 0.0; t <= 40.0; t++) {
|
||||
float percent = (t + offset) / 40.0;
|
||||
float weight = 4.0 * (percent - percent * percent);
|
||||
vec4 tex = texture(tex0, v_texCoord0 + toCenter * percent * strength);
|
||||
|
||||
/* switch to pre-multiplied alpha to correctly blur transparent images */
|
||||
tex.rgb *= tex.a;
|
||||
|
||||
color += tex * weight;
|
||||
total += weight;
|
||||
}
|
||||
|
||||
o_color = color / total;
|
||||
|
||||
/* switch back from pre-multiplied alpha */
|
||||
o_color.rgb /= o_color.a + 0.00001;
|
||||
}
|
||||
21
orx-fx/src/shaders/glsl/color/chromatic-aberration.frag
Normal file
21
orx-fx/src/shaders/glsl/color/chromatic-aberration.frag
Normal file
@@ -0,0 +1,21 @@
|
||||
in vec2 v_texCoord0;
|
||||
|
||||
uniform sampler2D tex0;
|
||||
|
||||
uniform float aberrationFactor;
|
||||
uniform vec2 dimensions;
|
||||
|
||||
out vec4 o_color;
|
||||
|
||||
void main() {
|
||||
vec2 uv = v_texCoord0;
|
||||
float factor = (1.0 / dimensions.x) * aberrationFactor;
|
||||
|
||||
vec4 tex = texture(tex0, uv);
|
||||
|
||||
float r = texture(tex0, vec2(uv.x - factor, uv.y)).r;
|
||||
float g = tex.g;
|
||||
float b = texture(tex0, vec2(uv.x + factor, uv.y)).b;
|
||||
|
||||
o_color = vec4(vec3(r, g, b), tex.a);
|
||||
}
|
||||
67
orx-fx/src/shaders/glsl/color/color-correction.frag
Normal file
67
orx-fx/src/shaders/glsl/color/color-correction.frag
Normal file
@@ -0,0 +1,67 @@
|
||||
/* based on "Brightness, contrast, saturation" by WojtaZam: https://www.shadertoy.com/view/XdcXzn */
|
||||
uniform float brightness;
|
||||
uniform float saturation;
|
||||
uniform float contrast;
|
||||
uniform float hueShift;
|
||||
uniform float gamma;
|
||||
uniform float opacity;
|
||||
uniform bool clamped;
|
||||
|
||||
uniform sampler2D tex0;
|
||||
in vec2 v_texCoord0;
|
||||
out vec4 o_color;
|
||||
|
||||
mat4 brightnessMatrix(float brightness) {
|
||||
return mat4(1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
brightness, brightness, brightness, 1);
|
||||
}
|
||||
|
||||
mat4 contrastMatrix(float contrast) {
|
||||
float t = (1.0 - contrast) / 2.0;
|
||||
return mat4(contrast, 0, 0, 0,
|
||||
0, contrast, 0, 0,
|
||||
0, 0, contrast, 0,
|
||||
t, t, t, 1 );
|
||||
}
|
||||
|
||||
mat4 saturationMatrix(float saturation) {
|
||||
vec3 luminance = vec3(0.3086, 0.6094, 0.0820);
|
||||
float oneMinusSat = 1.0 - saturation;
|
||||
vec3 red = vec3(luminance.x * oneMinusSat);
|
||||
red += vec3(saturation, 0, 0);
|
||||
|
||||
vec3 green = vec3(luminance.y * oneMinusSat);
|
||||
green += vec3(0, saturation, 0);
|
||||
|
||||
vec3 blue = vec3(luminance.z * oneMinusSat);
|
||||
blue += vec3(0, 0, saturation);
|
||||
|
||||
return mat4(red, 0,
|
||||
green, 0,
|
||||
blue, 0,
|
||||
0, 0, 0, 1 );
|
||||
}
|
||||
|
||||
// from starea's https://www.shadertoy.com/view/MdjBRy, which in turn remixed it from mAlk's https://www.shadertoy.com/view/MsjXRt
|
||||
vec3 shiftHue(in vec3 col, in float Shift) {
|
||||
vec3 P = vec3(0.55735) * dot(vec3(0.55735), col);
|
||||
vec3 U = col - P;
|
||||
vec3 V = cross(vec3(0.55735), U);
|
||||
col = U * cos(Shift * 6.2832) + V * sin(Shift * 6.2832) + P;
|
||||
return col;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 color = texture(tex0, v_texCoord0);
|
||||
vec4 nc = (color.a == 0.0) ? vec4(0.0) : vec4(color.rgb / color.a, color.a);
|
||||
nc.rgb = pow(nc.rgb, vec3(gamma));
|
||||
nc.rgb = shiftHue(nc.rgb, (hueShift/360.0));
|
||||
vec4 cc = brightnessMatrix(brightness) * contrastMatrix((contrast + 1)) * saturationMatrix(saturation + 1) * nc;
|
||||
if(clamped) {
|
||||
o_color = clamp(vec4(cc.rgb, 1.0) * color.a * opacity, 0.0, 1.0);
|
||||
} else {
|
||||
o_color = vec4(cc.rgb, 1.0) * color.a * opacity;
|
||||
}
|
||||
}
|
||||
40
orx-fx/src/shaders/glsl/color/color-lookup.frag
Normal file
40
orx-fx/src/shaders/glsl/color/color-lookup.frag
Normal file
@@ -0,0 +1,40 @@
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D lookup;
|
||||
uniform float seed;
|
||||
uniform float noiseGain;
|
||||
|
||||
|
||||
out vec4 o_color;
|
||||
|
||||
#define HASHSCALE 443.8975
|
||||
vec2 hash22(vec2 p) {
|
||||
vec3 p3 = fract(vec3(p.xyx) * HASHSCALE);
|
||||
p3 += dot(p3, p3.yzx+19.19);
|
||||
return fract(vec2((p3.x + p3.y)*p3.z, (p3.x+p3.z)*p3.y));
|
||||
}
|
||||
|
||||
// -- from https://github.com/jeromeetienne/threex.coloradjust/blob/master/threex.coloradjust.js
|
||||
vec4 sampleAs3DTexture(sampler2D lut, vec3 uv, float width) {
|
||||
float sliceSize = 1.0 / width; // space of 1 slice
|
||||
float slicePixelSize = sliceSize / width; // space of 1 pixel
|
||||
float sliceInnerSize = slicePixelSize * (width - 1.0); // space of width pixels
|
||||
float zSlice0 = min(floor(uv.z * width), width - 1.0);
|
||||
float zSlice1 = min(zSlice0 + 1.0, width - 1.0);
|
||||
float xOffset = slicePixelSize * 0.5 + uv.x * sliceInnerSize;
|
||||
float s0 = xOffset + (zSlice0 * sliceSize);
|
||||
float s1 = xOffset + (zSlice1 * sliceSize);
|
||||
vec4 slice0Color = texture(lut, vec2(s0, 1.0-uv.y));
|
||||
vec4 slice1Color = texture(lut, vec2(s1, 1.0-uv.y));
|
||||
float zOffset = mod(uv.z * width, 1.0);
|
||||
vec4 result = mix(slice0Color, slice1Color, zOffset);
|
||||
return result;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 color = texture(tex0, v_texCoord0);
|
||||
vec3 noise = vec3(hash22(v_texCoord0-vec2(seed)), hash22(-v_texCoord0+vec2(seed)).x);
|
||||
vec3 graded = sampleAs3DTexture(lookup, min(vec3(1.0), max(vec3(0.0),color.rgb + noise * noiseGain)), 16.0).rgb;
|
||||
o_color.rgb = min(vec3(1.0), max(vec3(0.0), graded));
|
||||
o_color.a = color.a;
|
||||
}
|
||||
18
orx-fx/src/shaders/glsl/color/color-mix.frag
Normal file
18
orx-fx/src/shaders/glsl/color/color-mix.frag
Normal file
@@ -0,0 +1,18 @@
|
||||
uniform float[25] colorMatrix;
|
||||
|
||||
vec4 colorTransform(vec4 color, float[25] matrix) {
|
||||
float r = color.r * matrix[0] + color.g * matrix[5] + color.b * matrix[10] + color.a * matrix[15] + matrix[20];
|
||||
float g = color.r * matrix[1] + color.g * matrix[6] + color.b * matrix[11] + color.a * matrix[16] + matrix[21];
|
||||
float b = color.r * matrix[2] + color.g * matrix[7] + color.b * matrix[12] + color.a * matrix[17] + matrix[22];
|
||||
float a = color.r * matrix[3] + color.g * matrix[8] + color.b * matrix[13] + color.a * matrix[18] + matrix[23];
|
||||
return vec4(r, g, b, a);
|
||||
}
|
||||
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0;
|
||||
|
||||
out vec4 o_color;
|
||||
void main() {
|
||||
vec4 c = texture(tex0, v_texCoord0);
|
||||
o_color = colorTransform(c, colorMatrix);
|
||||
}
|
||||
9
orx-fx/src/shaders/glsl/color/color-tint.frag
Normal file
9
orx-fx/src/shaders/glsl/color/color-tint.frag
Normal file
@@ -0,0 +1,9 @@
|
||||
uniform vec4 tint;
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0;
|
||||
|
||||
out vec4 o_color;
|
||||
void main() {
|
||||
vec4 c = texture(tex0, v_texCoord0);
|
||||
o_color = vec4(c.rgb * tint.rgb, c.a) * tint.a;
|
||||
}
|
||||
15
orx-fx/src/shaders/glsl/color/luma-map.frag
Normal file
15
orx-fx/src/shaders/glsl/color/luma-map.frag
Normal file
@@ -0,0 +1,15 @@
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0; // input
|
||||
uniform vec4 foreground;
|
||||
uniform vec4 background;
|
||||
uniform float foregroundOpacity;
|
||||
uniform float backgroundOpacity;
|
||||
|
||||
out vec4 o_color;
|
||||
void main() {
|
||||
vec4 c = texture(tex0, v_texCoord0);
|
||||
vec4 fgc = foreground * foregroundOpacity;
|
||||
vec4 bgc = background * backgroundOpacity;
|
||||
float luma = dot( (c.a> 0.0? c.rgb/c.a : vec3(0.0)), vec3(1.0/3.0));
|
||||
o_color = mix(bgc, fgc, luma) * c.a;
|
||||
}
|
||||
15
orx-fx/src/shaders/glsl/color/luma-opacity.frag
Normal file
15
orx-fx/src/shaders/glsl/color/luma-opacity.frag
Normal file
@@ -0,0 +1,15 @@
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0; // input
|
||||
uniform float foregroundLuma;
|
||||
uniform float backgroundLuma;
|
||||
uniform float foregroundOpacity;
|
||||
uniform float backgroundOpacity;
|
||||
|
||||
out vec4 o_color;
|
||||
void main() {
|
||||
vec4 c = texture(tex0, v_texCoord0);
|
||||
float l = dot( (c.a> 0.0? c.rgb/c.a : vec3(0.0)), vec3(1.0/3.0));
|
||||
float mf = smoothstep(backgroundLuma, foregroundLuma, l);
|
||||
float o = mix(backgroundOpacity, foregroundOpacity, mf);
|
||||
o_color = c * o;
|
||||
}
|
||||
16
orx-fx/src/shaders/glsl/color/luma-threshold.frag
Normal file
16
orx-fx/src/shaders/glsl/color/luma-threshold.frag
Normal file
@@ -0,0 +1,16 @@
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0; // input
|
||||
uniform vec4 foreground;
|
||||
uniform vec4 background;
|
||||
uniform float foregroundOpacity;
|
||||
uniform float backgroundOpacity;
|
||||
uniform float threshold;
|
||||
|
||||
out vec4 o_color;
|
||||
void main() {
|
||||
vec4 c = texture(tex0, v_texCoord0);
|
||||
vec4 fgc = foreground * foregroundOpacity;
|
||||
vec4 bgc = background * backgroundOpacity;
|
||||
float luma = dot(c.rgb, vec3(1.0/3.0));
|
||||
o_color = mix(bgc, fgc, step(threshold, luma ));
|
||||
}
|
||||
121
orx-fx/src/shaders/glsl/color/pal.frag
Normal file
121
orx-fx/src/shaders/glsl/color/pal.frag
Normal file
@@ -0,0 +1,121 @@
|
||||
// based on https://github.com/svofski/CRT
|
||||
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0; // input
|
||||
uniform float amount;
|
||||
uniform float pixelation;
|
||||
out vec4 o_color;
|
||||
|
||||
// Implementation by Evan Wallace (glfx.js)
|
||||
|
||||
uniform float filter_gain; // 1.0 is kind of normal
|
||||
uniform float filter_invgain; // 1.6 is normal
|
||||
|
||||
#define PI 3.14159265358
|
||||
#define FSC 4433618.75
|
||||
#define FLINE 15625
|
||||
#define VISIBLELINES 312
|
||||
|
||||
#define RGB_to_YIQ mat3x3( 0.299 , 0.595716 , 0.211456 , 0.587 , -0.274453 , -0.522591 , 0.114 , -0.321263 , 0.311135 )
|
||||
#define YIQ_to_RGB mat3x3( 1.0 , 1.0 , 1.0 , 0.9563 , -0.2721 , -1.1070 , 0.6210 , -0.6474 , 1.7046 )
|
||||
|
||||
#define RGB_to_YUV mat3x3( 0.299 , -0.14713 , 0.615 , 0.587 , -0.28886 , -0.514991 , 0.114 , 0.436 , -0.10001 )
|
||||
#define YUV_to_RGB mat3x3( 1.0 , 1.0 , 1.0 , 0.0 , -0.39465 , 2.03211 , 1.13983 , -0.58060 , 0.0 )
|
||||
|
||||
#define fetch(ofs,center,invx) texture(tex0, vec2((ofs) * (invx) + center.x, center.y))
|
||||
|
||||
#define FIRTAPS 20
|
||||
const float FIR[FIRTAPS] = float[FIRTAPS] (-0.008030271,0.003107906,0.016841352,0.032545161,0.049360136,0.066256720,0.082120150,0.095848433,0.106453014,0.113151423,0.115441842,0.113151423,0.106453014,0.095848433,0.082120150,0.066256720,0.049360136,0.032545161,0.016841352,0.003107906);
|
||||
|
||||
//#define FIR_GAIN 2.0
|
||||
//#define FIR_INVGAIN 1.02
|
||||
#define FIR_GAIN filter_gain
|
||||
#define FIR_INVGAIN filter_invgain
|
||||
|
||||
float width_ratio;
|
||||
float height_ratio;
|
||||
float altv;
|
||||
float invx;
|
||||
|
||||
|
||||
float modulated(vec2 xy, float sinwt, float coswt) {
|
||||
vec3 rgb = fetch(0.0, xy, invx).xyz;
|
||||
vec3 yuv = RGB_to_YUV * rgb;
|
||||
|
||||
// scanline modulation hack
|
||||
// yuv.x *= 0.8 + 0.2 * sin(xy.y*2.0*3.1415*200.0);
|
||||
|
||||
return clamp(yuv.x + yuv.y * sinwt + yuv.z * coswt, 0.0, 1.0);
|
||||
}
|
||||
|
||||
vec2 modem_uv(vec2 xy, int ofs) {
|
||||
float t = (xy.x + float(ofs) * invx) * textureSize(tex0, 0).x;
|
||||
float wt = t * 2.0 * PI / width_ratio;
|
||||
|
||||
float sinwt = sin(wt);
|
||||
float coswt = cos(wt + altv);
|
||||
|
||||
vec3 rgb = fetch(float(ofs), xy, invx).xyz;
|
||||
vec3 yuv = RGB_to_YUV * rgb;
|
||||
float signal = clamp(yuv.x + yuv.y * sinwt + yuv.z * coswt, 0.0, 1.0);
|
||||
|
||||
return vec2(signal * sinwt, signal * coswt);
|
||||
}
|
||||
|
||||
|
||||
vec3 shadow_mask(vec2 pos){
|
||||
const mat2 rot = mat2(0.707,0.707,-0.707,0.707);
|
||||
vec3 offset = vec3( 0. , 1./3. , 2./3. );
|
||||
vec2 spos = pos * rot * vec2(200.0);
|
||||
vec3 ret = vec3(1);
|
||||
ret.r = length( fract( spos + vec2(offset.r) ) -.5);
|
||||
ret.g = length( fract( spos + vec2(offset.g) ) -.5);
|
||||
ret.b = length( fract( spos + vec2(offset.b) ) -.5);
|
||||
return clamp( 1.5-ret*2.5 , 0.0, 1.0 );
|
||||
}
|
||||
|
||||
//
|
||||
//void mainmaskImage(out vec4 fragColor, in vec2 fragCoord ){
|
||||
// vec2 xy = fragCoord.st / iResolution.xy;
|
||||
//
|
||||
// fragColor.rgb = shadow_mask( fragCoord.st/ iResolution.y ) * texture(iChannel0, xy).rgb;
|
||||
//
|
||||
//
|
||||
// if ( fragCoord.y > iResolution.y*.5 ) {
|
||||
// fragColor = texture(iChannel0, xy);
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
void main() {
|
||||
// vec2 xy = fragCoord.st / iResolution.xy;
|
||||
vec2 xy = v_texCoord0;
|
||||
width_ratio = textureSize(tex0, 0).x / (float(FSC) / float(FLINE));
|
||||
height_ratio = textureSize(tex0, 0).y / float(VISIBLELINES);
|
||||
altv = mod(floor(xy.y * float(VISIBLELINES) + 0.5), 2.0) * PI;
|
||||
invx = 0.25 / (float(FSC)/float(FLINE)); // equals 4 samples per Fsc period
|
||||
|
||||
// lowpass U/V at baseband
|
||||
vec2 filtered = vec2(0.0, 0.0);
|
||||
for (int i = 0; i < FIRTAPS; i++) {
|
||||
vec2 uv = modem_uv(xy, i - FIRTAPS/2);
|
||||
filtered += FIR_GAIN * uv * FIR[i];
|
||||
}
|
||||
|
||||
float t = xy.x * textureSize(tex0, 0).x;
|
||||
float wt = t * 2.0 * PI / width_ratio;
|
||||
|
||||
float sinwt = sin(wt);
|
||||
float coswt = cos(wt + altv);
|
||||
|
||||
float luma = modulated(xy, sinwt, coswt) - FIR_INVGAIN * (filtered.x * sinwt + filtered.y * coswt);
|
||||
vec3 yuv_result = vec3(luma, filtered.x, filtered.y);
|
||||
|
||||
vec3 rgbmask = shadow_mask( xy * vec2(1.0, textureSize(tex0,0).x / textureSize(tex0,0).y) ); // needs anisotropy like: fragCoord.st/ iResolution.y );
|
||||
rgbmask = vec3(1.0,1.0,1.0) * (1.0-pixelation) + rgbmask * pixelation;
|
||||
o_color = texture(tex0,xy) * (1.0-amount) + amount * vec4(rgbmask * ( YUV_to_RGB * yuv_result ), 1.0);
|
||||
|
||||
// if (xy.y>0.5) {
|
||||
// o_color = texture(tex0, xy);
|
||||
// }
|
||||
}
|
||||
16
orx-fx/src/shaders/glsl/color/rgb-to-ycbcr.frag
Normal file
16
orx-fx/src/shaders/glsl/color/rgb-to-ycbcr.frag
Normal file
@@ -0,0 +1,16 @@
|
||||
uniform vec4 tint;
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0;
|
||||
|
||||
out vec4 o_color;
|
||||
void main() {
|
||||
vec4 c = texture(tex0, v_texCoord0);
|
||||
if (c.a != 0.0) {
|
||||
c.rgb /= c.a;
|
||||
}
|
||||
c.rgb *= 255.0;
|
||||
float y = 0.0 + 0.299 * c.r + 0.587 * c.g + 0.114 * c.b;
|
||||
float cb = 128 - (0.168736 * c.r) - (0.331264 * c.g) + (0.5 * c.b);
|
||||
float cr = 128 + (0.5 * c.r) - 0.418688 * c.g - 0.081312 * c.b;
|
||||
o_color = vec4(y/255.0, cb/255.0, cr/255.0, 1.0) * c.a;
|
||||
}
|
||||
18
orx-fx/src/shaders/glsl/color/sepia.frag
Normal file
18
orx-fx/src/shaders/glsl/color/sepia.frag
Normal file
@@ -0,0 +1,18 @@
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0; // input
|
||||
uniform float amount;
|
||||
out vec4 o_color;
|
||||
|
||||
// Implementation by Evan Wallace (glfx.js)
|
||||
void main() {
|
||||
vec4 color = texture(tex0, v_texCoord0);
|
||||
float r = color.r;
|
||||
float g = color.g;
|
||||
float b = color.b;
|
||||
|
||||
color.r = min(1.0, (r * (1.0 - (0.607 * amount))) + (g * (0.769 * amount)) + (b * (0.189 * amount)));
|
||||
color.g = min(1.0, (r * 0.349 * amount) + (g * (1.0 - (0.314 * amount))) + (b * 0.168 * amount));
|
||||
color.b = min(1.0, (r * 0.272 * amount) + (g * 0.534 * amount) + (b * (1.0 - (0.869 * amount))));
|
||||
|
||||
o_color = color;
|
||||
}
|
||||
10
orx-fx/src/shaders/glsl/color/set-background.frag
Normal file
10
orx-fx/src/shaders/glsl/color/set-background.frag
Normal file
@@ -0,0 +1,10 @@
|
||||
uniform vec4 background;
|
||||
uniform float backgroundOpacity;
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0;
|
||||
|
||||
out vec4 o_color;
|
||||
void main() {
|
||||
vec4 c = texture(tex0, v_texCoord0);
|
||||
o_color = c + (1.0 - c.a) * background * backgroundOpacity;
|
||||
}
|
||||
9
orx-fx/src/shaders/glsl/color/subtract-constant.frag
Normal file
9
orx-fx/src/shaders/glsl/color/subtract-constant.frag
Normal file
@@ -0,0 +1,9 @@
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0;
|
||||
uniform vec4 constant;
|
||||
|
||||
out vec4 o_color;
|
||||
void main() {
|
||||
vec4 c = texture(tex0, v_texCoord0);
|
||||
o_color = max(vec4(0.0), c - constant);
|
||||
}
|
||||
24
orx-fx/src/shaders/glsl/color/ycbcr-to-rgb.frag
Normal file
24
orx-fx/src/shaders/glsl/color/ycbcr-to-rgb.frag
Normal file
@@ -0,0 +1,24 @@
|
||||
uniform vec4 tint;
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0;
|
||||
|
||||
out vec4 o_color;
|
||||
void main() {
|
||||
vec2 ts = textureSize(tex0, 0);
|
||||
vec4 c = texture(tex0, v_texCoord0);
|
||||
|
||||
if (c.a != 0.0) {
|
||||
c.rgb /= c.a;
|
||||
}
|
||||
c.rgb *= 255.0;
|
||||
|
||||
float y = c.r;
|
||||
float cb = c.g;
|
||||
float cr = c.b;
|
||||
|
||||
float r = y + 1.402 * (cr - 128.0);
|
||||
float g = y - 0.344136 * (cb - 128.0) - 0.714136 * (cr - 128.0);
|
||||
float b = y + 1.772 * (cb - 128.0);
|
||||
|
||||
o_color = vec4(r/255.0, g/255.0, b/255.0, 1.0) * c.a;
|
||||
}
|
||||
39
orx-fx/src/shaders/glsl/distort/block-repeat.frag
Normal file
39
orx-fx/src/shaders/glsl/distort/block-repeat.frag
Normal file
@@ -0,0 +1,39 @@
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0;// input
|
||||
uniform float blockWidth;
|
||||
uniform float blockHeight;
|
||||
uniform float blockOffsetX;
|
||||
uniform float blockOffsetY;
|
||||
uniform float sourceOffsetX;
|
||||
uniform float sourceOffsetY;
|
||||
uniform float sourceScale;
|
||||
|
||||
out vec4 o_color;
|
||||
void main() {
|
||||
vec2 uv = v_texCoord0;
|
||||
vec2 blockSize = vec2(blockWidth, blockHeight);
|
||||
vec2 blockOffset = vec2(blockOffsetX, blockOffsetY);
|
||||
vec2 blockCoord = uv / blockSize + blockOffset;
|
||||
|
||||
ivec2 blockIndex = ivec2(blockCoord);
|
||||
vec2 blockUV = mod(blockCoord - blockIndex, vec2(1.0));
|
||||
vec2 blockAspect = vec2(1.0);
|
||||
|
||||
|
||||
if (blockWidth < blockHeight) {
|
||||
blockAspect = vec2(blockWidth / blockHeight, 1.0);
|
||||
}
|
||||
|
||||
if (blockHeight < blockWidth) {
|
||||
blockAspect = vec2(1.0, blockHeight/blockWidth);
|
||||
}
|
||||
|
||||
vec2 tUV = mix(blockUV * blockSize, blockUV * blockAspect, sourceScale);
|
||||
|
||||
// vec2 fw = fwidth(blockCoord);
|
||||
// float f = smoothstep(0.0, 0.01, blockUV.x) * smoothstep(0.0, 0.01, blockUV.y);
|
||||
|
||||
vec2 sourceOffset = vec2(sourceOffsetX, sourceOffsetY);
|
||||
vec4 c = texture(tex0, mod(tUV + sourceOffset, vec2(1.0)));
|
||||
o_color = c;
|
||||
}
|
||||
42
orx-fx/src/shaders/glsl/distort/displace-blend.frag
Normal file
42
orx-fx/src/shaders/glsl/distort/displace-blend.frag
Normal file
@@ -0,0 +1,42 @@
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0;// input
|
||||
uniform sampler2D tex1;// input
|
||||
uniform float offset;
|
||||
uniform float gain;
|
||||
uniform vec2 targetSize;
|
||||
uniform float rotation;
|
||||
uniform float feather;
|
||||
uniform float sourceOpacity;
|
||||
uniform float targetOpacity;
|
||||
out vec4 o_color;
|
||||
void main() {
|
||||
|
||||
|
||||
float phi = radians(rotation);
|
||||
float cp = cos(phi);
|
||||
float sp = sin(phi);
|
||||
mat2 rm = mat2(vec2(cp,sp), vec2(-sp,cp));
|
||||
|
||||
vec4 oa = texture(tex0, v_texCoord0);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
|
||||
float ar = targetSize.y / targetSize.x;
|
||||
|
||||
vec4 nb = b.a > 0? b/b.a : vec4(0.0);
|
||||
|
||||
vec2 offset = (nb.rg - vec2(offset))*vec2(gain) * nb.a;
|
||||
offset = rm * offset * vec2(1.0, ar);
|
||||
|
||||
|
||||
vec2 step = fwidth(v_texCoord0) * feather;
|
||||
|
||||
vec2 displaced = v_texCoord0 + offset;
|
||||
|
||||
float fx = smoothstep(0.0, step.x, displaced.x) * smoothstep(1.0, 1.0-step.x, displaced.x);
|
||||
float fy = smoothstep(0.0, step.y, displaced.y) * smoothstep(1.0, 1.0-step.y, displaced.y);
|
||||
|
||||
vec4 a = texture(tex0, displaced) * mix(1.0, fx * fy, b.a);
|
||||
|
||||
o_color = (a + (1.0-a.a) * oa * sourceOpacity) * b.a * targetOpacity + (1.0-b.a*targetOpacity) * oa * sourceOpacity;
|
||||
|
||||
}
|
||||
43
orx-fx/src/shaders/glsl/distort/fisheye.frag
Normal file
43
orx-fx/src/shaders/glsl/distort/fisheye.frag
Normal file
@@ -0,0 +1,43 @@
|
||||
uniform sampler2D tex0;
|
||||
uniform float strength;
|
||||
uniform float feather;
|
||||
uniform float scale;
|
||||
uniform float rotation;
|
||||
in vec2 v_texCoord0;
|
||||
out vec4 o_color;
|
||||
|
||||
void main() {
|
||||
vec2 uv = v_texCoord0;
|
||||
vec2 ts = textureSize(tex0, 0);
|
||||
vec2 step = 1.0 / ts;
|
||||
|
||||
float phi = radians(rotation);
|
||||
float cp = cos(phi);
|
||||
float sp = sin(phi);
|
||||
mat2 rm = mat2(vec2(cp,sp), vec2(-sp,cp));
|
||||
|
||||
|
||||
float aspectRatio = ts.y / ts.x;
|
||||
step.y /= aspectRatio;
|
||||
step *= feather;
|
||||
|
||||
vec2 intensity = vec2(strength,
|
||||
strength);
|
||||
|
||||
vec2 coords = uv;
|
||||
coords = (coords - 0.5) * 2.0;
|
||||
|
||||
coords = rm * coords;
|
||||
|
||||
vec2 realCoordOffs;
|
||||
realCoordOffs.x = (1.0 - coords.y * coords.y) * intensity.y * (coords.x);
|
||||
realCoordOffs.y = (1.0 - coords.x * coords.x) * intensity.x * (coords.y);
|
||||
|
||||
vec2 fuv = ((uv - realCoordOffs) - vec2(0.5)) * scale + vec2(0.5);
|
||||
|
||||
float fx = smoothstep(0.0, step.x, fuv.x) * smoothstep(1.0, 1.0 - step.x, fuv.x);
|
||||
float fy = smoothstep(0.0, step.y, fuv.y) * smoothstep(1.0, 1.0 - step.y, fuv.y);
|
||||
|
||||
vec4 color = texture(tex0, fuv) * fx * fy;
|
||||
o_color = color;
|
||||
}
|
||||
71
orx-fx/src/shaders/glsl/distort/fluid-distort.frag
Normal file
71
orx-fx/src/shaders/glsl/distort/fluid-distort.frag
Normal file
@@ -0,0 +1,71 @@
|
||||
// created by florian berger (flockaroo) - 2016
|
||||
// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
|
||||
|
||||
// single pass CFD
|
||||
// ---------------
|
||||
// this is some "computational flockarooid dynamics" ;)
|
||||
// the self-advection is done purely rotational on all scales.
|
||||
// therefore i dont need any divergence-free velocity field.
|
||||
// with stochastic sampling i get the proper "mean values" of rotations
|
||||
// over time for higher order scales.
|
||||
//
|
||||
// try changing "RotNum" for different accuracies of rotation calculation
|
||||
// for even RotNum uncomment the line #define SUPPORT_EVEN_ROTNUM
|
||||
|
||||
#define RotNum 5
|
||||
//#define SUPPORT_EVEN_ROTNUM
|
||||
|
||||
//#define keyTex iChannel3
|
||||
//#define KEY_I texture(keyTex,vec2((105.5-32.0)/256.0,(0.5+0.0)/3.0)).x
|
||||
|
||||
const float ang = 2.0*3.1415926535/float(RotNum);
|
||||
mat2 m = mat2(cos(ang), sin(ang), -sin(ang), cos(ang));
|
||||
mat2 mh = mat2(cos(ang*0.5), sin(ang*0.5), -sin(ang*0.5), cos(ang*0.5));
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform float time;
|
||||
uniform float random;
|
||||
|
||||
in vec2 v_texCoord0;
|
||||
uniform vec2 targetSize;
|
||||
|
||||
uniform float blend;
|
||||
|
||||
out vec4 o_color;
|
||||
|
||||
float getRot(vec2 pos, vec2 b) {
|
||||
vec2 Res = textureSize(tex0, 0);
|
||||
vec2 p = b;
|
||||
float rot = 0.0;
|
||||
for (int i = 0; i < RotNum; i++) {
|
||||
rot += dot(texture(tex0, fract((pos + p) / Res.xy)).xy -vec2(0.5), p.yx * vec2(1, -1));
|
||||
p = m * p;
|
||||
}
|
||||
return rot / float(RotNum)/dot(b, b);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 pos = v_texCoord0 * targetSize;
|
||||
vec2 Res = textureSize(tex0, 0);
|
||||
|
||||
vec2 b = vec2(cos(ang * random), sin(ang * random));
|
||||
vec2 v = vec2(0);
|
||||
float bbMax = 0.5 * Res.y;
|
||||
bbMax *= bbMax;
|
||||
for (int l = 0; l < 20; l++) {
|
||||
if (dot(b, b) > bbMax) break;
|
||||
vec2 p = b;
|
||||
for (int i = 0; i < RotNum; i++) {
|
||||
#ifdef SUPPORT_EVEN_ROTNUM
|
||||
v += p.yx * getRot(pos + p, -mh * b);
|
||||
#else
|
||||
// this is faster but works only for odd RotNum
|
||||
v += p.yx * getRot(pos + p, b);
|
||||
#endif
|
||||
p = m*p;
|
||||
}
|
||||
b *= 2.0;
|
||||
}
|
||||
o_color = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
o_color.xy = texture(tex0, fract((pos + v * vec2(-1, 1) * 2.0) / Res.xy)).xy * (1.0-blend) + v_texCoord0 * blend;
|
||||
}
|
||||
30
orx-fx/src/shaders/glsl/distort/horizontal-wave.frag
Normal file
30
orx-fx/src/shaders/glsl/distort/horizontal-wave.frag
Normal file
@@ -0,0 +1,30 @@
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0; // input
|
||||
uniform float phase;
|
||||
uniform float amplitude;
|
||||
uniform float frequency;
|
||||
|
||||
out vec4 o_color;
|
||||
|
||||
uniform int segments;
|
||||
float truncate(float x, int segments) {
|
||||
if (segments == 0) {
|
||||
return x;
|
||||
} else {
|
||||
return floor(x*segments) / segments;
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 uv = v_texCoord0;
|
||||
uv.x += amplitude * cos(truncate(uv.y, segments) * 3.1415926535 * frequency + phase * 3.1415926535);
|
||||
if (uv.x >= 0.0 && uv.x < 1.0) {
|
||||
if (segments == 0) {
|
||||
o_color = texture(tex0, uv);
|
||||
} else {
|
||||
o_color = textureLod(tex0, uv, 0.0);
|
||||
}
|
||||
} else {
|
||||
o_color = vec4(0.0);
|
||||
}
|
||||
}
|
||||
43
orx-fx/src/shaders/glsl/distort/perspective-plane.frag
Normal file
43
orx-fx/src/shaders/glsl/distort/perspective-plane.frag
Normal file
@@ -0,0 +1,43 @@
|
||||
// based on https://www.shadertoy.com/view/wsBSWG by bloxard
|
||||
|
||||
uniform sampler2D tex0;
|
||||
in vec2 v_texCoord0;
|
||||
uniform vec3 cameraPosition;
|
||||
uniform vec3 planePosition;
|
||||
uniform mat4 planeMatrix;
|
||||
uniform bool tile;
|
||||
uniform vec2 targetSize;
|
||||
out vec4 o_color;
|
||||
|
||||
void main() {
|
||||
vec3 vCamPos = cameraPosition;
|
||||
vec3 vPlanePos = planePosition;
|
||||
vec3 vPlaneRight = vec3(1.0, 0.0, 0.0);
|
||||
vec3 vPlaneUp = vec3(0.0, 1.0, 0.0);
|
||||
|
||||
mat3 m = mat3(planeMatrix);
|
||||
vPlaneUp *= m;
|
||||
vPlaneRight *= m;
|
||||
|
||||
vec3 vPlaneNormal = normalize(cross(vPlaneRight, vPlaneUp));
|
||||
float fPlaneDeltaNormalDistance = dot(vPlanePos, vPlaneNormal) - dot(vPlaneNormal, vCamPos);
|
||||
vec4 color = vec4(0.);
|
||||
for (int m = 0; m < 2; m++) {
|
||||
for (int n = 0; n < 2; n++) {
|
||||
vec2 s = (v_texCoord0 - vec2(0.5)) * 2.0;
|
||||
s*= vec2(1.0, targetSize.y / targetSize.x);
|
||||
vec3 vRayDir = normalize(vec3(s, -1.0));
|
||||
float t = fPlaneDeltaNormalDistance / dot(vPlaneNormal, vRayDir);
|
||||
vec3 hitPos = vCamPos + vRayDir * t;
|
||||
vec3 delta = hitPos - vPlanePos;
|
||||
vec2 bary = vec2(dot(delta, vPlaneRight), dot(delta, vPlaneUp));
|
||||
|
||||
bary /= vec2(1.0, targetSize.y / targetSize.x);
|
||||
bary += vec2(0.5);
|
||||
if ((tile || (bary.x >= 0.0 && bary.x <= 1.0 && bary.y >=0.0 && bary.y <= 1.0)) && t > 0.0) {
|
||||
color += texture(tex0, bary);
|
||||
}
|
||||
}
|
||||
}
|
||||
o_color = color * 0.25;
|
||||
}
|
||||
174
orx-fx/src/shaders/glsl/distort/perturb.frag
Normal file
174
orx-fx/src/shaders/glsl/distort/perturb.frag
Normal file
@@ -0,0 +1,174 @@
|
||||
// uniforms
|
||||
uniform float gain;
|
||||
uniform vec3 seed;
|
||||
uniform float phase;
|
||||
uniform float scale;
|
||||
|
||||
uniform float lacunarity;
|
||||
uniform float decay;
|
||||
|
||||
uniform int octaves;
|
||||
uniform sampler2D tex0;
|
||||
|
||||
uniform int xSegments;
|
||||
uniform int ySegments;
|
||||
|
||||
uniform bool outputUV;
|
||||
uniform vec2 offset;
|
||||
|
||||
// varyings
|
||||
in vec2 v_texCoord0;
|
||||
|
||||
// outputs
|
||||
out vec4 o_output;
|
||||
|
||||
// Simplex Noise 3D Implementation
|
||||
// Description : Array and textureless GLSL 2D/3D/4D simplex
|
||||
// noise functions.
|
||||
// Author : Ian McEwan, Ashima Arts.
|
||||
// Maintainer : ijm
|
||||
// Lastmod : 20110822 (ijm)
|
||||
// License : Copyright (C) 2011 Ashima Arts. All rights reserved.
|
||||
// Distributed under the MIT License. See LICENSE file.
|
||||
// https://github.com/ashima/webgl-noise
|
||||
// https://github.com/stegu/webgl-noise
|
||||
//
|
||||
//
|
||||
vec3 mod289(vec3 x) {
|
||||
return x - floor(x * (1.0 / 289.0)) * 289.0;
|
||||
}
|
||||
|
||||
vec4 mod289(vec4 x) {
|
||||
return x - floor(x * (1.0 / 289.0)) * 289.0;
|
||||
}
|
||||
|
||||
vec4 permute(vec4 x) {
|
||||
return mod289(((x*34.0)+1.0)*x);
|
||||
}
|
||||
|
||||
vec4 taylorInvSqrt(vec4 r)
|
||||
{
|
||||
return 1.79284291400159 - 0.85373472095314 * r;
|
||||
}
|
||||
|
||||
float snoise(vec3 v)
|
||||
{
|
||||
const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
|
||||
const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
|
||||
|
||||
// First corner
|
||||
vec3 i = floor(v + dot(v, C.yyy) );
|
||||
vec3 x0 = v - i + dot(i, C.xxx) ;
|
||||
|
||||
// Other corners
|
||||
vec3 g = step(x0.yzx, x0.xyz);
|
||||
vec3 l = 1.0 - g;
|
||||
vec3 i1 = min( g.xyz, l.zxy );
|
||||
vec3 i2 = max( g.xyz, l.zxy );
|
||||
|
||||
// x0 = x0 - 0.0 + 0.0 * C.xxx;
|
||||
// x1 = x0 - i1 + 1.0 * C.xxx;
|
||||
// x2 = x0 - i2 + 2.0 * C.xxx;
|
||||
// x3 = x0 - 1.0 + 3.0 * C.xxx;
|
||||
vec3 x1 = x0 - i1 + C.xxx;
|
||||
vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y
|
||||
vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y
|
||||
|
||||
// Permutations
|
||||
i = mod289(i);
|
||||
vec4 p = permute( permute( permute(
|
||||
i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
|
||||
+ i.y + vec4(0.0, i1.y, i2.y, 1.0 ))
|
||||
+ i.x + vec4(0.0, i1.x, i2.x, 1.0 ));
|
||||
|
||||
// Gradients: 7x7 points over a square, mapped onto an octahedron.
|
||||
// The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)
|
||||
float n_ = 0.142857142857; // 1.0/7.0
|
||||
vec3 ns = n_ * D.wyz - D.xzx;
|
||||
|
||||
vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7)
|
||||
|
||||
vec4 x_ = floor(j * ns.z);
|
||||
vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)
|
||||
|
||||
vec4 x = x_ *ns.x + ns.yyyy;
|
||||
vec4 y = y_ *ns.x + ns.yyyy;
|
||||
vec4 h = 1.0 - abs(x) - abs(y);
|
||||
|
||||
vec4 b0 = vec4( x.xy, y.xy );
|
||||
vec4 b1 = vec4( x.zw, y.zw );
|
||||
|
||||
//vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0;
|
||||
//vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0;
|
||||
vec4 s0 = floor(b0)*2.0 + 1.0;
|
||||
vec4 s1 = floor(b1)*2.0 + 1.0;
|
||||
vec4 sh = -step(h, vec4(0.0));
|
||||
|
||||
vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;
|
||||
vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;
|
||||
|
||||
vec3 p0 = vec3(a0.xy,h.x);
|
||||
vec3 p1 = vec3(a0.zw,h.y);
|
||||
vec3 p2 = vec3(a1.xy,h.z);
|
||||
vec3 p3 = vec3(a1.zw,h.w);
|
||||
|
||||
//Normalise gradients
|
||||
vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
|
||||
p0 *= norm.x;
|
||||
p1 *= norm.y;
|
||||
p2 *= norm.z;
|
||||
p3 *= norm.w;
|
||||
|
||||
// Mix final noise value
|
||||
vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
|
||||
m = m * m;
|
||||
return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
|
||||
dot(p2,x2), dot(p3,x3) ) );
|
||||
}
|
||||
|
||||
vec3 segment(vec3 t, int x, int y) {
|
||||
|
||||
float sx = x == 0? t.x : floor(t.x * x) / x;
|
||||
float sy = y == 0? t.y : floor(t.y * y) / y;
|
||||
|
||||
return vec3(sx,sy, t.z);
|
||||
}
|
||||
|
||||
void main() {
|
||||
float tx = 0.0;
|
||||
float ty = 0.0;
|
||||
|
||||
float _gain = gain;
|
||||
float shift = 100.0;
|
||||
|
||||
vec3 xseed = vec3(seed.xy, seed.z+cos(phase*3.1415926535));
|
||||
vec3 yseed = vec3(seed.yx, seed.z+sin(phase*3.1415926535));
|
||||
|
||||
vec3 uv = vec3(v_texCoord0 + offset, 1.0) * 2.0 - 1.0;
|
||||
vec3 px = ((segment(uv, xSegments, ySegments) + xseed) * scale);
|
||||
vec3 py = ((segment(uv, xSegments, ySegments) + yseed + vec3(100.37, 40.51, 9.43)) * scale);
|
||||
|
||||
for (int o = 0; o < octaves; ++o) {
|
||||
tx += snoise(px) * _gain;
|
||||
ty += snoise(py) * _gain;
|
||||
px = px * lacunarity + shift;
|
||||
py = py * lacunarity + shift;
|
||||
_gain *= decay;
|
||||
}
|
||||
|
||||
vec2 distCoord = v_texCoord0 + vec2(tx, ty);
|
||||
|
||||
if (!outputUV) {
|
||||
if (distCoord.x >= 0.0 && distCoord.y >= 0.0 && distCoord.x < 1.0 && distCoord.y < 1.0) {
|
||||
if (xSegments == 0 && ySegments == 0) {
|
||||
o_output = texture(tex0, distCoord);
|
||||
} else {
|
||||
o_output = textureLod(tex0, distCoord, 0.0);
|
||||
}
|
||||
} else {
|
||||
o_output = vec4(0.0);
|
||||
}
|
||||
} else {
|
||||
o_output = vec4(distCoord, 0.0, 1.0);
|
||||
}
|
||||
}
|
||||
40
orx-fx/src/shaders/glsl/distort/stack-repeat.frag
Normal file
40
orx-fx/src/shaders/glsl/distort/stack-repeat.frag
Normal file
@@ -0,0 +1,40 @@
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0;// input
|
||||
uniform int repeats;
|
||||
uniform float zoom;
|
||||
uniform float xOrigin;
|
||||
uniform float yOrigin;
|
||||
uniform float xOffset;
|
||||
uniform float yOffset;
|
||||
uniform float rotation;
|
||||
|
||||
out vec4 o_color;
|
||||
void main() {
|
||||
vec2 origin = vec2((xOrigin+1.0)/2.0, (yOrigin+1.0)/2.0);
|
||||
vec2 ts = textureSize(tex0, 0);
|
||||
float r = ts.x/ts.y;
|
||||
vec2 offset = vec2(1.0, r) * vec2(xOffset, yOffset);
|
||||
vec2 uv = v_texCoord0 - vec2(origin);
|
||||
float rad = (rotation/180) * 3.1415926535;
|
||||
vec2 cs0 = vec2(cos(rad), -sin(rad));
|
||||
vec2 cs1 = vec2(sin(rad), cos(rad));
|
||||
mat2 rotStep = mat2(cs0, cs1);
|
||||
|
||||
mat2 rot = rotStep;
|
||||
vec4 c = texture(tex0, v_texCoord0);
|
||||
for (int i = 1; i <= repeats; ++i) {
|
||||
//vec2 s = (uv * (1.0 + zoom) * i) + vec2(0.5);
|
||||
vec2 s = (rot * uv * pow(1.0 + zoom,i*1.0) )+ vec2(origin) + vec2(offset) * i;
|
||||
float f = s.x >= 0.0 && s.y > 0.0 && s.x < 1.0 && s.y < 1.0? 1.0 : 0.0;
|
||||
vec4 sc = texture(tex0, s) * f;
|
||||
|
||||
c = c * (1.0-sc.a) + sc;
|
||||
if (c.a > 1.0) {
|
||||
c.a = 1.0;
|
||||
}
|
||||
rot *= rotStep;
|
||||
}
|
||||
|
||||
|
||||
o_color = c;
|
||||
}
|
||||
40
orx-fx/src/shaders/glsl/distort/stretch-waves.frag
Normal file
40
orx-fx/src/shaders/glsl/distort/stretch-waves.frag
Normal file
@@ -0,0 +1,40 @@
|
||||
uniform sampler2D tex0;
|
||||
in vec2 v_texCoord0;
|
||||
|
||||
uniform float phase;
|
||||
uniform float rotation;
|
||||
uniform float distortion;
|
||||
uniform float frequency;
|
||||
uniform float feather;
|
||||
out vec4 o_color;
|
||||
|
||||
void main() {
|
||||
float phi = radians(rotation);
|
||||
float cp = cos(phi);
|
||||
float sp = sin(phi);
|
||||
mat2 rm = mat2(vec2(cp, sp), vec2(-sp, cp));
|
||||
mat2 irm = transpose(rm);
|
||||
|
||||
float tw = 1.0 / frequency;
|
||||
vec2 uv = rm * (v_texCoord0 - vec2(0.5)) + vec2(0.5) + vec2(phase * tw, 0.0);
|
||||
|
||||
float xd = (uv.x) * frequency;
|
||||
float xo = (fract(xd) - 0.5) * 2.0;
|
||||
float xf = fract(xd);
|
||||
|
||||
float offs = (1.0- xo * xo) * 1.0 * xo * distortion * 0.5;
|
||||
float f = mix(1.0, (1.0 - xo * xo), distortion);
|
||||
|
||||
vec2 fuv = uv;
|
||||
fuv.x = floor(uv.x * frequency) / frequency;
|
||||
fuv.x += (xf - offs) * tw;
|
||||
|
||||
fuv = irm * (fuv - vec2(0.5) - vec2(phase * tw, 0.0)) + vec2(0.5);
|
||||
|
||||
vec2 step = fwidth(fuv) * feather;
|
||||
float fx = smoothstep(0.0, step.x, fuv.x) * smoothstep(1.0, 1.0 - step.x, fuv.x);
|
||||
float fy = smoothstep(0.0, step.y, fuv.y) * smoothstep(1.0, 1.0 - step.y, fuv.y);
|
||||
|
||||
vec4 c = texture(tex0, fuv) * f * fx * fy;
|
||||
o_color = c;
|
||||
}
|
||||
64
orx-fx/src/shaders/glsl/distort/tape-noise.frag
Normal file
64
orx-fx/src/shaders/glsl/distort/tape-noise.frag
Normal file
@@ -0,0 +1,64 @@
|
||||
out vec4 o_output;
|
||||
uniform sampler2D tex0;
|
||||
in vec2 v_texCoord0;
|
||||
uniform float time;
|
||||
|
||||
uniform float gain;
|
||||
uniform float noiseLow;
|
||||
uniform float noiseHigh;
|
||||
uniform vec4 tint;
|
||||
uniform bool monochrome;
|
||||
uniform float deformAmplitude;
|
||||
uniform float deformFrequency;
|
||||
uniform float gapFrequency;
|
||||
uniform float gapLow;
|
||||
uniform float gapHigh;
|
||||
|
||||
#define HASHSCALE 443.8975
|
||||
vec2 hash22(vec2 p) {
|
||||
vec3 p3 = fract(vec3(p.xyx) * HASHSCALE);
|
||||
p3 += dot(p3, p3.yzx+19.19);
|
||||
return fract(vec2((p3.x + p3.y)*p3.z, (p3.x+p3.z)*p3.y));
|
||||
}
|
||||
|
||||
vec3 saturate(vec3 x) {
|
||||
return clamp(x, vec3(0.0), vec3(1.0));
|
||||
}
|
||||
|
||||
vec3 aberrationColor(float f) {
|
||||
f = f * 3.0 - 1.5;
|
||||
return saturate(vec3(-f, 1.0 - abs(f), f));
|
||||
}
|
||||
|
||||
void main() {
|
||||
float dk = 1.0/600.0;
|
||||
o_output = vec4(0.0);
|
||||
for (int k = 0; k < 10; ++k ) {
|
||||
vec2 duv = v_texCoord0;
|
||||
duv.y += smoothstep(pow(cos(time+k*dk+v_texCoord0.y*1.0),10.0)*0.1+0.1, 0.0, v_texCoord0.x)*deformAmplitude * cos((time+k*dk)*deformFrequency);
|
||||
duv.y += smoothstep(pow(1.0-cos(time+k*dk+v_texCoord0.y*1.0),10.0)*0.1+0.1, 0.9, v_texCoord0.x)*deformAmplitude * cos((time+k*dk)*deformFrequency);
|
||||
duv.y += sin(v_texCoord0.x*3.1415926535)*0.0;
|
||||
float bc = floor(hash22(vec2(time+k*dk, (time+k*dk)*0.1)).x*20.0);
|
||||
|
||||
float gb3 = floor(duv.y*bc)/bc;
|
||||
|
||||
vec2 v = hash22(duv.xy*0.003+time+k*dk);
|
||||
vec2 v2 = hash22(duv.xy*0.03+time+k*dk);
|
||||
vec2 v2b = hash22(duv.yx*0.03+time+k*dk);
|
||||
float stretch = (cos(time+k*dk)*0.001+0.002)*0.3+0.001;
|
||||
vec2 h = hash22(duv.yy*stretch+time+k*dk);
|
||||
float gap = smoothstep(gapLow, gapHigh, cos(gb3*(gapFrequency+duv.y*gapFrequency + (time+k*dk)*gapFrequency) +duv.x*gapFrequency)) * (cos(gb3)*0.5+0.5);
|
||||
|
||||
float r = smoothstep(noiseLow, noiseHigh, h.x*gap*v2.x)*1.0;
|
||||
float g = smoothstep(noiseLow, noiseHigh, h.x*gap*v2.y)*1.0;
|
||||
float b = smoothstep(noiseLow, noiseHigh, h.x*gap*v2b.x)*1.0;
|
||||
float a = smoothstep(noiseLow, noiseHigh, h.x*gap*v2b.y)*1.0;
|
||||
if (!monochrome) {
|
||||
o_output += vec4(r, g, b, a)*gain * tint;
|
||||
} else {
|
||||
o_output += vec4(r, r, r, a)*gain * tint;
|
||||
}
|
||||
}
|
||||
o_output *= o_output.a;
|
||||
o_output += texture(tex0, v_texCoord0);
|
||||
}
|
||||
35
orx-fx/src/shaders/glsl/distort/tiles.frag
Normal file
35
orx-fx/src/shaders/glsl/distort/tiles.frag
Normal file
@@ -0,0 +1,35 @@
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0; // input
|
||||
uniform float rotation;
|
||||
uniform int xSegments;
|
||||
uniform int ySegments;
|
||||
|
||||
out vec4 o_color;
|
||||
|
||||
uniform int segments;
|
||||
float truncate(float x, int segments) {
|
||||
if (segments == 0) {
|
||||
return x;
|
||||
} else {
|
||||
return floor(x*segments) / segments;
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 uv = v_texCoord0 - vec2(0.5);
|
||||
float cr = cos(radians(rotation));
|
||||
float sr = sin(radians(rotation));
|
||||
|
||||
mat2 rm = mat2(cr, -sr, sr, cr);
|
||||
|
||||
vec2 ruv = rm * uv;
|
||||
vec2 truv = vec2( truncate(ruv.x, xSegments), truncate(ruv.y, ySegments));
|
||||
vec2 tuv = transpose(rm) * truv + vec2(0.5);
|
||||
|
||||
vec4 c = vec4(0.0);
|
||||
tuv.x = clamp(tuv.x, 0.0, 1.0);
|
||||
tuv.y = clamp(tuv.y, 0.0, 1.0);
|
||||
c = texture(tex0, tuv);
|
||||
|
||||
o_color = c * texture(tex0, v_texCoord0).a;
|
||||
}
|
||||
9
orx-fx/src/shaders/glsl/distort/uvmap.frag
Normal file
9
orx-fx/src/shaders/glsl/distort/uvmap.frag
Normal file
@@ -0,0 +1,9 @@
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0;// uvmap
|
||||
uniform sampler2D tex1;// input
|
||||
out vec4 o_color;
|
||||
|
||||
void main() {
|
||||
vec2 uv = texture(tex0, v_texCoord0).xy;
|
||||
o_color = texture(tex1, uv);
|
||||
}
|
||||
30
orx-fx/src/shaders/glsl/distort/vertical-wave.frag
Normal file
30
orx-fx/src/shaders/glsl/distort/vertical-wave.frag
Normal file
@@ -0,0 +1,30 @@
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0; // input
|
||||
uniform float phase;
|
||||
uniform float amplitude;
|
||||
uniform float frequency;
|
||||
|
||||
out vec4 o_color;
|
||||
|
||||
uniform int segments;
|
||||
float truncate(float x, int segments) {
|
||||
if (segments == 0) {
|
||||
return x;
|
||||
} else {
|
||||
return floor(x*segments) / segments;
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 uv = v_texCoord0;
|
||||
uv.y += amplitude * sin(truncate(uv.x, segments) * 3.1415926535 * frequency + phase * 3.1415926535);
|
||||
if (uv.y >= 0.0 && uv.y < 1.0) {
|
||||
if (segments == 0) {
|
||||
o_color = texture(tex0, uv);
|
||||
} else {
|
||||
o_color = textureLod(tex0, uv, 0.0);
|
||||
}
|
||||
} else {
|
||||
o_color = vec4(0.0);
|
||||
}
|
||||
}
|
||||
68
orx-fx/src/shaders/glsl/distort/video-glitch.frag
Normal file
68
orx-fx/src/shaders/glsl/distort/video-glitch.frag
Normal file
@@ -0,0 +1,68 @@
|
||||
out vec4 o_output;
|
||||
uniform sampler2D tex0;
|
||||
in vec2 v_texCoord0;
|
||||
uniform float time;
|
||||
uniform float amplitude;
|
||||
uniform float vfreq;
|
||||
uniform float pfreq;
|
||||
uniform float hfreq;
|
||||
uniform float poffset;
|
||||
uniform float scrollOffset0;
|
||||
uniform float scrollOffset1;
|
||||
|
||||
uniform float borderHeight;
|
||||
|
||||
uniform bool linearInput;
|
||||
uniform bool linearOutput;
|
||||
|
||||
#define HASHSCALE 443.8975
|
||||
vec2 hash22(vec2 p) {
|
||||
vec3 p3 = fract(vec3(p.xyx) * HASHSCALE);
|
||||
p3 += dot(p3, p3.yzx+19.19);
|
||||
return fract(vec2((p3.x + p3.y)*p3.z, (p3.x+p3.z)*p3.y));
|
||||
}
|
||||
|
||||
vec3 saturate(vec3 x) {
|
||||
return clamp(x, vec3(0.0), vec3(1.0));
|
||||
}
|
||||
|
||||
vec4 getVideo(vec2 uv, float amplitude, float seconds) {
|
||||
float iTime = seconds;
|
||||
vec2 look = mod(uv, vec2(1.0));
|
||||
float window = 1.0/(1.0 + 20.0*(look.y-mod(iTime*vfreq, 1.0))*(look.y-mod(iTime*vfreq, 1.)));
|
||||
look.x = look.x + sin(look.y*pfreq + poffset * 3.1415)/50 *(1.+cos(iTime*hfreq))*window*amplitude;
|
||||
look.y = mod(look.y, 1.);
|
||||
|
||||
vec4 video = texture(tex0, look);
|
||||
return video;
|
||||
}
|
||||
|
||||
vec4 aberrationColor(float f) {
|
||||
f = f * 3.0 - 1.5;
|
||||
return vec4(saturate(vec3(-f, 1.0 - abs(f), f)), 1.0);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 c = vec4(0.0);
|
||||
float aa = amplitude + smoothstep(borderHeight, 0.0, v_texCoord0.y)*4.0 + smoothstep(1.0-borderHeight, 1.0, v_texCoord0.y)*4.0;
|
||||
float ds = scrollOffset1 - scrollOffset0;
|
||||
if (aa > 0.0 || ds > 0.0) {
|
||||
for (int i = 1; i < 16; ++i) {
|
||||
vec4 lc = getVideo(v_texCoord0 + vec2(0.0, scrollOffset0+ds*i), aa, time-i/(16*60.0));
|
||||
if (!linearInput) {
|
||||
lc.rgb = pow(lc.rgb, vec3(2.2));
|
||||
}
|
||||
c += lc * (3.0/16.0) * aberrationColor(i/16.0);
|
||||
}
|
||||
o_output = c;
|
||||
} else {
|
||||
vec4 lc = texture(tex0, mod(v_texCoord0 + vec2(0.0, scrollOffset1), vec2(1.0)));
|
||||
if (!linearInput) {
|
||||
lc.rgb = pow(lc.rgb, vec3(2.2));
|
||||
}
|
||||
o_output = lc;
|
||||
}
|
||||
if (!linearOutput) {
|
||||
o_output.rgb = pow(o_output.rgb, vec3(1/2.2));
|
||||
}
|
||||
}
|
||||
49
orx-fx/src/shaders/glsl/dither/a-dither.frag
Normal file
49
orx-fx/src/shaders/glsl/dither/a-dither.frag
Normal file
@@ -0,0 +1,49 @@
|
||||
// this shader is based on the "a dither" work by Øyvind Kolås
|
||||
// https://pippin.gimp.org/a_dither/
|
||||
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0;
|
||||
uniform int pattern;
|
||||
uniform int levels;
|
||||
|
||||
float mask1(int levels, float l, int x, int y, int c) {
|
||||
float mask = ((x ^ y * 149) * 1234& 511)/511.0;
|
||||
return floor(levels * l + mask)/levels;
|
||||
}
|
||||
|
||||
float mask2(int levels, float l, int x, int y, int c) {
|
||||
float mask = (((x+c*17) ^ y * 149) * 1234 & 511)/511.0;
|
||||
return floor(levels * l + mask)/levels;
|
||||
}
|
||||
float mask3(int levels, float l, int x, int y, int c) {
|
||||
float mask = ((x + y * 237) * 119 & 255)/255.0;
|
||||
return floor(levels * l + mask)/levels;
|
||||
}
|
||||
|
||||
float mask4(int levels, float l, int x, int y, int c) {
|
||||
float mask = (((x+c*67) + y * 236) * 119 & 255)/255.0;
|
||||
return floor(levels * l + mask)/levels;
|
||||
}
|
||||
|
||||
out vec4 o_color;
|
||||
void main() {
|
||||
vec4 c = texture(tex0, v_texCoord0);
|
||||
if (c.a > 0.0) {
|
||||
c.rgb/=c.a;
|
||||
}
|
||||
ivec2 ic = ivec2(v_texCoord0 * textureSize(tex0, 0));
|
||||
|
||||
vec4 rgba = vec4(0.0);
|
||||
if (pattern == 0) {
|
||||
rgba = vec4(mask1(levels, c.r, ic.x, ic.y, 0), mask1(levels, c.g, ic.x, ic.y, 1), mask1(levels, c.b, ic.x, ic.y, 2), mask1(levels, c.a, ic.x, ic.y, 3));
|
||||
} else if (pattern == 1) {
|
||||
rgba = vec4(mask2(levels, c.r, ic.x, ic.y, 0), mask2(levels, c.g, ic.x, ic.y, 1), mask2(levels, c.b, ic.x, ic.y, 2), mask2(levels, c.a, ic.x, ic.y, 3));
|
||||
} else if (pattern == 2) {
|
||||
rgba = vec4(mask3(levels, c.r, ic.x, ic.y, 0), mask3(levels, c.g, ic.x, ic.y, 1), mask3(levels, c.b, ic.x, ic.y, 2), mask3(levels, c.a, ic.x, ic.y, 3));
|
||||
} else {
|
||||
rgba = vec4(mask4(levels, c.r, ic.x, ic.y, 0), mask4(levels, c.g, ic.x, ic.y, 1), mask4(levels, c.b, ic.x, ic.y, 2), mask4(levels, c.a, ic.x, ic.y, 3));
|
||||
}
|
||||
|
||||
rgba.rgb *= rgba.a;
|
||||
o_color = rgba;
|
||||
}
|
||||
98
orx-fx/src/shaders/glsl/dither/cmyk-halftone.frag
Normal file
98
orx-fx/src/shaders/glsl/dither/cmyk-halftone.frag
Normal file
@@ -0,0 +1,98 @@
|
||||
/* Based on CMYK Halftone by tsone https://www.shadertoy.com/view/Mdf3Dn */
|
||||
uniform float dotSize;
|
||||
|
||||
#define SST 0.888
|
||||
#define SSQ 0.288
|
||||
|
||||
uniform float scale;
|
||||
uniform float rotation;
|
||||
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0;
|
||||
|
||||
out vec4 o_color;
|
||||
|
||||
vec4 rgb2cmyki(in vec3 c)
|
||||
{
|
||||
float k = max(max(c.r, c.g), c.b);
|
||||
return min(vec4(c.rgb / k, k), 1.0);
|
||||
}
|
||||
|
||||
vec3 cmyki2rgb(in vec4 c)
|
||||
{
|
||||
return c.rgb * c.a;
|
||||
}
|
||||
vec3 u(vec4 c) {
|
||||
if (c.a == 0) {
|
||||
return vec3(0.0);
|
||||
} else {
|
||||
return c.rgb/c.a;
|
||||
}
|
||||
|
||||
}
|
||||
vec4 cmyki2rgba(in vec4 cmyk){
|
||||
vec4 c = vec4(0.0, 1.0, 1.0, 1.0)*(1.0-cmyk.r);
|
||||
vec4 m = vec4(1.0, 0.0, 1.0, 1.0)*(1.0-cmyk.g);
|
||||
vec4 y = vec4(1.0, 1.0, 0.0, 1.0)*(1.0-cmyk.b);
|
||||
vec4 k = vec4(0.0, 0.0, 0.0, 1.0)*(1.0-cmyk.a);
|
||||
|
||||
vec4 f = c;
|
||||
f = (1.0-f.a) * m + f.a * vec4(u(f)*u(m),1.0) * m.a + (1.0-m.a) * f;
|
||||
f = (1.0-f.a) * y + f.a * vec4(u(f)*u(y),1.0) * y.a + (1.0-y.a) * f;
|
||||
f = (1.0-f.a) * k + f.a * vec4(u(f)*u(k),1.0) * k.a + (1.0-k.a) * f;
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
vec2 px2uv(in vec2 px)
|
||||
{
|
||||
return vec2(px / textureSize(tex0, 0));
|
||||
}
|
||||
|
||||
vec2 grid(in vec2 px)
|
||||
{
|
||||
return px - mod(px, scale);
|
||||
}
|
||||
|
||||
vec4 ss(in vec4 v)
|
||||
{
|
||||
return smoothstep(vec4(SST-SSQ), vec4(SST+SSQ), v);
|
||||
}
|
||||
|
||||
vec4 halftone(in vec2 fc,in mat2 m)
|
||||
{
|
||||
vec2 smp = (grid(m*fc) + 0.5*scale) * m;
|
||||
float s = min(length(fc-smp) / (dotSize*0.5*scale), 1.0);
|
||||
vec3 texc = texture(tex0, px2uv(smp+textureSize(tex0, 0)/2.0)).rgb;
|
||||
vec4 c = rgb2cmyki(texc);
|
||||
return c+s;
|
||||
}
|
||||
|
||||
mat2 rotm(in float r)
|
||||
{
|
||||
float cr = cos(r);
|
||||
float sr = sin(r);
|
||||
return mat2(
|
||||
cr,-sr,
|
||||
sr,cr
|
||||
);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 fc = v_texCoord0 * textureSize(tex0, 0) - textureSize(tex0, 0)/2.0;
|
||||
|
||||
mat2 mc = rotm(rotation + radians(15.0));
|
||||
mat2 mm = rotm(rotation + radians(75.0));
|
||||
mat2 my = rotm(rotation);
|
||||
mat2 mk = rotm(rotation + radians(45.0));
|
||||
|
||||
float k = halftone(fc, mk).a;
|
||||
vec4 c = cmyki2rgba(ss(vec4(
|
||||
halftone(fc, mc).r,
|
||||
halftone(fc, mm).g,
|
||||
halftone(fc, my).b,
|
||||
halftone(fc, mk).a
|
||||
)));
|
||||
|
||||
o_color = c;
|
||||
}
|
||||
53
orx-fx/src/shaders/glsl/dither/crosshatch.frag
Normal file
53
orx-fx/src/shaders/glsl/dither/crosshatch.frag
Normal file
@@ -0,0 +1,53 @@
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0;
|
||||
out vec4 o_color;
|
||||
|
||||
// thresholds
|
||||
uniform float t1;
|
||||
uniform float t2;
|
||||
uniform float t3;
|
||||
uniform float t4;
|
||||
|
||||
|
||||
// glsl-luma
|
||||
float luma(vec3 color) {
|
||||
return dot(color, vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
float luma(vec4 color) {
|
||||
return dot(color.rgb, vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
// glsl-crosshatch
|
||||
vec3 crosshatch(vec3 texColor, float t1, float t2, float t3, float t4) {
|
||||
float lum = luma(texColor);
|
||||
vec3 color = vec3(1.0);
|
||||
if (lum < t1) {
|
||||
if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) {
|
||||
color = vec3(0.0);
|
||||
}
|
||||
}
|
||||
if (lum < t2) {
|
||||
if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) {
|
||||
color = vec3(0.0);
|
||||
}
|
||||
}
|
||||
if (lum < t3) {
|
||||
if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) {
|
||||
color = vec3(0.0);
|
||||
}
|
||||
}
|
||||
if (lum < t4) {
|
||||
if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) {
|
||||
color = vec3(0.0);
|
||||
}
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
void main() {
|
||||
vec4 color = texture(tex0, v_texCoord0);
|
||||
vec3 demultiplied = color.a == 0.0 ? vec3(0.0) : color.rgb/color.a;
|
||||
o_color = vec4(crosshatch(demultiplied, t1, t2, t3, t4), 1.0) * color.a;
|
||||
}
|
||||
26
orx-fx/src/shaders/glsl/edges/contour.frag
Normal file
26
orx-fx/src/shaders/glsl/edges/contour.frag
Normal file
@@ -0,0 +1,26 @@
|
||||
uniform sampler2D tex0;
|
||||
in vec2 v_texCoord0;
|
||||
out vec4 o_output;
|
||||
uniform float levels;
|
||||
uniform float contourWidth;
|
||||
uniform float contourOpacity;
|
||||
uniform vec4 contourColor;
|
||||
uniform float backgroundOpacity;
|
||||
|
||||
void main() {
|
||||
vec2 step = 1.0 / textureSize(tex0, 0);
|
||||
vec4 box = vec4(0.0);
|
||||
for (int j = -1; j <=1; ++j) {
|
||||
for (int i = -1; i <= 1; ++i) {
|
||||
box += texture(tex0, v_texCoord0 + step * vec2(i, j));
|
||||
}
|
||||
}
|
||||
box /= 9.0;
|
||||
float v = sin(3.1415926535 * levels * dot(vec3(1.0/3.0),box.xyz));
|
||||
float level = floor(dot(vec3(1.0/3.0),box.xyz) * levels) / levels;
|
||||
//int plateauIndex = min(levels-1, int(level * levels));
|
||||
float contour = 1.0 - smoothstep(0., contourWidth, 0.5 * abs(v) / fwidth(v));
|
||||
|
||||
vec4 t = texture(tex0, v_texCoord0);
|
||||
o_output = t * backgroundOpacity * (1.0-contour) + contour * contourColor * contourOpacity * t.a;
|
||||
}
|
||||
37
orx-fx/src/shaders/glsl/edges/edges-work-1.frag
Normal file
37
orx-fx/src/shaders/glsl/edges/edges-work-1.frag
Normal file
@@ -0,0 +1,37 @@
|
||||
uniform sampler2D tex0;
|
||||
in vec2 v_texCoord0;
|
||||
out vec4 o_color;
|
||||
|
||||
uniform vec2 delta;
|
||||
|
||||
float random(vec3 scale, float seed) {
|
||||
/* use the fragment position for a different seed per-pixel */
|
||||
return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);
|
||||
}
|
||||
|
||||
// Implementation by Evan Wallace (glfx.js)
|
||||
void main() {
|
||||
vec4 center = texture(tex0, v_texCoord0);
|
||||
vec2 color = vec2(0.0);
|
||||
vec2 total = vec2(0.0);
|
||||
|
||||
/* randomize the lookup values to hide the fixed number of samples */
|
||||
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
|
||||
|
||||
for (float t = -30.0; t <= 30.0; t++) {
|
||||
float percent = (t + offset - 0.5) / 30.0;
|
||||
float weight = 1.0 - abs(percent);
|
||||
vec3 tex = texture(tex0, v_texCoord0 + delta * percent).rgb;
|
||||
float average = (tex.r + tex.g + tex.b) / 3.0;
|
||||
color.x += average * weight;
|
||||
total.x += weight;
|
||||
|
||||
if (abs(t) < 15.0) {
|
||||
weight = weight * 2.0 - 1.0;
|
||||
color.y += average * weight;
|
||||
total.y += weight;
|
||||
}
|
||||
}
|
||||
|
||||
o_color = vec4(color / total, 0.0, 1.0) * center.a;
|
||||
}
|
||||
38
orx-fx/src/shaders/glsl/edges/edges-work-2.frag
Normal file
38
orx-fx/src/shaders/glsl/edges/edges-work-2.frag
Normal file
@@ -0,0 +1,38 @@
|
||||
uniform sampler2D tex0;
|
||||
in vec2 v_texCoord0;
|
||||
out vec4 o_color;
|
||||
|
||||
uniform vec2 delta;
|
||||
uniform int radius;
|
||||
|
||||
float random(vec3 scale, float seed) {
|
||||
/* use the fragment position for a different seed per-pixel */
|
||||
return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);
|
||||
}
|
||||
|
||||
// Implementation by Evan Wallace (glfx.js)
|
||||
void main() {
|
||||
vec4 center = texture(tex0, v_texCoord0);
|
||||
vec2 color = vec2(0.0);
|
||||
vec2 total = vec2(0.0);
|
||||
|
||||
/* randomize the lookup values to hide the fixed number of samples */
|
||||
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
|
||||
|
||||
for (float t = -30.0; t <= 30.0; t++) {
|
||||
float percent = (t + offset - 0.5) / 30.0;
|
||||
float weight = 1.0 - abs(percent);
|
||||
vec2 tex = texture(tex0, v_texCoord0 + delta * percent).xy;
|
||||
color.x += tex.x * weight;
|
||||
total.x += weight;
|
||||
|
||||
if (abs(t) < 15.0) {
|
||||
weight = weight * 2.0 - 1.0;
|
||||
color.y += tex.y * weight;
|
||||
total.y += weight;
|
||||
}
|
||||
}
|
||||
float c = clamp(10000.0 * (color.y / total.y - color.x / total.x) + 0.5, 0.0, 1.0);
|
||||
|
||||
o_color = vec4(c, c, c, 1.0) * center.a;
|
||||
}
|
||||
47
orx-fx/src/shaders/glsl/edges/luma-sobel.frag
Normal file
47
orx-fx/src/shaders/glsl/edges/luma-sobel.frag
Normal file
@@ -0,0 +1,47 @@
|
||||
in vec2 v_texCoord0;
|
||||
|
||||
uniform sampler2D tex0;
|
||||
|
||||
uniform vec4 backgroundColor;
|
||||
uniform vec4 edgeColor;
|
||||
uniform float backgroundOpacity;
|
||||
uniform float edgeOpacity;
|
||||
out vec4 o_color;
|
||||
|
||||
float step = 1.0;
|
||||
|
||||
float luma(vec4 color){
|
||||
vec3 n = color.a == 0.0? vec3(0.0) : color.rgb/color.a;
|
||||
return dot(n, vec3(1.0/3.0));
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 step = 1.0 / textureSize(tex0, 0);
|
||||
|
||||
float tl = luma(texture(tex0, v_texCoord0 + vec2(-step.x, step.y)));
|
||||
float l = luma(texture(tex0, v_texCoord0 + vec2(-step.x, 0)));
|
||||
float bl = luma(texture(tex0, v_texCoord0 + vec2(-step.x, -step.y)));
|
||||
float t = luma(texture(tex0, v_texCoord0 + vec2(0, step.y)));
|
||||
float b = luma(texture(tex0, v_texCoord0 + vec2(0, -step.y)));
|
||||
float tr = luma(texture(tex0, v_texCoord0 + vec2(step.x, step.y)));
|
||||
float r = luma(texture(tex0, v_texCoord0 + vec2(step.x, 0)));
|
||||
float br = luma(texture(tex0, v_texCoord0 + vec2(step.x, -step.y)));
|
||||
|
||||
// Sobel masks (see http://en.wikipedia.org/wiki/Sobel_operator)
|
||||
// 1 0 -1 -1 -2 -1
|
||||
// X = 2 0 -2 Y = 0 0 0
|
||||
// 1 0 -1 1 2 1
|
||||
|
||||
// You could also use Scharr operator:
|
||||
// 3 0 -3 3 10 3
|
||||
// X = 10 0 -10 Y = 0 0 0
|
||||
// 3 0 -3 -3 -10 -3
|
||||
|
||||
float x = tl + 2.0 * l + bl - tr - 2.0 * r - br;
|
||||
float y = -tl - 2.0 * t - tr + bl + 2.0 * b + br;
|
||||
float intensity = sqrt((x*x) + (y*y)) / sqrt(2);
|
||||
vec4 color = mix(vec4(backgroundColor.rgb, backgroundOpacity), vec4(edgeColor.rgb, edgeOpacity), intensity);
|
||||
|
||||
vec4 a = texture(tex0, v_texCoord0);
|
||||
o_color = vec4(color.rgb, 1.0) * color.a * a.a;
|
||||
}
|
||||
91
orx-fx/src/shaders/glsl/grain/film-grain.frag
Normal file
91
orx-fx/src/shaders/glsl/grain/film-grain.frag
Normal file
@@ -0,0 +1,91 @@
|
||||
// Licensed under the MIT license:
|
||||
// https://opensource.org/licenses/MIT.
|
||||
|
||||
// Ad[a|o]pted from shader by "noby" https://www.shadertoy.com/view/3sGSWV
|
||||
uniform sampler2D tex0;
|
||||
in vec2 v_texCoord0;
|
||||
|
||||
uniform bool useColor;// false
|
||||
uniform float time;
|
||||
uniform float grainLiftRatio;// = 0.5;
|
||||
uniform float grainStrength;//= 1.0;
|
||||
uniform float grainRate;// = 1.0;
|
||||
// Range: [0.5, 1.0].
|
||||
uniform float grainPitch;// = 1.0;
|
||||
|
||||
uniform float colorLevel;// = 1.0;
|
||||
|
||||
out vec4 o_output;
|
||||
|
||||
|
||||
// From Dave Hoskins: https://www.shadertoy.com/view/4djSRW.
|
||||
float hash(vec3 p3){
|
||||
p3 = fract(p3 * 0.1031);
|
||||
p3 += dot(p3, p3.yzx + 19.19);
|
||||
return fract((p3.x + p3.y) * p3.z);
|
||||
}
|
||||
|
||||
// From iq: https://www.shadertoy.com/view/4sfGzS.
|
||||
float noise(vec3 x){
|
||||
vec3 i = floor(x);
|
||||
vec3 f = fract(x);
|
||||
f = f*f*(3.0-2.0*f);
|
||||
return mix(mix(mix(hash(i+vec3(0, 0, 0)),
|
||||
hash(i+vec3(1, 0, 0)), f.x),
|
||||
mix(hash(i+vec3(0, 1, 0)),
|
||||
hash(i+vec3(1, 1, 0)), f.x), f.y),
|
||||
mix(mix(hash(i+vec3(0, 0, 1)),
|
||||
hash(i+vec3(1, 0, 1)), f.x),
|
||||
mix(hash(i+vec3(0, 1, 1)),
|
||||
hash(i+vec3(1, 1, 1)), f.x), f.y), f.z);
|
||||
}
|
||||
|
||||
// Slightly high-passed continuous value-noise.
|
||||
float grain_source(vec3 x, float strength, float pitch){
|
||||
float center = noise(x);
|
||||
float v1 = center - noise(vec3(1, 0, 0)/pitch + x) + 0.5;
|
||||
float v2 = center - noise(vec3(0, 1, 0)/pitch + x) + 0.5;
|
||||
float v3 = center - noise(vec3(-1, 0, 0)/pitch + x) + 0.5;
|
||||
float v4 = center - noise(vec3(0, -1, 0)/pitch + x) + 0.5;
|
||||
|
||||
float total = (v1 + v2 + v3 + v4) / 4.0;
|
||||
return mix(1.0, 0.5 + total, strength);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 uv = v_texCoord0;
|
||||
vec2 x = gl_FragCoord.xy;
|
||||
|
||||
// Alternatively use iTime here instead and change the grain_rate
|
||||
// parameter to correspond to frames-per-second.
|
||||
float t = time;
|
||||
vec4 colorAlpha = texture(tex0, uv);
|
||||
vec3 color = colorAlpha.rgb;
|
||||
vec3 grain = vec3(0);
|
||||
|
||||
if (useColor) {
|
||||
float rg = grain_source(vec3(x, floor(grainRate*(t))), grainStrength, grainPitch);
|
||||
float gg = grain_source(vec3(x, floor(grainRate*(t+9.0))), grainStrength, grainPitch);
|
||||
float bg = grain_source(vec3(x, floor(grainRate*(t-9.0))), grainStrength, grainPitch);
|
||||
|
||||
// Consider using values outside the [0, 1] range as well
|
||||
// to introduce interesting color shifts to the source.
|
||||
|
||||
vec3 color_grain = vec3(rg, gg, bg);
|
||||
color_grain = mix(vec3(dot(color_grain, vec3(0.2126, 0.7152, 0.0722))), color_grain, colorLevel);
|
||||
grain = color_grain;
|
||||
} else {
|
||||
const float neutral_grain_factor = sqrt(2.0);
|
||||
grain = vec3(grain_source(vec3(x, floor(grainRate*t)), grainStrength/neutral_grain_factor, grainPitch));
|
||||
}
|
||||
|
||||
// Control whether to add or multiply or lift the source with the grain.
|
||||
// Multiply (0.0) should be more true to life, but adjust to taste.
|
||||
|
||||
color = max(mix(color*grain, color+(grain-1.0), grainLiftRatio), 0.0);
|
||||
|
||||
// After this you would normally perform tone mapping,
|
||||
// apply the grain before that.
|
||||
o_output.rgb = color;
|
||||
o_output.a = 1.0;
|
||||
}
|
||||
49
orx-fx/src/shaders/glsl/patterns/checkers.frag
Normal file
49
orx-fx/src/shaders/glsl/patterns/checkers.frag
Normal file
@@ -0,0 +1,49 @@
|
||||
#ifdef OR_IN_OUT
|
||||
in vec2 v_texCoord0;
|
||||
#else
|
||||
varying vec2 v_texCoord0;
|
||||
#endif
|
||||
|
||||
uniform vec4 foreground;
|
||||
uniform vec4 background;
|
||||
uniform vec2 targetSize;
|
||||
uniform float size;
|
||||
uniform float opacity;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
out vec4 o_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
float r = targetSize.x / targetSize.y;
|
||||
vec2 uv = v_texCoord0 - vec2(0.5);
|
||||
uv.x *= r;
|
||||
|
||||
vec2 cell = (uv / size);
|
||||
ivec2 cellIndex = ivec2(floor(cell));
|
||||
vec2 cellUV = cell - cellIndex;
|
||||
|
||||
int c = (cellIndex.x + cellIndex.y) % 2;
|
||||
vec2 w = fwidth(cell);
|
||||
|
||||
vec4 ca;
|
||||
vec4 cb;
|
||||
if (c == 0) {
|
||||
ca = background;
|
||||
cb = foreground;
|
||||
} else {
|
||||
ca = foreground;
|
||||
cb = background;
|
||||
}
|
||||
float s = w.x;
|
||||
float fx = smoothstep(s, 0.0, cellUV.x) + smoothstep(1.0 - s, 1.0, cellUV.x);
|
||||
float fy = smoothstep(s, 0.0, cellUV.y) + smoothstep(1.0 - s, 1.0, cellUV.y);
|
||||
|
||||
vec4 result = mix(ca, cb, min(0.5, fx * 0.5 + fy * 0.5)) * opacity;
|
||||
|
||||
#ifndef OR_GL_FRAGCOLOR
|
||||
o_color = result;
|
||||
#else
|
||||
gl_FragCoord = result;
|
||||
#endif
|
||||
}
|
||||
12
orx-fx/src/shaders/glsl/shadow/dropshadow-blend.frag
Normal file
12
orx-fx/src/shaders/glsl/shadow/dropshadow-blend.frag
Normal file
@@ -0,0 +1,12 @@
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform vec2 shift;
|
||||
|
||||
out vec4 o_color;
|
||||
void main() {
|
||||
vec4 a = texture(tex0, v_texCoord0-shift);
|
||||
vec4 b = texture(tex1, v_texCoord0);
|
||||
float alpha = min(1,max(0, b.a));
|
||||
o_color = a * (1.0-alpha) + b;
|
||||
}
|
||||
28
orx-fx/src/shaders/glsl/shadow/dropshadow-blur.frag
Normal file
28
orx-fx/src/shaders/glsl/shadow/dropshadow-blur.frag
Normal file
@@ -0,0 +1,28 @@
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0;
|
||||
uniform vec2 blurDirection;
|
||||
|
||||
uniform int window;
|
||||
uniform float sigma;
|
||||
uniform float gain;
|
||||
uniform vec4 subtract;
|
||||
uniform float spread;
|
||||
uniform vec4 color;
|
||||
out vec4 o_color;
|
||||
void main() {
|
||||
vec2 s = textureSize(tex0, 0).xy;
|
||||
s = vec2(1.0/s.x, 1.0/s.y);
|
||||
|
||||
int w = window;
|
||||
|
||||
vec4 sum = vec4(0, 0, 0, 0);
|
||||
float weight = 0;
|
||||
for (int x = -w; x<= w; ++x) {
|
||||
float lw = 1.0;
|
||||
sum += texture(tex0, v_texCoord0 + x * blurDirection * s * spread);
|
||||
weight += lw;
|
||||
}
|
||||
|
||||
o_color = (sum / weight) * gain;
|
||||
o_color.rgb = color.rgb * o_color.a;
|
||||
}
|
||||
27
orx-fx/src/shaders/glsl/tonemap/uncharted2-tonemap.frag
Normal file
27
orx-fx/src/shaders/glsl/tonemap/uncharted2-tonemap.frag
Normal file
@@ -0,0 +1,27 @@
|
||||
// ad[a|o]pted from http://filmicworlds.com/blog/filmic-tonemapping-operators/
|
||||
float A = 0.15;
|
||||
float B = 0.50;
|
||||
float C = 0.10;
|
||||
float D = 0.20;
|
||||
float E = 0.02;
|
||||
float F = 0.30;
|
||||
float W = 11.2;
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform float exposureBias;
|
||||
in vec2 v_texCoord0;
|
||||
out vec4 o_output;
|
||||
|
||||
vec3 Uncharted2Tonemap(vec3 x) {
|
||||
return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec3 texColor = texture(tex0,v_texCoord0).rgb;
|
||||
vec3 curr = Uncharted2Tonemap(exposureBias*texColor);
|
||||
vec3 whiteScale = 1.0f/Uncharted2Tonemap(vec3(W));
|
||||
vec3 color = curr*whiteScale;
|
||||
|
||||
vec3 retColor = pow(color, vec3(1/2.2));
|
||||
o_output = vec4(retColor, 1);
|
||||
}
|
||||
10
orx-fx/src/shaders/glsl/transform/flip-vertically.frag
Normal file
10
orx-fx/src/shaders/glsl/transform/flip-vertically.frag
Normal file
@@ -0,0 +1,10 @@
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0;
|
||||
uniform vec4 constant;
|
||||
|
||||
out vec4 o_color;
|
||||
void main() {
|
||||
vec2 uv = v_texCoord0;
|
||||
uv.y = 1.0 - uv.y;
|
||||
o_color = texture(tex0, uv);
|
||||
}
|
||||
Reference in New Issue
Block a user