Alpha Para-Perp
eharetea

Some VEX utilizing the para and perp parameters within a surface shader.

A .vfl file that creates an alpha para-perp effect for a surface shader.

Date Created:Friday December 29th, 2006 03:41 AM
Date Modified:Tuesday July 29th, 2008 09:38 PM

Alpha Para-Perp - test.3daet.com

Alpha Para-Perp - test.3daet.com


/*
*
* Author: Dan Lynch
*
*/

#pragma hint Ka color
#pragma hint Kd color
#pragma hint Ks color
#pragma hint map file

#pragma group Color Ka Kd Ks roughness
#pragma group Texture map

#pragma label map "Texture Map"
#pragma label Ka "Ambient"
#pragma label Kd "Diffuse"
#pragma label Ks "Specular"
#pragma label roughness "Roughness"

surface
d_paraperp
        (
        vector Ka=1Kd=1Ks=1;
        float apara=1aperp=0aroll=1roughness .1;
        string map "Mandril.pic";
        export vector uv=0;
        )
{

        vector Cd 1;
        float  Alpha 1;
        vector rest 0;

        float u 0;
        float V 0;
      
        if (!isbound("uv")) {
                s;
                t;
        } else {
                getcomp(uv,0);
                getcomp(uv,1);
        }

        vector Nn normalize(N);
        vector In normalize(I);
        vector Nf frontface(Nn,In);

        if (map != "") {
                vector tmap vector (texture(map,u,V));
        }

        float alpha=0;
        if (apara || aperp 1)
             alpha lerp(aperpaparapow(dot(Nf,-In), 1.0/aroll));
        else alpha 1;

        alpha  *= Alpha;
        Cf Cd;
        Cf += ambient(Nn,In)*Ka;
        Cf += diffuse(NnIn)*Kd;
        Cf += specular(Nn,-In,roughness)*Ks;

        if (map != "") {
                Cf *= tmap;
        }

        if (!isshadowray()) {
                Of 1;
                Cf += (Af);
                Af += (Af);
        } 

        Of *= alpha;
        Cf *= alpha;
        Af *= alpha;
}




Downloads:
Download: alpha_para-perp.vfl 2 KB

Please login or Click Here to register for downloads
Creative Commons License
Alpha Para-Perp 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