From 0340f67a5fe2861b74ecf8ec694d0f7a48513478 Mon Sep 17 00:00:00 2001 From: zeromus Date: Sat, 20 Jun 2009 19:27:22 +0000 Subject: [PATCH] rasterize: fix toon shading when no texture is set (mario kart star powerup) --- desmume/src/rasterize.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/desmume/src/rasterize.cpp b/desmume/src/rasterize.cpp index 1a805024d..956b3bae2 100644 --- a/desmume/src/rasterize.cpp +++ b/desmume/src/rasterize.cpp @@ -389,15 +389,26 @@ struct Shader u = invu*w; v = invv*w; texColor = sampler.sample(u,v); - u32 toonColorVal; toonColorVal = gfx3d.rgbToonTable[materialColor.r]; + u32 toonColorVal; + toonColorVal = gfx3d.rgbToonTable[materialColor.r]; FragmentColor toonColor; toonColor.r = ((toonColorVal & 0x0000FF) >> 3); toonColor.g = ((toonColorVal & 0x00FF00) >> 11); toonColor.b = ((toonColorVal & 0xFF0000) >> 19); - dst.r = modulate_table[texColor.r][toonColor.r]; - dst.g = modulate_table[texColor.g][toonColor.g]; - dst.b = modulate_table[texColor.b][toonColor.b]; - dst.a = modulate_table[texColor.a][materialColor.a]; + if(sampler.texFormat == 0) + { + //if no texture is set then we dont need to modulate texture with toon + //but rather just use toon directly + dst = toonColor; + dst.a = materialColor.a; + } + else + { + dst.r = modulate_table[texColor.r][toonColor.r]; + dst.g = modulate_table[texColor.g][toonColor.g]; + dst.b = modulate_table[texColor.b][toonColor.b]; + dst.a = modulate_table[texColor.a][materialColor.a]; + } if(gfx3d.shading == GFX3D::HIGHLIGHT) { dst.r = min(31, (dst.r + toonColor.r));