Difference between revisions of "Graphics Map Asset (Ghosts)"

From COD Engine Research
Jump to: navigation, search
 
Line 4: Line 4:
 
The graphics map (or gfx_map) has existed on every Call of Duty so far and is part of the D3DBSP system produced by Radiant. Where the [[:Collision Map Asset (Ghosts)|collision map]] is used for collision data in the map, the graphics map holds visual systems such as lights and particularly the dPVS system. The Dynamic Potentially Visible Sets (dPVS) were developed by Umbra Software to compute visibility databases in real time, and power the Call of Duty engine to this day.
 
The graphics map (or gfx_map) has existed on every Call of Duty so far and is part of the D3DBSP system produced by Radiant. Where the [[:Collision Map Asset (Ghosts)|collision map]] is used for collision data in the map, the graphics map holds visual systems such as lights and particularly the dPVS system. The Dynamic Potentially Visible Sets (dPVS) were developed by Umbra Software to compute visibility databases in real time, and power the Call of Duty engine to this day.
 
<syntaxhighlight lang="cpp">
 
<syntaxhighlight lang="cpp">
struct GfxAabbTree
+
struct GfxPortal;
{
+
  float mins[3];
+
  float maxs[3];
+
  unsigned __int16 childCount;
+
  unsigned __int16 surfaceCount;
+
  unsigned __int16 startSurfIndex;
+
  unsigned __int16 smodelIndexCount;
+
  unsigned __int16 *smodelIndexes;
+
  int childrenOffset;
+
};
+
  
struct XModelDrawInfo
+
struct __declspec(align(8)) GfxSky
 
{
 
{
   unsigned __int16 lod;
+
   int skySurfCount;
   unsigned __int16 surfId;
+
   int *skyStartSurfs;
 +
  GfxImage *skyImage;
 +
  char skySamplerState;
 
};
 
};
  
struct GfxSceneDynModel
+
struct GfxWorldDpvsPlanes
 
{
 
{
   XModelDrawInfo info;
+
   int cellCount;
   unsigned __int16 dynEntId;
+
  cplane_s *planes;
 +
   unsigned __int16 *nodes;
 +
  unsigned int *sceneEntCellBits;
 
};
 
};
  
struct BModelDrawInfo
+
struct GfxCellTreeCount
 
{
 
{
   unsigned __int16 surfId;
+
   int aabbTreeCount;
 
};
 
};
  
struct GfxSceneDynBrush
+
struct __declspec(align(8)) GfxAabbTree
 
{
 
{
   BModelDrawInfo info;
+
   Bounds bounds;
   unsigned __int16 dynEntId;
+
   unsigned __int16 childCount;
 +
  unsigned __int16 surfaceCount;
 +
  unsigned int startSurfIndex;
 +
  unsigned __int16 smodelIndexCount;
 +
  unsigned __int16 *smodelIndexes;
 +
  int childrenOffset;
 
};
 
};
  
#pragma pack(push, 4)
+
struct GfxCellTree
struct cplane_s
+
 
{
 
{
   float normal[3];
+
   GfxAabbTree *aabbTree;
  float dist;
+
  char type;
+
  char signbits;
+
};
+
 
+
struct GfxWorldDpvsPlanes
+
{
+
  int cellCount;
+
  cplane_s *planes;
+
  unsigned __int16 *nodes;
+
  unsigned int *sceneEntCellBits; //Size = cellCount << 11
+
};
+
 
+
struct unknownGfxWorldStruct2
+
{
+
  int unknownCount;
+
  int * unknownArray;
+
  GfxImage * unknownImage;
+
  int unknown;
+
 
};
 
};
  
Line 71: Line 50:
 
   char hullPointCount;
 
   char hullPointCount;
 
   float (*hullPoints)[2];
 
   float (*hullPoints)[2];
 +
  GfxPortal *queuedParent;
 
};
 
};
  
Line 76: Line 56:
 
{
 
{
 
   float coeffs[4];
 
   float coeffs[4];
  char side[3];
 
 
};
 
};
  
Line 84: Line 63:
 
   DpvsPlane plane;
 
   DpvsPlane plane;
 
   float (*vertices)[3];
 
   float (*vertices)[3];
      char unknown[4];
+
  unsigned __int16 cellIndex;
 +
  unsigned __int16 closeDistance;
 
   char vertexCount;
 
   char vertexCount;
 
   float hullAxis[2][3];
 
   float hullAxis[2][3];
Line 91: Line 71:
 
struct GfxCell
 
struct GfxCell
 
{
 
{
   float mins[3];
+
   Bounds bounds;
  float maxs[3];
+
 
   int portalCount;
 
   int portalCount;
 
   GfxPortal *portals;
 
   GfxPortal *portals;
 
   char reflectionProbeCount;
 
   char reflectionProbeCount;
 
   char *reflectionProbes;
 
   char *reflectionProbes;
      char unknownCount;
+
  char reflectionProbeReferenceCount;
      char *unknown; //Size = unknownCount
+
  char *reflectionProbeReferences;
 
};
 
};
  
typedef char GfxTexture[0x34];
+
struct GfxReflectionProbeVolumeData
 +
{
 +
  float volumePlanes[6][4];
 +
};
  
struct GfxReflectionProbe
+
struct __declspec(align(8)) GfxReflectionProbe
 
{
 
{
   float offset[3];
+
   float origin[3];
   unsigned int unknownCount;
+
   GfxReflectionProbeVolumeData *probeVolumes;
   char * unknown; //Size = ((unknownCount << 1) + unknownCount) << 5
+
   unsigned int probeVolumeCount;
 
};
 
};
  
struct GfxLightmapArray
+
struct GfxReflectionProbeReferenceOrigin
 
{
 
{
   GfxImage *primary;
+
   float origin[3];
  GfxImage *secondary;
+
 
};
 
};
  
union GfxColor
+
struct GfxReflectionProbeReference
 
{
 
{
  unsigned int packed;
+
   char index;
   char array[4];
+
 
};
 
};
  
union PackedUnitVec
+
struct GfxLightmapArray
 
{
 
{
   unsigned int packed;
+
   GfxImage *primary;
 +
  GfxImage *secondary;
 
};
 
};
  
Line 132: Line 113:
 
   float binormalSign;
 
   float binormalSign;
 
   GfxColor color;
 
   GfxColor color;
 +
#if defined(_XBOX) || defined(PS3)
 +
  PackedTexCoords texCoord;
 +
  PackedTexCoords lmapCoord;
 +
#else
 
   float texCoord[2];
 
   float texCoord[2];
 +
  float lmapCoord[2];
 +
#endif
 
   PackedUnitVec normal;
 
   PackedUnitVec normal;
 
   PackedUnitVec tangent;
 
   PackedUnitVec tangent;
Line 139: Line 126:
 
struct GfxWorldVertexData
 
struct GfxWorldVertexData
 
{
 
{
   GfxWorldVertex *vertices[2];
+
   GfxWorldVertex *vertices;
 +
#ifdef _XBOX
 +
  GfxWorldVertex *vertices2;
 +
#endif
 
   D3DVertexBuffer worldVb;
 
   D3DVertexBuffer worldVb;
 
};
 
};
Line 152: Line 142:
 
{
 
{
 
   unsigned int reflectionProbeCount;
 
   unsigned int reflectionProbeCount;
   GfxImage * * reflectionImages;
+
   GfxImage **reflectionProbes;
   GfxReflectionProbe *reflectionProbes;
+
   GfxReflectionProbe *reflectionProbeOrigins;
   GfxTexture * reflectionProbeTextures; //Count = refelctionProbeCount
+
   GfxTexture *reflectionProbeTextures;
      unsigned int unknownCount1;
+
  unsigned int reflectionProbeReferenceCount;
      char * unknown1; //Size = ((unknownCount1 << 1) + unknownCount1) << 2
+
  GfxReflectionProbeReferenceOrigin *reflectionProbeReferenceOrigins;
      char * unknown2; //Size = unknownCount1
+
  GfxReflectionProbeReference *reflectionProbeReferences;
 
   int lightmapCount;
 
   int lightmapCount;
 
   GfxLightmapArray *lightmaps;
 
   GfxLightmapArray *lightmaps;
   GfxTexture * lightmapPrimaryTextures; //Count = lightmapCount
+
   GfxTexture *lightmapPrimaryTextures;
   GfxTexture * lightmapSecondaryTextures; //Count = lightmapCount
+
   GfxTexture *lightmapSecondaryTextures;
   GfxImage *skyImage;
+
   GfxImage *lightmapOverridePrimary;
   GfxImage *outdoorImage;
+
   GfxImage *lightmapOverrideSecondary;
      int unknown3;
+
  unsigned int trisType;
 
   unsigned int vertexCount;
 
   unsigned int vertexCount;
 
   GfxWorldVertexData vd;
 
   GfxWorldVertexData vd;
 
   unsigned int vertexLayerDataSize;
 
   unsigned int vertexLayerDataSize;
 
   GfxWorldVertexLayerData vld;
 
   GfxWorldVertexLayerData vld;
   int indexCount;
+
   unsigned int indexCount;
 
   unsigned __int16 *indices;
 
   unsigned __int16 *indices;
 
   D3DIndexBuffer indexBuffer;
 
   D3DIndexBuffer indexBuffer;
Line 176: Line 166:
 
struct GfxLightGridEntry
 
struct GfxLightGridEntry
 
{
 
{
   unsigned __int16 colorsIndex;
+
   unsigned int colorsIndex;
   char primaryLightIndex;
+
  unsigned __int16 primaryLightEnvIndex;
 +
   char unused;
 
   char needsTrace;
 
   char needsTrace;
  int unknown;
 
 
};
 
};
  
Line 187: Line 177:
 
};
 
};
  
struct unknownGfxlightGridStruct1
+
struct GfxLightGridColorsHDR
 
{
 
{
   int unknown1;
+
  float colorVec3[56][3];
   unsigned int unknownCount1;
+
};
   char unknown2[0x30];
+
 
   char * unknown3; //Size = unknownCount1 << 2
+
struct GfxLightGridTree
   unsigned int unknownCount2;
+
{
   byte * unknown4; //count = unknownCount2
+
  char maxDepth;
 +
   int nodeCount;
 +
   int leafCount;
 +
   int coordMinGridSpace[3];
 +
   int coordMaxGridSpace[3];
 +
  int coordHalfSizeGridSpace[3];
 +
  int defaultColorIndexBitCount;
 +
  int defaultLightIndexBitCount;
 +
   unsigned int *p_nodeTable;
 +
   int leafTableSize;
 +
  char *p_leafTable;
 
};
 
};
  
Line 200: Line 200:
 
{
 
{
 
   bool hasLightRegions;
 
   bool hasLightRegions;
   unsigned int sunPrimaryLightIndex;
+
  bool useSkyForLowZ;
 +
   unsigned int lastSunPrimaryLightIndex;
 
   unsigned __int16 mins[3];
 
   unsigned __int16 mins[3];
 
   unsigned __int16 maxs[3];
 
   unsigned __int16 maxs[3];
Line 212: Line 213:
 
   unsigned int colorCount;
 
   unsigned int colorCount;
 
   GfxLightGridColors *colors;
 
   GfxLightGridColors *colors;
      char unknown1[0xF];
+
  unsigned int missingGridColorIndex;
      byte unknownCount1;
+
  int tableVersion;
      float * unknown2; //count = unknownCount1;
+
  int paletteVersion;
      unsigned int unknownCount2;
+
  char rangeExponent8BitsEncoding;
      int * unknown3; //count = unknownCount2;
+
  char rangeExponent12BitsEncoding;
      unsigned int unknownCount3;
+
  char rangeExponent16BitsEncoding;
      byte * unknown4; //count = unknownCount3
+
  char stageCount;
      char unknown5[0x150];
+
  float *stageLightingContrastGain;
      unknownGfxLightGridStruct1 unknownEmbeddedStruct;
+
  unsigned int paletteEntryCount;
 +
  int *paletteEntryAddress;
 +
  unsigned int paletteBitstreamSize;
 +
  char *paletteBitstream;
 +
  GfxLightGridColorsHDR skyLightGridColors;
 +
  GfxLightGridColorsHDR defaultLightGridColors;
 +
  GfxLightGridTree tree;
 
};
 
};
  
Line 243: Line 250:
 
};
 
};
  
struct sunflare_t
+
struct __declspec(align(8)) sunflare_t
 
{
 
{
 
   bool hasValidData;
 
   bool hasValidData;
Line 267: Line 274:
 
   int glareFadeOutTime;
 
   int glareFadeOutTime;
 
   float sunFxPosition[3];
 
   float sunFxPosition[3];
 +
};
 +
 +
struct XModelDrawInfo
 +
{
 +
  unsigned __int16 lod;
 +
  unsigned __int16 surfId;
 +
};
 +
 +
struct GfxSceneDynModel
 +
{
 +
  XModelDrawInfo info;
 +
  unsigned __int16 dynEntId;
 +
};
 +
 +
struct BModelDrawInfo
 +
{
 +
  unsigned __int16 surfId;
 +
};
 +
 +
struct GfxSceneDynBrush
 +
{
 +
  BModelDrawInfo info;
 +
  unsigned __int16 dynEntId;
 
};
 
};
  
Line 300: Line 330:
 
struct GfxStaticModelInst
 
struct GfxStaticModelInst
 
{
 
{
   float mins[3];
+
   Bounds bounds;
   float maxs[3];
+
   float lightingOrigin[3];
  GfxColor groundLighting;
+
 
};
 
};
  
 
struct srfTriangles_t
 
struct srfTriangles_t
 
{
 
{
   int vertexLayerData;
+
   unsigned int vertexLayerData;
   int firstVertex;
+
   unsigned int firstVertex;
 +
#ifdef PC
 +
  float maxEdgeLength;
 +
#endif
 
   unsigned __int16 vertexCount;
 
   unsigned __int16 vertexCount;
 
   unsigned __int16 triCount;
 
   unsigned __int16 triCount;
   int baseIndex;
+
   unsigned int baseIndex;
 
};
 
};
  
struct GfxSurface
+
struct GfxSurfaceLightingAndFlagsFields
 
{
 
{
  srfTriangles_t tris;
 
  Material *material;
 
 
   char lightmapIndex;
 
   char lightmapIndex;
 
   char reflectionProbeIndex;
 
   char reflectionProbeIndex;
   char primaryLightIndex;
+
#ifdef PC
   bool castsSunShadow;
+
  unsigned __int16 primaryLightEnvIndex;
 +
#else
 +
   char primaryLightEnvIndex;
 +
#endif
 +
   char flags;
 
};
 
};
  
struct GfxCullGroup
+
union GfxSurfaceLightingAndFlags
 
{
 
{
   float mins[3];
+
   GfxSurfaceLightingAndFlagsFields fields;
   float maxs[3];
+
#ifdef PC
   int surfaceCount;
+
   unsigned __int64 packed;
  int startSurfIndex;
+
#else
 +
   unsigned int packed;
 +
#endif
 
};
 
};
  
struct GfxDrawSurfFields
+
struct GfxSurface
 
{
 
{
   __int64 _bf0;
+
   srfTriangles_t tris;
 +
  Material *material;
 +
  GfxSurfaceLightingAndFlags laf;
 
};
 
};
  
union GfxDrawSurf
+
struct __declspec(align(4)) GfxSurfaceBounds
 
{
 
{
   GfxDrawSurfFields fields;
+
   Bounds bounds;
   unsigned __int64 packed;
+
   char flags;
 +
#ifdef _XBOX
 +
  float maxEdgeLength; //Not sure if this goes here, but the srfTriangles_t is missing 4 bytes and I need 4 here, and it'd make sense that this would go here, as it isn't in the Xbox 360 CoD4 srfTriangles_t.
 +
#endif
 
};
 
};
  
Line 346: Line 387:
 
{
 
{
 
   float origin[3];
 
   float origin[3];
 +
#if defined(_XBOX) || defined(PS3)
 
   PackedUnitVec axis[3];
 
   PackedUnitVec axis[3];
 +
#else
 +
  float axis[3][3];
 +
#endif
 
   float scale;
 
   float scale;
 
};
 
};
  
struct unknownGfxStaticModelDrawInstStruct1
+
struct GfxStaticModelVertexLighting
 
{
 
{
   char * unknown1; //Size = ((unknownCount1 << 1) + unknownCount1) << 2
+
   char visibility[4];
   D3DVertexBuffer vb;
+
   unsigned __int16 ambientColorFloat16[4];
   unsigned int unknownCount1;
+
#ifdef PC
 +
   unsigned __int16 highlightColorFloat16[4];
 +
#endif
 
};
 
};
  
struct GfxStaticModelDrawInst
+
struct __declspec(align(8)) GfxStaticModelVertexLightingInfo
 +
{
 +
  GfxStaticModelVertexLighting *lightingValues;
 +
  D3DVertexBuffer lightingValuesVb;
 +
  unsigned int numLightingValues;
 +
};
 +
 
 +
struct __declspec(align(8)) GfxStaticModelDrawInst
 
{
 
{
 
   GfxPackedPlacement placement;
 
   GfxPackedPlacement placement;
 
   XModel *model;
 
   XModel *model;
   float cullDist;
+
 
   char reflectionProbeIndex;
+
#ifdef PC
   char primaryLightIndex;
+
   float groundLighting[4];
 +
#else
 +
   float groundLighting[1];//Again, this makes sense... Either this, or a packed vertex.
 +
#endif
 +
 
 +
   GfxStaticModelVertexLightingInfo vertexLightingInfo;
 +
 
 +
#ifdef PC
 +
  GfxStaticModelLightmapInfo modelLightmapInfo;
 +
#endif
 +
 
 
   unsigned __int16 lightingHandle;
 
   unsigned __int16 lightingHandle;
   unknownGfxStaticModelDrawInstStruct1 * unknownEmbeddedStruct;
+
   unsigned __int16 cullDist;
   char unknown[0xC];
+
 
 +
#ifdef PC
 +
  unsigned __int16 flags;
 +
  unsigned __int16 staticModelId;
 +
  unsigned __int16 primaryLightEnvIndex;
 +
#else
 +
   char flags;
 +
  char staticModelId;
 +
  char primaryLightEnvIndex;
 +
#endif
 +
 
 +
  char reflectionProbeIndex;
 +
  char firstMtlSkinIndex;
 +
  char sunShadowFlags;
 +
};
 +
 
 +
struct GfxDrawSurfFields
 +
{
 +
  unsigned __int64 objectId : 16;
 +
  unsigned __int64 reflectionProbeIndex : 8;
 +
  unsigned __int64 hasGfxEntIndex : 1;
 +
  unsigned __int64 customIndex : 5;
 +
  unsigned __int64 materialSortedIndex : 13;
 +
  unsigned __int64 tessellation : 3;//This is probably PC only, but that would mean this structure would only need 4 bytes, and it needs 8
 +
  unsigned __int64 prepass : 2;
 +
  unsigned __int64 useHeroLighting : 1;
 +
  unsigned __int64 sceneLightEnvIndex : 16;
 +
  unsigned __int64 viewModelRender : 1;
 +
  unsigned __int64 surfType : 4;
 +
  unsigned __int64 primarySortKey : 6;
 +
  unsigned __int64 unused : 30;
 +
};
 +
 
 +
union GfxDrawSurf
 +
{
 +
  GfxDrawSurfFields fields;
 +
  Packed128 packed;
 
};
 
};
  
struct GfxWorldDpvsStatic
+
struct __declspec(align(8)) GfxWorldDpvsStatic
 
{
 
{
 
   unsigned int smodelCount;
 
   unsigned int smodelCount;
 
   unsigned int staticSurfaceCount;
 
   unsigned int staticSurfaceCount;
   unsigned int litSurfsBegin;
+
   unsigned int litOpaqueSurfsBegin;
   unsigned int litSurfsEnd;
+
   unsigned int litOpaqueSurfsEnd;
      char unknown1[0x20];
+
#ifdef PC
   char *smodelVisData[3];
+
  unsigned int litDecalSurfsBegin;
   char *surfaceVisData[3];
+
   unsigned int litDecalSurfsEnd;
   unsigned __int16 *sortedSurfIndex;
+
#endif
 +
  unsigned int litTransSurfsBegin;
 +
  unsigned int litTransSurfsEnd;
 +
  unsigned int shadowCasterSurfsBegin;
 +
  unsigned int shadowCasterSurfsEnd;
 +
  unsigned int emissiveSurfsBegin;
 +
  unsigned int emissiveSurfsEnd;
 +
  unsigned int smodelVisDataCount;
 +
  unsigned int surfaceVisDataCount;
 +
  unsigned int *smodelVisData[3];
 +
   unsigned int *surfaceVisData[3];
 +
#ifdef PC
 +
   unsigned int *tessellationCutoffVisData[3];
 +
#endif
 +
  unsigned int *sortedSurfIndex;
 
   GfxStaticModelInst *smodelInsts;
 
   GfxStaticModelInst *smodelInsts;
   GfxSurface *surfaces; //Count = GfxWorld::surfaceCount
+
   GfxSurface *surfaces;
   GfxCullGroup *cullGroups;
+
   GfxSurfaceBounds *surfacesBounds;
 
   GfxStaticModelDrawInst *smodelDrawInsts;
 
   GfxStaticModelDrawInst *smodelDrawInsts;
 
   GfxDrawSurf *surfaceMaterials;
 
   GfxDrawSurf *surfaceMaterials;
 
   unsigned int *surfaceCastsSunShadow;
 
   unsigned int *surfaceCastsSunShadow;
      unsigned int unknownCount1;
+
  unsigned int sunShadowOptCount;
      unsigned int unknownCount2;
+
  unsigned int sunSurfVisDataCount;
      char * unknown2; //size = (unknownCount1 * unknownCount2) << 2
+
  unsigned int *surfaceCastsSunShadowOpt;
 +
#ifdef PC
 +
  void **constantBuffersLit;
 +
  void **constantBuffersAmbient;
 +
#endif
 
   volatile int usageCount;
 
   volatile int usageCount;
 
};
 
};
Line 399: Line 517:
 
};
 
};
  
struct GfxWorld
+
struct GfxHeroOnlyLight
 +
{
 +
  char type;
 +
  char unused[3];
 +
  float color[3];
 +
  float dir[3];
 +
  float up[3];
 +
  float origin[3];
 +
  float radius;
 +
  float cosHalfFovOuter;
 +
  float cosHalfFovInner;
 +
  int exponent;
 +
};
 +
 
 +
struct __declspec(align(8)) GfxWorld
 
{
 
{
 
   const char *name;
 
   const char *name;
 
   const char *baseName;
 
   const char *baseName;
 +
  unsigned int bspVersion;
 
   int planeCount;
 
   int planeCount;
 
   int nodeCount;
 
   int nodeCount;
      int unknown2;
+
  unsigned int surfaceCount;
   int surfaceCount;
+
   int skyCount;
      unsigned int unknownCount1;
+
  GfxSky *skies;
      unknownGfxWorldStruct2 * unknownStructs1; //Count = unknownCount1;
+
  unsigned int primaryLightCount;
      char unknown1[0x18];
+
  unsigned int primaryLightEnvCount;
   GfxWorldDpvsPlanes dpvsPlanes; //The following rely on the count in this
+
#ifdef PC
      char *unknown4;
+
  unsigned int lastSunPrimaryLightIndex;
   GfxAabbTree *aabbTree;
+
  //One of these sortKey unsigned ints has to go on 360
 +
  //Given that GfxWorldDpvsStatic is missing 8 bytes in the first 0x30+8 bytes,
 +
  //I attribute that to the litDecal settings, which means this would also have to go
 +
  unsigned int sortKeyLitDecal;
 +
#endif
 +
  unsigned int sortKeyEffectDecal;
 +
  unsigned int sortKeyTopDecal;
 +
  unsigned int sortKeyEffectAuto;
 +
  unsigned int sortKeyDistortion;
 +
   GfxWorldDpvsPlanes dpvsPlanes;
 +
  GfxCellTreeCount *aabbTreeCounts;
 +
   GfxCellTree *aabbTrees;
 
   GfxCell *cells;
 
   GfxCell *cells;
   GfxWorldDraw worldDraw;
+
   GfxWorldDraw draw;
 
   GfxLightGrid lightGrid;
 
   GfxLightGrid lightGrid;
 
   int modelCount;
 
   int modelCount;
Line 426: Line 570:
 
   float outdoorLookupMatrix[4][4];
 
   float outdoorLookupMatrix[4][4];
 
   GfxImage *outdoorImage;
 
   GfxImage *outdoorImage;
   unsigned int *cellCasterBits[2];
+
   unsigned int *cellCasterBits;
 +
  unsigned int *cellHasSunLitSurfsBits;
 
   GfxSceneDynModel *sceneDynModel;
 
   GfxSceneDynModel *sceneDynModel;
 
   GfxSceneDynBrush *sceneDynBrush;
 
   GfxSceneDynBrush *sceneDynBrush;
Line 432: Line 577:
 
   unsigned int *primaryLightDynEntShadowVis[2];
 
   unsigned int *primaryLightDynEntShadowVis[2];
 
   char *primaryLightForModelDynEnt;
 
   char *primaryLightForModelDynEnt;
   GfxShadowGeometry *shadowGeom[2];
+
   GfxShadowGeometry *shadowGeom;
 +
#ifdef _XBOX
 +
  GfxShadowGeometry *shadowGeom1;
 +
#endif
 
   GfxLightRegion *lightRegion;
 
   GfxLightRegion *lightRegion;
 
   GfxWorldDpvsStatic dpvs;
 
   GfxWorldDpvsStatic dpvs;
 
   GfxWorldDpvsDynamic dpvsDyn;
 
   GfxWorldDpvsDynamic dpvsDyn;
      unsigned int unknownCount2;
+
  unsigned int mapVtxChecksum;
      char * unknown2; //Size = unknownCount2 * 0x44
+
  unsigned int heroOnlyLightCount;
      int unknown3;
+
  GfxHeroOnlyLight *heroOnlyLights;
 +
  char fogTypesAllowed;
 
};
 
};
#pragma pack(pop)
 
 
</syntaxhighlight>
 
</syntaxhighlight>
 
Keep in mind that the checksum is checked on other clients using the mapcrc dvar.
 
Keep in mind that the checksum is checked on other clients using the mapcrc dvar.

Latest revision as of 00:47, 21 January 2015

The graphics map (or gfx_map) has existed on every Call of Duty so far and is part of the D3DBSP system produced by Radiant. Where the collision map is used for collision data in the map, the graphics map holds visual systems such as lights and particularly the dPVS system. The Dynamic Potentially Visible Sets (dPVS) were developed by Umbra Software to compute visibility databases in real time, and power the Call of Duty engine to this day.

struct GfxPortal;
 
struct __declspec(align(8)) GfxSky
{
  int skySurfCount;
  int *skyStartSurfs;
  GfxImage *skyImage;
  char skySamplerState;
};
 
struct GfxWorldDpvsPlanes
{
  int cellCount;
  cplane_s *planes;
  unsigned __int16 *nodes;
  unsigned int *sceneEntCellBits;
};
 
struct GfxCellTreeCount
{
  int aabbTreeCount;
};
 
struct __declspec(align(8)) GfxAabbTree
{
  Bounds bounds;
  unsigned __int16 childCount;
  unsigned __int16 surfaceCount;
  unsigned int startSurfIndex;
  unsigned __int16 smodelIndexCount;
  unsigned __int16 *smodelIndexes;
  int childrenOffset;
};
 
struct GfxCellTree
{
  GfxAabbTree *aabbTree;
};
 
struct GfxPortalWritable
{
  bool isQueued;
  bool isAncestor;
  char recursionDepth;
  char hullPointCount;
  float (*hullPoints)[2];
  GfxPortal *queuedParent;
};
 
struct DpvsPlane
{
  float coeffs[4];
};
 
struct GfxPortal
{
  GfxPortalWritable writable;
  DpvsPlane plane;
  float (*vertices)[3];
  unsigned __int16 cellIndex;
  unsigned __int16 closeDistance;
  char vertexCount;
  float hullAxis[2][3];
};
 
struct GfxCell
{
  Bounds bounds;
  int portalCount;
  GfxPortal *portals;
  char reflectionProbeCount;
  char *reflectionProbes;
  char reflectionProbeReferenceCount;
  char *reflectionProbeReferences;
};
 
struct GfxReflectionProbeVolumeData
{
  float volumePlanes[6][4];
};
 
struct __declspec(align(8)) GfxReflectionProbe
{
  float origin[3];
  GfxReflectionProbeVolumeData *probeVolumes;
  unsigned int probeVolumeCount;
};
 
struct GfxReflectionProbeReferenceOrigin
{
  float origin[3];
};
 
struct GfxReflectionProbeReference
{
  char index;
};
 
struct GfxLightmapArray
{
  GfxImage *primary;
  GfxImage *secondary;
};
 
struct GfxWorldVertex
{
  float xyz[3];
  float binormalSign;
  GfxColor color;
#if defined(_XBOX) || defined(PS3)
  PackedTexCoords texCoord;
  PackedTexCoords lmapCoord;
#else
  float texCoord[2];
  float lmapCoord[2];
#endif
  PackedUnitVec normal;
  PackedUnitVec tangent;
};
 
struct GfxWorldVertexData
{
  GfxWorldVertex *vertices;
#ifdef _XBOX
  GfxWorldVertex *vertices2;
#endif
  D3DVertexBuffer worldVb;
};
 
struct GfxWorldVertexLayerData
{
  char *data;
  D3DVertexBuffer layerVb;
};
 
struct GfxWorldDraw
{
  unsigned int reflectionProbeCount;
  GfxImage **reflectionProbes;
  GfxReflectionProbe *reflectionProbeOrigins;
  GfxTexture *reflectionProbeTextures;
  unsigned int reflectionProbeReferenceCount;
  GfxReflectionProbeReferenceOrigin *reflectionProbeReferenceOrigins;
  GfxReflectionProbeReference *reflectionProbeReferences;
  int lightmapCount;
  GfxLightmapArray *lightmaps;
  GfxTexture *lightmapPrimaryTextures;
  GfxTexture *lightmapSecondaryTextures;
  GfxImage *lightmapOverridePrimary;
  GfxImage *lightmapOverrideSecondary;
  unsigned int trisType;
  unsigned int vertexCount;
  GfxWorldVertexData vd;
  unsigned int vertexLayerDataSize;
  GfxWorldVertexLayerData vld;
  unsigned int indexCount;
  unsigned __int16 *indices;
  D3DIndexBuffer indexBuffer;
};
 
struct GfxLightGridEntry
{
  unsigned int colorsIndex;
  unsigned __int16 primaryLightEnvIndex;
  char unused;
  char needsTrace;
};
 
struct GfxLightGridColors
{
  char rgb[56][3];
};
 
struct GfxLightGridColorsHDR
{
  float colorVec3[56][3];
};
 
struct GfxLightGridTree
{
  char maxDepth;
  int nodeCount;
  int leafCount;
  int coordMinGridSpace[3];
  int coordMaxGridSpace[3];
  int coordHalfSizeGridSpace[3];
  int defaultColorIndexBitCount;
  int defaultLightIndexBitCount;
  unsigned int *p_nodeTable;
  int leafTableSize;
  char *p_leafTable;
};
 
struct GfxLightGrid
{
  bool hasLightRegions;
  bool useSkyForLowZ;
  unsigned int lastSunPrimaryLightIndex;
  unsigned __int16 mins[3];
  unsigned __int16 maxs[3];
  unsigned int rowAxis;
  unsigned int colAxis;
  unsigned __int16 *rowDataStart;
  unsigned int rawRowDataSize;
  char *rawRowData;
  unsigned int entryCount;
  GfxLightGridEntry *entries;
  unsigned int colorCount;
  GfxLightGridColors *colors;
  unsigned int missingGridColorIndex;
  int tableVersion;
  int paletteVersion;
  char rangeExponent8BitsEncoding;
  char rangeExponent12BitsEncoding;
  char rangeExponent16BitsEncoding;
  char stageCount;
  float *stageLightingContrastGain;
  unsigned int paletteEntryCount;
  int *paletteEntryAddress;
  unsigned int paletteBitstreamSize;
  char *paletteBitstream;
  GfxLightGridColorsHDR skyLightGridColors;
  GfxLightGridColorsHDR defaultLightGridColors;
  GfxLightGridTree tree;
};
 
struct GfxBrushModelWritable
{
  float mins[3];
  float maxs[3];
};
 
struct GfxBrushModel
{
  GfxBrushModelWritable writable;
  float bounds[2][3];
  unsigned int surfaceCount;
  unsigned int startSurfIndex;
};
 
struct MaterialMemory
{
  Material *material;
  int memory;
};
 
struct __declspec(align(8)) sunflare_t
{
  bool hasValidData;
  Material *spriteMaterial;
  Material *flareMaterial;
  float spriteSize;
  float flareMinSize;
  float flareMinDot;
  float flareMaxSize;
  float flareMaxDot;
  float flareMaxAlpha;
  int flareFadeInTime;
  int flareFadeOutTime;
  float blindMinDot;
  float blindMaxDot;
  float blindMaxDarken;
  int blindFadeInTime;
  int blindFadeOutTime;
  float glareMinDot;
  float glareMaxDot;
  float glareMaxLighten;
  int glareFadeInTime;
  int glareFadeOutTime;
  float sunFxPosition[3];
};
 
struct XModelDrawInfo
{
  unsigned __int16 lod;
  unsigned __int16 surfId;
};
 
struct GfxSceneDynModel
{
  XModelDrawInfo info;
  unsigned __int16 dynEntId;
};
 
struct BModelDrawInfo
{
  unsigned __int16 surfId;
};
 
struct GfxSceneDynBrush
{
  BModelDrawInfo info;
  unsigned __int16 dynEntId;
};
 
struct GfxShadowGeometry
{
  unsigned __int16 surfaceCount;
  unsigned __int16 smodelCount;
  unsigned __int16 *sortedSurfIndex;
  unsigned __int16 *smodelIndex;
};
 
struct GfxLightRegionAxis
{
  float dir[3];
  float midPoint;
  float halfSize;
};
 
struct GfxLightRegionHull
{
  float kdopMidPoint[9];
  float kdopHalfSize[9];
  unsigned int axisCount;
  GfxLightRegionAxis *axis;
};
 
struct GfxLightRegion
{
  unsigned int hullCount;
  GfxLightRegionHull *hulls;
};
 
struct GfxStaticModelInst
{
  Bounds bounds;
  float lightingOrigin[3];
};
 
struct srfTriangles_t
{
  unsigned int vertexLayerData;
  unsigned int firstVertex;
#ifdef PC
  float maxEdgeLength;
#endif
  unsigned __int16 vertexCount;
  unsigned __int16 triCount;
  unsigned int baseIndex;
};
 
struct GfxSurfaceLightingAndFlagsFields
{
  char lightmapIndex;
  char reflectionProbeIndex;
#ifdef PC
  unsigned __int16 primaryLightEnvIndex;
#else
  char primaryLightEnvIndex;
#endif
  char flags;
};
 
union GfxSurfaceLightingAndFlags
{
  GfxSurfaceLightingAndFlagsFields fields;
#ifdef PC
  unsigned __int64 packed;
#else
  unsigned int packed;
#endif
};
 
struct GfxSurface
{
  srfTriangles_t tris;
  Material *material;
  GfxSurfaceLightingAndFlags laf;
};
 
struct __declspec(align(4)) GfxSurfaceBounds
{
  Bounds bounds;
  char flags;
#ifdef _XBOX
  float maxEdgeLength; //Not sure if this goes here, but the srfTriangles_t is missing 4 bytes and I need 4 here, and it'd make sense that this would go here, as it isn't in the Xbox 360 CoD4 srfTriangles_t.
#endif
};
 
struct GfxPackedPlacement
{
  float origin[3];
#if defined(_XBOX) || defined(PS3)
  PackedUnitVec axis[3];
#else
  float axis[3][3];
#endif
  float scale;
};
 
struct GfxStaticModelVertexLighting
{
  char visibility[4];
  unsigned __int16 ambientColorFloat16[4];
#ifdef PC
  unsigned __int16 highlightColorFloat16[4];
#endif
};
 
struct __declspec(align(8)) GfxStaticModelVertexLightingInfo
{
  GfxStaticModelVertexLighting *lightingValues;
  D3DVertexBuffer lightingValuesVb;
  unsigned int numLightingValues;
};
 
struct __declspec(align(8)) GfxStaticModelDrawInst
{
  GfxPackedPlacement placement;
  XModel *model;
 
#ifdef PC
  float groundLighting[4];
#else
  float groundLighting[1];//Again, this makes sense... Either this, or a packed vertex.
#endif
 
  GfxStaticModelVertexLightingInfo vertexLightingInfo;
 
#ifdef PC
  GfxStaticModelLightmapInfo modelLightmapInfo;
#endif
 
  unsigned __int16 lightingHandle;
  unsigned __int16 cullDist;
 
#ifdef PC
  unsigned __int16 flags;
  unsigned __int16 staticModelId;
  unsigned __int16 primaryLightEnvIndex;
#else
  char flags;
  char staticModelId;
  char primaryLightEnvIndex;
#endif
 
  char reflectionProbeIndex;
  char firstMtlSkinIndex;
  char sunShadowFlags;
};
 
struct GfxDrawSurfFields
{
  unsigned __int64 objectId : 16;
  unsigned __int64 reflectionProbeIndex : 8;
  unsigned __int64 hasGfxEntIndex : 1;
  unsigned __int64 customIndex : 5;
  unsigned __int64 materialSortedIndex : 13;
  unsigned __int64 tessellation : 3;//This is probably PC only, but that would mean this structure would only need 4 bytes, and it needs 8
  unsigned __int64 prepass : 2;
  unsigned __int64 useHeroLighting : 1;
  unsigned __int64 sceneLightEnvIndex : 16;
  unsigned __int64 viewModelRender : 1;
  unsigned __int64 surfType : 4;
  unsigned __int64 primarySortKey : 6;
  unsigned __int64 unused : 30;
};
 
union GfxDrawSurf
{
  GfxDrawSurfFields fields;
  Packed128 packed;
};
 
struct __declspec(align(8)) GfxWorldDpvsStatic
{
  unsigned int smodelCount;
  unsigned int staticSurfaceCount;
  unsigned int litOpaqueSurfsBegin;
  unsigned int litOpaqueSurfsEnd;
#ifdef PC
  unsigned int litDecalSurfsBegin;
  unsigned int litDecalSurfsEnd;
#endif
  unsigned int litTransSurfsBegin;
  unsigned int litTransSurfsEnd;
  unsigned int shadowCasterSurfsBegin;
  unsigned int shadowCasterSurfsEnd;
  unsigned int emissiveSurfsBegin;
  unsigned int emissiveSurfsEnd;
  unsigned int smodelVisDataCount;
  unsigned int surfaceVisDataCount;
  unsigned int *smodelVisData[3];
  unsigned int *surfaceVisData[3];
#ifdef PC
  unsigned int *tessellationCutoffVisData[3];
#endif
  unsigned int *sortedSurfIndex;
  GfxStaticModelInst *smodelInsts;
  GfxSurface *surfaces;
  GfxSurfaceBounds *surfacesBounds;
  GfxStaticModelDrawInst *smodelDrawInsts;
  GfxDrawSurf *surfaceMaterials;
  unsigned int *surfaceCastsSunShadow;
  unsigned int sunShadowOptCount;
  unsigned int sunSurfVisDataCount;
  unsigned int *surfaceCastsSunShadowOpt;
#ifdef PC
  void **constantBuffersLit;
  void **constantBuffersAmbient;
#endif
  volatile int usageCount;
};
 
struct GfxWorldDpvsDynamic
{
  unsigned int dynEntClientWordCount[2];
  unsigned int dynEntClientCount[2];
  unsigned int *dynEntCellBits[2];
  char *dynEntVisData[2][3];
};
 
struct GfxHeroOnlyLight
{
  char type;
  char unused[3];
  float color[3];
  float dir[3];
  float up[3];
  float origin[3];
  float radius;
  float cosHalfFovOuter;
  float cosHalfFovInner;
  int exponent;
};
 
struct __declspec(align(8)) GfxWorld
{
  const char *name;
  const char *baseName;
  unsigned int bspVersion;
  int planeCount;
  int nodeCount;
  unsigned int surfaceCount;
  int skyCount;
  GfxSky *skies;
  unsigned int primaryLightCount;
  unsigned int primaryLightEnvCount;
#ifdef PC
  unsigned int lastSunPrimaryLightIndex;
  //One of these sortKey unsigned ints has to go on 360
  //Given that GfxWorldDpvsStatic is missing 8 bytes in the first 0x30+8 bytes,
  //I attribute that to the litDecal settings, which means this would also have to go
  unsigned int sortKeyLitDecal;
#endif
  unsigned int sortKeyEffectDecal;
  unsigned int sortKeyTopDecal;
  unsigned int sortKeyEffectAuto;
  unsigned int sortKeyDistortion;
  GfxWorldDpvsPlanes dpvsPlanes;
  GfxCellTreeCount *aabbTreeCounts;
  GfxCellTree *aabbTrees;
  GfxCell *cells;
  GfxWorldDraw draw;
  GfxLightGrid lightGrid;
  int modelCount;
  GfxBrushModel *models;
  float mins[3];
  float maxs[3];
  unsigned int checksum;
  int materialMemoryCount;
  MaterialMemory *materialMemory;
  sunflare_t sun;
  float outdoorLookupMatrix[4][4];
  GfxImage *outdoorImage;
  unsigned int *cellCasterBits;
  unsigned int *cellHasSunLitSurfsBits;
  GfxSceneDynModel *sceneDynModel;
  GfxSceneDynBrush *sceneDynBrush;
  unsigned int *primaryLightEntityShadowVis;
  unsigned int *primaryLightDynEntShadowVis[2];
  char *primaryLightForModelDynEnt;
  GfxShadowGeometry *shadowGeom;
#ifdef _XBOX
  GfxShadowGeometry *shadowGeom1;
#endif
  GfxLightRegion *lightRegion;
  GfxWorldDpvsStatic dpvs;
  GfxWorldDpvsDynamic dpvsDyn;
  unsigned int mapVtxChecksum;
  unsigned int heroOnlyLightCount;
  GfxHeroOnlyLight *heroOnlyLights;
  char fogTypesAllowed;
};

Keep in mind that the checksum is checked on other clients using the mapcrc dvar.