UFO: Alien Invasion
Loading...
Searching...
No Matches
lighting.h File Reference
#include "common/shared.h"
#include "common/bspfile.h"
#include "common/polylib.h"
Include dependency graph for lighting.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  patch_t

Macros

#define MAX_PATCHES   65000 /* larger will cause 32 bit overflows */

Functions

void BuildFacelights (unsigned int facenum)
void FinalLightFace (unsigned int facenum)
 Add the indirect lighting on top of the direct lighting and save into final map format.
void ExportLightmaps (const char *bspFileName)
 Export the day and night lightmap and direction data for the given map.
void BuildLights (void)
 Create lights out of patches and entity lights.
void BuildPatches (void)
 Create surface fragments for light-emitting surfaces so that light sources may be computed along them.
void SubdividePatches (void)
 Iterate all of the head face patches, subdividing them as necessary.
void CalcTextureReflectivity (void)
 Calculates the texture color that is used for light emitting surfaces.
void LightWorld (void)
 Build the lightmap out of light entities and surface lights (patches).
void BuildVertexNormals (void)
 Calculate per-vertex (instead of per-plane) normal vectors. This is done by finding all of the faces which share a given vertex, and calculating a weighted average of their normals.
void FreePatches (void)
 After light sources have been created, patches may be freed.

Variables

patch_tface_patches [MAX_MAP_FACES]
vec3_t face_offset [MAX_MAP_FACES]

Macro Definition Documentation

◆ MAX_PATCHES

#define MAX_PATCHES   65000 /* larger will cause 32 bit overflows */

Definition at line 31 of file lighting.h.

Function Documentation

◆ BuildFacelights()

◆ BuildLights()

◆ BuildPatches()

void BuildPatches ( void )

Create surface fragments for light-emitting surfaces so that light sources may be computed along them.

Definition at line 198 of file patches.cpp.

References BuildPatch(), curTile, EntityForModel(), f, face_offset, face_patches, dBspModel_t::firstface, GetVectorForKey(), HasLight(), i, dBspModel_t::numfaces, winding_t::numpoints, OBJZERO, winding_t::p, VectorAdd, VectorCopy, and WindingFromFace().

Referenced by LightWorld().

◆ BuildVertexNormals()

void BuildVertexNormals ( void )

Calculate per-vertex (instead of per-plane) normal vectors. This is done by finding all of the faces which share a given vertex, and calculating a weighted average of their normals.

Definition at line 673 of file lightmap.cpp.

References BuildFaceExtents(), curTile, face_extents, FacesWithVert(), i, MAX_VERT_FACES, extents_t::maxs, extents_t::mins, dBspPlane_t::normal, dBspSurface_t::planenum, scale, dBspSurface_t::side, VectorAdd, VectorClear, VectorLength(), VectorNormalize(), VectorScale, and VectorSubtract.

Referenced by LightWorld(), and main().

◆ CalcTextureReflectivity()

void CalcTextureReflectivity ( void )

Calculates the texture color that is used for light emitting surfaces.

Definition at line 41 of file patches.cpp.

References Com_sprintf(), curTile, i, Img_LoadImage(), MAX_QPATH, Q_streq, texture_reflectivity, VectorCopy, VectorSet, VERB_EXTRA, VERB_NORMAL, and Verb_Printf().

Referenced by main().

◆ ExportLightmaps()

void ExportLightmaps ( const char * bspFileName)

Export the day and night lightmap and direction data for the given map.

Note
The bsp file must already be loaded.
Parameters
bspFileNameThe path of the loaded bsp file.

Definition at line 963 of file lightmap.cpp.

References BuildFaceExtents(), Com_FilePath(), Com_Printf(), Com_SkipPath(), Com_StripExtension(), ExportLightmap(), and MAX_QPATH.

Referenced by main().

◆ FinalLightFace()

void FinalLightFace ( unsigned int facenum)

Add the indirect lighting on top of the direct lighting and save into final map format.

See also
BuildFacelights

Definition at line 987 of file lightmap.cpp.

References config, curTile, dest, facelight_t::directions, DotProduct, f, facelight, luminosity, MAX_MAP_LIGHTING, facelight_t::numsamples, facelight_t::samples, sun_ambient_color, SURF_WARP, Sys_Error(), ThreadLock(), ThreadUnlock(), VectorAdd, VectorCopy, VectorMix(), VectorScale, and VectorSet.

Referenced by LightWorld().

◆ FreePatches()

void FreePatches ( void )

After light sources have been created, patches may be freed.

Definition at line 325 of file patches.cpp.

References face_patches, i, MAX_MAP_FACES, Mem_Free, and patch_t::next.

Referenced by LightWorld().

◆ LightWorld()

void LightWorld ( void )

Build the lightmap out of light entities and surface lights (patches).

Note
Call CalcTextureReflectivity before entering this function

Definition at line 34 of file lighting.cpp.

References BuildFacelights(), BuildLights(), BuildPatches(), BuildVertexNormals(), CloseTracingNodes(), config, curTile, FinalLightFace(), FreePatches(), LEVEL_LASTLIGHTBLOCKING, MakeTracingNodes(), RunThreadsOn(), SubdividePatches(), Sys_Error(), and VERB_NORMAL.

Referenced by main().

◆ SubdividePatches()

void SubdividePatches ( void )

Iterate all of the head face patches, subdividing them as necessary.

Definition at line 312 of file patches.cpp.

References face_patches, i, MAX_MAP_FACES, and SubdividePatch().

Referenced by LightWorld().

Variable Documentation

◆ face_offset

vec3_t face_offset[MAX_MAP_FACES]
extern

for rotating bmodels

Definition at line 34 of file lightmap.cpp.

Referenced by BuildFacelights(), and BuildPatches().

◆ face_patches

patch_t* face_patches[MAX_MAP_FACES]
extern

Definition at line 30 of file patches.cpp.

Referenced by BuildLights(), BuildPatch(), BuildPatches(), FreePatches(), and SubdividePatches().