Definition in file zone_lighter.cpp.
#include "std3d.h"
#include "3d/zone_lighter.h"
#include "3d/landscape.h"
#include "3d/patchuv_locator.h"
#include "3d/shape.h"
#include "3d/mesh.h"
#include "3d/mesh_multi_lod.h"
#include "3d/mesh_mrm.h"
#include "3d/transform_shape.h"
#include "3d/water_shape.h"
#include "3d/texture_file.h"
#include "nel/misc/common.h"
#include "nel/misc/thread.h"
#include "nel/misc/path.h"
#include "nel/misc/file.h"
#include "nel/misc/aabbox.h"
#include "nel/misc/algo.h"
Go to the source code of this file.
Data Structures | |
| struct | CTileOfPatch |
| a struct that helps us to know which tile we've processed More... | |
Defines | |
| #define | AllBack 1 |
| #define | AllFront 0 |
| #define | BLUR_SIZE 4 |
| #define | Clipped 2 |
| #define | CLIPPED_ALL (CLIPPED_TOP|CLIPPED_BOTTOM|CLIPPED_LEFT|CLIPPED_RIGHT) |
| #define | CLIPPED_BOTTOM 2 |
| #define | CLIPPED_LEFT 4 |
| #define | CLIPPED_RIGHT 3 |
| #define | CLIPPED_TOP 1 |
| #define | DEFAULT_JITTER 0.4f |
| #define | DEFAULT_SUN_CENTER (CVector (0, 0, 0)) |
| #define | DEFAULT_SUN_DISTANCE 50000 |
| #define | DEFAULT_SUN_FOV (NLMISC::Pi/6) |
| #define | DEFAULT_SUN_RADIUS 5000 |
| #define | DEFAULT_SUN_SRQT_SAMPLES 4 |
| #define | DEFAULT_ZBUFFER_LANDSCAPE_SIZE 32768 |
| #define | DEFAULT_ZBUFFER_OBJECT_SIZE (32768*3) |
| #define | NL3D_ZONE_LIGHTER_CUBE_GRID_SIZE 16 |
| #define | USE_JPEG |
Typedefs | |
| typedef std::map< CTileOfPatch, NLMISC::CAABBox > | TTileOfPatchMap |
| A set of tiles from patch and their bbox. | |
Functions | |
| void | draw2dLine (CBitmap &bitmap, float x0, float y0, float x1, float y1, const CRGBA &color) |
| float | easineasout (float x) |
| float | easineasoutC2 (float x) |
| void | FilterZBuffer (CZoneLighter::CZBuffer &zbuffer, uint filterRadius) |
| std::string | getDir (const std::string &path) |
| std::string | getExt (const std::string &path) |
| std::string | getName (const std::string &path) |
| void | InitZBuffer (CZoneLighter::CZBuffer &zbuffer, const CVector &SunPosition, const CMatrix &rayBasis, const CAABBoxExt &zoneBB, uint zBufferPixelSize, const CZoneLighter::CLightDesc &description) |
| void | NEL3DCalcBase (CVector &direction, CMatrix &matrix) |
| bool | operator< (const CTileOfPatch &lhs, const CTileOfPatch &rhs) |
| for map insertion of CTileOfPatch structs | |
| void | RenderTriangle (const CZoneLighter::CTriangle &triangle, const CZoneLighter::CLightDesc &description, CPolygon2D::TRasterVect &borders, CFastMutex &mutex, CZoneLighter::CZBuffer &zbuffer, uint radius) |
| void | setCPUMask (IThread *thread, uint process) |
| float | testZPercentageCloserFilter (float x, float y, float z, CZoneLighter::CZBuffer &zbuffer, const CZoneLighter::CLightDesc &description, bool &zBufferOverflowFlag) |
| void | transformVectorToZBuffer (const CZoneLighter::CZBuffer &zbuffer, const CVector &world, CVector &projected) |
Variables | |
| const sint | deltaDirection [8][2] |
| const sint | DeltaZ [9][2] |
|
|
Definition at line 1446 of file zone_lighter.cpp. |
|
|
Definition at line 1445 of file zone_lighter.cpp. |
|
|
Referenced by NL3D::CZoneLighter::buildZoneInformation(). |
|
|
Definition at line 1447 of file zone_lighter.cpp. |
|
|
Definition at line 442 of file zone_lighter.cpp. Referenced by RenderTriangle(). |
|
|
Definition at line 439 of file zone_lighter.cpp. Referenced by RenderTriangle(). |
|
|
Definition at line 441 of file zone_lighter.cpp. Referenced by RenderTriangle(). |
|
|
Definition at line 440 of file zone_lighter.cpp. Referenced by RenderTriangle(). |
|
|
Definition at line 438 of file zone_lighter.cpp. Referenced by RenderTriangle(). |
|
|
Definition at line 72 of file zone_lighter.cpp. Referenced by NL3D::CZoneLighter::CLightDesc::CLightDesc(). |
|
|
Definition at line 77 of file zone_lighter.cpp. Referenced by NL3D::CZoneLighter::CLightDesc::CLightDesc(). |
|
|
Definition at line 75 of file zone_lighter.cpp. Referenced by NL3D::CZoneLighter::CLightDesc::CLightDesc(). |
|
|
Definition at line 76 of file zone_lighter.cpp. Referenced by NL3D::CZoneLighter::CLightDesc::CLightDesc(). |
|
|
Definition at line 78 of file zone_lighter.cpp. Referenced by NL3D::CZoneLighter::CLightDesc::CLightDesc(). |
|
|
Definition at line 79 of file zone_lighter.cpp. Referenced by NL3D::CZoneLighter::CLightDesc::CLightDesc(). |
|
|
Definition at line 73 of file zone_lighter.cpp. Referenced by NL3D::CZoneLighter::CLightDesc::CLightDesc(). |
|
|
Definition at line 74 of file zone_lighter.cpp. Referenced by NL3D::CZoneLighter::CLightDesc::CLightDesc(). |
|
|
Definition at line 82 of file zone_lighter.cpp. Referenced by NL3D::CZoneLighter::compilePointLightRT(). |
|
|
Definition at line 28 of file zone_lighter.cpp. |
|
|
A set of tiles from patch and their bbox.
Definition at line 3560 of file zone_lighter.cpp. Referenced by NL3D::CZoneLighter::computeTileFlagsForPositionTowardWater(). |
|
||||||||||||||||||||||||||||
|
Definition at line 712 of file zone_lighter.cpp. References NLMISC::drawFullLine(), NLMISC::CBitmap::getHeight(), NLMISC::CBitmap::getPixels(), NLMISC::CBitmap::getWidth(), height, sint, uint, width, x, and y.
00713 {
00714 static vector< std::pair<sint, sint> > lines;
00715 drawFullLine (x0, y0, x1, y1, lines);
00716
00717 // Bitmap pixels
00718 CRGBA *pixels = (CRGBA*)&(bitmap.getPixels ()[0]);
00719
00720 // Bitmap size
00721 sint width = (sint)bitmap.getWidth ();
00722 sint height = (sint)bitmap.getHeight ();
00723
00724 // Draw the line
00725 uint i;
00726 for (i=0; i<lines.size (); i++)
00727 {
00728 sint x = lines[i].first;
00729 sint y = lines[i].second;
00730
00731 // Clip
00732 if ( (x >= 0) && (x < width) && (y >= 0) && (y < height) )
00733 {
00734 pixels[x+(height-y-1)*width] = color;
00735 }
00736 }
00737 }
|
|
|
Definition at line 158 of file zone_lighter.cpp. Referenced by NL3D::CZoneLighter::buildZoneInformation().
|
|
|
Definition at line 1487 of file zone_lighter.cpp.
|
|
||||||||||||
|
Definition at line 883 of file zone_lighter.cpp. References DeltaZ, NL3D::CZoneLighter::CZBuffer::LocalZBufferHeight, NL3D::CZoneLighter::CZBuffer::LocalZBufferWidth, NL3D::CZoneLighter::CZBuffer::Pixels, sint, uint, x, and y. Referenced by NL3D::CZoneLighter::light().
00884 {
00885 // Resize the temp buffer
00886 static std::vector<float> tempPixels;
00887 tempPixels = zbuffer.Pixels;
00888
00889 sint x, y;
00890 for (y=0; y<zbuffer.LocalZBufferHeight; y++)
00891 for (x=0; x<zbuffer.LocalZBufferWidth; x++)
00892 {
00893 // The Value
00894 const float &oldValue = zbuffer.Pixels[x+y*zbuffer.LocalZBufferWidth];
00895 float &newValue = tempPixels[x+y*zbuffer.LocalZBufferWidth];
00896
00897 uint n;
00898 for (n=1; n<filterRadius; n++)
00899 {
00900 const sint fx = x + DeltaZ[n][0];
00901 const sint fy = y + DeltaZ[n][1];
00902
00903 // Clip
00904 if ( (fx>=0) && (fx < zbuffer.LocalZBufferWidth) && (fy>=0) && (fy < zbuffer.LocalZBufferHeight) )
00905 {
00906 const float &testValue = zbuffer.Pixels[fx+fy*zbuffer.LocalZBufferWidth];
00907 if (testValue < newValue)
00908 newValue = testValue;
00909 }
00910 }
00911
00912 }
00913
00914 // Copy the new zbuffer
00915 zbuffer.Pixels = tempPixels;
00916 }
|
|
|
Definition at line 2868 of file zone_lighter.cpp. Referenced by getExt(), and getName().
02869 {
02870 char tmpPath[512];
02871 strcpy (tmpPath, path.c_str());
02872 char* slash=strrchr (tmpPath, '/');
02873 if (!slash)
02874 {
02875 slash=strrchr (tmpPath, '\\');
02876 }
02877
02878 if (!slash)
02879 return "";
02880
02881 slash++;
02882 *slash=0;
02883 return tmpPath;
02884 }
|
|
|
Definition at line 2910 of file zone_lighter.cpp. References getDir(), getName(), and nlassert. Referenced by NL3D::CZoneLighter::lightWater().
02911 {
02912 std::string dir = getDir (path);
02913 std::string name = getName (path);
02914
02915 char tmpPath[512];
02916 strcpy (tmpPath, path.c_str());
02917
02918 char *ext=tmpPath;
02919 nlassert (dir.length()+name.length()<=strlen(tmpPath));
02920 ext+=dir.length()+name.length();
02921
02922 return ext;
02923 }
|
|
|
Definition at line 2889 of file zone_lighter.cpp. References getDir(), and nlassert. Referenced by NL3D::CInstanceGroup::addToScene(), NL3D::CInstanceGroup::getDynamicPortals(), getExt(), and NL3D::CMeshBaseInstance::registerToChannelMixer().
02890 {
02891 std::string dir=getDir (path);
02892
02893 char tmpPath[512];
02894 strcpy (tmpPath, path.c_str());
02895
02896 char *name=tmpPath;
02897 nlassert (dir.length()<=strlen(tmpPath));
02898 name+=dir.length();
02899
02900 char* point=strrchr (name, '.');
02901 if (point)
02902 *point=0;
02903
02904 return name;
02905 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 741 of file zone_lighter.cpp. References NL3D::CZoneLighter::CZBuffer::BoundingBoxVectors, NLMISC::CAABBoxExt::getMax(), NLMISC::CAABBoxExt::getMin(), NLMISC::CMatrix::identity(), NL3D::CFrustum::init(), NLMISC::CMatrix::invert(), NL3D::CZoneLighter::CZBuffer::LocalZBufferHeight, NL3D::CZoneLighter::CZBuffer::LocalZBufferWidth, NL3D::CZoneLighter::CZBuffer::LocalZBufferXMax, NL3D::CZoneLighter::CZBuffer::LocalZBufferXMin, NL3D::CZoneLighter::CZBuffer::LocalZBufferYMax, NL3D::CZoneLighter::CZBuffer::LocalZBufferYMin, NL3D::CZoneLighter::CZBuffer::LocalZBufferZMax, NL3D::CZoneLighter::CZBuffer::LocalZBufferZMin, NL3D::CZoneLighter::CZBuffer::Pixels, NLMISC::CMatrix::setPos(), sint, NL3D::CZoneLighter::CLightDesc::SunDistance, NL3D::CZoneLighter::CLightDesc::SunFOV, transformVectorToZBuffer(), uint, NL3D::CZoneLighter::CZBuffer::WorldToZBuffer, NL3D::CZoneLighter::CZBuffer::WorldToZBufferFrustum, NLMISC::CVector::x, NLMISC::CVector::y, NLMISC::CVector::z, and NL3D::CZoneLighter::CZBuffer::ZBufferPixelSize. Referenced by NL3D::CZoneLighter::light().
00742 {
00743 // Clac the zbuffer world size
00744 const float zBufferWorldSize = (float)(tan (description.SunFOV/2)*description.SunDistance*2);
00745
00746 // ** Compute the zbuffer basis
00747 zbuffer.WorldToZBuffer.identity ();
00748
00749 zbuffer.WorldToZBuffer = rayBasis;
00750 zbuffer.WorldToZBuffer.setPos (SunPosition);
00751 zbuffer.WorldToZBuffer.invert ();
00752 zbuffer.WorldToZBufferFrustum.init ((float)zBufferWorldSize, (float)zBufferWorldSize, description.SunDistance, description.SunDistance*2);
00753
00754 // Zbuffer size
00755 zbuffer.ZBufferPixelSize = zBufferPixelSize;
00756
00757 // Evaluate the size of the local zbuffer
00758
00759 // The zone bounding box
00760 CVector bMin = zoneBB.getMin ();
00761 CVector bMax = zoneBB.getMax ();
00762 transformVectorToZBuffer (zbuffer, CVector (bMin.x, bMax.y, bMin.z), zbuffer.BoundingBoxVectors[0]);
00763 transformVectorToZBuffer (zbuffer, CVector (bMin.x, bMin.y, bMin.z), zbuffer.BoundingBoxVectors[1]);
00764 transformVectorToZBuffer (zbuffer, CVector (bMax.x, bMin.y, bMin.z), zbuffer.BoundingBoxVectors[2]);
00765 transformVectorToZBuffer (zbuffer, CVector (bMax.x, bMax.y, bMin.z), zbuffer.BoundingBoxVectors[3]);
00766 transformVectorToZBuffer (zbuffer, CVector (bMin.x, bMax.y, bMax.z), zbuffer.BoundingBoxVectors[4]);
00767 transformVectorToZBuffer (zbuffer, CVector (bMin.x, bMin.y, bMax.z), zbuffer.BoundingBoxVectors[5]);
00768 transformVectorToZBuffer (zbuffer, CVector (bMax.x, bMin.y, bMax.z), zbuffer.BoundingBoxVectors[6]);
00769 transformVectorToZBuffer (zbuffer, CVector (bMax.x, bMax.y, bMax.z), zbuffer.BoundingBoxVectors[7]);
00770
00771 // Get the min and max
00772 zbuffer.LocalZBufferXMin = 0x7fffffff;
00773 zbuffer.LocalZBufferYMin = 0x7fffffff;
00774 zbuffer.LocalZBufferXMax = 0x80000000;
00775 zbuffer.LocalZBufferYMax = 0x80000000;
00776 zbuffer.LocalZBufferZMin = FLT_MAX;
00777 zbuffer.LocalZBufferZMax = -FLT_MAX;
00778 uint j;
00779 for (j=0; j<8; j++)
00780 {
00781 sint minX = (sint)floor (zbuffer.BoundingBoxVectors[j].x);
00782 sint maxX = (sint)ceil (zbuffer.BoundingBoxVectors[j].x);
00783 sint minY = (sint)floor (zbuffer.BoundingBoxVectors[j].y);
00784 sint maxY = (sint)ceil (zbuffer.BoundingBoxVectors[j].y);
00785 if (minX<zbuffer.LocalZBufferXMin)
00786 zbuffer.LocalZBufferXMin = minX;
00787 if (maxX>zbuffer.LocalZBufferXMax)
00788 zbuffer.LocalZBufferXMax = maxX;
00789 if (minY<zbuffer.LocalZBufferYMin)
00790 zbuffer.LocalZBufferYMin = minY;
00791 if (maxY>zbuffer.LocalZBufferYMax)
00792 zbuffer.LocalZBufferYMax = maxY;
00793 if ((-zbuffer.BoundingBoxVectors[j].z)<zbuffer.LocalZBufferZMin)
00794 zbuffer.LocalZBufferZMin = -zbuffer.BoundingBoxVectors[j].z;
00795 if ((-zbuffer.BoundingBoxVectors[j].z)>zbuffer.LocalZBufferZMax)
00796 zbuffer.LocalZBufferZMax = -zbuffer.BoundingBoxVectors[j].z;
00797 }
00798
00799 // Expand the zbuffer
00800 zbuffer.LocalZBufferXMax++;
00801 zbuffer.LocalZBufferXMin--;
00802 zbuffer.LocalZBufferYMax++;
00803 zbuffer.LocalZBufferYMin--;
00804
00805 zbuffer.LocalZBufferWidth = zbuffer.LocalZBufferXMax-zbuffer.LocalZBufferXMin;
00806 zbuffer.LocalZBufferHeight = zbuffer.LocalZBufferYMax-zbuffer.LocalZBufferYMin;
00807
00808 // Resize and clear the zbuffer
00809 zbuffer.Pixels.resize (0);
00810 zbuffer.Pixels.resize (zbuffer.LocalZBufferWidth*zbuffer.LocalZBufferHeight, FLT_MAX);
00811 }
|
|
||||||||||||
|
Definition at line 323 of file zone_lighter.cpp. References matrix.
|
|
||||||||||||
|
for map insertion of CTileOfPatch structs
Definition at line 3552 of file zone_lighter.cpp. References CTileOfPatch::Patch, and CTileOfPatch::TileId.
|
|
||||||||||||||||||||||||||||
|
Definition at line 444 of file zone_lighter.cpp. References alpha, NL3D::CZoneLighter::CTriangle::AlphaTestThreshold, NLMISC::clamp(), CLIPPED_ALL, CLIPPED_BOTTOM, CLIPPED_LEFT, CLIPPED_RIGHT, CLIPPED_TOP, NLMISC::CPolygon2D::computeBorders(), NLMISC::CTriangle::computeGradient(), DeltaZ, NLMISC::CFastMutex::enter(), NL3D::CZoneLighter::CTriangle::Flags, NLMISC::CBitmap::getHeight(), NLMISC::CBitmap::getPixels(), NLMISC::CBitmap::getWidth(), height, in, NLMISC::CFastMutex::leave(), NL3D::CZoneLighter::CZBuffer::LocalZBufferHeight, NL3D::CZoneLighter::CZBuffer::LocalZBufferWidth, NL3D::CZoneLighter::CZBuffer::LocalZBufferXMax, NL3D::CZoneLighter::CZBuffer::LocalZBufferXMin, NL3D::CZoneLighter::CZBuffer::LocalZBufferYMax, NL3D::CZoneLighter::CZBuffer::LocalZBufferYMin, min, NL3D::CZoneLighter::CZBuffer::Pixels, sint, NL3D::CZoneLighter::CTriangle::Texture, transformVectorToZBuffer(), NLMISC::CPolygon2D::TRaster, NLMISC::CPolygon2D::TRasterVect, NL3D::CZoneLighter::CTriangle::Triangle, NL3D::CZoneLighter::CTriangle::U, uint, uint8, v, NL3D::CZoneLighter::CTriangle::V, NLMISC::CTriangle::V0, NLMISC::CPolygon2D::Vertices, width, x, y, and z. Referenced by NL3D::CRenderZBuffer::run().
00446 {
00447 // *** Transform it in the zbuffer basis
00448
00449 // 2d polygon used for rasteriation
00450 CPolygon2D zBasis;
00451 zBasis.Vertices.resize (3);
00452
00453 // 3d polygon used for the gradient
00454 NLMISC::CTriangle gradientTriangle;
00455
00456 // One over z value
00457 float ooz[3];
00458
00459 // Clipping
00460 uint8 in = 0;
00461
00462 // For each vertex
00463 for (uint j=0; j<3; j++)
00464 {
00465 // Pointer on the vector
00466 const CVector *pt = (&triangle.Triangle.V0)+j;
00467 CVector *ptDest = (&gradientTriangle.V0)+j;
00468
00469 // Transform it in the zbuffer basis
00470 transformVectorToZBuffer (zbuffer, *pt, *ptDest);
00471
00472 // Clip
00473 if (ptDest->x >= zbuffer.LocalZBufferXMin)
00474 in |= CLIPPED_LEFT;
00475 if (ptDest->x <= zbuffer.LocalZBufferXMax)
00476 in |= CLIPPED_RIGHT;
00477 if (ptDest->y >= zbuffer.LocalZBufferYMin)
00478 in |= CLIPPED_TOP;
00479 if (ptDest->y <= zbuffer.LocalZBufferYMax)
00480 in |= CLIPPED_BOTTOM;
00481
00482 // Set the 2d points
00483 zBasis.Vertices[j].x = ptDest->x - (float)zbuffer.LocalZBufferXMin;
00484 zBasis.Vertices[j].y = ptDest->y - (float)zbuffer.LocalZBufferYMin;
00485 ooz[j] = 1.f / ptDest->z;
00486
00487 // No z
00488 ptDest->z = 0;
00489 }
00490
00491 // Not clipped ?
00492 if (in == CLIPPED_ALL)
00493 {
00494 // Rasterise
00495 sint minimumY;
00496 borders.clear ();
00497 zBasis.computeBorders (borders, minimumY);
00498
00499 // Compute the gradient for one over z
00500 CVector ozzGradient;
00501 gradientTriangle.computeGradient (ooz[0], ooz[1], ooz[2], ozzGradient);
00502
00503 // Need uv ?
00504 bool needUV = triangle.Texture != NULL;
00505
00506 // Compute the gradient for uv
00507 CVector uGradient;
00508 CVector vGradient;
00509 if (needUV)
00510 {
00511 gradientTriangle.computeGradient (triangle.U[0], triangle.U[1], triangle.U[2], uGradient);
00512 gradientTriangle.computeGradient (triangle.V[0], triangle.V[1], triangle.V[2], vGradient);
00513 }
00514
00515 // Texture informations
00516 uint width;
00517 uint height;
00518 const CObjectVector<uint8> *pixels;
00519 if (needUV)
00520 {
00521 // Get pixels
00522 pixels = &triangle.Texture->getPixels ();
00523
00524 // Get width and height
00525 width = triangle.Texture->getWidth ();
00526 height = triangle.Texture->getHeight ();
00527 }
00528
00529 // For each scanlines
00530 sint y = std::max (minimumY, 0);
00531 sint yMax = std::min ((sint)(minimumY+borders.size ()), zbuffer.LocalZBufferHeight);
00532 for (; y<yMax; y++)
00533 {
00534 // Ref on the raster
00535 const CPolygon2D::TRaster &raster = borders[y-minimumY];
00536
00537 // Gradient y for ooz, u and v
00538 const float deltaY = (float)y - zBasis.Vertices[0].y;
00539 const float oozGradientY = deltaY * ozzGradient.y;
00540 float uGradientY;
00541 float vGradientY;
00542 if (needUV)
00543 {
00544 uGradientY = deltaY * uGradient.y;
00545 vGradientY = deltaY * vGradient.y;
00546 }
00547
00548 // Clip it
00549 sint x = std::max (raster.first, 0);
00550 sint xMax = std::min (raster.second+1, zbuffer.LocalZBufferWidth);
00551 for (; x<xMax; x++)
00552 {
00553 // Gradient x for ooz, u and v
00554 const float deltaX = (float)x - zBasis.Vertices[0].x;
00555 const float oozGradientX = deltaX * ozzGradient.x;
00556 float uGradientX;
00557 float vGradientX;
00558 if (needUV)
00559 {
00560 uGradientX = deltaX * uGradient.x;
00561 vGradientX = deltaX * vGradient.x;
00562 }
00563
00564 // Calc z
00565 float z = - 1.f / (ooz[0] + oozGradientX + oozGradientY);
00566
00567 // Calc u & v
00568 float u;
00569 float v;
00570 bool alphaTest = true;
00571 if (needUV)
00572 {
00573 // Compute uv
00574 u = triangle.U[0] + uGradientX + uGradientY;
00575 v = triangle.V[0] + vGradientX + vGradientY;
00576
00577 // Clamp or wrap ?
00578 if (triangle.Flags & CZoneLighter::CTriangle::ClampU)
00579 clamp (u, 0.f, 1.f);
00580 else
00581 u -= (float)floor (u);
00582 if (triangle.Flags & CZoneLighter::CTriangle::ClampV)
00583 clamp (v, 0.f, 1.f);
00584 else
00585 v -= (float)floor (v);
00586
00587 // Lookup in the texture
00588 u *= width;
00589 v *= height;
00590 clamp (u, 0, width-1);
00591 clamp (v, 0, height-1);
00592 uint8 alpha = ((const CRGBA*)&((*pixels)[(((uint)u)+((uint)v)*width)*sizeof (CRGBA)]))->A;
00593
00594 // Alpha test
00595 alphaTest = alpha >= triangle.AlphaTestThreshold;
00596 }
00597
00598 // Good alpha test ?
00599 if (alphaTest)
00600 {
00601 // Enter the mutex
00602 mutex.enter ();
00603
00604 // Write Z around
00605 uint d;
00606 for (d=0; d<radius; d++)
00607 {
00608 // Ref in the zbuffer
00609 sint fx = x + DeltaZ[d][0];
00610 sint fy = y + DeltaZ[d][1];
00611 if ( (fx >= 0) && (fx < zbuffer.LocalZBufferWidth) && (fy >= 0) && (fy < zbuffer.LocalZBufferHeight) )
00612 {
00613 float &zValue = zbuffer.Pixels[fx+(zbuffer.LocalZBufferHeight-fy-1)*zbuffer.LocalZBufferWidth];
00614
00615 // Z test
00616 if (z < zValue)
00617 {
00618 // Render z in zbuffer
00619 zValue = z;
00620 }
00621 }
00622 }
00623
00624 // Leave the mutex
00625 mutex.leave ();
00626 }
00627 }
00628 }
00629 }
00630 }
|
|
||||||||||||
|
Definition at line 338 of file zone_lighter.cpp. References count, nlassert, uint, and uint64. Referenced by NL3D::CRenderZBuffer::run(), and NL3D::CLightRunnable::run().
00339 {
00340 // Set the processor mask
00341 uint64 mask = IProcess::getCurrentProcess()->getCPUMask ();
00342
00343 // Mask must not be NULL
00344 nlassert (mask != 0);
00345
00346 if (mask != 0)
00347 {
00348 uint i=0;
00349 uint count = 0;
00350 while (1)
00351 {
00352 if (mask & (1<<i))
00353 {
00354 if (count == process)
00355 break;
00356 count++;
00357 }
00358 i++;
00359 if (i==64)
00360 i = 0;
00361 }
00362
00363 // Set the CPU mask
00364 thread->setCPUMask (1<<i);
00365 }
00366 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 201 of file zone_lighter.cpp. References NL3D::CZoneLighter::CZBuffer::LocalZBufferHeight, NL3D::CZoneLighter::CZBuffer::LocalZBufferWidth, nlassert, NL3D::CZoneLighter::CZBuffer::Pixels, sint, x, y, and z. Referenced by NL3D::CZoneLighter::attenuation().
00202 {
00203 // See "Rendering Antialiased Shadows With Depth Maps" Reeves, Salesint, Cook, ACM 1987
00204
00205 // Bilinear filtering
00206
00207 float biliValues[2][2];
00208
00209 float ix = (float)floor (x-0.5f);
00210 float factorX = x - (ix+0.5f);
00211 nlassert (factorX>=0);
00212 nlassert (factorX<=1);
00213
00214 float iy = (float)floor (y-0.5f);
00215 float factorY = y - (iy+0.5f);
00216 nlassert (factorY>=0);
00217 nlassert (factorY<=1);
00218
00219 sint dx, dy;
00220 for (dy=0; dy<2; dy++)
00221 for (dx=0; dx<2; dx++)
00222 {
00223 const sint fx = dx + (sint)ix;
00224 const sint fy = dy + (sint)iy;
00225 if ((fx >= 0) && (fx < zbuffer.LocalZBufferWidth) && (fy >= 0) && (fy < zbuffer.LocalZBufferHeight))
00226 {
00227 const float zRed = zbuffer.Pixels[fx + (zbuffer.LocalZBufferHeight - 1 - fy) * zbuffer.LocalZBufferWidth];
00228
00229 biliValues[dx][dy] = (zRed < (-z)) ? 0.f : 1.f;
00230 }
00231 else
00232 {
00233 biliValues[dx][dy] = 1;
00234 zBufferOverflowFlag = true;
00235 }
00236 }
00237
00238 // Bilinear
00239 return (biliValues[0][0] * (1 - factorX) + biliValues[1][0] * factorX) * (1 - factorY) +
00240 (biliValues[0][1] * (1 - factorX) + biliValues[1][1] * factorX) * factorY;
00241 }
|
|
||||||||||||||||
|
Definition at line 170 of file zone_lighter.cpp. References NL3D::CFrustum::project(), NL3D::CZoneLighter::CZBuffer::WorldToZBuffer, NL3D::CZoneLighter::CZBuffer::WorldToZBufferFrustum, and NL3D::CZoneLighter::CZBuffer::ZBufferPixelSize. Referenced by NL3D::CZoneLighter::attenuation(), InitZBuffer(), and RenderTriangle().
00171 {
00172 projected = zbuffer.WorldToZBuffer * world;
00173 float temp = projected.z;
00174 projected.z = projected.y;
00175 projected.y = -temp;
00176 projected = zbuffer.WorldToZBufferFrustum.project (projected);
00177
00178 // Scale to zbuffer size
00179 projected.x *= zbuffer.ZBufferPixelSize;
00180 projected.y *= zbuffer.ZBufferPixelSize;
00181 projected.z = temp;
00182 }
|
|
|
Initial value:
{
{1, 0},
{1, 1},
{0, 1},
{-1, 1},
{-1, 0},
{-1, -1},
{0, -1},
{1, -1},
}
Definition at line 282 of file zone_lighter.cpp. Referenced by NL3D::CZoneLighter::calcSkyContribution(). |
|
|
Initial value:
{
{0, 0},
{-1, 0},
{1, 0},
{0, -1},
{0, 1},
{-1, -1},
{1, 1},
{1, -1},
{-1, 1},
}
Definition at line 186 of file zone_lighter.cpp. Referenced by FilterZBuffer(), and RenderTriangle(). |
1.3.6