Updated texturemapping code for speed optimization.