Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Macros | Enumerations | Functions | Variables
lightmap.cpp File Reference
#include <boost/algorithm/clamp.hpp>
#include <limits.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <memory>
#include "SDL_keycode.h"
#include "SDL_mutex.h"
#include "SDL_opengl.h"
#include "SDL_stdinc.h"
#include "SDL_thread.h"
#include "SDL_timer.h"
#include "inexor/engine/blend.hpp"
#include "inexor/engine/lightmap.hpp"
#include "inexor/engine/material.hpp"
#include "inexor/engine/octa.hpp"
#include "inexor/engine/octaedit.hpp"
#include "inexor/engine/octarender.hpp"
#include "inexor/engine/octree.hpp"
#include "inexor/engine/renderbackground.hpp"
#include "inexor/engine/shader.hpp"
#include "inexor/engine/world.hpp"
#include "inexor/fpsgame/entities.hpp"
#include "inexor/fpsgame/fps.hpp"
#include "inexor/io/Logging.hpp"
#include "inexor/io/input/InputRouter.hpp"
#include "inexor/model/model.hpp"
#include "inexor/model/rendermodel.hpp"
#include "inexor/network/SharedVar.hpp"
#include "inexor/physics/physics.hpp"
#include "inexor/shared/command.hpp"
#include "inexor/shared/cube_formatting.hpp"
#include "inexor/shared/cube_hash.hpp"
#include "inexor/shared/cube_loops.hpp"
#include "inexor/shared/cube_tools.hpp"
#include "inexor/shared/cube_types.hpp"
#include "inexor/shared/cube_vector.hpp"
#include "inexor/shared/ents.hpp"
#include "inexor/shared/geom.hpp"
#include "inexor/shared/tools.hpp"
#include "inexor/texture/image.hpp"
#include "inexor/texture/savetexture.hpp"
#include "inexor/texture/slot.hpp"
#include "inexor/texture/texsettings.hpp"
#include "inexor/texture/texture.hpp"

Classes

struct  lightmapworker
 Structure containing anything to calculate while calclighting, which gets passed to the lightmap threads. More...
 
struct  lightmapinfo
 
struct  lightmaptask
 
struct  lightmapext
 
struct  layoutinfo
 
struct  lightcacheentry
 

Macros

#define MAXLIGHTMAPTASKS   4096
 
#define LIGHTMAPBUFSIZE   (2*1024*1024)
 
#define CHECK_PROGRESS_LOCKED(exit, before, after)   CHECK_CALCLIGHT_PROGRESS_LOCKED(exit, show_calclight_progress, before, after)
 
#define CHECK_PROGRESS(exit)   CHECK_PROGRESS_LOCKED(exit, , )
 
#define NCHECK(n)
 
#define SURFACE_AMBIENT   SURFACE_AMBIENT_BOTTOM
 
#define SURFACE_LIGHTMAP   SURFACE_LIGHTMAP_BOTTOM
 
#define EDGE_TOLERANCE(x, y)
 
#define AA_EDGE_TOLERANCE(x, y, i)   EDGE_TOLERANCE(x + aacoords[i][0], y + aacoords[i][1])
 
#define LIGHTCACHESIZE   1024
 
#define LIGHTCACHEHASH(x, y)   (((((x)^(y))<<5) + (((x)^(y))>>5)) & (LIGHTCACHESIZE - 1))
 
#define ALLOCLOCK(name, init)   { if(lightmapping > 1) name = init(); if(!name) lightmapping = 1; }
 
#define FREELOCK(name, destroy)   { if(name) { destroy(name); name = NULL; } }
 

Enumerations

enum  {
  NO_SURFACE = 0, SURFACE_AMBIENT_BOTTOM, SURFACE_AMBIENT_TOP, SURFACE_LIGHTMAP_BOTTOM,
  SURFACE_LIGHTMAP_TOP, SURFACE_LIGHTMAP_BLEND
}
 

Functions

 VARR (lightprecision, 1, 32, 1024)
 
 VARR (lighterror, 1, 8, 16)
 
 VARR (bumperror, 1, 3, 16)
 
 VARR (lightlod, 0, 0, 10)
 
 HVARFR (ambient, 1, 0x191919, 0xFFFFFF,{if(ambient<=255) ambient|=(ambient<< 8)|(ambient<< 16);ambientcolor=bvec((ambient >>16)&0xFF,(ambient >>8)&0xFF, ambient &0xFF);})
 
 HVARFR (skylight, 0, 0, 0xFFFFFF,{if(skylight<=255) skylight|=(skylight<< 8)|(skylight<< 16);skylightcolor=bvec((skylight >>16)&0xFF,(skylight >>8)&0xFF, skylight &0xFF);})
 
void setupsunlight ()
 
 HVARFR (sunlight, 0, 0, 0xFFFFFF,{if(sunlight<=255) sunlight|=(sunlight<< 8)|(sunlight<< 16);sunlightcolor=bvec((sunlight >>16)&0xFF,(sunlight >>8)&0xFF, sunlight &0xFF);setupsunlight();})
 
 FVARFR (sunlightscale, 0, 1, 16, setupsunlight())
 
void setsunlightdir ()
 
 VARFR (sunlightyaw, 0, 0, 360, setsunlightdir())
 
 VARFR (sunlightpitch,-90, 90, 90, setsunlightdir())
 
 VARR (skytexturelight, 0, 1, 1)
 
void brightencube (cube &c)
 
void setsurfaces (cube &c, const surfaceinfo *surfs, const vertinfo *verts, int numverts)
 
void setsurface (cube &c, int orient, const surfaceinfo &src, const vertinfo *srcverts, int numsrcverts)
 
 VARN (lmshadows, lmshadows_, 0, 2, 2)
 
 VARN (lmaa, lmaa_, 0, 3, 3)
 
 VARN (lerptjoints, lerptjoints_, 0, 1, 1)
 
 VARN (lmao, lmao_, 0, 1, 1)
 
void check_calclight_canceled ()
 
void show_calclight_progress ()
 
static void insertunlit (int i)
 
static void insertlightmap (lightmapinfo &li, layoutinfo &si)
 
static void copylightmap (lightmapinfo &li, layoutinfo &si)
 
static bool htcmp (const lightmapinfo &k, const layoutinfo &v)
 
static uint hthash (const lightmapinfo &k)
 
 VAR (lightcompress, 0, 3, 6)
 
static bool packlightmap (lightmapinfo &l, layoutinfo &surface)
 
static void updatelightmap (const layoutinfo &surface)
 
 VARR (ambientocclusion, 0, 0, 255)
 
 FVARR (ambientocclusionradius, 1.0, 2.0, 200.0)
 
 VAR (debugao, 0, 0, 1)
 
static float calcocclusion (ShadowRayCache *cache, const vec &o, const vec &normal, float tolerance)
 Calculates a value between 0 and 1 representing the occulation of a pixel. More...
 
static uint generatelumel (lightmapworker *w, const float tolerance, uint lightmask, const vector< const extentity * > &lights, const vec &target, const vec &normal, vec &sample, uchar &occlusionsample, int x, int y)
 Generate Lumels (Pixel) of a specific sample, calculating its color. More...
 
static bool lumelsample (const vec &sample, int aasample, int stride)
 Returns whether sample does need to be saved (whether lumels/pixels need to be generated). More...
 
static void calcskylight (lightmapworker *w, const vec &o, const vec &normal, float tolerance, uchar *skylight, int flags=RAY_ALPHAPOLY, extentity *t=nullptr)
 
static bool hasskylight ()
 
 VARR (blurlms, 0, 0, 2)
 
 VARR (blurskylight, 0, 0, 2)
 
static void generatealpha (lightmapworker *w, float tolerance, const vec &pos, uchar &alpha)
 
 VAR (edgetolerance, 1, 4, 64)
 
 VAR (adaptivesample, 0, 2, 2)
 
static bool generatelightmap (lightmapworker *w, float lpu, const lerpvert *lv, int numv, vec origin1, const vec &xstep1, const vec &ystep1, vec origin2, const vec &xstep2, const vec &ystep2, float side0, float sidestep)
 
static int finishlightmap (lightmapworker *w)
 
static int previewlightmapalpha (lightmapworker *w, float lpu, const vec &origin1, const vec &xstep1, const vec &ystep1, const vec &origin2, const vec &xstep2, const vec &ystep2, float side0, float sidestep)
 
static void clearsurfaces (cube *c)
 
 VARF (lightcachesize, 4, 6, 12, clearlightcache())
 
void clearlightcache (int id)
 
const vector< int > & checklightcache (int x, int y)
 
static void addlight (lightmapworker *w, const extentity &light, int cx, int cy, int cz, int size, const vec *v, const vec *n, int numv)
 
static bool findlights (lightmapworker *w, int cx, int cy, int cz, int size, const vec *v, const vec *n, int numv, const Slot &slot, const VSlot &vslot)
 
static int packlightmaps (lightmapworker *w=nullptr)
 
static lightmapinfoalloclightmap (lightmapworker *w)
 
static void freelightmap (lightmapworker *w)
 
static int setupsurface (lightmapworker *w, plane planes[2], int numplanes, const vec *p, const vec *n, int numverts, vertinfo *litverts, bool preview=false)
 
static void removelmalpha (lightmapworker *w)
 
static lightmapinfosetupsurfaces (lightmapworker *w, lightmaptask &task)
 
static bool processtasks (bool finish=false)
 
static void generatelightmaps (cube *c, const ivec &co, int size)
 
static bool previewblends (lightmapworker *w, cube &c, const ivec &co, int size)
 
static bool previewblends (lightmapworker *w, cube *c, const ivec &co, int size, const ivec &bo, const ivec &bs)
 
void previewblends (const ivec &bo, const ivec &bs)
 
void cleanuplightmaps ()
 
void resetlightmaps (bool fullclean)
 
static Uint32 calclighttimer (Uint32 interval, void *param)
 
bool setlightmapquality (int quality)
 
 VARP (lightthreads, 0, 0, 16)
 
static void cleanuplocks ()
 
static void setupthreads (int numthreads)
 
static void cleanupthreads ()
 
void calclight (int *quality)
 
 COMMAND (calclight,"i")
 
 VAR (patchnormals, 0, 0, 1)
 
void patchlight (int *quality)
 
 COMMAND (patchlight,"i")
 
void clearlightmaps ()
 
 COMMAND (clearlightmaps,"")
 
void setfullbrightlevel (int fullbrightlevel)
 
 VARF (fullbright, 0, 0, 1, if(lightmaptexs.length()){initlights();lightents();})
 
 VARF (fullbrightlevel, 0, 128, 255, setfullbrightlevel(fullbrightlevel))
 
static void rotatenormals (LightMap &lmlv, int x, int y, int w, int h, int rotate)
 
static void rotatenormals (cube *c)
 
void fixlightmapnormals ()
 
void fixrotatedlightmaps (cube &c, const ivec &co, int size)
 
void fixrotatedlightmaps ()
 
static void copylightmap (LightMap &lm, uchar *dst, size_t stride)
 
void genreservedlightmaptexs ()
 
static void findunlit (int i)
 
 VARF (roundlightmaptex, 0, 4, 16,{cleanuplightmaps();initlights();allchanged();})
 
 VARF (batchlightmaps, 0, 4, 256,{cleanuplightmaps();initlights();allchanged();})
 
void genlightmaptexs (int flagmask, int flagval)
 
void clearlights ()
 
void lightent (extentity &e, float height)
 
void lightents (bool force)
 
void initlights ()
 
static void fastskylight (const vec &o, float tolerance, uchar *skylight, int flags=RAY_ALPHAPOLY, extentity *t=nullptr, bool fast=false)
 
void lightreaching (const vec &target, vec &color, vec &dir, bool fast, extentity *t, float ambient)
 
entitybrightestlight (const vec &target, const vec &dir)
 
void dumplms ()
 
 COMMAND (dumplms,"")
 

Variables

static vector< lightmapworker * > lightmapworkers
 
static vector< lightmaptasklightmaptasks [2]
 
static vector< lightmapextlightmapexts
 
static int packidx = 0
 
static int allocidx = 0
 
static SDL_mutex * lightlock = nullptr
 
static SDL_mutex * tasklock = nullptr
 
static SDL_cond * fullcond = nullptr
 
static SDL_cond * emptycond = nullptr
 
int lightmapping = 0
 
vector< LightMaplightmaps
 
bvec ambientcolor (0x19, 0x19, 0x19)
 
bvec skylightcolor (0, 0, 0)
 
bvec sunlightcolor (0, 0, 0)
 
vec sunlightdir (0, 0, 1)
 
entity sunlightent
 
static const surfaceinfo brightsurfaces [6]
 
static int lmshadows = 2
 
static int lmaa = 3
 
static int lerptjoints = 1
 
static int lmao = 1
 
static uint progress = 0
 
static uint taskprogress = 0
 
static GLuint progresstex = 0
 
static int progresstexticks = 0
 
static int progresslightmap = -1
 
bool calclight_canceled = false
 
volatile bool check_calclight_progress = false
 
static hashset< layoutinfocompressed
 
static struct lightcacheentry lightcache [LIGHTCACHESIZE]
 
vector< LightMapTexturelightmaptexs
 
bool brightengeom = false
 
bool shouldlightents = false
 

Class Documentation

struct lightmapinfo
Class Members
int bpp
int bufsize
cube * c
uchar * colorbuf
int h
int layers
lightmapinfo * next
bool packed
bvec * raybuf
int surface
int type
int w
struct lightmaptask
Class Members
cube * c
cubeext * ext
lightmapinfo * lightmaps
ivec o
int progress
int size
int usefaces
lightmapworker * worker
struct lightmapext
Class Members
cube * c
cubeext * ext
struct layoutinfo
Class Members
uchar h
ushort lmid
uchar w
ushort x
ushort y
struct lightcacheentry
Class Members
vector< int > lights
int x
int y

Macro Definition Documentation

#define AA_EDGE_TOLERANCE (   x,
  y,
 
)    EDGE_TOLERANCE(x + aacoords[i][0], y + aacoords[i][1])

Referenced by generatelightmap().

#define ALLOCLOCK (   name,
  init 
)    { if(lightmapping > 1) name = init(); if(!name) lightmapping = 1; }

Referenced by setupthreads().

#define CHECK_PROGRESS (   exit)    CHECK_PROGRESS_LOCKED(exit, , )

Referenced by generatelightmaps(), and processtasks().

#define CHECK_PROGRESS_LOCKED (   exit,
  before,
  after 
)    CHECK_CALCLIGHT_PROGRESS_LOCKED(exit, show_calclight_progress, before, after)

Referenced by processtasks().

#define EDGE_TOLERANCE (   x,
 
)
Value:
(x < blurlms \
|| x+1 > w->w - blurlms \
|| y < blurlms \
|| y+1 > w->h - blurlms \
? edgetolerance : 1)

Referenced by generatelightmap().

#define FREELOCK (   name,
  destroy 
)    { if(name) { destroy(name); name = NULL; } }

Referenced by cleanuplocks().

#define LIGHTCACHEHASH (   x,
 
)    (((((x)^(y))<<5) + (((x)^(y))>>5)) & (LIGHTCACHESIZE - 1))

Referenced by checklightcache(), and clearlightcache().

#define LIGHTCACHESIZE   1024

Referenced by clearlightcache().

#define LIGHTMAPBUFSIZE   (2*1024*1024)
#define MAXLIGHTMAPTASKS   4096

Referenced by generatelightmaps().

#define NCHECK (   n)
Value:
if((n).x >= int(ambientcolor[0])+1 || (n).y >= int(ambientcolor[1])+1 || (n).z >= int(ambientcolor[2])+1) \
return true;
bvec ambientcolor(0x19, 0x19, 0x19)

Referenced by lumelsample().

#define SURFACE_AMBIENT   SURFACE_AMBIENT_BOTTOM
#define SURFACE_LIGHTMAP   SURFACE_LIGHTMAP_BOTTOM

Referenced by setupsurface().

Enumeration Type Documentation

anonymous enum
Enumerator
NO_SURFACE 
SURFACE_AMBIENT_BOTTOM 
SURFACE_AMBIENT_TOP 
SURFACE_LIGHTMAP_BOTTOM 
SURFACE_LIGHTMAP_TOP 
SURFACE_LIGHTMAP_BLEND 

Function Documentation

static void addlight ( lightmapworker w,
const extentity light,
int  cx,
int  cy,
int  cz,
int  size,
const vec v,
const vec n,
int  numv 
)
inlinestatic
static lightmapinfo* alloclightmap ( lightmapworker w)
static
void brightencube ( cube c)
entity* brightestlight ( const vec target,
const vec dir 
)
void calclight ( int *  quality)
static Uint32 calclighttimer ( Uint32  interval,
void param 
)
static

References check_calclight_progress.

Referenced by calclight(), and patchlight().

static float calcocclusion ( ShadowRayCache cache,
const vec o,
const vec normal,
float  tolerance 
)
static

Calculates a value between 0 and 1 representing the occulation of a pixel.

Attention
crashes if a normal vector of length zero occurs

References ASSERT, vec::isnormalized(), vec::iszero(), RAD, RAY_ALPHAPOLY, RAY_SHADOW, RAY_SKIPSKY, game::rays, and shadowray().

Referenced by generatelumel().

static void calcskylight ( lightmapworker w,
const vec o,
const vec normal,
float  tolerance,
uchar skylight,
int  flags = RAY_ALPHAPOLY,
extentity t = nullptr 
)
static
void check_calclight_canceled ( )
const vector<int>& checklightcache ( int  x,
int  y 
)
void cleanuplightmaps ( )
static void cleanuplocks ( )
static

References emptycond, FREELOCK, fullcond, lightlock, and tasklock.

Referenced by cleanupthreads(), and setupthreads().

static void cleanupthreads ( )
static
void clearlightcache ( int  id)
void clearlightmaps ( )
void clearlights ( )
static void clearsurfaces ( cube c)
static
COMMAND ( calclight  ,
"i"   
)
COMMAND ( patchlight  ,
"i"   
)
COMMAND ( clearlightmaps  ,
""   
)
COMMAND ( dumplms  ,
""   
)
static void copylightmap ( lightmapinfo li,
layoutinfo si 
)
static
static void copylightmap ( LightMap lm,
uchar dst,
size_t  stride 
)
static
void dumplms ( )
static void fastskylight ( const vec o,
float  tolerance,
uchar skylight,
int  flags = RAY_ALPHAPOLY,
extentity t = nullptr,
bool  fast = false 
)
inlinestatic
static bool findlights ( lightmapworker w,
int  cx,
int  cy,
int  cz,
int  size,
const vec v,
const vec n,
int  numv,
const Slot slot,
const VSlot vslot 
)
static
static void findunlit ( int  i)
static
static int finishlightmap ( lightmapworker w)
static
void fixlightmapnormals ( )

References rotatenormals(), and worldroot.

Referenced by load_world().

void fixrotatedlightmaps ( cube c,
const ivec co,
int  size 
)
void fixrotatedlightmaps ( )
static void freelightmap ( lightmapworker w)
static
FVARFR ( sunlightscale  ,
,
,
16  ,
setupsunlight()   
)
FVARR ( ambientocclusionradius  ,
1.  0,
2.  0,
200.  0 
)
static void generatealpha ( lightmapworker w,
float  tolerance,
const vec pos,
uchar alpha 
)
inlinestatic
static bool generatelightmap ( lightmapworker w,
float  lpu,
const lerpvert lv,
int  numv,
vec  origin1,
const vec xstep1,
const vec ystep1,
vec  origin2,
const vec xstep2,
const vec ystep2,
float  side0,
float  sidestep 
)
static
static void generatelightmaps ( cube c,
const ivec co,
int  size 
)
static
static uint generatelumel ( lightmapworker w,
const float  tolerance,
uint  lightmask,
const vector< const extentity * > &  lights,
const vec target,
const vec normal,
vec sample,
uchar occlusionsample,
int  x,
int  y 
)
static
void genlightmaptexs ( int  flagmask,
int  flagval 
)
void genreservedlightmaptexs ( )
static bool hasskylight ( )
inlinestatic
static bool htcmp ( const lightmapinfo k,
const layoutinfo v 
)
inlinestatic
static uint hthash ( const lightmapinfo k)
inlinestatic
HVARFR ( ambient  ,
,
0x191919  ,
0xFFFFFF  ,
{if(ambient<=255) ambient|=(ambient<< 8)|(ambient<< 16);ambientcolor=bvec((ambient >>16)&0xFF,(ambient >>8)&0xFF, ambient &0xFF);}   
)
HVARFR ( skylight  ,
,
,
0xFFFFFF  ,
{if(skylight<=255) skylight|=(skylight<< 8)|(skylight<< 16);skylightcolor=bvec((skylight >>16)&0xFF,(skylight >>8)&0xFF, skylight &0xFF);}   
)
HVARFR ( sunlight  ,
,
,
0xFFFFFF  ,
{if(sunlight<=255) sunlight|=(sunlight<< 8)|(sunlight<< 16);sunlightcolor=bvec((sunlight >>16)&0xFF,(sunlight >>8)&0xFF, sunlight &0xFF);setupsunlight();}   
)
void initlights ( )
static void insertlightmap ( lightmapinfo li,
layoutinfo si 
)
static
static void insertunlit ( int  i)
static
void lightent ( extentity e,
float  height 
)
void lightents ( bool  force)
void lightreaching ( const vec target,
vec color,
vec dir,
bool  fast,
extentity t,
float  ambient 
)
static bool lumelsample ( const vec sample,
int  aasample,
int  stride 
)
static

Returns whether sample does need to be saved (whether lumels/pixels need to be generated).

true if sample colour is not darker than the ambient light (hence saveworthy).

References ambientcolor, and NCHECK.

Referenced by generatelightmap().

static bool packlightmap ( lightmapinfo l,
layoutinfo surface 
)
static
static int packlightmaps ( lightmapworker w = nullptr)
static
void patchlight ( int *  quality)
static bool previewblends ( lightmapworker w,
cube c,
const ivec co,
int  size 
)
static

References vec::add(), lightmapworker::blendmapcache, lightmapworker::bpp, brightbottomsurface, surfaceinfo::brighten(), brightsurface, brightsurfaces, lightmapworker::bufstart, lightmapworker::bufused, lightmapworker::c, copylightmap(), lightmapworker::curlightmaps, DEFAULT_SKY, cube::ext, f(), faceconvexity(), lightmapworker::firstlightmap, flataxisface(), genfaceverts(), lightmapworker::h, layoutinfo::h, isempty, lightmapworker::lastlightmap, VSlot::layer, LAYER_BLEND, LAYER_BOTTOM, lightmaps, LM_ALPHA, LM_BUMPMAP0, LM_DIFFUSE, LM_PACKH, LM_PACKW, surfaceinfo::lmid, layoutinfo::lmid, LMID_RESERVED, lookupvslot(), loopi(), loopj, loopk, ivec::mask(), MAT_ALPHA, cube::material, MAXFACEVERTS, vec::mul(), vec::normalize(), sphere::numverts, surfaceinfo::numverts, lightmapworker::orient, packlightmap(), lightmapworker::rotate, VSlot::rotation, vertinfo::set(), setblendmaporigin(), setsurfaces(), setupsurface(), Slot::shader, shader(), SHADER_NORMALSLMS, ivec::shl(), VSlot::slot, lightmapworker::slot, SURFACE_AMBIENT_TOP, SURFACE_LIGHTMAP_BLEND, cubeext::surfaces, cube::texture, plane::toplane(), surfaceinfo::totalverts(), lightmapworker::type, Shader::type, vertinfo::u, updatelightmap(), vertinfo::v, surfaceinfo::verts, cubeext::verts(), visibletris(), lightmapworker::vslot, lightmapworker::w, layoutinfo::w, vertinfo::x, layoutinfo::x, vertinfo::y, and layoutinfo::y.

Referenced by clearblendmapsel(), invertblendmap(), invertblendmapsel(), paintblendmap(), previewblends(), and showblendmap().

static bool previewblends ( lightmapworker w,
cube c,
const ivec co,
int  size,
const ivec bo,
const ivec bs 
)
static
void previewblends ( const ivec bo,
const ivec bs 
)
static int previewlightmapalpha ( lightmapworker w,
float  lpu,
const vec origin1,
const vec xstep1,
const vec ystep1,
const vec origin2,
const vec xstep2,
const vec ystep2,
float  side0,
float  sidestep 
)
static
static bool processtasks ( bool  finish = false)
static
static void removelmalpha ( lightmapworker w)
static
void resetlightmaps ( bool  fullclean)
static void rotatenormals ( LightMap lmlv,
int  x,
int  y,
int  w,
int  h,
int  rotate 
)
static

References LightMap::data, LM_PACKW, loopi(), and loopj.

Referenced by fixlightmapnormals(), and rotatenormals().

static void rotatenormals ( cube c)
static
void setfullbrightlevel ( int  fullbrightlevel)
bool setlightmapquality ( int  quality)

References lerptjoints, lmaa, lmao, and lmshadows.

Referenced by calclight(), and patchlight().

void setsunlightdir ( )
void setsurface ( cube c,
int  orient,
const surfaceinfo src,
const vertinfo srcverts,
int  numsrcverts 
)
void setsurfaces ( cube c,
const surfaceinfo surfs,
const vertinfo verts,
int  numverts 
)
void setupsunlight ( )
static int setupsurface ( lightmapworker w,
plane  planes[2],
int  numplanes,
const vec p,
const vec n,
int  numverts,
vertinfo litverts,
bool  preview = false 
)
static
static lightmapinfo* setupsurfaces ( lightmapworker w,
lightmaptask task 
)
static
static void setupthreads ( int  numthreads)
static
void show_calclight_progress ( )
static void updatelightmap ( const layoutinfo surface)
static
VAR ( lightcompress  ,
,
,
 
)
VAR ( debugao  ,
,
,
 
)
VAR ( edgetolerance  ,
,
,
64   
)
VAR ( adaptivesample  ,
,
,
 
)
VAR ( patchnormals  ,
,
,
 
)
VARF ( lightcachesize  ,
,
,
12  ,
clearlightcache()   
)
VARF ( fullbright  ,
,
,
,
if(lightmaptexs.length()){initlights();lightents();}   
)
VARF ( fullbrightlevel  ,
,
128  ,
255  ,
setfullbrightlevel(fullbrightlevel)   
)
VARF ( roundlightmaptex  ,
,
,
16  ,
{cleanuplightmaps();initlights();allchanged();}   
)
VARF ( batchlightmaps  ,
,
,
256  ,
{cleanuplightmaps();initlights();allchanged();}   
)
VARFR ( sunlightyaw  ,
,
,
360  ,
setsunlightdir()   
)
VARFR ( sunlightpitch  ,
90,
90  ,
90  ,
setsunlightdir()   
)
VARN ( lmshadows  ,
lmshadows_  ,
,
,
 
)
VARN ( lmaa  ,
lmaa_  ,
,
,
 
)
VARN ( lerptjoints  ,
lerptjoints_  ,
,
,
 
)
VARN ( lmao  ,
lmao_  ,
,
,
 
)
VARP ( lightthreads  ,
,
,
16   
)
VARR ( lightprecision  ,
,
32  ,
1024   
)
VARR ( lighterror  ,
,
,
16   
)
VARR ( bumperror  ,
,
,
16   
)
VARR ( lightlod  ,
,
,
10   
)
VARR ( skytexturelight  ,
,
,
 
)
VARR ( ambientocclusion  ,
,
,
255   
)
VARR ( blurlms  ,
,
,
 
)
VARR ( blurskylight  ,
,
,
 
)

Variable Documentation

int allocidx = 0
static
bvec ambientcolor(0x19, 0x19, 0x19)
bool brightengeom = false

Referenced by changebatchtmus(), and gengrassquads().

const surfaceinfo brightsurfaces[6]
static
Initial value:
=
{
brightsurface
}
static const surfaceinfo brightsurface
Definition: octree.hpp:86

Referenced by brightencube(), and previewblends().

bool calclight_canceled = false
volatile bool check_calclight_progress = false
hashset<layoutinfo> compressed
static
SDL_cond * emptycond = nullptr
static
SDL_cond* fullcond = nullptr
static
int lerptjoints = 1
static
struct lightcacheentry lightcache[LIGHTCACHESIZE]
static

Referenced by checklightcache(), and clearlightcache().

SDL_mutex* lightlock = nullptr
static
vector<lightmapext> lightmapexts
static
int lightmapping = 0
vector<LightMap> lightmaps
vector<lightmaptask> lightmaptasks[2]
static
vector<LightMapTexture> lightmaptexs
vector<lightmapworker *> lightmapworkers
static
int lmaa = 3
static
int lmao = 1
static
int lmshadows = 2
static
int packidx = 0
static
uint progress = 0
static
int progresslightmap = -1
static
GLuint progresstex = 0
static
int progresstexticks = 0
static
bool shouldlightents = false

Referenced by clearlights(), initlights(), and lightents().

bvec skylightcolor(0, 0, 0)
bvec sunlightcolor(0, 0, 0)
vec sunlightdir(0, 0, 1)
entity sunlightent

Referenced by brightestlight(), and setupsunlight().

SDL_mutex * tasklock = nullptr
static
uint taskprogress = 0
static