UFO: Alien Invasion
|
Go to the source code of this file.
Functions | |
void | R_AddLight (const vec3_t origin, float radius, const vec3_t color) |
Create light to be rendered in the current frame (will be removed before the next) More... | |
void | R_AddSustainedLight (const vec3_t org, float radius, const vec3_t color, float sustain) |
void | R_UpdateSustainedLights (void) |
Updates state of sustained lights; should be called once per frame right before world rendering. More... | |
void | R_EnableWorldLights (void) |
Set up lighting data for the GLSL world shader. More... | |
void | R_EnableModelLights (const light_t **lights, int numLights, bool inShadow, bool enable) |
Enable or disable realtime dynamic lighting for models. More... | |
void | R_AddStaticLight (const vec3_t origin, float radius, const vec3_t color) |
Add static light for model lighting (world already got them baked into lightmap) More... | |
void | R_DisableLights (void) |
void | R_ClearStaticLights (void) |
Remove all static light data. More... | |
static void | R_AddLightToEntity (const vec_t *pos, lighting_t *ltng, const light_t *light, const float distSqr) |
Adds light to the entity's lights list, sorted by distance. More... | |
void | R_UpdateLightList (entity_t *ent) |
Recalculate active lights list for the given entity; R_CalcTransform(ent) should be called before this. More... | |
Variables | |
static sustain_t | r_sustainArray [MAX_GL_LIGHTS] |
static lighting_t | fakeLightingData |
Create light to be rendered in the current frame (will be removed before the next)
Definition at line 36 of file r_light.cpp.
References light_s::color, Com_DPrintf(), DEBUG_RENDERER, rendererData_t::dynamicLights, i, MAX_GL_LIGHTS, rendererData_t::numDynamicLights, light_s::origin, light_s::radius, refdef, and VectorCopy.
Referenced by CL_ParticleRun2(), and R_UpdateSustainedLights().
|
static |
Adds light to the entity's lights list, sorted by distance.
In the long run, it would probably be highly beneficial to separate the rendering of the world from the updating of the world. Having a "rendering" thread that was separate from a "thinking" thread (that was responsible for updating the sorted light list, updating models and textures based on animations or material properties, updating the state of the world based on user input, etc.). It would require that care to be taken to ensure proper synchronization and avoid race-conditions, but it would allow us to decouple the framerate of the renderer from the speed at which we can compute all the other stuff which isn't directly linked to the frame-by-frame rendering process (this includes anything that is supposed to change at a fixed rate of time, like animations; we don't want the animation speed to be linked to the framerate).
Obviously, we would need to maintain compatibility with single-core systems, but multi-core systems are becoming so common that it would make sense to take advantage of that extra power when it exists. Additionally, this type of threaded structure can be effective even on a single processor system by allowing us to prioritize things which must be done in real-time (ie. rendering) from things which won't be noticable to the user if they happen a bit slower, or are updated a bit less often.
[in] | pos | Origin of entity for which light is added |
[in] | ltng | Lighting data for entity being updated |
[in] | light | The light itself |
[in] | distSqr | Squared distance from entity's origin to the light |
Definition at line 350 of file r_light.cpp.
References i, cvar_s::integer, lighting_s::lights, lighting_s::numLights, r_dynamic_lights, and VectorDistSqr.
Referenced by R_UpdateLightList().
Add static light for model lighting (world already got them baked into lightmap)
Definition at line 261 of file r_light.cpp.
References light_s::color, Com_DPrintf(), Com_Printf(), DEBUG_RENDERER, MAX_STATIC_LIGHTS, rendererData_t::numStaticLights, light_s::origin, light_s::radius, refdef, rendererData_t::staticLights, and VectorCopy.
Referenced by SP_light().
Definition at line 58 of file r_light.cpp.
References light_s::color, i, sustain_s::light, MAX_GL_LIGHTS, light_s::origin, r_sustainArray, light_s::radius, refdef, sustain_s::sustain, sustain_s::time, rendererData_t::time, and VectorCopy.
Referenced by CL_ParticleRun2().
Remove all static light data.
Definition at line 300 of file r_light.cpp.
References rendererData_t::numStaticLights, and refdef.
Referenced by R_ModBeginLoading(), and R_SetDefaultState().
Definition at line 282 of file r_light.cpp.
References i, MAX_GL_LIGHTS, and MIN_GL_CONSTANT_ATTENUATION.
Enable or disable realtime dynamic lighting for models.
lights | The lights to enable |
numLights | The amount of lights in the given lights list |
inShadow | Whether model is shadowed from the sun |
enable | Whether to turn realtime lighting on or off |
Definition at line 149 of file r_light.cpp.
References light_s::color, defaultMaterial, rstate_s::dynamic_lighting_enabled, GLPositionTransform(), i, cvar_s::integer, rstate_s::lighting_enabled, MAX_GL_LIGHTS, rendererData_t::modelAmbientColor, light_s::origin, R_DisableAttribute(), r_dynamic_lights, R_EnableAttribute(), r_locals, R_ProgramParameter3fv(), R_ProgramParameter3fvs(), R_ProgramParameter4fvs(), r_programs, r_state, R_UseMaterial(), light_s::radius, refdef, rendererData_t::sunDiffuseColor, rendererData_t::sunVector, Vector4Set, VectorCopy, and rlocals_s::world_matrix.
Referenced by R_DrawAliasModel(), and R_DrawMaterialSurfaces().
Set up lighting data for the GLSL world shader.
Definition at line 108 of file r_light.cpp.
References light_s::color, rendererData_t::dynamicLights, GLPositionTransform(), i, cvar_s::integer, MAX_GL_LIGHTS, rendererData_t::numDynamicLights, light_s::origin, r_dynamic_lights, R_EnableAttribute(), r_locals, R_ProgramParameter3fvs(), R_ProgramParameter4fvs(), r_programs, light_s::radius, refdef, Vector4Set, VectorCopy, and rlocals_s::world_matrix.
Referenced by R_RenderAlphaTestBspRRefs(), and R_RenderOpaqueBspRRefs().
Recalculate active lights list for the given entity; R_CalcTransform(ent) should be called before this.
[in] | ent | Entity to recalculate lights for |
< Worldspace position for which lighting is calculated
< The root entitity of tagent tree, which holds the lighting data (af any)
< Lighting data for the entity being processed
< conservative estimate of entity's bounding sphere diameter, in vector form
< value of this entity's diameter (approx)
< as if sun wasn't at infinite distance
Definition at line 394 of file r_light.cpp.
References CACHE_CLEAR_TRESHOLD, lighting_s::cachedLights, rendererData_t::dynamicLights, fakeLightingData, trace_s::fraction, rlocals_s::frame, i, lighting_s::inShadow, cvar_s::integer, lighting_s::lastCachePos, lighting_s::lastLitFrame, lighting_s::lights, MASK_SOLID, lighting_s::numCachedLights, rendererData_t::numDynamicLights, lighting_s::numLights, rendererData_t::numStaticLights, OBJZERO, light_s::origin, R_AddLightToEntity(), r_dynamic_lights, r_locals, R_Trace(), light_s::radius, refdef, RF_ACTOR, rendererData_t::staticLights, rendererData_t::sunVector, rendererData_t::trace, VectorCopy, VectorDist, VectorDistSqr, VectorLength(), and VectorMA().
Referenced by R_DrawAliasModel().
Updates state of sustained lights; should be called once per frame right before world rendering.
Definition at line 83 of file r_light.cpp.
References light_s::color, i, sustain_s::light, MAX_GL_LIGHTS, light_s::origin, R_AddLight(), light_s::radius, refdef, sustain_s::sustain, sustain_s::time, rendererData_t::time, and VectorScale.
Referenced by R_RenderFrame().
|
static |
To return if no actual lighting data is provided
Definition at line 384 of file r_light.cpp.
Referenced by R_UpdateLightList().
|
static |
Definition at line 30 of file r_light.cpp.
Referenced by R_AddSustainedLight().