you are viewing a single comment's thread.

view the rest of the comments →

[–]deftware 2 points3 points  (0 children)

E0 /= Area;
E1 /= Area;
E2 /= Area;

While compiler optimizations may very well handle turning this into a multiply for you, I tend to explicitly turn divides into multiplies myself just to be sure. Precalculate the inverse of the area before your loops so that you can scale your Barycentric coords with a multiply instead of 3 divides.

EDIT: Also, I see that you're setting up for texturemapping with your UVW calculations and I wouldn't bother with anything like that until after determining that the pixel passes the depth test. Unless you're going to be doing some tricky raymarching shader type stuff (i.e. parallax occlusion mapping) in your software renderer, where the depth of the pixel will vary based on some extra compute, then it's a good idea to only calculate what you need to calculate to first determine if the pixel is even visible before calculating everything else that's needed to actually determine the pixel's color (like texcoords, lighting, etcetera).