First off I am new at this so let me know if I am already in over my head. I wanted to make a shader to round the corner on a cube. Looking for information on the internet I found someone that had already done this. I took the time to convince myself of why it should work but when I tried it out it did not round the edges but instead rounded the center lines of the cube in the shape of a plus and did not touch the edges. Can anyone look at this and tell if it is a shader code error or a user error
/*
* round(): displace the edege of a bilinear patch so that, if it is
* placed next to another patch at a right angle, the edge will be
* rounded.
*/
displacement
round(
float radius = .10)
{
float uu, vv, lu, lv;
point center, dpdu, dpdv;
if (u < .5)
{
uu = u;
dpdu = dPdu;
}
else
{
uu = 1 - u;
dpdu = -dPdu;
}
if (v < .5)
{
vv = v;
dpdv = dPdv;
}
else
{
vv = 1 - v;
dpdv = -dPdv;
}
lu = length(dPdu*uu);
lv = length(dPdv*vv);
if (lu < radius || lv < radius)
{
center = point(0, 0, 0);
if (lu < radius)
{
center = (radius-lu)*normalize(dpdu);
}
if (lv < radius)
{
center += (radius-lv)*normalize(dpdv);
}
center += P - radius*normalize(N);
P = center + radius*normalize(P-center);
}
N = calculatenormal(P);
}
never mind, I was using polys not nurbs. I get it now