void RasGouraud::RasterizePixel( SScanLine& scanLine, const SScanLinesData& rasData ) { #if USE_PERSPEC_CORRECT == 1 //双曲插值最后一步 float inv_w = 1 / scanLine.zw.y; scanLine.pixelColor.Set(scanLine.curClr.x*inv_w, scanLine.curClr.y*inv_w, scanLine.curClr.z*inv_w); #else scanLine.pixelColor = scanLine.curClr; #endif scanLine.pixelColor.Saturate(); DWORD& dwDestColor = *scanLine.pFragmeng->finalColor; #if USE_OIT == 0 SColor destPixelColor; destPixelColor.SetAsInt(dwDestColor); DoAlphaBlending(destPixelColor, scanLine.pixelColor, destPixelColor, rasData.pMaterial); dwDestColor = destPixelColor.GetAsInt(); #else scanLine.pixelColor.a *= rasData.pMaterial->transparency; dwDestColor = scanLine.pixelColor.GetAsInt(); #endif #if USE_PROFILER == 1 g_env.profiler->AddRenderedPixel(); #endif }
void RasNormalMap::FragmentPS( SFragment& frag ) { SColor texColor(SColor::WHITE), lightColor(SColor::WHITE); SMaterial* pMaterial = frag.pMaterial; if(pMaterial->pDiffuseMap && pMaterial->bUseBilinearSampler) { pMaterial->pDiffuseMap->Tex2D_Bilinear(frag.uv, texColor, frag.texLod); } else if(pMaterial->pDiffuseMap) { pMaterial->pDiffuseMap->Tex2D_Point(frag.uv, texColor, frag.texLod); } SLightingContext_NormalMap lc; lc.uv = &frag.uv; lc.lightDirTS = &frag.lightDirTS; lc.hVectorTS = &frag.hVectorTS; DoPerPixelLighting(lightColor, &lc, pMaterial); // Don't modify alpha [1/19/2014 mavaL] float alpha = texColor.a; texColor *= lightColor; texColor.a = alpha; texColor.Saturate(); DWORD& dwDestColor = *frag.finalColor; #if USE_OIT == 0 SColor destPixelColor; destPixelColor.SetAsInt(dwDestColor); DoAlphaBlending(destPixelColor, texColor, destPixelColor, pMaterial); dwDestColor = destPixelColor.GetAsInt(); #else texColor.a *= pMaterial->transparency; dwDestColor = texColor.GetAsInt(); #endif #if USE_PROFILER == 1 g_env.profiler->AddRenderedPixel(); #endif }
void RasLightMap::RasterizePixel( SScanLine& scanLine, const SScanLinesData& rasData ) { #if USE_PERSPEC_CORRECT == 1 //双曲插值最后一步 float inv_w = 1 / scanLine.zw.y; scanLine.finalUV.Set(scanLine.curUV.x*inv_w, scanLine.curUV.y*inv_w); #else scanLine.finalUV = scanLine.curUV; #endif if(rasData.pMaterial->bUseBilinearSampler) { rasData.pMaterial->pDiffuseMap->Tex2D_Bilinear(scanLine.finalUV, scanLine.pixelColor, rasData.texLod); } else { rasData.pMaterial->pDiffuseMap->Tex2D_Point(scanLine.finalUV, scanLine.pixelColor, rasData.texLod); } DWORD& dwDestColor = *(scanLine.pFragmeng->finalColor); #if USE_OIT == 0 SColor destPixelColor; destPixelColor.SetAsInt(dwDestColor); DoAlphaBlending(destPixelColor, scanLine.pixelColor, destPixelColor, rasData.pMaterial); dwDestColor = destPixelColor.GetAsInt(); #else scanLine.pixelColor.a *= rasData.pMaterial->transparency; dwDestColor = scanLine.pixelColor.GetAsInt(); #endif #if USE_PROFILER == 1 g_env.profiler->AddRenderedPixel(); #endif }