29 #include "../idlib/precompiled.h"
127 if ( args.
Argc() != 4 ) {
128 common->
Printf(
"usage: modulateLights <redFloat> <greenFloat> <blueFloat>\n" );
134 for ( i = 0 ; i < 3 ; i++ ) {
135 modulate[
i] = atof( args.
Argv( i+1 ) );
145 for (
int j = 0 ;
j < 3 ;
j++ ) {
197 for (i = 0 ; i < 8 ; i++) {
246 normal = up.
Cross( right );
250 dist = target * normal;
256 scale = ( 0.5f * dist ) / rLen;
258 scale = -( 0.5f * dist ) / uLen;
261 lightProject[2] = normal;
262 lightProject[2][3] = -( origin * lightProject[2].
Normal() );
264 lightProject[0] =
right;
265 lightProject[0][3] = -( origin * lightProject[0].
Normal() );
267 lightProject[1] = up;
268 lightProject[1][3] = -( origin * lightProject[1].
Normal() );
271 targetGlobal.
ToVec3() = target + origin;
273 ofs = 0.5f - ( targetGlobal * lightProject[0].
ToVec4() ) / ( targetGlobal * lightProject[2].ToVec4() );
274 lightProject[0].
ToVec4() += ofs * lightProject[2].
ToVec4();
275 ofs = 0.5f - ( targetGlobal * lightProject[1].
ToVec4() ) / ( targetGlobal * lightProject[2].ToVec4() );
276 lightProject[1].
ToVec4() += ofs * lightProject[2].
ToVec4();
279 normal = stop -
start;
280 dist = normal.Normalize();
284 lightProject[3] = normal * ( 1.0f / dist );
285 startGlobal = start + origin;
286 lightProject[3][3] = -( startGlobal * lightProject[3].
Normal() );
301 frustum[0] = lightProject[0];
302 frustum[1] = lightProject[1];
303 frustum[2] = lightProject[2] - lightProject[0];
304 frustum[3] = lightProject[2] - lightProject[1];
307 frustum[4] = lightProject[3];
309 frustum[5] = lightProject[3];
310 frustum[5][3] -= 1.0f;
311 frustum[5] = -frustum[5];
313 for ( i = 0 ; i < 6 ; i++ ) {
316 frustum[
i] = -frustum[
i];
336 for ( i = 0; i < 6; i++ ) {
406 for ( i = 0 ; i < 6 ; i++ ) {
411 for ( i = 0 ; i < 4 ; i++ ) {
446 #define MAX_LIGHT_VERTS 40
459 for ( i = 0 ; i < tri->
numVerts ; i++ ) {
504 memset( &fakeLight, 0,
sizeof( fakeLight ) );
505 fakeLight.
parms = renderLight;
511 for (
int i = 0 ;
i < 6 ;
i++ ) {
528 for ( j = 0 ; j < 6 ; j++ ) {
570 for ( prt = area->
portals ; prt ; prt = prt->
next ) {
610 for ( lref = ldef->
references ; lref ; lref = nextRef ) {
671 if ( !keepCachedDynamicModel ) {
677 for ( ref = def->
entityRefs ; ref ; ref = next ) {
702 inter->FreeSurfaces();
835 if ( i < rw->numPortalAreas ) {
idRenderWorldLocal * world
const idMaterial * lightShader
void AddEntityRefToArea(idRenderEntityLocal *def, portalArea_t *area)
idRenderModel * dynamicModel
GLsizei const GLfloat * points
virtual idRenderModel * DefaultModel()=0
void R_RenderLightFrustum(const renderLight_t &renderLight, idPlane lightFrustum[6])
void R_SetLightFrustum(const idPlane lightProject[4], idPlane frustum[6])
struct doublePortal_s * foggedPortals
void R_SetLightProject(idPlane lightProject[4], const idVec3 origin, const idVec3 target, const idVec3 rightVector, const idVec3 upVector, const idVec3 start, const idVec3 stop)
const idVec3 & Normal(void) const
void R_FreeEntityDefOverlay(idRenderEntityLocal *def)
void R_CreateLightRefs(idRenderLightLocal *light)
idRenderLightLocal * fogLight
virtual void UpdateLightDef(qhandle_t lightHandle, const renderLight_t *rlight)
srfTriangles_t * R_PolytopeSurface(int numPlanes, const idPlane *planes, idWinding **windings)
GLenum GLenum GLenum GLenum GLenum scale
areaReference_t * entityRefs
idList< idRenderEntityLocal * > entityDefs
void FlowLightThroughPortals(idRenderLightLocal *light)
const idVec4 & ToVec4(void) const
idRenderWorldLocal * primaryWorld
void R_RegenerateWorld_f(const idCmdArgs &args)
virtual const idMaterial * FindMaterial(const char *name, bool makeDefault=true)=0
idList< idRenderWorldLocal * > worlds
idVec3 Cross(const idVec3 &a) const
deferredEntityCallback_t callback
static void Free(idRenderModelOverlay *overlay)
void R_CheckForEntityDefsUsingModel(idRenderModel *model)
idList< idRenderLightLocal * > lightDefs
float shaderParms[MAX_ENTITY_SHADER_PARMS]
void R_ReCreateWorldReferences(void)
bool LightCastsShadows() const
struct doublePortal_s * nextFoggedPortal
void R_CreateEntityRefs(idRenderEntityLocal *def)
GLuint GLuint GLsizei count
void R_FreeLightDefFrustum(idRenderLightLocal *ldef)
virtual void FreeLightDef(qhandle_t lightHandle)
int GetNumPoints(void) const
idRenderModelDecal * decals
GLubyte GLubyte GLubyte GLubyte w
idVec3 vec3_origin(0.0f, 0.0f, 0.0f)
idRenderWorldLocal * world
areaReference_t * references
idCVar r_showUpdates("r_showUpdates","0", CVAR_RENDERER|CVAR_BOOL,"report entity and light updates and ref counts")
void R_FreeEntityDefDerivedData(idRenderEntityLocal *def, bool keepDecals, bool keepCachedDynamicModel)
idInteraction * firstInteraction
struct areaReference_s * ownerNext
const int MAX_RENDERENTITY_GUI
void R_MakeShadowFrustums(idRenderLightLocal *def)
void R_FreeStaticTriSurf(srfTriangles_t *tri)
idBlockAlloc< areaReference_t, 1024 > areaReferenceAllocator
void R_ModulateLights_f(const idCmdArgs &args)
virtual void Printf(const char *fmt,...) id_attribute((format(printf
float Normalize(bool fixDegenerate=true)
virtual idBounds Bounds(const struct renderEntity_s *ent=NULL) const =0
idRenderModel * cachedDynamicModel
idDeclManager * declManager
srfTriangles_t * frustumTris
bool WindingCompletelyInsideLight(const idWinding *w, const idRenderLightLocal *ldef)
static idRenderModelDecal * RemoveFadedDecals(idRenderModelDecal *decals, int time)
void R_CreateLightDefFogPortals(idRenderLightLocal *ldef)
void R_FreeEntityDefDecals(idRenderEntityLocal *def)
void R_FreeDerivedData(void)
idRenderModelManager * renderModelManager
idRenderModel * prelightModel
bool IsCleared(void) const
void R_DeriveLightData(idRenderLightLocal *light)
void R_FreeEntityDefFadedDecals(idRenderEntityLocal *def, int time)
void R_LocalPlaneToGlobal(const float modelMatrix[16], const idPlane &in, idPlane &out)
portalArea_t * portalAreas
virtual int PointInArea(const idVec3 &point) const
void Mem_Free16(void *ptr)
idRenderModelDecal * Next(void) const
idRenderModelOverlay * overlay
idWinding * frustumWindings[6]
struct portalArea_s * area
class idUserInterface * gui[MAX_RENDERENTITY_GUI]
bool TestMaterialFlag(const int flag) const
struct areaReference_s * areaNext
const idVec3 & ToVec3(void) const
const char * Argv(int arg) const
void PushVolumeIntoTree(idRenderEntityLocal *def, idRenderLightLocal *light, int numPoints, const idVec3(*points))
struct doublePortal_s * doublePortal
idInteraction * firstInteraction
void R_LocalPointToGlobal(const float modelMatrix[16], const idVec3 &in, idVec3 &out)
virtual void Error(const char *fmt,...) id_attribute((format(printf
const idMaterial * shader
idImage * LightFalloffImage() const
void R_AxisToModelMatrix(const idMat3 &axis, const idVec3 &origin, float modelMatrix[16])
void R_FreeLightDefDerivedData(idRenderLightLocal *ldef)
idCVar r_useLightPortalFlow("r_useLightPortalFlow","1", CVAR_RENDERER|CVAR_BOOL,"use a more precise area reference determination")
void R_ClearEntityDefDynamicModel(idRenderEntityLocal *def)
struct areaReference_s * areaPrev
static void Free(idRenderModelDecal *decal)