Guest User

cdak

a guest
Sep 9th, 2010
6,138
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. sampler s;
  2. float2 j;
  3. float4 h:register(c1);
  4.  
  5.  
  6. float3 q(sampler s,float2 x) {
  7.     float4 c=tex2D(s,x),d=3/pow(c.w,.15);
  8.     return saturate(c.x/d)*d;
  9.  
  10. }
  11.  
  12. float3x3 r(float3 g) {
  13.     g*=6.283;
  14.     float a=cos(g.x),b=sin(g.x),c=cos(g.y),d=sin(g.y),e=cos(g.z),f=sin(g.z);
  15.  
  16.     return float3x3(c*e+b*d*f,-a*f,b*c*f-d*e,c*f-b*d*e,a*e,-d*f-b*c*e,a*d,b,a*c);
  17.  
  18. }
  19.  
  20. float3x3 w() {
  21.     return r(float3(0,0,smoothstep(-7,30,t))+smoothstep(170,300,t)*float3(1,2,3)+sin(float3(5,6,7)*(h.z*100+t*.002))*.08*(2-sin((h.z*2222-h.w))));
  22. }
  23.  
  24. float f1(float3 p) {
  25.     float3 g=(frac(mul(p+sin(p.yzx*.1)/3,r(sin(p.z*.07)*float3(0,0,.3)*smoothstep(150,60,p.z)))/6)-.5)*6;
  26.     float d1=2.4*smoothstep(20,70,t)-abs(p.x)-1,d2=max(abs(g.x),max(abs(g.y),abs(g.z)))-2.3,d3=length(p-float3(0,0,84))-18;
  27.  
  28.     d1=lerp(d1,min(max(d1,-.7-d2),max(d2-.3,abs(d1-.9)-1.3)),saturate(p.z*.03-.5+sin(p.z*.1)*.1));
  29.     d1=max(max(d1,25-p.z),p.z-116);
  30.     d1=min(min(max(d1,min(11-abs(d3),max(-p.z+84,abs(length(p.xy)-1.3+sin(p.z*.9)/5)-.2))),max(d1+.5,abs(d3-4)-.5))-.3*smoothstep(60,110,t),max(111-p.z,min(7-length(p.xy)/2-sin(p.z*.3+sin(p.z*2)/25+t/5)*6,max(-p.x+(p.z-105)*.1,abs(p.y)-1.8))));
  31.     g=mul(p-float3(0,0,44),r(pow(smoothstep(36,4,t)*float3(1,2,3),2)*step(-p.z,-15)));
  32.    
  33.     if(t<44)
  34.         d1=lerp(d1,max(abs(g.x),max(abs(g.y),abs(g.z)))-4-15*smoothstep(27,36,t),smoothstep(44,30,t));
  35.        
  36.     d1=min(d1,.8*max(p.z-14,abs(length(p.xy)-1.5-sin(floor(p.z))/5)-1));
  37.    
  38.     return d1;
  39. }
  40.  
  41. float f2(float3 p) {
  42.     p.z-=138;
  43.     float ln=pow(1/length(p+3*sin(t*float3(5.1,7.6,1)*.023)),2)+pow(1/length(p+3*sin(t*float3(4.5,2.7,2)*.033)),2)+pow(1/length(p+3*sin(t*float3(6.3,3.7,4)*.031)),2)+pow(1/length(p+3*sin(t*float3(7.5,6.3,5)*.023)),2),d1=1/sqrt(ln)-1;
  44.    
  45.     d1=min(lerp(d1-.7,min(abs(d1+.3)-.3,abs(d1-.7)*2-.3),smoothstep(150,230,t-p.y/9)),abs(d1-5)-1+4.2*smoothstep(210,150,t+p.y/5))+2*smoothstep(230,270,t+p.y);
  46.    
  47.     return d1;
  48. }
  49.  
  50. float3 k() {
  51.     return mul(float3(0,.1,-.1-2*smoothstep(170,190,t)),w())+float3(0,0,smoothstep(-.07,1,t*.005)*140);
  52. }
  53.  
  54. float f(float3 p) {
  55.     p+=.01;
  56.     float d1=95-length(p-k()),d2=f2(p);
  57.  
  58.     if(t<280)
  59.         d1=min(d1,f1(p))+14*smoothstep(140,230,t);
  60.     if(t>130)
  61.         d1=min(d1,d2);
  62.  
  63.     d1*=.3;
  64.     p*=.3;
  65.     for(float i=0; i<4; i++) {
  66.         float3 q=1+i*i*.18*(1+4*(1+.3*sin(t*.001))*sin(float3(5.7,6.4,7.3)*i*1.145+.3*sin(h.w*.015)*(3+i))),g=(frac(p*q)-.5)/q;
  67.         d1=min(d1+.03,max(d1,max(abs(g.x),max(abs(g.y),abs(g.z)))-.148));
  68.     }
  69.    
  70.     return d1/.28;
  71. }
  72.  
  73. float3 nn(float3 p) {
  74.     float2 e={4e-3,0};
  75.  
  76.     return -normalize(float3(f(p+e.xyy),f(p+e.yxy),f(p+e.yyx)));
  77. }
  78.  
  79. float u(float3 p,float3 y) {
  80.     float o=.8,g=f(p),d;
  81.    
  82.     for(float i=0;i<1;i+=.25) {
  83.         d=i*.15+.025;
  84.         o-=(g<.01)*(d-f(p-y*d))*2*(2-i*1.8);
  85.     }
  86.    
  87.     return o;
  88. }
  89.  
  90. float4 p0(float2 vp:vpos):color0 {
  91.     float2 x=(vp+.5)/j;
  92.     float3 p=k(),a=p,y=mul(normalize(float3(2*sin((vp-.5-j/2)/j.y),cos(length((vp-.5-j/2)/j.y/2)*2*sqrt(2)))),w());
  93.     float g=0,df=f(p)+.002;
  94.  
  95.     for(float i=0;i<90&&abs(df)>.00032;i++) {
  96.         g+=smoothstep(.5,.07,df)*.01*(1-g);
  97.         p+=y*(df+.000001*length(p-a));
  98.         df=f(p).x;
  99.     }
  100.    
  101.     float3 n=nn(p);
  102.     float d=length(p-a),o=u(p,n),z=2*pow(.5+dot(n,normalize(normalize(sin(p.yzx/5+h.w+float3(.14,.47,.33)*t))))/2,.5);
  103.    
  104.     z*=1+.8/pow(d+.5,.6)*sin(floor(p*1.6+sin(floor(p.yzx*3))*3)+sin(floor(p.zxy*1.7)))+.7*sin(t*.08+4*length(sin(floor(p*3+t*.1+sin(floor(p.yzx*133))*.24/d*sin(t*.3+floor(p.zxy*.15)))+sin(floor(p.yzx*7))))+step(length(frac(p.xy*7)-.5)+.6*sin(length(sin(t*float2(.5,.7)+floor(p.xy*7)))),.5))*sin(floor(p.z)*3+floor(p.x+sin(floor(p.yzx*15))));
  105.     z+=pow(.45+.45*sin(o*38+t),19);
  106.    
  107.     return float4(z,g,o,d);
  108. }
  109.  
  110. float4 p1(float2 vp:vpos):color0 {
  111.     float2 x=(vp+.5)/j;
  112.     float3 c=tex2D(s,x).x,b=tex2D(s,x).yzw;
  113.     float2 w=4e-4/j*j.x/pow(b.z+.03,.5)*(pow(b.y,2)+.1);
  114.     float3 e={1,-1,0},_11=q(s,x+w*e.yy),_12=q(s,x+w*e.zy),_13=q(s,x+w*e.xy),_21=q(s,x+w*e.yz),_23=q(s,x+w*e.xz),_31=q(s,x+w*e.yx),_32=q(s,x+w*e.zx),_33=q(s,x+w*e.xx),v=_13+2*_23+_33-(_11+2*_21+_31),z=_11+2*_12+_13-(_31+2*_32+_33);
  115.  
  116.     c=lerp((saturate(pow(sqrt(v*v*float3(.5,.01,1)+z*z*float3(.02,1,1)),.5)*.4/pow(b.z,.3))*sqrt(h.x*50+1)+b.x*b.x*12/pow(b.z+.5,.6))*pow(b.y,1.1)*1.04,h.x*70+h.x*smoothstep(50,10,t)*2,saturate(b.z/110-.1+h.x*3));
  117.     c=pow(c+saturate(1-c)*b.x,1.8*float3(1.8,1.2,1.1)-1+9/t+.1/(pow(h.x*20,float3(3,4,3))+.05))*2;
  118.    
  119.     return c.xyzz;
  120. }
RAW Paste Data