OOoh, check out this one :
#version 430 core
uniform float fGlobalTime; // in seconds
uniform vec2 v2Resolution; // viewport resolution (in pixels)
uniform sampler1D texFFT; // towards 0.0 is bass / lower freq, towards 1.0 is higher / treble freq
uniform sampler1D texFFTSmoothed; // this one has longer falloff and less harsh transients
uniform sampler2D texChecker;
uniform sampler2D texNoise;
uniform sampler2D texTex1;
uniform sampler2D texTex2;
uniform sampler2D texTex3;
uniform sampler2D texTex4;
layout(location = 0) out vec4 out_color; // out_color must be written in order to see anything
// CableAndhollowCylinders
#ifdef GL_ES
precision mediump float;
#endif
// T21: Can anyone fix the fringe around the cylinders ???
//
// fernlightning says: Lets try adding a ring/disk at the end of the cylinder, and ensuring the color returned is stable
// - retrofitted glowing cable from http://glsl.heroku.com/e#6129.0
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
float rand(vec3 n)
{
n = floor(n);
return fract(sin((n.x+n.y*1e2+n.z*1e4)*1e-4)*1e5);
}
// .x is distance, .y = colour
vec2 map( vec3 p )
{
const float RADIUS = 0.2;
// cylinder
vec3 f = fract( p ) - 0.5;
float d = length( f.xy );
float cr = rand( p );
// float cd = d - cr*RADIUS; // closed cylinder
float cd = abs(d - cr*RADIUS); // abs for hollow
// inner cable
if(d-0.02 < cd)
{
cd = d-0.02;
cr = 4.0; // glow!
}
// end - calc (rand) radius at more stable pos
p.z -= 0.5;
float rr = rand( p );
float rn = d - rr*RADIUS;
float rm = abs( fract( p.z ) - 0.5 ); // offset so at end of cylinder
// float rd = max( rn , rm ); // end with disk
float rd = sqrt( rn*rn + rm*rm ); // end with ring
return (cd < rd) ? vec2( cd, cr ) : vec2( rd, rr ); // min
}
void main( void )
{
vec2 pos = (gl_FragCoord.xy*2.0 - v2Resolution.xy) / v2Resolution.y;
vec3 camPos = vec3(cos(fGlobalTime*0.3), sin(fGlobalTime*0.3), 3.5);
vec3 camTarget = vec3(0.0, 0.0, .0);
vec3 camDir = normalize(camTarget-camPos);
vec3 camUp = normalize(vec3(0.0, 1.0, 0.0));
vec3 camSide = cross(camDir, camUp);
float focus = 1.8;
vec3 rayDir = normalize(camSide*pos.x + camUp*pos.y + camDir*focus);
vec3 ray = camPos;
float m = 0.32;
vec2 d;
float total_d = 0.;
const int MAX_MARCH = 100;
const float MAX_DISTANCE = 100.0;
for(int i=0; i<MAX_MARCH; ++i) {
d = map(ray-vec3(0.,0.,fGlobalTime/2.));
total_d += d.x;
ray += rayDir * d.x;
m += 1.0;
if(abs(d.x)<0.01) { break; }
if(total_d>MAX_DISTANCE) { total_d=MAX_DISTANCE; break; }
}
float c = (total_d)*0.0001;
vec4 result = vec4( 1.0-vec3((d.y>2.0)?1.0:c, c, c) - vec3(0.025, 0.025, 0.02)*m*0.8, 1.0 );
gl_FragColor = result*d.y;
}