Definition in file texture_far.cpp.
#include "std3d.h"
#include "3d/texture_far.h"
#include "3d/tile_far_bank.h"
#include "3d/patch.h"
#include "3d/tile_color.h"
#include "3d/zone.h"
#include "3d/landscape.h"
#include "nel/misc/system_info.h"
Go to the source code of this file.
|
Definition at line 1342 of file texture_far.cpp. Referenced by NL3D_expandLightmap().
01344 { 01345 } |
|
Definition at line 1346 of file texture_far.cpp. Referenced by NL3D_expandLightmap().
01348 { 01349 } |
|
Definition at line 1350 of file texture_far.cpp. Referenced by NL3D_expandLightmap().
01352 { 01353 } |
|
Definition at line 1341 of file texture_far.cpp. References index, len, and uint. Referenced by NL3D_expandLightmap().
01341 {} |
|
Definition at line 1338 of file texture_far.cpp. Referenced by NL3D_drawFarTileInFarTexture(), NL3D_drawFarTileInFarTextureAlpha(), and NL3D_expandLightmap().
01338 {} |
|
Definition at line 1339 of file texture_far.cpp. References len, src, uint, and uint16. Referenced by NL3D_expandLightmap().
01339 {} |
|
Definition at line 1340 of file texture_far.cpp. References len, src, and uint. Referenced by NL3D_expandLightmap().
01340 {} |
|
Definition at line 1845 of file texture_far.cpp. Referenced by NL3D_drawFarTileInFarTextureAlpha().
01847 { 01848 } |
|
Definition at line 1841 of file texture_far.cpp. Referenced by NL3D_drawFarTileInFarTexture().
01843 { 01844 } |
|
Definition at line 1853 of file texture_far.cpp. References NL3D_CComputeTileFar::AsmMMX, NLMISC::CRGBA::B, NL3D_CComputeTileFar::DstDeltaX, NL3D_CComputeTileFar::DstDeltaY, NL3D_CComputeTileFar::DstPixels, NLMISC::CRGBA::G, NL3D_asmEndMMX(), NL3D_asmModulateLineColors(), NLMISC::CRGBA::R, NL3D_CComputeTileFar::Size, NL3D_CComputeTileFar::SrcDeltaX, NL3D_CComputeTileFar::SrcDeltaY, NL3D_CComputeTileFar::SrcDiffusePixels, NL3D_CComputeTileFar::SrcLightingDeltaY, NL3D_CComputeTileFar::SrcLightingPixels, uint, uint8, x, and y. Referenced by NL3D::CTextureFar::rebuildPatch().
01854 { 01855 // Pointer of the Src diffuse pixels 01856 const CRGBA* pSrcPixels=pTileFar->SrcDiffusePixels; 01857 01858 // Pointer of the Dst pixels 01859 const CRGBA* pSrcLightPixels=pTileFar->SrcLightingPixels; 01860 01861 // Pointer of the Dst pixels 01862 CRGBA* pDstPixels=pTileFar->DstPixels; 01863 01864 // For each pixels 01865 int x, y; 01866 for (y=0; y<pTileFar->Size; y++) 01867 { 01868 // MMX implementation 01869 //--------- 01870 if(pTileFar->AsmMMX) 01871 { 01872 NL3D_asmModulateLineColors(pDstPixels, pSrcPixels, pSrcLightPixels, 01873 pTileFar->Size, pTileFar->SrcDeltaX, pTileFar->DstDeltaX); 01874 } 01875 // C Implementation. 01876 //--------- 01877 else 01878 { 01879 // Pointer of the source line 01880 const CRGBA* pSrcLine=pSrcPixels; 01881 01882 // Pointer of the source lighting line 01883 const CRGBA* pSrcLightingLine=pSrcLightPixels; 01884 01885 // Pointer of the destination line 01886 CRGBA* pDstLine=pDstPixels; 01887 01888 // For each pixels on the line 01889 for (x=0; x<pTileFar->Size; x++) 01890 { 01891 // Read and write a pixel 01892 pDstLine->R=(uint8)(((uint)pSrcLine->R*(uint)pSrcLightingLine->R)>>8); 01893 pDstLine->G=(uint8)(((uint)pSrcLine->G*(uint)pSrcLightingLine->G)>>8); 01894 pDstLine->B=(uint8)(((uint)pSrcLine->B*(uint)pSrcLightingLine->B)>>8); 01895 01896 // Next pixel 01897 pSrcLine+=pTileFar->SrcDeltaX; 01898 pSrcLightingLine++; 01899 pDstLine+=pTileFar->DstDeltaX; 01900 } 01901 } 01902 01903 // Next line 01904 pSrcPixels+=pTileFar->SrcDeltaY; 01905 pSrcLightPixels+=pTileFar->SrcLightingDeltaY; 01906 pDstPixels+=pTileFar->DstDeltaY; 01907 } 01908 01909 // stop MMX if used 01910 if(pTileFar->AsmMMX) 01911 NL3D_asmEndMMX(); 01912 } |
|
Definition at line 1983 of file texture_far.cpp. References NLMISC::CRGBA::B, NL3D_CComputeTileFar::DstDeltaX, NL3D_CComputeTileFar::DstDeltaY, NL3D_CComputeTileFar::DstPixels, NLMISC::CRGBA::G, NLMISC::CRGBA::R, NL3D_CComputeTileFar::Size, NL3D_CComputeTileFar::SrcAdditivePixels, NL3D_CComputeTileFar::SrcDeltaX, NL3D_CComputeTileFar::SrcDeltaY, NL3D_CComputeTileFar::SrcDiffusePixels, NL3D_CComputeTileFar::SrcLightingDeltaY, NL3D_CComputeTileFar::SrcLightingPixels, uint, uint8, x, and y. Referenced by NL3D::CTextureFar::rebuildPatch().
01984 { 01985 // Pointer of the Src diffuse pixels 01986 const CRGBA* pSrcPixels=pTileFar->SrcDiffusePixels; 01987 01988 // Pointer of the Src additive pixels 01989 const CRGBA* pSrcAddPixels=pTileFar->SrcAdditivePixels; 01990 01991 // Pointer of the Dst pixels 01992 const CRGBA* pSrcLightPixels=pTileFar->SrcLightingPixels; 01993 01994 // Pointer of the Dst pixels 01995 CRGBA* pDstPixels=pTileFar->DstPixels; 01996 01997 // For each pixels 01998 int x, y; 01999 for (y=0; y<pTileFar->Size; y++) 02000 { 02001 // Pointer of the source line 02002 const CRGBA* pSrcLine=pSrcPixels; 02003 02004 // Pointer of the source line 02005 const CRGBA* pSrcAddLine=pSrcAddPixels; 02006 02007 // Pointer of the source lighting line 02008 const CRGBA* pSrcLightingLine=pSrcLightPixels; 02009 02010 // Pointer of the destination line 02011 CRGBA* pDstLine=pDstPixels; 02012 02013 // For each pixels on the line 02014 for (x=0; x<pTileFar->Size; x++) 02015 { 02016 // Read and write a pixel 02017 uint nTmp=(((uint)pSrcLine->R*(uint)pSrcLightingLine->R)>>8)+(uint)pSrcAddLine->R; 02018 if (nTmp>255) 02019 nTmp=255; 02020 pDstLine->R=(uint8)nTmp; 02021 nTmp=(((uint)pSrcLine->G*(uint)pSrcLightingLine->G)>>8)+(uint)pSrcAddLine->G; 02022 if (nTmp>255) 02023 nTmp=255; 02024 pDstLine->G=(uint8)nTmp; 02025 nTmp=(((uint)pSrcLine->B*(uint)pSrcLightingLine->B)>>8)+(uint)pSrcAddLine->B; 02026 if (nTmp>255) 02027 nTmp=255; 02028 pDstLine->B=(uint8)nTmp; 02029 02030 // Next pixel 02031 pSrcLine+=pTileFar->SrcDeltaX; 02032 pSrcAddLine+=pTileFar->SrcDeltaX; 02033 pSrcLightingLine++; 02034 pDstLine+=pTileFar->DstDeltaX; 02035 } 02036 02037 // Next line 02038 pSrcPixels+=pTileFar->SrcDeltaY; 02039 pSrcAddPixels+=pTileFar->SrcDeltaY; 02040 pSrcLightPixels+=pTileFar->SrcLightingDeltaY; 02041 pDstPixels+=pTileFar->DstDeltaY; 02042 } 02043 } |
|
Definition at line 2050 of file texture_far.cpp. References NLMISC::CRGBA::A, alpha, NLMISC::CRGBA::B, NL3D_CComputeTileFar::DstDeltaX, NL3D_CComputeTileFar::DstDeltaY, NL3D_CComputeTileFar::DstPixels, NLMISC::CRGBA::G, NLMISC::CRGBA::R, NL3D_CComputeTileFar::Size, NL3D_CComputeTileFar::SrcAdditivePixels, NL3D_CComputeTileFar::SrcDeltaX, NL3D_CComputeTileFar::SrcDeltaY, NL3D_CComputeTileFar::SrcDiffusePixels, NL3D_CComputeTileFar::SrcLightingDeltaY, NL3D_CComputeTileFar::SrcLightingPixels, uint, uint8, x, and y. Referenced by NL3D::CTextureFar::rebuildPatch().
02051 { 02052 // Pointer of the Src pixels 02053 const CRGBA* pSrcPixels=pTileFar->SrcDiffusePixels; 02054 02055 // Pointer of the Src pixels 02056 const CRGBA* pSrcAddPixels=pTileFar->SrcAdditivePixels; 02057 02058 // Pointer of the Dst pixels 02059 const CRGBA* pSrcLightPixels=pTileFar->SrcLightingPixels; 02060 02061 // Pointer of the Dst pixels 02062 CRGBA* pDstPixels=pTileFar->DstPixels; 02063 02064 // Fill the buffer with layer 0 02065 int x, y; 02066 for (y=0; y<pTileFar->Size; y++) 02067 { 02068 // Pointer of the source line 02069 const CRGBA* pSrcLine=pSrcPixels; 02070 02071 // Pointer of the source line 02072 const CRGBA* pSrcAddLine=pSrcAddPixels; 02073 02074 // Pointer of the source lighting line 02075 const CRGBA* pSrcLightingLine=pSrcLightPixels; 02076 02077 // Pointer of the Dst pixels 02078 CRGBA* pDstLine=pDstPixels; 02079 02080 // For each pixels on the line 02081 for (x=0; x<pTileFar->Size; x++) 02082 { 02083 // Read and write a pixel 02084 register uint alpha=pSrcLine->A; 02085 register uint oneLessAlpha=255-pSrcLine->A; 02086 02087 // Read and write a pixel 02088 uint nTmp=(((uint)pSrcLine->R*(uint)pSrcLightingLine->R)>>8)+(uint)pSrcAddLine->R; 02089 if (nTmp>255) 02090 nTmp=255; 02091 pDstLine->R=(uint8)((nTmp*alpha+pDstLine->R*oneLessAlpha)>>8); 02092 nTmp=(((uint)pSrcLine->G*(uint)pSrcLightingLine->G)>>8)+(uint)pSrcAddLine->G; 02093 if (nTmp>255) 02094 nTmp=255; 02095 pDstLine->G=(uint8)((nTmp*alpha+pDstLine->G*oneLessAlpha)>>8); 02096 nTmp=(((uint)pSrcLine->B*(uint)pSrcLightingLine->B)>>8)+(uint)pSrcAddLine->B; 02097 if (nTmp>255) 02098 nTmp=255; 02099 pDstLine->B=(uint8)((nTmp*alpha+pDstLine->B*oneLessAlpha)>>8); 02100 02101 // Next pixel 02102 pSrcLine+=pTileFar->SrcDeltaX; 02103 pSrcAddLine+=pTileFar->SrcDeltaX; 02104 pSrcLightingLine++; 02105 pDstLine+=pTileFar->DstDeltaX; 02106 } 02107 02108 // Next line 02109 pSrcPixels+=pTileFar->SrcDeltaY; 02110 pSrcAddPixels+=pTileFar->SrcDeltaY; 02111 pSrcLightPixels+=pTileFar->SrcLightingDeltaY; 02112 pDstPixels+=pTileFar->DstDeltaY; 02113 } 02114 } |
|
Definition at line 1916 of file texture_far.cpp. References NLMISC::CRGBA::A, alpha, NL3D_CComputeTileFar::AsmMMX, NLMISC::CRGBA::B, NL3D_CComputeTileFar::DstDeltaX, NL3D_CComputeTileFar::DstDeltaY, NL3D_CComputeTileFar::DstPixels, NLMISC::CRGBA::G, NL3D_asmEndMMX(), NL3D_asmModulateAndBlendLineColors(), NLMISC::CRGBA::R, NL3D_CComputeTileFar::Size, NL3D_CComputeTileFar::SrcDeltaX, NL3D_CComputeTileFar::SrcDeltaY, NL3D_CComputeTileFar::SrcDiffusePixels, NL3D_CComputeTileFar::SrcLightingDeltaY, NL3D_CComputeTileFar::SrcLightingPixels, uint, uint8, x, and y. Referenced by NL3D::CTextureFar::rebuildPatch().
01917 { 01918 // Pointer of the Src pixels 01919 const CRGBA* pSrcPixels=pTileFar->SrcDiffusePixels; 01920 01921 // Pointer of the Dst pixels 01922 const CRGBA* pSrcLightPixels=pTileFar->SrcLightingPixels; 01923 01924 // Pointer of the Dst pixels 01925 CRGBA* pDstPixels=pTileFar->DstPixels; 01926 01927 // Fill the buffer with layer 0 01928 int x, y; 01929 for (y=0; y<pTileFar->Size; y++) 01930 { 01931 // MMX implementation 01932 //--------- 01933 if(pTileFar->AsmMMX) 01934 { 01935 NL3D_asmModulateAndBlendLineColors(pDstPixels, pSrcPixels, pSrcLightPixels, 01936 pTileFar->Size, pTileFar->SrcDeltaX, pTileFar->DstDeltaX); 01937 } 01938 // C Implementation. 01939 //--------- 01940 else 01941 { 01942 // Pointer of the source line 01943 const CRGBA* pSrcLine=pSrcPixels; 01944 01945 // Pointer of the source lighting line 01946 const CRGBA* pSrcLightingLine=pSrcLightPixels; 01947 01948 // Pointer of the Dst pixels 01949 CRGBA* pDstLine=pDstPixels; 01950 01951 // For each pixels on the line 01952 for (x=0; x<pTileFar->Size; x++) 01953 { 01954 // Read and write a pixel 01955 register uint alpha=pSrcLine->A; 01956 register uint oneLessAlpha=255-pSrcLine->A; 01957 pDstLine->R=(uint8)(((((uint)pSrcLine->R*(uint)pSrcLightingLine->R)>>8)*alpha+(uint)pDstLine->R*oneLessAlpha)>>8); 01958 pDstLine->G=(uint8)(((((uint)pSrcLine->G*(uint)pSrcLightingLine->G)>>8)*alpha+(uint)pDstLine->G*oneLessAlpha)>>8); 01959 pDstLine->B=(uint8)(((((uint)pSrcLine->B*(uint)pSrcLightingLine->B)>>8)*alpha+(uint)pDstLine->B*oneLessAlpha)>>8); 01960 01961 // Next pixel 01962 pSrcLine+=pTileFar->SrcDeltaX; 01963 pSrcLightingLine++; 01964 pDstLine+=pTileFar->DstDeltaX; 01965 } 01966 } 01967 01968 // Next line 01969 pSrcPixels+=pTileFar->SrcDeltaY; 01970 pSrcLightPixels+=pTileFar->SrcLightingDeltaY; 01971 pDstPixels+=pTileFar->DstDeltaY; 01972 } 01973 01974 // stop MMX if used 01975 if(pTileFar->AsmMMX) 01976 NL3D_asmEndMMX(); 01977 } |
|
Definition at line 1359 of file texture_far.cpp. References NLMISC::CRGBA::addRGBOnly(), NLMISC::CRGBA::B, NLMISC::CRGBA::blendFromui(), NL3D::CTileColor::Color565, NL3D_CExpandLightmap::ColorTile, NL3D_CExpandLightmap::DstPixels, NLMISC::CRGBA::G, NL3D_CExpandLightmap::Height, index, NL3D_CExpandLightmap::LumelTile, min, NLMISC::CRGBA::modulateFromColorRGBOnly(), NL3D_CExpandLightmap::MulFactor, NL3D_asmAssembleShading1x1(), NL3D_asmAssembleShading2x2(), NL3D_asmAssembleShading4x4(), NL3D_asmBlendLines(), NL3D_asmEndMMX(), NL3D_asmExpandLineColor565(), NL3D_asmExpandLineColor8888(), NL_LUMEL_BY_TILE, NL_MAX_TILES_BY_PATCH_EDGE, nlassert, NLMISC::CRGBA::R, NLMISC::CRGBA::set565(), NL3D_CExpandLightmap::StaticLightColor, NL3D_CExpandLightmap::TLIColor, uint, uint8, v, and NL3D_CExpandLightmap::Width. Referenced by NL3D::CTextureFar::rebuildPatch().
01360 { 01361 bool asmMMX= false; 01362 #ifdef NL_OS_WINDOWS 01363 asmMMX= CSystemInfo::hasMMX(); 01364 // A CTileColor must be a 565 only. 01365 nlassert(sizeof(CTileColor)==2); 01366 #endif 01367 01368 // Expanded width 01369 uint dstWidth=(pLightmap->Width-1)*pLightmap->MulFactor; 01370 uint dstHeight=(pLightmap->Height-1)*pLightmap->MulFactor; 01371 01372 // *** First expand user color and TLI colors 01373 // First pass, expand on U 01374 static CRGBA expandedUserColorLine[ (NL_MAX_TILES_BY_PATCH_EDGE+1)* 01375 (NL_MAX_TILES_BY_PATCH_EDGE+1)*NL_LUMEL_BY_TILE ]; 01376 static CRGBA expandedTLIColorLine[ (NL_MAX_TILES_BY_PATCH_EDGE+1)* 01377 (NL_MAX_TILES_BY_PATCH_EDGE+1)*NL_LUMEL_BY_TILE ]; 01378 // Second pass, expand on V. 01379 static CRGBA expandedUserColor[ (NL_MAX_TILES_BY_PATCH_EDGE+1)*NL_LUMEL_BY_TILE * 01380 (NL_MAX_TILES_BY_PATCH_EDGE+1)*NL_LUMEL_BY_TILE ]; 01381 static CRGBA expandedTLIColor[ (NL_MAX_TILES_BY_PATCH_EDGE+1)*NL_LUMEL_BY_TILE * 01382 (NL_MAX_TILES_BY_PATCH_EDGE+1)*NL_LUMEL_BY_TILE ]; 01383 01384 01385 // ** Expand on U 01386 //========= 01387 uint u, v; 01388 01389 // Expansion factor 01390 uint expandFactor=((pLightmap->Width-1)<<8)/(dstWidth-1); 01391 01392 // Destination pointer 01393 CRGBA *expandedUserColorLinePtr= expandedUserColorLine; 01394 CRGBA *expandedTLIColorLinePtr= expandedTLIColorLine; 01395 01396 // Source pointer 01397 const NL3D::CTileColor *colorTilePtr=pLightmap->ColorTile; 01398 const NLMISC::CRGBA *colorTLIPtr= pLightmap->TLIColor; 01399 01400 // Go for U 01401 for (v=0; v<pLightmap->Height; v++) 01402 { 01403 // First pixel 01404 expandedUserColorLinePtr[0].set565 (colorTilePtr[0].Color565); 01405 expandedTLIColorLinePtr[0]= colorTLIPtr[0]; 01406 01407 // MMX implementation. 01408 //------------- 01409 if(asmMMX) 01410 { 01411 NL3D_asmExpandLineColor565(&colorTilePtr->Color565, expandedUserColorLinePtr, expandFactor, dstWidth-2); 01412 NL3D_asmExpandLineColor8888(colorTLIPtr, expandedTLIColorLinePtr, expandFactor, dstWidth-2); 01413 } 01414 // C implementation 01415 //------------- 01416 else 01417 { 01418 // Index next pixel 01419 uint srcIndexPixel=expandFactor; 01420 01421 for (u=1; u<dstWidth-1; u++) 01422 { 01423 // Check 01424 nlassert ( (u+v*dstWidth) < (sizeof(expandedUserColorLine)/sizeof(CRGBA)) ); 01425 01426 // Color index 01427 uint srcIndex=srcIndexPixel>>8; 01428 nlassert (srcIndex>=0); 01429 nlassert (srcIndex<pLightmap->Width-1); 01430 01431 // Compute current color 01432 CRGBA color0; 01433 CRGBA color1; 01434 color0.set565 (colorTilePtr[srcIndex].Color565); 01435 color1.set565 (colorTilePtr[srcIndex+1].Color565); 01436 expandedUserColorLinePtr[u].blendFromui (color0, color1, srcIndexPixel&0xff); 01437 // Compute current TLI color 01438 color0= colorTLIPtr[srcIndex]; 01439 color1= colorTLIPtr[srcIndex+1]; 01440 expandedTLIColorLinePtr[u].blendFromui (color0, color1, srcIndexPixel&0xff); 01441 01442 // Next index 01443 srcIndexPixel+=expandFactor; 01444 } 01445 } 01446 01447 // Last pixel 01448 expandedUserColorLinePtr[dstWidth-1].set565 (colorTilePtr[pLightmap->Width-1].Color565); 01449 expandedTLIColorLinePtr[dstWidth-1]= colorTLIPtr[pLightmap->Width-1]; 01450 01451 // Next line 01452 expandedUserColorLinePtr+= dstWidth; 01453 expandedTLIColorLinePtr+= dstWidth; 01454 colorTilePtr+=pLightmap->Width; 01455 colorTLIPtr+=pLightmap->Width; 01456 } 01457 01458 // stop MMX if used 01459 if(asmMMX) 01460 NL3D_asmEndMMX(); 01461 01462 // ** Expand on V 01463 //========= 01464 01465 // Expansion factor 01466 expandFactor=((pLightmap->Height-1)<<8)/(dstHeight-1); 01467 01468 // Destination pointer 01469 CRGBA *expandedUserColorPtr= expandedUserColor; 01470 CRGBA *expandedTLIColorPtr= expandedTLIColor; 01471 01472 // Src pointer 01473 expandedUserColorLinePtr= expandedUserColorLine; 01474 expandedTLIColorLinePtr= expandedTLIColorLine; 01475 01476 // Copy first row 01477 memcpy(expandedUserColorPtr, expandedUserColorLinePtr, dstWidth*sizeof(CRGBA)); 01478 memcpy(expandedTLIColorPtr, expandedTLIColorLinePtr, dstWidth*sizeof(CRGBA)); 01479 01480 // Next line 01481 expandedUserColorPtr+=dstWidth; 01482 expandedTLIColorPtr+=dstWidth; 01483 01484 // Index next pixel 01485 uint indexPixel=expandFactor; 01486 01487 // Go for V 01488 for (v=1; v<dstHeight-1; v++) 01489 { 01490 // Color index 01491 uint index=indexPixel>>8; 01492 01493 // Source pointer 01494 CRGBA *colorTilePtr0= expandedUserColorLine + index*dstWidth; 01495 CRGBA *colorTilePtr1= expandedUserColorLine + (index+1)*dstWidth; 01496 CRGBA *colorTLIPtr0= expandedTLIColorLine + index*dstWidth; 01497 CRGBA *colorTLIPtr1= expandedTLIColorLine + (index+1)*dstWidth; 01498 01499 // MMX implementation. 01500 //------------- 01501 if(asmMMX) 01502 { 01503 NL3D_asmBlendLines(expandedUserColorPtr, colorTilePtr0, colorTilePtr1, indexPixel, dstWidth); 01504 NL3D_asmBlendLines(expandedTLIColorPtr, colorTLIPtr0, colorTLIPtr1, indexPixel, dstWidth); 01505 } 01506 // C implementation 01507 //------------- 01508 else 01509 { 01510 // Copy the row 01511 for (u=0; u<dstWidth; u++) 01512 { 01513 expandedUserColorPtr[u].blendFromui (colorTilePtr0[u], colorTilePtr1[u], indexPixel&0xff); 01514 expandedTLIColorPtr[u].blendFromui (colorTLIPtr0[u], colorTLIPtr1[u], indexPixel&0xff); 01515 } 01516 } 01517 01518 // Next index 01519 indexPixel+=expandFactor; 01520 01521 // Next line 01522 expandedUserColorPtr+=dstWidth; 01523 expandedTLIColorPtr+=dstWidth; 01524 } 01525 01526 // stop MMX if used 01527 if(asmMMX) 01528 NL3D_asmEndMMX(); 01529 01530 // Last row 01531 // Destination pointer 01532 expandedUserColorPtr= expandedUserColor + dstWidth*(dstHeight-1); 01533 expandedTLIColorPtr= expandedTLIColor + dstWidth*(dstHeight-1); 01534 // Src pointer 01535 expandedUserColorLinePtr= expandedUserColorLine + dstWidth*(pLightmap->Height-1); 01536 expandedTLIColorLinePtr= expandedTLIColorLine + dstWidth*(pLightmap->Height-1); 01537 01538 // Copy last row 01539 memcpy(expandedUserColorPtr, expandedUserColorLinePtr, dstWidth*sizeof(CRGBA)); 01540 memcpy(expandedTLIColorPtr, expandedTLIColorLinePtr, dstWidth*sizeof(CRGBA)); 01541 01542 // *** Now combine with shading 01543 //========= 01544 01545 // Switch to the optimal method for each expansion value 01546 switch (pLightmap->MulFactor) 01547 { 01548 case 1: 01549 { 01550 // Make 4x4 -> 1x1 blend 01551 CRGBA *lineUSCPtr= expandedUserColor; 01552 CRGBA *lineTLIPtr= expandedTLIColor; 01553 CRGBA *lineDestPtr=pLightmap->DstPixels; 01554 const uint8 *lineLumelPtr=pLightmap->LumelTile; 01555 uint lineWidth=dstWidth<<2; 01556 uint lineWidthx2=lineWidth<<1; 01557 uint lineWidthx3=lineWidthx2+lineWidth; 01558 uint lineWidthx4=lineWidth<<2; 01559 01560 // For each line 01561 for (v=0; v<dstHeight; v++) 01562 { 01563 // MMX implementation. 01564 //------------- 01565 if(asmMMX) 01566 { 01567 NL3D_asmAssembleShading1x1(lineLumelPtr, pLightmap->StaticLightColor, lineTLIPtr, lineUSCPtr, lineDestPtr, 01568 lineWidth, dstWidth); 01569 } 01570 // C implementation 01571 //------------- 01572 else 01573 { 01574 // For each lumel block 01575 for (u=0; u<dstWidth; u++) 01576 { 01577 // index 01578 uint lumelIndex=u<<2; 01579 01580 // Shading is filtred 01581 uint shading= 01582 ((uint)lineLumelPtr[lumelIndex]+(uint)lineLumelPtr[lumelIndex+1]+(uint)lineLumelPtr[lumelIndex+2]+(uint)lineLumelPtr[lumelIndex+3] 01583 +(uint)lineLumelPtr[lumelIndex+lineWidth]+(uint)lineLumelPtr[lumelIndex+1+lineWidth]+(uint)lineLumelPtr[lumelIndex+2+lineWidth]+(uint)lineLumelPtr[lumelIndex+3+lineWidth] 01584 +(uint)lineLumelPtr[lumelIndex+lineWidthx2]+(uint)lineLumelPtr[lumelIndex+1+lineWidthx2]+(uint)lineLumelPtr[lumelIndex+2+lineWidthx2]+(uint)lineLumelPtr[lumelIndex+3+lineWidthx2] 01585 +(uint)lineLumelPtr[lumelIndex+lineWidthx3]+(uint)lineLumelPtr[lumelIndex+1+lineWidthx3]+(uint)lineLumelPtr[lumelIndex+2+lineWidthx3]+(uint)lineLumelPtr[lumelIndex+3+lineWidthx3] 01586 )>>4; 01587 01588 // Add shading with TLI color. 01589 CRGBA col; 01590 col.addRGBOnly(pLightmap->StaticLightColor[shading], lineTLIPtr[u]); 01591 01592 // Mul by the userColor 01593 lineDestPtr[u].modulateFromColorRGBOnly(col, lineUSCPtr[u]); 01594 01595 lineDestPtr[u].R = min(((uint)lineDestPtr[u].R)*2, 255U); 01596 lineDestPtr[u].G = min(((uint)lineDestPtr[u].G)*2, 255U); 01597 lineDestPtr[u].B = min(((uint)lineDestPtr[u].B)*2, 255U); 01598 } 01599 } 01600 01601 // Next line 01602 lineUSCPtr+=dstWidth; 01603 lineTLIPtr+=dstWidth; 01604 lineDestPtr+=dstWidth; 01605 lineLumelPtr+=lineWidthx4; 01606 } 01607 break; 01608 } 01609 case 2: 01610 { 01611 // Make 2x2 -> 1x1 blend 01612 CRGBA *lineUSCPtr= expandedUserColor; 01613 CRGBA *lineTLIPtr= expandedTLIColor; 01614 CRGBA *lineDestPtr=pLightmap->DstPixels; 01615 const uint8 *lineLumelPtr=pLightmap->LumelTile; 01616 uint lineWidth=dstWidth*2; 01617 uint lineWidthx2=lineWidth<<1; 01618 01619 // For each line 01620 for (v=0; v<dstHeight; v++) 01621 { 01622 // MMX implementation. 01623 //------------- 01624 if(asmMMX) 01625 { 01626 NL3D_asmAssembleShading2x2(lineLumelPtr, pLightmap->StaticLightColor, lineTLIPtr, lineUSCPtr, lineDestPtr, 01627 lineWidth, dstWidth); 01628 } 01629 // C implementation 01630 //------------- 01631 else 01632 { 01633 // For each lumel block 01634 for (u=0; u<dstWidth; u++) 01635 { 01636 // index 01637 uint lumelIndex=u<<1; 01638 01639 // Shading is filtred 01640 uint shading= 01641 ((uint)lineLumelPtr[lumelIndex]+(uint)lineLumelPtr[lumelIndex+1]+(uint)lineLumelPtr[lumelIndex+lineWidth]+(uint)lineLumelPtr[lumelIndex+1+lineWidth])>>2; 01642 01643 // Add shading with TLI color. 01644 CRGBA col; 01645 col.addRGBOnly(pLightmap->StaticLightColor[shading], lineTLIPtr[u]); 01646 01647 // Mul by the userColor 01648 lineDestPtr[u].modulateFromColorRGBOnly(col, lineUSCPtr[u]); 01649 01650 lineDestPtr[u].R = min(((uint)lineDestPtr[u].R)*2, 255U); 01651 lineDestPtr[u].G = min(((uint)lineDestPtr[u].G)*2, 255U); 01652 lineDestPtr[u].B = min(((uint)lineDestPtr[u].B)*2, 255U); 01653 } 01654 } 01655 01656 // Next line 01657 lineUSCPtr+=dstWidth; 01658 lineTLIPtr+=dstWidth; 01659 lineDestPtr+=dstWidth; 01660 lineLumelPtr+=lineWidthx2; 01661 } 01662 break; 01663 } 01664 01665 case 4: 01666 // Make copy 01667 CRGBA *lineUSCPtr= expandedUserColor; 01668 CRGBA *lineTLIPtr= expandedTLIColor; 01669 CRGBA *lineDestPtr=pLightmap->DstPixels; 01670 const uint8 *lineLumelPtr=pLightmap->LumelTile; 01671 uint nbTexel=dstWidth*dstHeight; 01672 01673 // MMX implementation. 01674 //------------- 01675 if(asmMMX) 01676 { 01677 NL3D_asmAssembleShading4x4(lineLumelPtr, pLightmap->StaticLightColor, lineTLIPtr, lineUSCPtr, lineDestPtr, 01678 nbTexel); 01679 } 01680 // C implementation 01681 //------------- 01682 else 01683 { 01684 // For each pixel 01685 for (u=0; u<nbTexel; u++) 01686 { 01687 // Shading is filtred 01688 uint shading=lineLumelPtr[u]; 01689 01690 // Add shading with TLI color. 01691 CRGBA col; 01692 col.addRGBOnly(pLightmap->StaticLightColor[shading], lineTLIPtr[u]); 01693 01694 // Mul by the userColor 01695 lineDestPtr[u].modulateFromColorRGBOnly(col, lineUSCPtr[u]); 01696 01697 lineDestPtr[u].R = min(((uint)lineDestPtr[u].R)*2, 255U); 01698 lineDestPtr[u].G = min(((uint)lineDestPtr[u].G)*2, 255U); 01699 lineDestPtr[u].B = min(((uint)lineDestPtr[u].B)*2, 255U); 01700 } 01701 } 01702 break; 01703 } 01704 01705 // stop MMX if used 01706 if(asmMMX) 01707 NL3D_asmEndMMX(); 01708 01709 } |