Tuesday, June 15, 2010

dPds works !

This was posted on the renderman forums, so i'm pretty sure its common knowledge.
Basically if you are in need of a consistent local basis transform for the usual stuff like normal maps and mapped anisotropic direction, you'll need a reliable tangent vector, sometimes referred to (by me, mainly) as dPds.

The RSL code is as follows:


void dPdst( float ss,tt; point PP;
output varying vector dPds;
output varying vector dPdt; )
{
float Dus = Du(ss);
float Dut = Du(tt);
float Dvs = Dv(ss);
float Dvt = Dv(tt);
vector DuP = Du(PP);
vector DvP = Dv(PP);
float det = (Dus*Dvt-Dvs*Dut);
dPds = (DuP*Dvt - DvP*Dut) / det;
dPdt = (DvP*Dus - DuP*Dvs) / det;
}

No comments: