}
}
-void R_Model_Alias_DrawFakeShadow (entity_render_t *ent)
-{
- int i, meshnum;
- aliasmesh_t *mesh;
- aliasskin_t *skin;
- rmeshstate_t m;
- float *v, plane[4], dist, projection[3], floororigin[3], surfnormal[3], lightdirection[3], v2[3];
-
- if ((ent->effects & EF_ADDITIVE) || ent->alpha < 1)
- return;
-
- lightdirection[0] = 0.5;
- lightdirection[1] = 0.2;
- lightdirection[2] = -1;
- VectorNormalizeFast(lightdirection);
-
- VectorMA(ent->origin, 65536.0f, lightdirection, v2);
- if (CL_TraceLine(ent->origin, v2, floororigin, surfnormal, false, NULL, SUPERCONTENTS_SOLID) == 1)
- return;
-
- R_Mesh_Matrix(&ent->matrix);
-
- memset(&m, 0, sizeof(m));
- R_Mesh_State_Texture(&m);
-
- GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- GL_DepthMask(false);
- GL_DepthTest(true);
- GL_VertexPointer(varray_vertex3f);
- GL_Color(0, 0, 0, 0.5);
-
- // put a light direction in the entity's coordinate space
- Matrix4x4_Transform3x3(&ent->inversematrix, lightdirection, projection);
- VectorNormalizeFast(projection);
-
- // put the plane's normal in the entity's coordinate space
- Matrix4x4_Transform3x3(&ent->inversematrix, surfnormal, plane);
- VectorNormalizeFast(plane);
-
- // put the plane's distance in the entity's coordinate space
- VectorSubtract(floororigin, ent->origin, floororigin);
- plane[3] = DotProduct(floororigin, surfnormal) + 2;
-
- dist = -1.0f / DotProduct(projection, plane);
- VectorScale(projection, dist, projection);
- for (meshnum = 0, mesh = ent->model->alias.aliasdata_meshes;meshnum < ent->model->alias.aliasnum_meshes;meshnum++)
- {
- skin = R_FetchAliasSkin(ent, mesh);
- if (skin->flags & ALIASSKIN_TRANSPARENT)
- continue;
- R_Model_Alias_GetMesh_Array3f(ent, mesh, MODELARRAY_VERTEX, varray_vertex3f);
- for (i = 0, v = varray_vertex3f;i < mesh->num_vertices;i++, v += 3)
- {
- dist = DotProduct(v, plane) - plane[3];
- if (dist > 0)
- VectorMA(v, dist, projection, v);
- }
- c_alias_polys += mesh->num_triangles;
- R_Mesh_Draw(mesh->num_vertices, mesh->num_triangles, mesh->data_element3i);
- }
-}
-
void R_Model_Alias_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin, float lightradius)
{
int meshnum;
}
}
-void R_Model_Zymotic_DrawFakeShadow(entity_render_t *ent)
-{
- // FIXME
-}
-
void R_Model_Zymotic_DrawLight(entity_render_t *ent, vec3_t relativelightorigin, float lightradius2, float lightdistbias, float lightsubtract, float *lightcolor)
{
// FIXME
cvar_t r_drawentities = {0, "r_drawentities","1"};
cvar_t r_drawviewmodel = {0, "r_drawviewmodel","1"};
-cvar_t r_shadows = {CVAR_SAVE, "r_shadows", "0"};
cvar_t r_shadow_staticworldlights = {0, "r_shadow_staticworldlights", "1"};
cvar_t r_speeds = {0, "r_speeds","0"};
cvar_t r_fullbright = {0, "r_fullbright","0"};
Cmd_AddCommand("timerefresh", R_TimeRefresh_f);
Cvar_RegisterVariable(&r_drawentities);
Cvar_RegisterVariable(&r_drawviewmodel);
- Cvar_RegisterVariable(&r_shadows);
Cvar_RegisterVariable(&r_shadow_staticworldlights);
Cvar_RegisterVariable(&r_speeds);
Cvar_RegisterVariable(&r_fullbrights);
}
}
-void R_DrawFakeShadows(void)
-{
- int i;
- entity_render_t *ent;
-
- ent = &cl_entities[0].render;
- if (ent->model && ent->model->DrawFakeShadow)
- ent->model->DrawFakeShadow(ent);
-
- if (!r_drawentities.integer)
- return;
- for (i = 0;i < r_refdef.numentities;i++)
- {
- ent = r_refdef.entities[i];
- if ((ent->flags & RENDER_SHADOW) && ent->model && ent->model->DrawFakeShadow)
- ent->model->DrawFakeShadow(ent);
- }
-}
-
#include "r_shadow.h"
int shadowframecount = 0;
R_DrawModels();
R_TimeReport("models");
- if (r_shadows.integer == 1 && !r_shadow_realtime_world.integer)
- {
- R_DrawFakeShadows();
- R_TimeReport("fakeshadow");
- }
-
if (r_shadow_realtime_world.integer || r_shadow_realtime_dlight.integer)
{
R_ShadowVolumeLighting(false);
static qbyte templight[MAX_LIGHTMAP_SIZE*MAX_LIGHTMAP_SIZE*4];
cvar_t r_ambient = {0, "r_ambient", "0"};
-cvar_t r_vertexsurfaces = {0, "r_vertexsurfaces", "0"};
cvar_t r_dlightmap = {CVAR_SAVE, "r_dlightmap", "1"};
cvar_t r_drawportals = {0, "r_drawportals", "0"};
cvar_t r_testvis = {0, "r_testvis", "0"};
if (fogenabled)
RSurfShader_OpaqueWall_Pass_Fog(ent, texture, surfchain);
}
- else if (r_vertexsurfaces.integer)
- {
- // opaque vertex shaded from lightmap
- for (chain = surfchain;(surf = *chain) != NULL;chain++)
- if (surf->visframe == r_framecount)
- RSurfShader_Wall_Pass_BaseVertex(ent, surf, texture, texture->rendertype, texture->currentalpha);
- if (texture->skin.glow)
- for (chain = surfchain;(surf = *chain) != NULL;chain++)
- if (surf->visframe == r_framecount)
- RSurfShader_Wall_Pass_Glow(ent, surf, texture, texture->rendertype, texture->currentalpha);
- if (fogenabled)
- for (chain = surfchain;(surf = *chain) != NULL;chain++)
- if (surf->visframe == r_framecount)
- RSurfShader_Wall_Pass_Fog(ent, surf, texture, texture->rendertype, texture->currentalpha);
- }
else
{
// opaque lightmapped
{
c_faces++;
surf->visframe = r_framecount;
- if (surf->cached_dlight && surf->lightmaptexture != NULL && !r_vertexsurfaces.integer)
+ if (surf->cached_dlight && surf->lightmaptexture != NULL)
R_BuildLightMap(ent, surf);
}
}
}
}
-/*
-void R_Q3BSP_DrawFakeShadow(entity_render_t *ent)
-{
-}
-*/
-
void R_Q3BSP_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin, float lightradius)
{
int i;
dlightdivtable[i] = 4194304 / (i << 7);
Cvar_RegisterVariable(&r_ambient);
- Cvar_RegisterVariable(&r_vertexsurfaces);
Cvar_RegisterVariable(&r_dlightmap);
Cvar_RegisterVariable(&r_drawportals);
Cvar_RegisterVariable(&r_testvis);
#define BOUNDI(VALUE,MIN,MAX) if (VALUE < MIN || VALUE >= MAX) Host_Error("model %s has an invalid ##VALUE (%d exceeds %d - %d)\n", loadmodel->name, VALUE, MIN, MAX);
#define BOUNDF(VALUE,MIN,MAX) if (VALUE < MIN || VALUE >= MAX) Host_Error("model %s has an invalid ##VALUE (%f exceeds %f - %f)\n", loadmodel->name, VALUE, MIN, MAX);
extern void R_Model_Alias_Draw(entity_render_t *ent);
-extern void R_Model_Alias_DrawFakeShadow(entity_render_t *ent);
extern void R_Model_Alias_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin, float lightradius);
extern void R_Model_Alias_DrawLight(entity_render_t *ent, vec3_t relativelightorigin, vec3_t relativeeyeorigin, float lightradius, float *lightcolor, const matrix4x4_t *matrix_modeltofilter, const matrix4x4_t *matrix_modeltoattenuationxyz, const matrix4x4_t *matrix_modeltoattenuationz);
void Mod_IDP0_Load(model_t *mod, void *buffer)
loadmodel->alias.aliastype = ALIASTYPE_ALIAS;
loadmodel->DrawSky = NULL;
loadmodel->Draw = R_Model_Alias_Draw;
- loadmodel->DrawFakeShadow = R_Model_Alias_DrawFakeShadow;
loadmodel->DrawShadowVolume = R_Model_Alias_DrawShadowVolume;
loadmodel->DrawLight = R_Model_Alias_DrawLight;
loadmodel->alias.aliastype = ALIASTYPE_ALIAS;
loadmodel->DrawSky = NULL;
loadmodel->Draw = R_Model_Alias_Draw;
- loadmodel->DrawFakeShadow = R_Model_Alias_DrawFakeShadow;
loadmodel->DrawShadowVolume = R_Model_Alias_DrawShadowVolume;
loadmodel->DrawLight = R_Model_Alias_DrawLight;
loadmodel->alias.aliastype = ALIASTYPE_ALIAS;
loadmodel->DrawSky = NULL;
loadmodel->Draw = R_Model_Alias_Draw;
- loadmodel->DrawFakeShadow = R_Model_Alias_DrawFakeShadow;
loadmodel->DrawShadowVolume = R_Model_Alias_DrawShadowVolume;
loadmodel->DrawLight = R_Model_Alias_DrawLight;
loadmodel->flags = 0;
extern void R_Model_Zymotic_DrawSky(entity_render_t *ent);
extern void R_Model_Zymotic_Draw(entity_render_t *ent);
-extern void R_Model_Zymotic_DrawFakeShadow(entity_render_t *ent);
extern void R_Model_Zymotic_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin, float lightradius);
extern void R_Model_Zymotic_DrawLight(entity_render_t *ent, vec3_t relativelightorigin, vec3_t relativeeyeorigin, float lightradius, float *lightcolor, const matrix4x4_t *matrix_modeltofilter, const matrix4x4_t *matrix_modeltoattenuationxyz, const matrix4x4_t *matrix_modeltoattenuationz);
void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer)
loadmodel->alias.aliastype = ALIASTYPE_ZYM;
loadmodel->DrawSky = NULL;
loadmodel->Draw = R_Model_Zymotic_Draw;
- loadmodel->DrawFakeShadow = NULL;//R_Model_Zymotic_DrawFakeShadow;
loadmodel->DrawShadowVolume = NULL;//R_Model_Zymotic_DrawShadowVolume;
loadmodel->DrawLight = NULL;//R_Model_Zymotic_DrawLight;
// this gets altered below if sky is used
mod->DrawSky = NULL;
mod->Draw = R_Model_Brush_Draw;
- mod->DrawFakeShadow = NULL;
mod->DrawShadowVolume = R_Model_Brush_DrawShadowVolume;
mod->DrawLight = R_Model_Brush_DrawLight;
mod->brushq1.pvstexturechains = Mem_Alloc(originalloadmodel->mempool, mod->brushq1.numtextures * sizeof(msurface_t **));
//extern void R_Q3BSP_DrawSky(struct entity_render_s *ent);
extern void R_Q3BSP_Draw(struct entity_render_s *ent);
-//extern void R_Q3BSP_DrawFakeShadow(struct entity_render_s *ent);
extern void R_Q3BSP_DrawShadowVolume(struct entity_render_s *ent, vec3_t relativelightorigin, float lightradius);
extern void R_Q3BSP_DrawLight(struct entity_render_s *ent, vec3_t relativelightorigin, vec3_t relativeeyeorigin, float lightradius, float *lightcolor, const matrix4x4_t *matrix_modeltofilter, const matrix4x4_t *matrix_modeltoattenuationxyz, const matrix4x4_t *matrix_modeltoattenuationz);
void Mod_Q3BSP_Load(model_t *mod, void *buffer)
mod->brush.TraceBox = Mod_Q3BSP_TraceBox;
//mod->DrawSky = R_Q3BSP_DrawSky;
mod->Draw = R_Q3BSP_Draw;
- //mod->DrawFakeShadow = R_Q3BSP_DrawFakeShadow;
mod->DrawShadowVolume = R_Q3BSP_DrawShadowVolume;
mod->DrawLight = R_Q3BSP_DrawLight;
void(*DrawSky)(struct entity_render_s *ent);
// draw the model using lightmap/dlight shading
void(*Draw)(struct entity_render_s *ent);
- // draw a fake shadow for the model
- void(*DrawFakeShadow)(struct entity_render_s *ent);
// draw a shadow volume for the model based on light source
void(*DrawShadowVolume)(struct entity_render_s *ent, vec3_t relativelightorigin, float lightradius);
// draw the lighting on a model (through stencil)
loadmodel->DrawSky = NULL;
loadmodel->Draw = R_Model_Sprite_Draw;
- loadmodel->DrawFakeShadow = NULL;
loadmodel->DrawShadowVolume = NULL;
loadmodel->DrawLight = NULL;