viewing angle + distance to colorcode

Hi,

I would like to encode the distance and viewing angle as a “fragment” color. I copy/pasted myself an osl-script, but I keep getting a Segmentation Fault Crash. Any help?

shader visibility(                output color Col = (0.0))
{
    vector E;  
    getattribute("Empty","object:location",E); 
    P=transform("object","world",P);
    point dir = E-P;
    float dist = 1./length(dir);
    float angle = max(0.0, dot(N, dir));
    float value = (dist+angle)/4.;
    color c = color(value, 1., 1.);
    Col = transformc("rgb", "hsv", c);
}

EDIT: sorry for missing that one: http://www.blenderartists.org/forum/showthread.php?291923-OSL-getattribute()-Crash