Light Model Switch
eharetea

Create a light model switch parameter on a surface shader in VEX.

A .vfl that allows user control of the lighting model of a surface shader.

Date Created:Friday December 29th, 2006 03:41 AM
Date Modified:Wednesday July 30th, 2008 04:10 PM


#pragma hint clr color
#pragma label clr "color"
#pragma label multdan "multiply"
#pragma label diff "Diffuse"
#pragma label spec "Specular"
#pragma label amb "Ambient"
#pragma label rough "Roughness"
#pragma choice lmodel "0" "Lambert"
#pragma choice lmodel "1" "Phong"
#pragma choice lmodel "2" "Blinn"


float pulse(float a,b,fuzz,x)
{
    return(smooth(a-fuzz,a,x)-smooth(b-fuzz,b,x));
}

surface
danLmodel  (
        vector clr={0,1,0};
        float multdan 1;
        float diff 1;
        float spec 1;
        float amb 0.1;
    float rough 0.1;
    string lmodel "0";
        )
{
    vector dan_noise;
    vector Nn normalize(N);
    vector In normalize(I);
    vector Nf frontface(NnI);    
    vector tpos wo_space(P);

        dan_noise snoise(tpos)*(clr);
        vector opac dan_noise;
        vector newcolr multdan*dan_noise;

    Cf =  newcolr;
        Of =  opac;
    Cf *= Of;

    if (lmodel == "0"Cf += amb ambient() + diff diffuse(Nf);
    if (lmodel == "1"Cf += amb ambient() + diff diffuse(Nf) + spec phong(Nf, -In1.0/rough);
    if (lmodel == "2"Cf += amb ambient() + diff diffuse(Nf) + spec blinn(Nf, -Inrough);

       

}




Downloads:
Download: danlmodel.vfl 1 KB

Please login or Click Here to register for downloads
Creative Commons License
Light Model Switch 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