/* NewsPaper.sl */ /* Author: Jeremy S. De Bonet jsd@ai.mit.edu */ /* * NewsPaperShade() : Shades a surface to look like a newspaper * NewsPaperDisp() : Displaces a surface to simulate the effects crumpling */ float sqr(float x) { return x*x; } float dist (float x,y) { return (sqrt(sqr(x)+sqr(y))); } float Gaussian(float x,m,s) { return (exp(-sqr((x)-(m))/sqr(s)));} #define PI 3.14 surface NewsPaperShade( float cCols=11; float rPictures=1.1; float rTitleHeight=.9; ) { float T=t/2+.5; float S=s/2+.5; float fIsPix=0; Ci=color(1,1,1); if (T.48 ? S < .52 ? 1 : 0 : 0)) /* Make Swirls */ + Gaussian(mod(noise(S,T),1),.5,.002) /* Make Column dividers terminators */ + Gaussian(noise(floor((S-.5)*cCols)/cCols,T),.5,.002) /* Make Columns */ + Gaussian(mod(S,1.0/cCols),.5/cCols,.004)); /* Add pictures */ fIsPix=mod(5*floor((S-.5)*cCols/2)+3*floor(T*10)/5,rPictures); if (fIsPix>1) { Ci=color(noise(S*25,T*25), noise(S*25,T*25), noise(S*25,T*25)); Ci*=clamp((noise(S,T)+noise(S*5,T*5))/2,0,1); } } else { /* DO TITLE WORDS*/ fIsPix=(noise(S*40,T*5)); fIsPix=(fIsPix>.5)?1:0; /* CENTER IT */ fIsPix*=(S>.1)?1:0; fIsPix*=(S<.9)?1:0; /* ADD WORDS */ fIsPix*=Gaussian(T,1-((1-rTitleHeight)/2),(1-rTitleHeight)/4); /* ADD SEPARATOR */ fIsPix+=Gaussian(T,rTitleHeight+.01,.015); Ci*=(1-fIsPix); } Os=1; } displacement NewsPaperDisp( ) { P+=noise(10*s,20*t)/10* normalize(N); N=calculatenormal(P); }