Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

146 lines
3.4 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. //
  8. //-----------------------------------------------------------------------------
  9. // $Log: $
  10. //
  11. // $NoKeywords: $
  12. //=============================================================================//
  13. #ifndef LIGHTMAP_H
  14. #define LIGHTMAP_H
  15. #pragma once
  16. #include "mathlib/bumpvects.h"
  17. #include "bsplib.h"
  18. typedef struct
  19. {
  20. dface_t *faces[2];
  21. Vector interface_normal;
  22. qboolean coplanar;
  23. } edgeshare_t;
  24. extern edgeshare_t edgeshare[MAX_MAP_EDGES];
  25. //==============================================
  26. // This is incremented each time BuildFaceLights and FinalLightFace
  27. // are called. It's used for a status bar in WorldCraft.
  28. extern int g_iCurFace;
  29. extern int vertexref[MAX_MAP_VERTS];
  30. extern int *vertexface[MAX_MAP_VERTS];
  31. struct faceneighbor_t
  32. {
  33. int numneighbors; // neighboring faces that share vertices
  34. int *neighbor; // neighboring face list (max of 64)
  35. Vector *normal; // adjusted normal per vertex
  36. Vector facenormal; // face normal
  37. bool bHasDisp; // is this surface a displacement surface???
  38. };
  39. extern faceneighbor_t faceneighbor[MAX_MAP_FACES];
  40. //==============================================
  41. struct sample_t
  42. {
  43. // in local luxel space
  44. winding_t *w;
  45. int s, t;
  46. Vector2D coord;
  47. Vector2D mins;
  48. Vector2D maxs;
  49. // in world units
  50. Vector pos;
  51. Vector normal;
  52. float area;
  53. };
  54. struct facelight_t
  55. {
  56. // irregularly shaped light sample data, clipped by face and luxel grid
  57. int numsamples;
  58. sample_t *sample;
  59. LightingValue_t *light[MAXLIGHTMAPS][NUM_BUMP_VECTS+1]; // result of direct illumination, indexed by sample
  60. // regularly spaced lightmap grid
  61. int numluxels;
  62. Vector *luxel; // world space position of luxel
  63. Vector *luxelNormals; // world space normal of luxel
  64. float worldAreaPerLuxel;
  65. };
  66. extern directlight_t *activelights;
  67. extern directlight_t *freelights;
  68. extern facelight_t facelight[MAX_MAP_FACES];
  69. extern int numdlights;
  70. //==============================================
  71. struct lightinfo_t
  72. {
  73. vec_t facedist;
  74. Vector facenormal;
  75. Vector facemid; // world coordinates of center
  76. Vector modelorg; // for origined bmodels
  77. Vector luxelOrigin;
  78. Vector worldToLuxelSpace[2]; // s = (world - luxelOrigin) . worldToLuxelSpace[0], t = (world - luxelOrigin) . worldToLuxelSpace[1]
  79. Vector luxelToWorldSpace[2]; // world = luxelOrigin + s * luxelToWorldSpace[0] + t * luxelToWorldSpace[1]
  80. int facenum;
  81. dface_t *face;
  82. int isflat;
  83. int hasbumpmap;
  84. };
  85. struct SSE_SampleInfo_t
  86. {
  87. int m_FaceNum;
  88. int m_WarnFace;
  89. dface_t *m_pFace;
  90. facelight_t *m_pFaceLight;
  91. int m_LightmapWidth;
  92. int m_LightmapHeight;
  93. int m_LightmapSize;
  94. int m_NormalCount;
  95. int m_iThread;
  96. texinfo_t *m_pTexInfo;
  97. bool m_IsDispFace;
  98. int m_NumSamples;
  99. int m_NumSampleGroups;
  100. int m_Clusters[4];
  101. FourVectors m_Points;
  102. FourVectors m_PointNormals[ NUM_BUMP_VECTS + 1 ];
  103. };
  104. extern void InitLightinfo( lightinfo_t *l, int facenum );
  105. void FreeDLights();
  106. void ExportDirectLightsToWorldLights();
  107. float CalculateAmbientOcclusion( Vector *pPosition, Vector *pNormal );
  108. fltx4 CalculateAmbientOcclusion4( const FourVectors &position4, const FourVectors &normal4, int static_prop_index_to_ignore );
  109. float SoftenCosineTerm( float flDot );
  110. fltx4 SoftenCosineTerm( fltx4 dots );
  111. #endif // LIGHTMAP_H