Code: Select all
proc SYSTEM_BUS_T.Spectrum(x as float ) as vector3
' https://www.shadertoy.com/view/wlSBzD
dim as float r, g, b
r = iif(x<.16 , smoothstep(0., .16, x)*.169 , _
iif(x<.22 , smoothstep(.22, .16, x)*.134+.035 , _
iif(x<.41 , smoothstep(.22, .41, x)*.098+.035 , _
iif(x<.64 , smoothstep(.41,.64,x)*.851+.133 , _
smoothstep(1., .64, x)*.984))))
g = iif(x<.05 , 0. , _
iif(x<.15 , smoothstep(.05, .15, x)*.047 , _
iif(x<.45 , smoothstep(.15, .45, x)*.882+.047 , _
iif(x<.70 , smoothstep(.70, .45, x)*.796+.133 , _
smoothstep(1.0, .70, x)*.133))))
b = iif(x<.18 , smoothstep(0.0, .18, x)*.5 , _
iif(x<.22 , smoothstep(.22, .18, x)*.1+.4 , _
iif(x<.35 , smoothstep(.22, .35, x)*.059+.4 , _
iif(x<.54 , smoothstep(.54, .35, x)*.334+.125 , _
iif(x<.60 , smoothstep(.54, .60, x)*.169+.125 , _
iif(x<.69 , smoothstep(.69, .60, x)*.243+.051 , _
iif(x<.72 , smoothstep(.69, .72, x)*.043+.051 , _
iif(x<.89 , smoothstep(.89, .72, x)*.094 , 0.))))))))
return vector3(r,g,b)
end proc
proc SYSTEM_BUS_T.SpectrumPoly(x as float) as vector3
' https://www.shadertoy.com/view/wlSBzD
return (vector3( 1.220023e0,-1.933277e0, 1.623776e0) _
+(vector3(-2.965000e1, 6.806567e1,-3.606269e1) _
+(vector3( 5.451365e2,-7.921759e2, 6.966892e2) _
+(vector3(-4.121053e3, 4.432167e3,-4.463157e3) _
+(vector3( 1.501655e4,-1.264621e4, 1.375260e4) _
+(vector3(-2.904744e4, 1.969591e4,-2.330431e4) _
+(vector3( 3.068214e4,-1.698411e4, 2.229810e4) _
+(vector3(-1.675434e4, 7.594470e3,-1.131826e4) _
+ vector3( 3.707437e3,-1.366175e3, 2.372779e3) _
*x)*x)*x)*x)*x)*x)*x)*x)*x
end proc
def SYSTEM_BUS_T.mainImage overload (fragColor as vector4, fragCoord as const vector2)
dim as vector2 uv = fragCoord/iResolution.xy
dim as vector3 col = vector3(0)
dim as vector3 spectrum3 = iif((iGlobalTime mod 2.)<1. , Spectrum(uv.x) , SpectrumPoly(uv.x))
col = spectrum3*smoothstep(.3, .7, uv.y)
col += smoothstep(.01, .0, abs(spectrum3-uv.y*2.))
fragColor = vector4(col,1.0)
end def
What it actually does: