|
|
|
|
|
|
return PolygonRadiance(L, twoSided); |
|
|
|
} |
|
|
|
|
|
|
|
float LineFpo(float l, float rcpD, float rcpDL) |
|
|
|
float LineFpo(float tLDDL, float lrcpD, float rcpD) |
|
|
|
// Compute: l / d / (d * d + l * l) + 1.0 / (d * d) * atan(l / d). |
|
|
|
return l * rcpDL + sq(rcpD) * atan(l * rcpD); |
|
|
|
// Compute: ((l / d) / (d * d + l * l)) + (1.0 / (d * d)) * atan(l / d). |
|
|
|
return tLDDL + sq(rcpD) * atan(lrcpD); |
|
|
|
float LineFwt(float sqL, float rcpDL) |
|
|
|
float LineFwt(float tLDDL, float l) |
|
|
|
// Compute: l * l / d / (d * d + l * l). |
|
|
|
return sqL * rcpDL; |
|
|
|
// Compute: l * ((l / d) / (d * d + l * l)). |
|
|
|
return l * tLDDL; |
|
|
|
} |
|
|
|
|
|
|
|
// Computes the integral of the clamped cosine over the line segment. |
|
|
|
|
|
|
// the shaded point and the line, pointing away from the shaded point. |
|
|
|
float LineIrradiance(float l1, float l2, float3 normal, float3 tangent) |
|
|
|
{ |
|
|
|
float dist = length(normal); |
|
|
|
float rcpDL1 = rcp(dist) * rcp(sq(dist) + sq(l1)); |
|
|
|
float rcpDL2 = rcp(dist) * rcp(sq(dist) + sq(l2)); |
|
|
|
float intP0 = LineFpo(l2, rcp(dist), rcpDL2) - LineFpo(l1, rcp(dist), rcpDL1); |
|
|
|
float intWt = LineFwt(sq(l2), rcpDL2) - LineFwt(sq(l1), rcpDL1); |
|
|
|
float d = length(normal); |
|
|
|
float l1rcpD = l1 * rcp(d); |
|
|
|
float l2rcpD = l2 * rcp(d); |
|
|
|
float tLDDL1 = l1rcpD * rcp(sq(d) + sq(l1)); |
|
|
|
float tLDDL2 = l2rcpD * rcp(sq(d) + sq(l2)); |
|
|
|
float intWt = LineFwt(tLDDL2, l2) - LineFwt(tLDDL1, l1); |
|
|
|
float intP0 = LineFpo(tLDDL2, l2rcpD, rcp(d)) - LineFpo(tLDDL1, l1rcpD, rcp(d)); |
|
|
|
return intP0 * normal.z + intWt * tangent.z; |
|
|
|
} |
|
|
|
|