A noise surface shader in VEX.
A .vfl file that computes a noise shader.
Date Created:Friday December 29th, 2006 03:41 AM
Date Modified:Wednesday July 30th, 2008 04:13 PM
#pragma opname dan_material
#pragma oplabel "VEX DPL Material"
//hint tells you what kind of parameter it is
#pragma hint clr color
//label renames everything so its easier to understand in GUI
#pragma label clr "color"
#pragma label multdan "multiply"
#pragma label dnfreq "Frequency"
#pragma label diff "Diffuse"
#pragma label spec "Specular"
#pragma label amb "Ambient"
#pragma label rough "Roughness"
//smooths edges and anti-aliasing
float pulse(float a,b,fuzz,x)
{
return(smooth(a-fuzz,a,x)-smooth(b-fuzz,b,x));
}
surface danman (
//parameters
vector clr={0,1,0};
float multdan = 1;
float dnfreq = 1;
float diff = 1;
float spec = 1;
float amb = 0.1;
float rough = 0.1;
)
{
//here is where the magic happens
vector restpos, dan_noise;
//make a rest position in vex for object space
restpos = wo_space(P)*dnfreq;
//this is for noise with color
dan_noise = snoise(restpos)*(clr);
//set the opacity based on the noise
vector opac = dan_noise;
vector newcolr = multdan*dan_noise;
//this is what you do for black and white
float dnny = noise(P)*multdan;
vector ng = frontface(normalize(N), I);
Cf = dnny;
Cf += amb * ambient();
Cf += diff * diffuse(ng);
Cf += spec * specular(ng, normalize(I), 1.0/rough);
Of = opac;
Cf *= Of;
}
Downloads:
Download: noise.vfl 1 KB
Please login or Click Here to register for downloads
Noise by Dan Lynch
is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
Based on a work at www.3daet.com
Permissions beyond the scope of this license may be available at http://www.3daet.com
