//Copyright 2008-2011 Charles Lohr under the new BSD license. uniform sampler2D Tex; const float fDeltaSq = 1./2048.; //const float quality = 1.0; //const float minoctave = 1.; //const float maxoctave = 6.; //const float multiplier = 2.6; uniform float Q; uniform float MINOCTAVE; uniform float MAXOCTAVE; uniform float MULTIPLIER; uniform float FREQUENCYSLOPE; uniform float KEY; //Positive slope allows higher frequencies to affect more clearly. //.1 is pretty high. void main() { float fcoffset = KEY; //Half steps from E (-4 is c) (7 is b) //-1 D#, and +3 G# for jar of hearts //Technicolor phase might be -2 //DR ROCKER is 2.0!!! //Set to -4.15 for E=RED vec4 total = vec4( 0. ); for( float octave = MINOCTAVE; octave <= MAXOCTAVE; octave ++ ) { //vec4 InData = texture2D( Tex, gl_TexCoord[0].xy ); float freq = pow( 2., gl_TexCoord[0].x + 4.466 + octave + fcoffset / 12. ); //4.15 for C // vec2 RunningTotal = vec2( 0.0, 0.0 ); vec2 Avg = vec2( 0.0, 0.0 ); for( float x = 0.; x < 1.; x+=(fDeltaSq*4.) ) { vec4 CInData = (texture2D( Tex, vec2( x/4.0, 0.0) )-0.5) * min( 1.0-x, x ); vec4 vals = vec4( freq ) * ( vec4( x ) + vec4( 0., 1., 2., 3. ) * fDeltaSq ); vec4 sins = sin( vals ) * CInData.x; vec4 coss = cos( vals ) * CInData.x; RunningTotal += vec2( dot( sins, vec4(1.) ), dot( coss , vec4(1.) ) ); } //RunningTotal -= Avg; float magnitude = (RunningTotal.x * RunningTotal.x)+(RunningTotal.y* RunningTotal.y); // magnitude = log( sqrt( magnitude) )/1.+1.0; magnitude = sqrt(magnitude)/10.; magnitude *= 1. + (gl_TexCoord[0].x + 4.466 + octave)*FREQUENCYSLOPE; float attScalar = 1.; if( octave == MINOCTAVE ) attScalar = gl_TexCoord[0].x; if( octave == MAXOCTAVE ) attScalar = 1. - gl_TexCoord[0].x; total += vec4( gl_TexCoord[0].x * 1.0-0.5, 0.1*magnitude, 0.1, 1.0 ) * attScalar; } total.y = total.y * 3. * MULTIPLIER;//* total.y * total.y * total.y *2.; gl_FragColor = total/3.; }