Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // framebuffer.glvs
- #version 330
- in vec4 position;
- in vec4 texcoord;
- out vec2 vTexcoord;
- void main()
- {
- vTexcoord = texcoord.xy;
- gl_Position = position;
- }
- // voronoi.glfs
- #version 330
- in vec2 vTexcoord;
- out vec4 outColor;
- uniform sampler2D tex0;
- uniform float width;
- uniform float height;
- uniform float elapsedTime;
- void main()
- {
- vec2 st = gl_FragCoord.xy/vec2(width, height);
- st.x *= width/height;
- vec3 color = vec3(0.0);
- // Cell positions
- vec2 point[1];
- point[0] = vec2(width*0.5/height, 0.5);
- float m_dist = 1.0; // minimun distance
- vec2 m_point; // minimum position
- // Iterate through the points positions
- for (int i = 0; i < 1; i++)
- {
- float dist = distance(st, point[i]);
- if (dist < m_dist)
- {
- // Keep the closer distance
- m_dist = dist;
- // Kepp the position of the closer point
- m_point = point[i];
- }
- }
- // Add distance field to closest point center
- color += m_dist*2.;
- // tint acording the closest point position
- //color = vec3(m_point, m_point, m_point);
- // Show isolines
- color -= abs(sin(80.0*m_dist))*0.07;
- // Draw point center
- //color += 1.-step(.02, m_dist);
- gl_FragColor = (vec4(1.0, 1.0, 1.0, 1.0) - vec4(color, 1.0))*texture(tex0, vTexcoord);
- }
- // frost.glfs
- #version 330
- in vec2 vTexcoord;
- out vec4 outColor;
- uniform sampler2D tex0;
- uniform sampler2D tex1;
- uniform float PixelX = 2.0;
- uniform float PixelY = 2.0;
- uniform float Freq = 0.115;
- uniform float width;
- uniform float height;
- vec4 spline(float x, vec4 c1, vec4 c2, vec4 c3, vec4 c4, vec4 c5, vec4 c6, vec4 c7, vec4 c8, vec4 c9)
- {
- float w1 = 0.0, w2 = 0.0, w3 = 0.0, w4 = 0.0, w5 = 0.0, w6 = 0.0, w7 = 0.0, w8 = 0.0, w9 = 0.0;
- float tmp = x * 8.0;
- if (tmp <= 1.0)
- {
- w1 = 1.0 - tmp;
- w2 = tmp;
- }
- else if (tmp <= 2.0)
- {
- tmp = tmp - 1.0;
- w2 = 1.0 - tmp;
- w3 = tmp;
- }
- else if (tmp <= 3.0)
- {
- tmp = tmp - 2.0;
- w3 = 1.0-tmp;
- w4 = tmp;
- }
- else if (tmp <= 4.0)
- {
- tmp = tmp - 3.0;
- w4 = 1.0-tmp;
- w5 = tmp;
- }
- else if (tmp <= 5.0)
- {
- tmp = tmp - 4.0;
- w5 = 1.0-tmp;
- w6 = tmp;
- }
- else if (tmp <= 6.0)
- {
- tmp = tmp - 5.0;
- w6 = 1.0-tmp;
- w7 = tmp;
- }
- else if (tmp <= 7.0)
- {
- tmp = tmp - 6.0;
- w7 = 1.0 - tmp;
- w8 = tmp;
- }
- else
- {
- tmp = clamp(tmp - 7.0, 0.0, 1.0);
- w8 = 1.0-tmp;
- w9 = tmp;
- }
- return w1*c1 + w2*c2 + w3*c3 + w4*c4 + w5*c5 + w6*c6 + w7*c7 + w8*c8 + w9*c9;
- }
- vec3 noise(vec2 p)
- {
- return texture2D(tex1, p).xyz;
- }
- void main()
- {
- vec3 tc = vec3(1.0, 0.0, 0.0);
- float DeltaX = PixelX / width;
- float DeltaY = PixelY / height;
- vec2 ox = vec2(DeltaX, 0.0);
- vec2 oy = vec2(0.0, DeltaY);
- vec2 PP = vTexcoord - oy;
- vec4 C00 = texture2D(tex0, PP - ox);
- vec4 C01 = texture2D(tex0, PP);
- vec4 C02 = texture2D(tex0, PP + ox);
- PP = vTexcoord;
- vec4 C10 = texture2D(tex0, PP - ox);
- vec4 C11 = texture2D(tex0, PP);
- vec4 C12 = texture2D(tex0, PP + ox);
- PP = vTexcoord + oy;
- vec4 C20 = texture2D(tex0, PP - ox);
- vec4 C21 = texture2D(tex0, PP);
- vec4 C22 = texture2D(tex0, PP + ox);
- float n = noise(Freq*vTexcoord).x;
- n = mod(n, 0.111111)/0.111111;
- vec4 result = spline(n, C00, C01, C02, C10, C11, C12, C20, C21, C22);
- tc = result.rgb;
- outColor = vec4(tc, 1.0);
- }
- // hdr - glfs
- #version 330
- in vec2 vTexcoord;
- out vec4 outColor;
- uniform sampler2D tex0;
- uniform float gamma;
- uniform float width;
- uniform float height;
- void main()
- {
- vec2 texOffset = vec2(1.0/600.0, 1.0/600.0);
- float kernel[9] = float[]
- (
- 0.00481007202,
- 0.0286864862,
- 0.102712765,
- 0.220796734,
- 0.284958780,
- 0.220796734,
- 0.102712765,
- 0.0286864862,
- 0.00481007202
- );
- float exposure = 1.0;
- vec3 gammaCorrection = vec3(1.0/gamma, 1.0/gamma, 1.0/gamma);
- vec3 hdrColor = texture(tex0, vTexcoord).rgb;
- vec3 mapped = vec3(1.0) - exp(-hdrColor*exposure);
- //mapped = pow(mapped, gammaCorrection);
- vec4 sum = vec4(0.0);
- for (int i = -4; i <= 4; i++)
- sum += texture(tex0, vec2(vTexcoord.x + i*texOffset.x, vTexcoord.y + i*texOffset.y))*kernel[i+4];
- outColor = pow(vec4(mapped, 1.0)*sum, vec4(gammaCorrection, 1.0));
- }
- // nightvision.glfs
- #version 330
- in vec2 vTexcoord;
- out vec4 outColor;
- uniform sampler2D tex0;
- uniform sampler2D tex1;
- uniform float elapsedTime;
- uniform float luminanceThreshold; // 0.2
- uniform float colorAmplification; // 4.0
- uniform float width;
- uniform float height;
- void main()
- {
- vec3 finalColor;
- vec2 uv;
- uv.x = 0.4*sin(elapsedTime*40.0);
- uv.y = 0.4*cos(elapsedTime*40.0);
- vec3 n = texture(tex1, (vTexcoord*3.5) + uv).rgb;
- vec3 c = texture(tex0, vTexcoord + (n.xy*0.005)).rgb;
- float lum = dot(vec3(0.30, 0.59, 0.11), c);
- if (lum < luminanceThreshold) c *= colorAmplification;
- vec3 visionColor = vec3(0.1, 0.95, 0.2);
- finalColor = (c + (n*0.2)) * visionColor * 0.3;
- float w = width/2.0;
- float h = height/2.0;
- float w2 = w*w;
- float h2 = h*h;
- float x2 = (gl_FragCoord.x - w)*(gl_FragCoord.x - w);
- float y2 = (gl_FragCoord.y - h)*(gl_FragCoord.y - h);
- if (x2/w2 + y2/h2 <= 1.0)
- outColor = vec4(finalColor, 1.0);
- else
- outColor = vec4(0.0, 0.0, 0.0, 1.0);
- }
- // oldtv.glfs
- #version 330
- in vec2 vTexcoord;
- out vec4 outColor;
- uniform sampler2D tex0;
- uniform sampler2D tex1;
- uniform float gamma;
- uniform float width;
- uniform float height;
- uniform float level;
- uniform float angle;
- vec2 translatedTexcoord(in vec2 _texcoord, in float _angle)
- {
- return _texcoord + vec2(0.0, -angle);
- }
- vec2 rotatedTexcoord(in vec2 _texcoord, in float _angle, in float _width, in float _height)
- {
- float sinf = sin(_angle);
- float cosf = cos(_angle);
- return mat2(cosf, sinf, -sinf, cosf)*vec2((_texcoord.x - 0.5)*(_width/_height), _texcoord.y - 0.5);
- }
- vec2 modifiedTexcoord(in vec2 _texcoord, in float _angle)
- {
- vec2 uv;
- uv.x = 0.4*sin(_angle*40.0);
- uv.y = 0.4*cos(_angle*40.0);
- return _texcoord*0.5 + uv;
- }
- void main()
- {
- vec2 texOffset = vec2(1.0/200.0, 1.0/200.0);
- vec2 texOffset1 = vec2(1.0/100.0, 1.0/100.0);
- float kernel[9] = float[]
- (
- 0.00481007202,
- 0.0286864862,
- 0.102712765,
- 0.220796734,
- 0.284958780,
- 0.220796734,
- 0.102712765,
- 0.0286864862,
- 0.00481007202
- );
- float exposure = 1.0;
- vec3 gammaCorrection = vec3(1.0/gamma, 1.0/gamma, 1.0/gamma);
- vec3 hdrColor = texture(tex0, vTexcoord).rgb;
- vec3 mapped = vec3(1.0) - exp(-hdrColor*exposure);
- mapped = pow(mapped, gammaCorrection);
- vec4 sum = vec4(0.0);
- for (int i = -4; i <= 4; i++)
- sum += texture(tex0, vec2(vTexcoord.x + i*texOffset.x, vTexcoord.y + i*texOffset.y))*kernel[i+4];
- vec4 sum1 = vec4(0.0);
- for (int i = -4; i <= 4; i++)
- sum1 += texture(tex0, vec2(vTexcoord.x + i*texOffset1.x, vTexcoord.y + i*texOffset1.y))*kernel[i+4];
- vec4 c = pow(vec4(mapped, 1.0)*sum, vec4(gammaCorrection, 1.0));
- float a = (c.r + c.g + c.b + c.a)/4.0;
- vec4 d = pow(vec4(mapped, 1.0)*sum1, vec4(gammaCorrection, 1.0));
- float b = (d.r + d.g + d.b + d.a)/4.0;
- vec2 texcoord = modifiedTexcoord(vTexcoord, angle);
- vec4 cr = mix(vec4(a, a, a, 1.0), texture(tex1, texcoord), 0.1);
- vec4 cb = mix(vec4(b, b, b, 1.0), texture(tex1, texcoord), 0.1)*1.03;
- if (gl_FragCoord.y > level - 40.0 && gl_FragCoord.y < level + 40.0)
- outColor = cb;
- else
- outColor = cr;
- }
- // sobel.glfs
- #version 330
- in vec2 vTexcoord;
- out vec4 outColor;
- uniform sampler2D tex0;
- void main()
- {
- vec4 top = texture(tex0, vec2(vTexcoord.x, vTexcoord.y + 1.0/100.0));
- vec4 bottom = texture(tex0, vec2(vTexcoord.x, vTexcoord.y - 1.0/100.0));
- vec4 left = texture(tex0, vec2(vTexcoord.x - 1.0/100.0, vTexcoord.y));
- vec4 right = texture(tex0, vec2(vTexcoord.x + 1.0/100.0, vTexcoord.y));
- vec4 topLeft = texture(tex0, vec2(vTexcoord.x - 1.0/100.0, vTexcoord.y + 1.0/100.0));
- vec4 topRight = texture(tex0, vec2(vTexcoord.x + 1.0/100.0, vTexcoord.y + 1.0/100.0));
- vec4 bottomLeft = texture(tex0, vec2(vTexcoord.x - 1.0/100.0, vTexcoord.y - 1.0/100.0));
- vec4 bottomRight = texture(tex0, vec2(vTexcoord.x + 1.0/100.0, vTexcoord.y - 1.0/100.0));
- vec4 sx = -topLeft - 2*left - bottomLeft + topRight + 2*right + bottomRight;
- vec4 sy = -topLeft - 2*top - topRight + bottomLeft + 2*bottom + bottomRight;
- vec4 sobel = sqrt(sx*sx + sy*sy);
- vec4 diffuse = texture(tex0, vTexcoord);
- outColor = sobel;
- }
- // sobel_v2.glfs
- #version 330
- in vec2 vTexcoord;
- out vec4 outColor;
- uniform sampler2D tex0;
- void main()
- {
- vec3 diffuse = texture(tex0, vTexcoord).rgb;
- mat3 I;
- for (int i = -1; i < 2; i++)
- {
- for (int j = -1; j < 2; j++)
- {
- vec3 s = texture(tex0, vec2(vTexcoord.x + i/100.0, vTexcoord.y + j/100.0)).rgb;
- I[i+1][j+1] = length(s);
- }
- }
- mat3 sx = mat3(
- 1.0, 2.0, 1.0,
- 0.0, 0.0, 0.0,
- -1.0, -2.0, -1.0
- );
- mat3 sy = mat3(
- 1.0, 0.0, -1.0,
- 2.0, 0.0, -2.0,
- 1.0, 0.0, -1.0
- );
- float gx = dot(sx[0], I[0]) + dot(sx[1], I[1]) + dot(sx[2], I[2]);
- float gy = dot(sy[0], I[0]) + dot(sy[1], I[1]) + dot(sy[2], I[2]);
- float g = sqrt(pow(gx, 2.0) + pow(gy, 2.0));
- outColor = vec4(diffuse - vec3(g), 1.0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement