From bf054c32ed300cb73abeb9db379b86e68e5f9767 Mon Sep 17 00:00:00 2001 From: zeromus Date: Sat, 31 Jan 2009 04:01:10 +0000 Subject: [PATCH] fix vertex source texcoord generation (fixes environment mapping e.g. stars in sm64); this is a low risk fix and could be safely ported into release branch --- desmume/src/gfx3d.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/desmume/src/gfx3d.cpp b/desmume/src/gfx3d.cpp index 48384cfac..405059d39 100644 --- a/desmume/src/gfx3d.cpp +++ b/desmume/src/gfx3d.cpp @@ -916,10 +916,11 @@ void gfx3d_glNormal(unsigned long v) if (texCoordinateTransform == 2) { - last_s =( (normal[0] *mtxCurrent[3][0] + normal[1] *mtxCurrent[3][4] + - normal[2] *mtxCurrent[3][8]) + _s); - last_t =( (normal[0] *mtxCurrent[3][1] + normal[1] *mtxCurrent[3][5] + - normal[2] *mtxCurrent[3][9]) + _t); + float normal_fixed[3] = {normal[0]/8,normal[1]/8,normal[2]/8}; + last_s =( (normal_fixed[0] *mtxCurrent[3][0] + normal_fixed[1] *mtxCurrent[3][4] + + normal_fixed[2] *mtxCurrent[3][8]) + _s); + last_t =( (normal_fixed[0] *mtxCurrent[3][1] + normal_fixed[1] *mtxCurrent[3][5] + + normal_fixed[2] *mtxCurrent[3][9]) + _t); }