|
UFO: Alien Invasion
|

Go to the source code of this file.
Data Structures | |
| struct | lightinfo_t |
| lightinfo is a temporary bucket for lighting calculations More... | |
| struct | extents_t |
| face extents More... | |
| struct | facelight_t |
| buckets for sample accumulation - clipped by the surface More... | |
| struct | light_t |
| a light source More... | |
Macros | |
| #define | sun_angles config.sun_angles[config.compile_for_day] |
| #define | sun_normal config.sun_normal[config.compile_for_day] |
| #define | sun_color config.sun_color[config.compile_for_day] |
| #define | sun_intensity config.sun_intensity[config.compile_for_day] |
| #define | sun_ambient_color config.sun_ambient_color[config.compile_for_day] |
| #define | SAMPLE_NUDGE 0.25 |
| #define | MAX_VERT_FACES 256 |
| #define | MAX_SAMPLES 5 |
| #define | SOFT_SAMPLES 4 |
| #define | TGA_HEADER_SIZE 18 |
Enumerations | |
| enum | emittype_t { emit_surface , emit_point , emit_spotlight } |
| Different types of sources emitting light. More... | |
Functions | |
| static void | BuildFaceExtents (void) |
| Populates face_extents for all dBspSurface_t, prior to light creation. This is done so that sample positions may be nudged outward along the face normal and towards the face center to help with traces. | |
| static void | CalcLightinfoExtents (lightinfo_t *l) |
| static void | CalcLightinfoVectors (lightinfo_t *l) |
| Fills in texorg, worldtotex. and textoworld. | |
| static void | CalcPoints (lightinfo_t *l, float sofs, float tofs) |
| For each texture aligned grid point, back project onto the plane to get the world xyz value of the sample point. | |
| void | BuildLights (void) |
| Create lights out of patches and entity lights. | |
| static bool | TR_TestLineSingleTile (const vec3_t start, const vec3_t stop, int *headhint) |
| Checks traces against a single-tile map, optimized for ufo2map. This trace is only for visible levels. | |
| static void | GatherSampleSunlight (const vec3_t pos, const vec3_t normal, float *sample, float *direction, float scale, int *headhint) |
| A follow-up to GatherSampleLight, simply trace along the sun normal, adding sunlight. | |
| static void | GatherSampleLight (vec3_t pos, const vec3_t normal, float *sample, float *direction, float scale, int *headhints) |
| static void | NudgeSamplePosition (const vec3_t in, const vec3_t normal, const vec3_t center, vec3_t out) |
| Move the incoming sample position towards the surface center and along the surface normal to reduce false-positive traces. | |
| static void | FacesWithVert (int vert, int *faces, int *nfaces) |
| Populate faces with indexes of all dBspFace_t's referencing the specified edge. | |
| 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. | |
| static void | SampleNormal (const lightinfo_t *l, const vec3_t pos, vec3_t normal) |
| For Phong-shaded samples, interpolate the vertex normals for the surface in question, weighting them according to their proximity to the sample position. | |
| void | BuildFacelights (unsigned int facenum) |
| static void | WriteTGA24 (const char *filename, const byte *data, int width, int height, int offset) |
| static void | CalcTextureSize (const dBspSurface_t *s, vec2_t texsize, int scale) |
| Calculates the texture width for the lightmap texture. This depends on the surface mins and maxs and the texture scale. | |
| static void | ExportLightmap (const char *path, const char *name, bool day) |
| Export all the faces for one particular lightmap (day or night). | |
| void | ExportLightmaps (const char *bspFileName) |
| Export the day and night lightmap and direction data for the given map. | |
| void | FinalLightFace (unsigned int facenum) |
| Add the indirect lighting on top of the direct lighting and save into final map format. | |
Variables | |
| vec3_t | face_offset [MAX_MAP_FACES] |
| static extents_t | face_extents [MAX_MAP_FACES] |
| static facelight_t | facelight [LIGHTMAP_MAX][MAX_MAP_FACES] |
| static light_t * | lights [LIGHTMAP_MAX] |
| static int | numlights [LIGHTMAP_MAX] |
| static const float | sampleofs [2][MAX_SAMPLES][2] |
| static const vec3_t | luminosity = {0.2125, 0.7154, 0.0721} |
| #define MAX_SAMPLES 5 |
Definition at line 742 of file lightmap.cpp.
Referenced by BuildFacelights().
| #define MAX_VERT_FACES 256 |
Definition at line 633 of file lightmap.cpp.
Referenced by BuildVertexNormals(), FacesWithVert(), and SampleNormal().
| #define SAMPLE_NUDGE 0.25 |
Definition at line 613 of file lightmap.cpp.
Referenced by NudgeSamplePosition().
| #define SOFT_SAMPLES 4 |
Definition at line 743 of file lightmap.cpp.
Referenced by BuildFacelights().
| #define sun_ambient_color config.sun_ambient_color[config.compile_for_day] |
Definition at line 32 of file lightmap.cpp.
Referenced by BuildLights(), and FinalLightFace().
| #define sun_angles config.sun_angles[config.compile_for_day] |
Definition at line 28 of file lightmap.cpp.
Referenced by BuildLights().
| #define sun_color config.sun_color[config.compile_for_day] |
Definition at line 30 of file lightmap.cpp.
Referenced by BuildLights(), and GatherSampleSunlight().
| #define sun_intensity config.sun_intensity[config.compile_for_day] |
Definition at line 31 of file lightmap.cpp.
Referenced by BuildLights(), and GatherSampleSunlight().
| #define sun_normal config.sun_normal[config.compile_for_day] |
Definition at line 29 of file lightmap.cpp.
Referenced by BuildLights(), and GatherSampleSunlight().
| #define TGA_HEADER_SIZE 18 |
Definition at line 871 of file lightmap.cpp.
Referenced by WriteTGA24().
| enum emittype_t |
Different types of sources emitting light.
| Enumerator | |
|---|---|
| emit_surface | surface light via SURF_LIGHT |
| emit_point | point light given via light entity |
| emit_spotlight | spotlight given via light entity (+target) or via light_spot entity |
Definition at line 267 of file lightmap.cpp.
Populates face_extents for all dBspSurface_t, prior to light creation. This is done so that sample positions may be nudged outward along the face normal and towards the face center to help with traces.
Definition at line 72 of file lightmap.cpp.
References curTile, DotProduct, face_extents, dBspSurface_t::firstedge, i, dBspSurface_t::numedges, dBspSurface_t::texinfo, v, dBspTexinfo_t::vecs, and VectorSet.
Referenced by BuildVertexNormals(), and ExportLightmaps().
Definition at line 753 of file lightmap.cpp.
References CalcLightinfoExtents(), CalcLightinfoVectors(), CalcPoints(), Com_Printf(), config, curTile, facelight_t::directions, dBspPlane_t::dist, DotProduct, lightinfo_t::face, face_extents, face_offset, lightinfo_t::facedist, facelight, lightinfo_t::facenormal, GatherSampleLight(), i, MAX_MAP_FACES, MAX_SAMPLES, Mem_AllocTypeN, Mem_Free, lightinfo_t::modelorg, dBspPlane_t::normal, NudgeSamplePosition(), numlights, facelight_t::numsamples, lightinfo_t::numsurfpt, OBJZERO, dBspSurface_t::planenum, SampleNormal(), sampleofs, facelight_t::samples, scale, dBspSurface_t::side, SOFT_SAMPLES, lightinfo_t::step, SURF_PHONG, SURF_WARP, dBspTexinfo_t::surfaceFlags, lightinfo_t::surfpt, TangentVectors(), dBspSurface_t::texinfo, lightinfo_t::textoworld, dBspTexinfo_t::vecs, VectorCopy, VectorEmpty, VectorMA(), VectorNegate, VectorNormalize(), VectorNotEmpty, and VectorSet.
Referenced by LightWorld().
Create lights out of patches and entity lights.
Definition at line 293 of file lightmap.cpp.
References ANGLE_DOWN, ANGLE_UP, AngleVectors(), light_t::color, ColorNormalize(), Com_Printf(), config, dest, emit_point, emit_spotlight, emit_surface, entities, f, face_patches, FindTargetEntity(), FloatForKey(), GetVectorForKey(), GetVectorFromString(), i, light_t::intensity, lights, MAX_MAP_FACES, Mem_AllocType, name, light_t::next, light_t::normal, num_entities, numlights, light_t::origin, Q_streq, Q_strstart(), light_t::stopdot, sun_ambient_color, sun_angles, sun_color, sun_intensity, sun_normal, Sys_Error(), torad, light_t::type, ValueForKey(), VectorClear, VectorCopy, VectorEmpty, VectorNormalize(), VectorSet, VectorSubtract, VERB_EXTRA, VERB_NORMAL, and Verb_Printf().
Referenced by LightWorld().
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().
|
static |
Definition at line 128 of file lightmap.cpp.
References config, curTile, lightinfo_t::face, face_extents, i, MAX_MAP_LIGHTMAP, Sys_Error(), lightinfo_t::texmins, and lightinfo_t::texsize.
Referenced by BuildFacelights().
|
static |
Fills in texorg, worldtotex. and textoworld.
Definition at line 155 of file lightmap.cpp.
References config, curTile, DotProduct, lightinfo_t::face, lightinfo_t::facedist, lightinfo_t::facenormal, i, len, Mem_AllocTypeN, lightinfo_t::modelorg, lightinfo_t::numsurfpt, lightinfo_t::step, lightinfo_t::surfpt, Sys_Error(), dBspSurface_t::texinfo, lightinfo_t::texorg, lightinfo_t::texsize, lightinfo_t::textoworld, UFO_SIZE_T, vec3_origin, dBspTexinfo_t::vecs, VectorAdd, VectorCopy, VectorLength(), VectorMA(), VectorNormalize(), VectorScale, VectorSubtract, VERB_EXTRA, Verb_Printf(), and lightinfo_t::worldtotex.
Referenced by BuildFacelights().
|
static |
For each texture aligned grid point, back project onto the plane to get the world xyz value of the sample point.
| [in,out] | l | The resulting lightinfo data |
| [in] | sofs | The sample offset for the s coordinates |
| [in] | tofs | The sample offset for the t coordinates |
Definition at line 230 of file lightmap.cpp.
References lightinfo_t::step, lightinfo_t::surfpt, lightinfo_t::texmins, lightinfo_t::texorg, lightinfo_t::texsize, and lightinfo_t::textoworld.
Referenced by BuildFacelights().
|
static |
Calculates the texture width for the lightmap texture. This depends on the surface mins and maxs and the texture scale.
| [in] | s | The surface to calculate the lightmap size for |
| [out] | texsize | The resulting texture size vector. First value is width, second value is height |
| [in] | scale | The scale (1/scale) of the lightmap texture in relation to the surface texture |
Definition at line 912 of file lightmap.cpp.
References curTile, face_extents, i, and scale.
Referenced by ExportLightmap().
|
static |
Export all the faces for one particular lightmap (day or night).
| path | The path to write the files into |
| name | The name of the map to export the lightmap for |
| day | true to export the day lightmap data, false to export the night lightmap data |
Definition at line 931 of file lightmap.cpp.
References CalcTextureSize(), Com_Printf(), Com_sprintf(), curTile, i, dBspSurface_t::lightofs, MAX_QPATH, name, scale, Vector2NotEmpty, and WriteTGA24().
Referenced by ExportLightmaps().
| void ExportLightmaps | ( | const char * | bspFileName | ) |
Export the day and night lightmap and direction data for the given map.
| bspFileName | The 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().
Populate faces with indexes of all dBspFace_t's referencing the specified edge.
| [in] | vert | The index of the vertex to check |
| [out] | faces | The index table of the faces found |
| [out] | nfaces | The number of dBspFace_t's referencing edge |
Definition at line 641 of file lightmap.cpp.
References curTile, dBspSurface_t::firstedge, i, MAX_VERT_FACES, dBspSurface_t::numedges, SURF_PHONG, dBspTexinfo_t::surfaceFlags, Sys_Error(), dBspSurface_t::texinfo, and v.
Referenced by BuildVertexNormals().
Add the indirect lighting on top of the direct lighting and save into final map format.
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().
|
static |
| [in] | pos | The point in the world that receives the light |
| [in] | normal | The light direction (normal vector) |
| [out] | sample | The sample color |
| [out] | direction | |
| [in] | scale | is the normalizer for multisampling |
| [in,out] | headhints | An array of theads for each light to optimize the tracing |
Definition at line 548 of file lightmap.cpp.
References light_t::color, config, DotProduct, emit_point, emit_spotlight, emit_surface, GatherSampleSunlight(), light_t::intensity, lights, light_t::next, light_t::normal, light_t::origin, scale, light_t::stopdot, Sys_Error(), TR_TestLineSingleTile(), light_t::type, VectorMA(), VectorMix(), VectorNormalize(), and VectorSubtract.
Referenced by BuildFacelights().
|
static |
A follow-up to GatherSampleLight, simply trace along the sun normal, adding sunlight.
Definition at line 507 of file lightmap.cpp.
References DotProduct, scale, sun_color, sun_intensity, sun_normal, TR_TestLineSingleTile(), VectorMA(), and VectorMix().
Referenced by GatherSampleLight().
|
inlinestatic |
Move the incoming sample position towards the surface center and along the surface normal to reduce false-positive traces.
Definition at line 619 of file lightmap.cpp.
References SAMPLE_NUDGE, VectorCopy, VectorMA(), VectorNormalize(), and VectorSubtract.
Referenced by BuildFacelights().
|
static |
For Phong-shaded samples, interpolate the vertex normals for the surface in question, weighting them according to their proximity to the sample position.
Definition at line 714 of file lightmap.cpp.
References curTile, lightinfo_t::face, dBspSurface_t::firstedge, i, MAX_VERT_FACES, dBspSurface_t::numedges, v, VectorCopy, VectorLength(), and VectorSubtract.
Referenced by BuildFacelights().
Checks traces against a single-tile map, optimized for ufo2map. This trace is only for visible levels.
| [in] | start | The position to start the trace. |
| [in] | stop | The position where the trace ends. |
| [in,out] | headhint | The t-head where the previous trace found an obstacle. |
Definition at line 471 of file lightmap.cpp.
References curTile, i, level, LEVEL_LASTLIGHTBLOCKING, mapTiles, and TR_TestLine_r().
Referenced by GatherSampleLight(), and GatherSampleSunlight().
|
static |
Definition at line 872 of file lightmap.cpp.
References data, FILE_WRITE, FS_OpenFile(), FS_Write(), i, Mem_AllocTypeN, Mem_Free, Sys_Error(), and TGA_HEADER_SIZE.
Referenced by ExportLightmap().
|
static |
Definition at line 65 of file lightmap.cpp.
Referenced by BuildFaceExtents(), BuildFacelights(), BuildVertexNormals(), CalcLightinfoExtents(), and CalcTextureSize().
| vec3_t face_offset[MAX_MAP_FACES] |
for rotating bmodels
Definition at line 34 of file lightmap.cpp.
Referenced by BuildFacelights(), and BuildPatches().
|
static |
Definition at line 264 of file lightmap.cpp.
Referenced by BuildFacelights(), and FinalLightFace().
|
static |
Definition at line 285 of file lightmap.cpp.
Referenced by BuildLights(), GatherSampleLight(), and R_EnableModelLights().
|
static |
Definition at line 980 of file lightmap.cpp.
Referenced by FinalLightFace().
|
static |
Definition at line 286 of file lightmap.cpp.
Referenced by BuildFacelights(), and BuildLights().
|
static |
Definition at line 744 of file lightmap.cpp.
Referenced by BuildFacelights().