DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
r_shadow.h File Reference
#include "qtypes.h"
#include "taskqueue.h"
#include "matrixlib.h"
+ Include dependency graph for r_shadow.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  r_shadow_bouncegrid_photon_path_t
 
struct  r_shadow_bouncegrid_photon_t
 
struct  r_shadow_bouncegrid_settings_t
 
struct  r_shadow_bouncegrid_state_t
 

Macros

#define LP_DYNLIGHT   4
 
#define LP_LIGHTMAP   1
 
#define LP_RTWORLD   2
 
#define PHOTON_MAX_PATHS   11
 
#define R_SHADOW_SHADOWMAP_NUMCUBEMAPS   8
 

Functions

void R_CompleteLightPoint (float *ambient, float *diffuse, float *lightdir, const vec3_t p, const int flags, float lightmapintensity, float ambientintensity)
 
void R_RTLight_Compile (struct rtlight_s *rtlight)
 
void R_RTLight_Uncompile (struct rtlight_s *rtlight)
 
void R_RTLight_Update (struct rtlight_s *rtlight, int isstatic, matrix4x4_t *matrix, vec3_t color, int style, const char *cubemapname, int shadow, vec_t corona, vec_t coronasizescale, vec_t ambientscale, vec_t diffusescale, vec_t specularscale, int flags)
 
int R_Shadow_CalcSphereSideMask (const vec3_t p1, float radius, float bias)
 
int R_Shadow_CalcTriangleSideMask (const vec3_t p1, const vec3_t p2, const vec3_t p3, float bias)
 
int R_Shadow_ChooseSidesFromBox (int firsttriangle, int numtris, const float *invertex3f, const int *elements, const matrix4x4_t *worldtolight, const vec3_t projectorigin, const vec3_t projectdirection, const vec3_t lightmins, const vec3_t lightmaxs, const vec3_t surfacemins, const vec3_t surfacemaxs, int *totals)
 
void R_Shadow_ClearShadowMapTexture (void)
 
void R_Shadow_ClearStencil (void)
 
void R_Shadow_DrawCoronas (void)
 
void R_Shadow_DrawLights (void)
 
void R_Shadow_DrawPrepass (void)
 
void R_Shadow_DrawShadowMaps (void)
 
void R_Shadow_Init (void)
 
void R_Shadow_PrepareLights (void)
 
void R_Shadow_PrepareModelShadows (void)
 
void R_Shadow_PrepareShadowMark (int numtris)
 
void R_Shadow_PrepareShadowSides (int numtris)
 
void R_Shadow_RenderLighting (int texturenumsurfaces, const struct msurface_s **texturesurfacelist)
 
void R_Shadow_RenderMode_ActiveLight (const struct rtlight_s *rtlight)
 
void R_Shadow_RenderMode_Begin (void)
 
void R_Shadow_RenderMode_DrawDeferredLight (qbool shadowmapping)
 
void R_Shadow_RenderMode_End (void)
 
void R_Shadow_RenderMode_Lighting (qbool transparent, qbool shadowmapping, qbool noselfshadowpass)
 
void R_Shadow_RenderMode_Reset (void)
 
void R_Shadow_RenderMode_VisibleLighting (qbool transparent)
 
qbool R_Shadow_ScissorForBBox (const float *mins, const float *maxs)
 
void R_Shadow_SetupEntityLight (const struct entity_render_s *ent)
 
void R_Shadow_ShadowMapFromList (int numverts, int numtris, const float *vertex3f, const int *elements, int numsidetris, const int *sidetotals, const unsigned char *sides, const int *sidetris)
 
qbool R_Shadow_ShadowMappingEnabled (void)
 
void R_Shadow_UpdateWorldLightSelection (void)
 

Variables

matrix4x4_t matrix_attenuationxyz
 
matrix4x4_t matrix_attenuationz
 
int maxshadowmark
 
int maxshadowsides
 
int numshadowmark
 
int numshadowsides
 
r_shadow_bouncegrid_state_t r_shadow_bouncegrid_state
 
struct cvar_s r_shadow_bumpscale_basetexture
 
struct cvar_s r_shadow_bumpscale_bumpmap
 
struct rtlight_s * r_shadow_compilingrtlight
 
struct cvar_s r_shadow_debuglight
 
struct cvar_s r_shadow_frontsidecasting
 
struct cvar_s r_shadow_gloss
 
struct cvar_s r_shadow_gloss2exponent
 
struct cvar_s r_shadow_gloss2intensity
 
struct cvar_s r_shadow_glossexact
 
struct cvar_s r_shadow_glossexponent
 
struct cvar_s r_shadow_glossintensity
 
struct cvar_s r_shadow_lightattenuationpower
 
struct cvar_s r_shadow_lightattenuationscale
 
struct cvar_s r_shadow_lightintensityscale
 
struct cvar_s r_shadow_lightradiusscale
 
struct cvar_s r_shadow_projectdistance
 
struct cvar_s r_shadow_realtime_dlight
 
struct cvar_s r_shadow_realtime_dlight_portalculling
 
struct cvar_s r_shadow_realtime_dlight_shadows
 
struct cvar_s r_shadow_realtime_dlight_svbspculling
 
struct cvar_s r_shadow_realtime_world
 
struct cvar_s r_shadow_realtime_world_compile
 
struct cvar_s r_shadow_realtime_world_compileportalculling
 
struct cvar_s r_shadow_realtime_world_compileshadow
 
struct cvar_s r_shadow_realtime_world_compilesvbsp
 
struct cvar_s r_shadow_realtime_world_lightmaps
 
struct cvar_s r_shadow_realtime_world_shadows
 
struct cvar_s r_shadow_scissor
 
intshadowmark
 
int shadowmarkcount
 
intshadowmarklist
 
unsigned char * shadowsides
 
intshadowsideslist
 

Macro Definition Documentation

◆ LP_DYNLIGHT

◆ LP_LIGHTMAP

◆ LP_RTWORLD

◆ PHOTON_MAX_PATHS

#define PHOTON_MAX_PATHS   11

Definition at line 68 of file r_shadow.h.

Referenced by R_Shadow_BounceGrid_TracePhotons_Shot().

◆ R_SHADOW_SHADOWMAP_NUMCUBEMAPS

#define R_SHADOW_SHADOWMAP_NUMCUBEMAPS   8

Definition at line 12 of file r_shadow.h.

Function Documentation

◆ R_CompleteLightPoint()

void R_CompleteLightPoint ( float * ambient,
float * diffuse,
float * lightdir,
const vec3_t p,
const int flags,
float lightmapintensity,
float ambientintensity )

Definition at line 6014 of file r_shadow.c.

6015{
6016 int i, numlights, flag, q;
6017 rtlight_t *light;
6018 dlight_t *dlight;
6019 float relativepoint[3];
6020 float color[3];
6021 float dist;
6022 float dist2;
6023 float intensity;
6024 float sa[3], sx[3], sy[3], sz[3], sd[3];
6025 float lightradius2;
6026
6027 // use first order spherical harmonics to combine directional lights
6028 for (q = 0; q < 3; q++)
6029 sa[q] = sx[q] = sy[q] = sz[q] = sd[q] = 0;
6030
6031 if (flags & LP_LIGHTMAP)
6032 {
6034 {
6035 float tempambient[3];
6036 for (q = 0; q < 3; q++)
6037 tempambient[q] = color[q] = relativepoint[q] = 0;
6038 r_refdef.scene.worldmodel->brush.LightPoint(r_refdef.scene.worldmodel, p, tempambient, color, relativepoint);
6039 // calculate a weighted average light direction as well
6041 for (q = 0; q < 3; q++)
6042 {
6043 sa[q] += (0.5f * color[q] + tempambient[q]) * lightmapintensity;
6044 sx[q] += (relativepoint[0] * color[q]) * lightmapintensity;
6045 sy[q] += (relativepoint[1] * color[q]) * lightmapintensity;
6046 sz[q] += (relativepoint[2] * color[q]) * lightmapintensity;
6047 sd[q] += (intensity * relativepoint[q]) * lightmapintensity;
6048 }
6049 }
6050 else
6051 {
6052 // unlit map - fullbright but scaled by lightmapintensity
6053 for (q = 0; q < 3; q++)
6054 sa[q] += lightmapintensity;
6055 }
6056 }
6057
6058 if (flags & LP_RTWORLD)
6059 {
6062 for (i = 0; i < numlights; i++)
6063 {
6065 if (!dlight)
6066 continue;
6067 light = &dlight->rtlight;
6068 if (!(light->flags & flag))
6069 continue;
6070 // sample
6071 lightradius2 = light->radius * light->radius;
6072 VectorSubtract(light->shadoworigin, p, relativepoint);
6073 dist2 = VectorLength2(relativepoint);
6074 if (dist2 >= lightradius2)
6075 continue;
6076 dist = sqrt(dist2) / light->radius;
6078 if (intensity <= 0.0f)
6079 continue;
6081 continue;
6082 for (q = 0; q < 3; q++)
6083 color[q] = light->currentcolor[q] * intensity;
6085 VectorNormalize(relativepoint);
6086 for (q = 0; q < 3; q++)
6087 {
6088 sa[q] += 0.5f * color[q];
6089 sx[q] += relativepoint[0] * color[q];
6090 sy[q] += relativepoint[1] * color[q];
6091 sz[q] += relativepoint[2] * color[q];
6092 sd[q] += intensity * relativepoint[q];
6093 }
6094 }
6095 // FIXME: sample bouncegrid too!
6096 }
6097
6098 if (flags & LP_DYNLIGHT)
6099 {
6100 // sample dlights
6101 for (i = 0;i < r_refdef.scene.numlights;i++)
6102 {
6103 light = r_refdef.scene.lights[i];
6104 // sample
6105 lightradius2 = light->radius * light->radius;
6106 VectorSubtract(light->shadoworigin, p, relativepoint);
6107 dist2 = VectorLength2(relativepoint);
6108 if (dist2 >= lightradius2)
6109 continue;
6110 dist = sqrt(dist2) / light->radius;
6112 if (intensity <= 0.0f)
6113 continue;
6115 continue;
6116 for (q = 0; q < 3; q++)
6117 color[q] = light->currentcolor[q] * intensity;
6119 VectorNormalize(relativepoint);
6120 for (q = 0; q < 3; q++)
6121 {
6122 sa[q] += 0.5f * color[q];
6123 sx[q] += relativepoint[0] * color[q];
6124 sy[q] += relativepoint[1] * color[q];
6125 sz[q] += relativepoint[2] * color[q];
6126 sd[q] += intensity * relativepoint[q];
6127 }
6128 }
6129 }
6130
6131 // calculate the weighted-average light direction (bentnormal)
6132 for (q = 0; q < 3; q++)
6133 lightdir[q] = sd[q];
6134 VectorNormalize(lightdir);
6135 for (q = 0; q < 3; q++)
6136 {
6137 // extract the diffuse color along the chosen direction and scale it
6138 diffuse[q] = (lightdir[0] * sx[q] + lightdir[1] * sy[q] + lightdir[2] * sz[q]);
6139 // subtract some of diffuse from ambient
6140 ambient[q] = sa[q] + -0.333f * diffuse[q] + ambientintensity;
6141 }
6142}
#define SUPERCONTENTS_SOLID
Definition bspfile.h:196
trace_t CL_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_t *passedict, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask, float extend, qbool hitnetworkbrushmodels, qbool hitnetworkplayers, int *hitnetworkentity, qbool hitcsqcentities, qbool hitsurfaces)
#define LIGHTFLAG_NORMALMODE
Definition client.h:34
#define LIGHTFLAG_REALTIMEMODE
Definition client.h:35
cvar_t collision_extendmovelength
Definition collision.c:14
float flags
vector color
static int(ZEXPORT *qz_inflate)(z_stream *strm
r_refdef_t r_refdef
Definition gl_rmain.c:57
#define min(A, B)
Definition mathlib.h:37
#define VectorNormalize(v)
Definition mathlib.h:104
#define VectorLength(a)
Definition mathlib.h:109
#define VectorLength2(a)
Definition mathlib.h:110
#define VectorSubtract(a, b, out)
Definition mathlib.h:99
float sqrt(float f)
#define MATERIALFLAGMASK_TRANSLUCENT
int i
#define NULL
Definition qtypes.h:12
cvar_t r_shadow_lightattenuationdividebias
Definition r_shadow.c:153
cvar_t r_shadow_lightintensityscale
Definition r_shadow.c:155
static memexpandablearray_t r_shadow_worldlightsarray
Definition r_shadow.c:273
cvar_t r_shadow_lightattenuationlinearscale
Definition r_shadow.c:154
#define LP_DYNLIGHT
Definition r_shadow.h:194
#define LP_LIGHTMAP
Definition r_shadow.h:192
#define LP_RTWORLD
Definition r_shadow.h:193
float intensity
Definition snd_mix.c:314
float value
Definition cvar.h:74
rtlight_t rtlight
Definition client.h:301
void(* LightPoint)(struct model_s *model, const vec3_t p, vec3_t ambientcolor, vec3_t diffusecolor, vec3_t diffusenormal)
model_brush_t brush
qbool lit
model_t * worldmodel
same as worldentity->model
Definition render.h:358
rtlight_t * lights[MAX_DLIGHTS]
Definition render.h:372
r_refdef_scene_t scene
Definition render.h:418
vec3_t currentcolor
Definition client.h:147
int shadow
whether light should render shadows (see castshadows for whether it actually does this frame)
Definition client.h:122
int flags
LIGHTFLAG_* flags.
Definition client.h:134
vec3_t shadoworigin
used only for casting shadows
Definition client.h:138
vec_t radius
size of the light (remove?)
Definition client.h:116
double fraction
Definition collision.h:40
#define MOVE_NOMONSTERS
Definition world.h:29
size_t Mem_ExpandableArray_IndexRange(const memexpandablearray_t *l)
Definition zone.c:763
void * Mem_ExpandableArray_RecordAtIndex(const memexpandablearray_t *l, size_t index)
Definition zone.c:780

References model_t::brush, CL_TraceLine(), collision_extendmovelength, color, rtlight_t::currentcolor, flags, rtlight_t::flags, trace_t::fraction, i, int(), intensity, LIGHTFLAG_NORMALMODE, LIGHTFLAG_REALTIMEMODE, model_brush_t::LightPoint, r_refdef_scene_t::lights, model_t::lit, LP_DYNLIGHT, LP_LIGHTMAP, LP_RTWORLD, MATERIALFLAGMASK_TRANSLUCENT, Mem_ExpandableArray_IndexRange(), Mem_ExpandableArray_RecordAtIndex(), min, MOVE_NOMONSTERS, NULL, r_refdef_scene_t::numlights, r_refdef, r_shadow_lightattenuationdividebias, r_shadow_lightattenuationlinearscale, r_shadow_lightintensityscale, r_shadow_worldlightsarray, rtlight_t::radius, dlight_t::rtlight, r_refdef_scene_t::rtworld, r_refdef_t::scene, rtlight_t::shadow, rtlight_t::shadoworigin, sqrt(), SUPERCONTENTS_SOLID, cvar_t::value, VectorLength, VectorLength2, VectorNormalize, VectorSubtract, and r_refdef_scene_t::worldmodel.

Referenced by CL_UpdateEntityShading_Entity(), R_DrawParticle_TransparentCallback(), R_HDR_UpdateIrisAdaptation(), and VM_CL_getlight().

◆ R_RTLight_Compile()

void R_RTLight_Compile ( struct rtlight_s * rtlight)

◆ R_RTLight_Uncompile()

void R_RTLight_Uncompile ( struct rtlight_s * rtlight)

◆ R_RTLight_Update()

void R_RTLight_Update ( struct rtlight_s * rtlight,
int isstatic,
matrix4x4_t * matrix,
vec3_t color,
int style,
const char * cubemapname,
int shadow,
vec_t corona,
vec_t coronasizescale,
vec_t ambientscale,
vec_t diffusescale,
vec_t specularscale,
int flags )

◆ R_Shadow_CalcSphereSideMask()

int R_Shadow_CalcSphereSideMask ( const vec3_t p1,
float radius,
float bias )

Definition at line 966 of file r_shadow.c.

967{
968 // p is in the cubemap's local coordinate system
969 // bias = border/(size - border)
970 float dxyp = p[0] + p[1], dxyn = p[0] - p[1], axyp = fabs(dxyp), axyn = fabs(dxyn);
971 float dyzp = p[1] + p[2], dyzn = p[1] - p[2], ayzp = fabs(dyzp), ayzn = fabs(dyzn);
972 float dzxp = p[2] + p[0], dzxn = p[2] - p[0], azxp = fabs(dzxp), azxn = fabs(dzxn);
973 int mask = 0x3F;
974 if(axyp > bias*axyn + radius) mask &= dxyp < 0 ? ~((1<<0)|(1<<2)) : ~((2<<0)|(2<<2));
975 if(axyn > bias*axyp + radius) mask &= dxyn < 0 ? ~((1<<0)|(2<<2)) : ~((2<<0)|(1<<2));
976 if(ayzp > bias*ayzn + radius) mask &= dyzp < 0 ? ~((1<<2)|(1<<4)) : ~((2<<2)|(2<<4));
977 if(ayzn > bias*ayzp + radius) mask &= dyzn < 0 ? ~((1<<2)|(2<<4)) : ~((2<<2)|(1<<4));
978 if(azxp > bias*azxn + radius) mask &= dzxp < 0 ? ~((1<<4)|(1<<0)) : ~((2<<4)|(2<<0));
979 if(azxn > bias*azxp + radius) mask &= dzxn < 0 ? ~((1<<4)|(2<<0)) : ~((2<<4)|(1<<0));
980 return mask;
981}
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
Definition glquake.h:609
float fabs(float f)

References fabs(), and mask.

◆ R_Shadow_CalcTriangleSideMask()

int R_Shadow_CalcTriangleSideMask ( const vec3_t p1,
const vec3_t p2,
const vec3_t p3,
float bias )

Definition at line 863 of file r_shadow.c.

864{
865 // p1, p2, p3 are in the cubemap's local coordinate system
866 // bias = border/(size - border)
867 int mask = 0x3F;
868
869 float dp1 = p1[0] + p1[1], dn1 = p1[0] - p1[1], ap1 = fabs(dp1), an1 = fabs(dn1),
870 dp2 = p2[0] + p2[1], dn2 = p2[0] - p2[1], ap2 = fabs(dp2), an2 = fabs(dn2),
871 dp3 = p3[0] + p3[1], dn3 = p3[0] - p3[1], ap3 = fabs(dp3), an3 = fabs(dn3);
872 if(ap1 > bias*an1 && ap2 > bias*an2 && ap3 > bias*an3)
873 mask &= (3<<4)
874 | (dp1 >= 0 ? (1<<0)|(1<<2) : (2<<0)|(2<<2))
875 | (dp2 >= 0 ? (1<<0)|(1<<2) : (2<<0)|(2<<2))
876 | (dp3 >= 0 ? (1<<0)|(1<<2) : (2<<0)|(2<<2));
877 if(an1 > bias*ap1 && an2 > bias*ap2 && an3 > bias*ap3)
878 mask &= (3<<4)
879 | (dn1 >= 0 ? (1<<0)|(2<<2) : (2<<0)|(1<<2))
880 | (dn2 >= 0 ? (1<<0)|(2<<2) : (2<<0)|(1<<2))
881 | (dn3 >= 0 ? (1<<0)|(2<<2) : (2<<0)|(1<<2));
882
883 dp1 = p1[1] + p1[2], dn1 = p1[1] - p1[2], ap1 = fabs(dp1), an1 = fabs(dn1),
884 dp2 = p2[1] + p2[2], dn2 = p2[1] - p2[2], ap2 = fabs(dp2), an2 = fabs(dn2),
885 dp3 = p3[1] + p3[2], dn3 = p3[1] - p3[2], ap3 = fabs(dp3), an3 = fabs(dn3);
886 if(ap1 > bias*an1 && ap2 > bias*an2 && ap3 > bias*an3)
887 mask &= (3<<0)
888 | (dp1 >= 0 ? (1<<2)|(1<<4) : (2<<2)|(2<<4))
889 | (dp2 >= 0 ? (1<<2)|(1<<4) : (2<<2)|(2<<4))
890 | (dp3 >= 0 ? (1<<2)|(1<<4) : (2<<2)|(2<<4));
891 if(an1 > bias*ap1 && an2 > bias*ap2 && an3 > bias*ap3)
892 mask &= (3<<0)
893 | (dn1 >= 0 ? (1<<2)|(2<<4) : (2<<2)|(1<<4))
894 | (dn2 >= 0 ? (1<<2)|(2<<4) : (2<<2)|(1<<4))
895 | (dn3 >= 0 ? (1<<2)|(2<<4) : (2<<2)|(1<<4));
896
897 dp1 = p1[2] + p1[0], dn1 = p1[2] - p1[0], ap1 = fabs(dp1), an1 = fabs(dn1),
898 dp2 = p2[2] + p2[0], dn2 = p2[2] - p2[0], ap2 = fabs(dp2), an2 = fabs(dn2),
899 dp3 = p3[2] + p3[0], dn3 = p3[2] - p3[0], ap3 = fabs(dp3), an3 = fabs(dn3);
900 if(ap1 > bias*an1 && ap2 > bias*an2 && ap3 > bias*an3)
901 mask &= (3<<2)
902 | (dp1 >= 0 ? (1<<4)|(1<<0) : (2<<4)|(2<<0))
903 | (dp2 >= 0 ? (1<<4)|(1<<0) : (2<<4)|(2<<0))
904 | (dp3 >= 0 ? (1<<4)|(1<<0) : (2<<4)|(2<<0));
905 if(an1 > bias*ap1 && an2 > bias*ap2 && an3 > bias*ap3)
906 mask &= (3<<2)
907 | (dn1 >= 0 ? (1<<4)|(2<<0) : (2<<4)|(1<<0))
908 | (dn2 >= 0 ? (1<<4)|(2<<0) : (2<<4)|(1<<0))
909 | (dn3 >= 0 ? (1<<4)|(2<<0) : (2<<4)|(1<<0));
910
911 return mask;
912}

References fabs(), and mask.

Referenced by R_Shadow_ChooseSidesFromBox().

◆ R_Shadow_ChooseSidesFromBox()

int R_Shadow_ChooseSidesFromBox ( int firsttriangle,
int numtris,
const float * invertex3f,
const int * elements,
const matrix4x4_t * worldtolight,
const vec3_t projectorigin,
const vec3_t projectdirection,
const vec3_t lightmins,
const vec3_t lightmaxs,
const vec3_t surfacemins,
const vec3_t surfacemaxs,
int * totals )

Definition at line 1058 of file r_shadow.c.

1059{
1060 int t, tend;
1061 const int *e;
1062 const float *v[3];
1063 float normal[3];
1064 vec3_t p[3];
1065 float bias;
1066 int mask, surfacemask = 0;
1067 if (!BoxesOverlap(lightmins, lightmaxs, surfacemins, surfacemaxs))
1068 return 0;
1070 tend = firsttriangle + numtris;
1071 if (BoxInsideBox(surfacemins, surfacemaxs, lightmins, lightmaxs))
1072 {
1073 // surface box entirely inside light box, no box cull
1074 if (projectdirection)
1075 {
1076 for (t = firsttriangle, e = elements + t * 3;t < tend;t++, e += 3)
1077 {
1078 v[0] = invertex3f + e[0] * 3, v[1] = invertex3f + e[1] * 3, v[2] = invertex3f + e[2] * 3;
1079 TriangleNormal(v[0], v[1], v[2], normal);
1080 if (r_shadow_frontsidecasting.integer == (DotProduct(normal, projectdirection) < 0))
1081 {
1082 Matrix4x4_Transform(worldtolight, v[0], p[0]), Matrix4x4_Transform(worldtolight, v[1], p[1]), Matrix4x4_Transform(worldtolight, v[2], p[2]);
1083 mask = R_Shadow_CalcTriangleSideMask(p[0], p[1], p[2], bias);
1084 surfacemask |= mask;
1085 if(totals)
1086 {
1087 totals[0] += mask&1, totals[1] += (mask>>1)&1, totals[2] += (mask>>2)&1, totals[3] += (mask>>3)&1, totals[4] += (mask>>4)&1, totals[5] += mask>>5;
1090 }
1091 }
1092 }
1093 }
1094 else
1095 {
1096 for (t = firsttriangle, e = elements + t * 3;t < tend;t++, e += 3)
1097 {
1098 v[0] = invertex3f + e[0] * 3, v[1] = invertex3f + e[1] * 3, v[2] = invertex3f + e[2] * 3;
1099 if (r_shadow_frontsidecasting.integer == PointInfrontOfTriangle(projectorigin, v[0], v[1], v[2]))
1100 {
1101 Matrix4x4_Transform(worldtolight, v[0], p[0]), Matrix4x4_Transform(worldtolight, v[1], p[1]), Matrix4x4_Transform(worldtolight, v[2], p[2]);
1102 mask = R_Shadow_CalcTriangleSideMask(p[0], p[1], p[2], bias);
1103 surfacemask |= mask;
1104 if(totals)
1105 {
1106 totals[0] += mask&1, totals[1] += (mask>>1)&1, totals[2] += (mask>>2)&1, totals[3] += (mask>>3)&1, totals[4] += (mask>>4)&1, totals[5] += mask>>5;
1109 }
1110 }
1111 }
1112 }
1113 }
1114 else
1115 {
1116 // surface box not entirely inside light box, cull each triangle
1117 if (projectdirection)
1118 {
1119 for (t = firsttriangle, e = elements + t * 3;t < tend;t++, e += 3)
1120 {
1121 v[0] = invertex3f + e[0] * 3, v[1] = invertex3f + e[1] * 3, v[2] = invertex3f + e[2] * 3;
1122 TriangleNormal(v[0], v[1], v[2], normal);
1123 if (r_shadow_frontsidecasting.integer == (DotProduct(normal, projectdirection) < 0)
1124 && TriangleBBoxOverlapsBox(v[0], v[1], v[2], lightmins, lightmaxs))
1125 {
1126 Matrix4x4_Transform(worldtolight, v[0], p[0]), Matrix4x4_Transform(worldtolight, v[1], p[1]), Matrix4x4_Transform(worldtolight, v[2], p[2]);
1127 mask = R_Shadow_CalcTriangleSideMask(p[0], p[1], p[2], bias);
1128 surfacemask |= mask;
1129 if(totals)
1130 {
1131 totals[0] += mask&1, totals[1] += (mask>>1)&1, totals[2] += (mask>>2)&1, totals[3] += (mask>>3)&1, totals[4] += (mask>>4)&1, totals[5] += mask>>5;
1134 }
1135 }
1136 }
1137 }
1138 else
1139 {
1140 for (t = firsttriangle, e = elements + t * 3;t < tend;t++, e += 3)
1141 {
1142 v[0] = invertex3f + e[0] * 3, v[1] = invertex3f + e[1] * 3, v[2] = invertex3f + e[2] * 3;
1143 if (r_shadow_frontsidecasting.integer == PointInfrontOfTriangle(projectorigin, v[0], v[1], v[2])
1144 && TriangleBBoxOverlapsBox(v[0], v[1], v[2], lightmins, lightmaxs))
1145 {
1146 Matrix4x4_Transform(worldtolight, v[0], p[0]), Matrix4x4_Transform(worldtolight, v[1], p[1]), Matrix4x4_Transform(worldtolight, v[2], p[2]);
1147 mask = R_Shadow_CalcTriangleSideMask(p[0], p[1], p[2], bias);
1148 surfacemask |= mask;
1149 if(totals)
1150 {
1151 totals[0] += mask&1, totals[1] += (mask>>1)&1, totals[2] += (mask>>2)&1, totals[3] += (mask>>3)&1, totals[4] += (mask>>4)&1, totals[5] += mask>>5;
1154 }
1155 }
1156 }
1157 }
1158 }
1159 return surfacemask;
1160}
const GLdouble * v
Definition glquake.h:762
#define BoxesOverlap(a, b, c, d)
Definition mathlib.h:122
#define BoxInsideBox(a, b, c, d)
Definition mathlib.h:123
#define PointInfrontOfTriangle(p, a, b, c)
Definition mathlib.h:143
#define TriangleNormal(a, b, c, n)
Definition mathlib.h:126
#define DotProduct(a, b)
Definition mathlib.h:98
#define TriangleBBoxOverlapsBox(a, b, c, d, e)
Definition mathlib.h:124
void Matrix4x4_Transform(const matrix4x4_t *in, const float v[3], float out[3])
Definition matrixlib.c:1657
vec_t vec3_t[3]
Definition qtypes.h:71
int R_Shadow_CalcTriangleSideMask(const vec3_t p1, const vec3_t p2, const vec3_t p3, float bias)
Definition r_shadow.c:863
int r_shadow_shadowmapmaxsize
Definition r_shadow.c:55
int numshadowsides
Definition r_shadow.c:83
unsigned char * shadowsides
Definition r_shadow.c:84
cvar_t r_shadow_frontsidecasting
Definition r_shadow.c:158
int * shadowsideslist
Definition r_shadow.c:85
int r_shadow_shadowmapborder
Definition r_shadow.c:61
precision highp float
Definition shader_glsl.h:53
vec3 normal
int integer
Definition cvar.h:73

References BoxesOverlap, BoxInsideBox, DotProduct, float, cvar_t::integer, mask, Matrix4x4_Transform(), normal, numshadowsides, PointInfrontOfTriangle, R_Shadow_CalcTriangleSideMask(), r_shadow_frontsidecasting, r_shadow_shadowmapborder, r_shadow_shadowmapmaxsize, shadowsides, shadowsideslist, TriangleBBoxOverlapsBox, TriangleNormal, and v.

Referenced by R_Mod_CompileShadowMap().

◆ R_Shadow_ClearShadowMapTexture()

void R_Shadow_ClearShadowMapTexture ( void )

Definition at line 1480 of file r_shadow.c.

1481{
1482 r_viewport_t viewport;
1483 float clearcolor[4];
1484
1485 // if they don't exist, create our textures now
1490
1491 // we're setting up to render shadowmaps, so change rendermode
1493
1498 else
1500 R_SetupShader_DepthOrShadow(true, r_shadow_shadowmap2ddepthbuffer != NULL, false); // FIXME test if we have a skeletal model?
1502 GL_DepthMask(true);
1503 GL_DepthTest(true);
1504
1505 // we have to set a viewport to clear anything in some renderpaths (D3D)
1507 R_SetViewport(&viewport);
1508 GL_Scissor(viewport.x, viewport.y, viewport.width, viewport.height);
1510 GL_ColorMask(1, 1, 1, 1);
1511 else
1512 GL_ColorMask(0, 0, 0, 0);
1513 switch (vid.renderpath)
1514 {
1515 case RENDERPATH_GL32:
1516 case RENDERPATH_GLES2:
1518 break;
1519 }
1520 Vector4Set(clearcolor, 1, 1, 1, 1);
1522 GL_Clear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT, clearcolor, 1.0f, 0);
1523 else
1524 GL_Clear(GL_DEPTH_BUFFER_BIT, clearcolor, 1.0f, 0);
1525}
void GL_Clear(int mask, const float *colorvalue, float depthvalue, int stencilvalue)
void GL_CullFace(int state)
void GL_ColorMask(int r, int g, int b, int a)
void GL_DepthMask(int state)
void GL_DepthTest(int state)
void R_Mesh_SetRenderTargets(int fbo)
void GL_PolygonOffset(float planeoffset, float depthoffset)
void R_SetViewport(const r_viewport_t *v)
Definition gl_backend.c:897
void R_Viewport_InitOrtho(r_viewport_t *v, const matrix4x4_t *cameramatrix, int x, int y, int width, int height, float x1, float y1, float x2, float y2, float nearclip, float farclip, const float *nearplane)
Definition gl_backend.c:587
void R_Mesh_ResetTextureState(void)
void GL_Scissor(int x, int y, int width, int height)
void R_SetupShader_DepthOrShadow(qbool notrippy, qbool depthrgb, qbool skeletal)
Definition gl_rmain.c:1493
#define GL_COLOR_BUFFER_BIT
Definition glquake.h:171
#define GL_DEPTH_BUFFER_BIT
Definition glquake.h:169
#define Vector4Set(vec, r, g, b, a)
Definition mathlib.h:86
const matrix4x4_t identitymatrix
Definition matrixlib.c:9
qbool r_shadow_shadowmapvsdct
Definition r_shadow.c:57
r_shadow_rendermode_t r_shadow_rendermode
Definition r_shadow.c:32
static void R_Shadow_MakeVSDCT(void)
Definition r_shadow.c:1436
static void R_Shadow_MakeShadowMap(int texturesize)
Definition r_shadow.c:1456
int r_shadow_shadowmaptexturesize
Definition r_shadow.c:56
@ R_SHADOW_RENDERMODE_SHADOWMAP2D
Definition r_shadow.c:21
void R_Shadow_RenderMode_Reset(void)
Definition r_shadow.c:1409
rtexture_t * r_shadow_shadowmapvsdcttexture
Definition r_shadow.c:112
rtexture_t * r_shadow_shadowmap2ddepthtexture
Definition r_shadow.c:111
GLuint r_shadow_fbo2d
Definition r_shadow.c:49
rtexture_t * r_shadow_shadowmap2ddepthbuffer
Definition r_shadow.c:110
cvar_t r_shadow_shadowmapping_polygonoffset
Definition r_shadow.c:187
cvar_t r_shadow_shadowmapping_polygonfactor
Definition r_shadow.c:186
r_refdef_view_t view
Definition render.h:406
int cullface_back
Definition render.h:318
renderpath_t renderpath
Definition vid.h:80
@ RENDERPATH_GLES2
Definition vid.h:38
@ RENDERPATH_GL32
Definition vid.h:37
viddef_t vid
global video state
Definition vid_shared.c:64

References r_refdef_view_t::cullface_back, GL_Clear(), GL_COLOR_BUFFER_BIT, GL_ColorMask(), GL_CullFace(), GL_DEPTH_BUFFER_BIT, GL_DepthMask(), GL_DepthTest(), GL_PolygonOffset(), GL_Scissor(), r_viewport_t::height, identitymatrix, NULL, R_Mesh_ResetTextureState(), R_Mesh_SetRenderTargets(), r_refdef, R_SetupShader_DepthOrShadow(), R_SetViewport(), r_shadow_fbo2d, R_Shadow_MakeShadowMap(), R_Shadow_MakeVSDCT(), r_shadow_rendermode, R_Shadow_RenderMode_Reset(), R_SHADOW_RENDERMODE_SHADOWMAP2D, r_shadow_shadowmap2ddepthbuffer, r_shadow_shadowmap2ddepthtexture, r_shadow_shadowmapping_polygonfactor, r_shadow_shadowmapping_polygonoffset, r_shadow_shadowmaptexturesize, r_shadow_shadowmapvsdct, r_shadow_shadowmapvsdcttexture, R_Viewport_InitOrtho(), viddef_t::renderpath, RENDERPATH_GL32, RENDERPATH_GLES2, cvar_t::value, Vector4Set, vid, r_refdef_t::view, r_viewport_t::width, r_viewport_t::x, and r_viewport_t::y.

Referenced by R_Shadow_DrawShadowMaps().

◆ R_Shadow_ClearStencil()

void R_Shadow_ClearStencil ( void )

Definition at line 1430 of file r_shadow.c.

1431{
1434}
#define GL_STENCIL_BUFFER_BIT
Definition glquake.h:170
@ r_stat_lights_clears
Definition r_stats.h:28
int stats[r_stat_count]
Definition render.h:466

References GL_Clear(), GL_STENCIL_BUFFER_BIT, NULL, r_refdef, r_stat_lights_clears, and r_refdef_t::stats.

◆ R_Shadow_DrawCoronas()

void R_Shadow_DrawCoronas ( void )

Definition at line 4528 of file r_shadow.c.

4529{
4530 int i, flag;
4531 qbool usequery = false;
4532 size_t lightindex;
4533 dlight_t *light;
4534 rtlight_t *rtlight;
4535 size_t range;
4536 if (r_coronas.value < (1.0f / 256.0f) && !gl_flashblend.integer)
4537 return;
4539 return;
4542
4544
4545 // check occlusion of coronas, using occlusion queries or raytraces
4546 r_numqueries = 0;
4547 switch (vid.renderpath)
4548 {
4549 case RENDERPATH_GL32:
4550 case RENDERPATH_GLES2:
4551 // buffer binding target GL_QUERY_BUFFER: Core since version 4.4
4553#ifndef USE_GLES2
4554 if (usequery)
4555 {
4556 GL_ColorMask(0,0,0,0);
4557 if (r_maxqueries < ((unsigned int)range + r_refdef.scene.numlights) * 2)
4559 {
4560 i = r_maxqueries;
4561 r_maxqueries = ((unsigned int)range + r_refdef.scene.numlights) * 4;
4564 qglGenQueries(r_maxqueries - i, r_queries + i);
4566 }
4567 RSurf_ActiveModelEntity(r_refdef.scene.worldentity, false, false, false);
4570 GL_DepthMask(false);
4571 GL_DepthRange(0, 1);
4572 GL_PolygonOffset(0, 0);
4573 GL_DepthTest(true);
4575 R_SetupShader_Generic_NoTexture(false, false);
4576 }
4577#endif
4578 break;
4579 }
4580 for (lightindex = 0;lightindex < range;lightindex++)
4581 {
4583 if (!light)
4584 continue;
4585 rtlight = &light->rtlight;
4586 rtlight->corona_visibility = 0;
4588 rtlight->corona_queryindex_allpixels = 0;
4589 if (!(rtlight->flags & flag))
4590 continue;
4591 if (rtlight->corona <= 0)
4592 continue;
4593 if (r_shadow_debuglight.integer >= 0 && r_shadow_debuglight.integer != (int)lightindex)
4594 continue;
4595 R_BeginCoronaQuery(rtlight, rtlight->radius * rtlight->coronasizescale * r_coronas_occlusionsizescale.value, usequery);
4596 }
4597 for (i = 0;i < r_refdef.scene.numlights;i++)
4598 {
4599 rtlight = r_refdef.scene.lights[i];
4600 rtlight->corona_visibility = 0;
4602 rtlight->corona_queryindex_allpixels = 0;
4603 if (!(rtlight->flags & flag))
4604 continue;
4605 if (rtlight->corona <= 0)
4606 continue;
4607 R_BeginCoronaQuery(rtlight, rtlight->radius * rtlight->coronasizescale * r_coronas_occlusionsizescale.value, usequery);
4608 }
4609 if (usequery)
4611
4612 // now draw the coronas using the query data for intensity info
4613 for (lightindex = 0;lightindex < range;lightindex++)
4614 {
4616 if (!light)
4617 continue;
4618 rtlight = &light->rtlight;
4619 if (rtlight->corona_visibility <= 0)
4620 continue;
4621 R_DrawCorona(rtlight, rtlight->corona * r_coronas.value * 0.25f, rtlight->radius * rtlight->coronasizescale);
4622 }
4623 for (i = 0;i < r_refdef.scene.numlights;i++)
4624 {
4625 rtlight = r_refdef.scene.lights[i];
4626 if (rtlight->corona_visibility <= 0)
4627 continue;
4628 R_DrawCorona(rtlight, rtlight->corona * r_coronas.value * 0.25f, rtlight->radius * rtlight->coronasizescale);
4629 }
4630}
void GL_DepthRange(float nearfrac, float farfrac)
void GL_BlendFunc(int blendfunc1, int blendfunc2)
void R_EntityMatrix(const matrix4x4_t *matrix)
Definition gl_rmain.c:4417
void R_SetupShader_Generic_NoTexture(qbool usegamma, qbool notrippy)
Definition gl_rmain.c:1488
unsigned int r_maxqueries
Definition gl_rmain.c:299
r_framebufferstate_t r_fb
Definition gl_rmain.c:265
unsigned int r_numqueries
Definition gl_rmain.c:298
void RSurf_ActiveModelEntity(const entity_render_t *ent, qbool wantnormals, qbool wanttangents, qbool prepass)
Definition gl_rmain.c:6921
unsigned int r_queries[MAX_OCCLUSION_QUERIES]
Definition gl_rmain.c:297
#define GL_NONE
Definition glquake.h:127
#define CHECKGLERROR
Definition glquake.h:1059
#define GL_ZERO
Definition glquake.h:73
#define GL_ONE
Definition glquake.h:74
#define MAX_OCCLUSION_QUERIES
max number of query objects that can be used in one frame
Definition qdefs.h:124
bool qbool
Definition qtypes.h:9
cvar_t r_shadow_debuglight
Definition r_shadow.c:143
cvar_t r_coronas
Definition r_shadow.c:233
static void R_BeginCoronaQuery(rtlight_t *rtlight, float scale, qbool usequery)
Definition r_shadow.c:4420
cvar_t r_coronas_occlusionquery
Definition r_shadow.c:235
static void R_DrawCorona(rtlight_t *rtlight, float cscale, float scale)
Definition r_shadow.c:4469
cvar_t r_coronas_occlusionsizescale
Definition r_shadow.c:234
cvar_t gl_flashblend
Definition r_shadow.c:236
r_waterstate_t water
Definition render.h:898
entity_render_t * worldentity
the world
Definition render.h:355
int colormask[4]
which color components to allow (for anaglyph glasses)
Definition render.h:299
qbool renderingscene
Definition render.h:876
float corona_visibility
used by corona updates, due to occlusion query
Definition client.h:149
vec_t corona
intensity of corona to render
Definition client.h:124
unsigned int corona_queryindex_visiblepixels
Definition client.h:150
vec_t coronasizescale
radius scale of corona to render (1.0 means same as light radius)
Definition client.h:126
unsigned int corona_queryindex_allpixels
Definition client.h:151
int glversion
this is at least 32
Definition vid.h:44
viddef_support_t support
Definition vid.h:89

References CHECKGLERROR, r_refdef_view_t::colormask, rtlight_t::corona, rtlight_t::corona_queryindex_allpixels, rtlight_t::corona_queryindex_visiblepixels, rtlight_t::corona_visibility, rtlight_t::coronasizescale, rtlight_t::flags, GL_BlendFunc(), GL_ColorMask(), GL_CullFace(), GL_DepthMask(), GL_DepthRange(), GL_DepthTest(), gl_flashblend, GL_NONE, GL_ONE, GL_PolygonOffset(), GL_ZERO, viddef_support_t::glversion, i, identitymatrix, int(), cvar_t::integer, LIGHTFLAG_NORMALMODE, LIGHTFLAG_REALTIMEMODE, r_refdef_scene_t::lights, MAX_OCCLUSION_QUERIES, Mem_ExpandableArray_IndexRange(), Mem_ExpandableArray_RecordAtIndex(), min, r_refdef_scene_t::numlights, R_BeginCoronaQuery(), r_coronas, r_coronas_occlusionquery, r_coronas_occlusionsizescale, R_DrawCorona(), R_EntityMatrix(), r_fb, r_maxqueries, R_Mesh_ResetTextureState(), r_numqueries, r_queries, r_refdef, R_SetupShader_Generic_NoTexture(), r_shadow_debuglight, r_shadow_worldlightsarray, rtlight_t::radius, r_waterstate_t::renderingscene, viddef_t::renderpath, RENDERPATH_GL32, RENDERPATH_GLES2, RSurf_ActiveModelEntity(), dlight_t::rtlight, r_refdef_scene_t::rtworld, r_refdef_t::scene, viddef_t::support, cvar_t::value, vid, r_refdef_t::view, r_framebufferstate_t::water, and r_refdef_scene_t::worldentity.

Referenced by R_RenderScene().

◆ R_Shadow_DrawLights()

void R_Shadow_DrawLights ( void )

Definition at line 4226 of file r_shadow.c.

4227{
4228 int lnum;
4229
4231
4232 for (lnum = 0; lnum < r_shadow_scenenumlights; lnum++)
4234
4236}
void R_Shadow_RenderMode_Begin(void)
Definition r_shadow.c:1369
int r_shadow_scenenumlights
Definition r_shadow.c:35
rtlight_t ** r_shadow_scenelightlist
Definition r_shadow.c:36
static void R_Shadow_DrawLight(rtlight_t *rtlight)
Definition r_shadow.c:3838
void R_Shadow_RenderMode_End(void)
Definition r_shadow.c:2872

References R_Shadow_DrawLight(), R_Shadow_RenderMode_Begin(), R_Shadow_RenderMode_End(), r_shadow_scenelightlist, and r_shadow_scenenumlights.

Referenced by R_RenderScene().

◆ R_Shadow_DrawPrepass()

void R_Shadow_DrawPrepass ( void )

Definition at line 3958 of file r_shadow.c.

3959{
3960 int i;
3961 int lnum;
3962 entity_render_t *ent;
3963 float clearcolor[4];
3964
3966 GL_DepthMask(true);
3967 GL_ColorMask(1,1,1,1);
3969 GL_Color(1,1,1,1);
3970 GL_DepthTest(true);
3972 Vector4Set(clearcolor, 0.5f,0.5f,0.5f,1.0f);
3973 GL_Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, clearcolor, 1.0f, 0);
3975 R_TimeReport("prepasscleargeom");
3976
3980 R_TimeReport("prepassworld");
3981
3982 for (i = 0;i < r_refdef.scene.numentities;i++)
3983 {
3985 continue;
3986 ent = r_refdef.scene.entities[i];
3987 if (ent->model && ent->model->DrawPrepass != NULL)
3988 ent->model->DrawPrepass(ent);
3989 }
3990
3992 R_TimeReport("prepassmodels");
3993
3994 GL_DepthMask(false);
3995 GL_ColorMask(1,1,1,1);
3996 GL_Color(1,1,1,1);
3997 GL_DepthTest(true);
3999 Vector4Set(clearcolor, 0, 0, 0, 0);
4000 GL_Clear(GL_COLOR_BUFFER_BIT, clearcolor, 1.0f, 0);
4002 R_TimeReport("prepassclearlit");
4003
4005
4006 for (lnum = 0; lnum < r_shadow_scenenumlights; lnum++)
4008
4010
4012 R_TimeReport("prepasslights");
4013}
client_state_t cl
Definition cl_main.c:117
void GL_Color(float cr, float cg, float cb, float ca)
GLuint r_shadow_prepasslightingdiffusespecularfbo
Definition r_shadow.c:115
GLuint r_shadow_prepassgeometryfbo
Definition r_shadow.c:114
int r_timereport_active
Definition r_stats.c:189
void R_TimeReport(const char *desc)
Definition r_stats.c:193
csqc_vidvars_t csqc_vidvars
Definition client.h:834
qbool drawworld
Definition client.h:706
model_t * model
Definition client.h:343
void(* DrawPrepass)(struct entity_render_s *ent)
entity_render_t ** entities
renderable entities (excluding world)
Definition render.h:361
r_refdef_viewcache_t viewcache
Definition render.h:407
unsigned char * entityvisible
which entities are currently visible for this viewpoint (the used range is 0...r_refdef....
Definition render.h:336

References cl, client_state_t::csqc_vidvars, model_t::DrawPrepass, csqc_vidvars_t::drawworld, r_refdef_scene_t::entities, r_refdef_viewcache_t::entityvisible, GL_BlendFunc(), GL_Clear(), GL_Color(), GL_COLOR_BUFFER_BIT, GL_ColorMask(), GL_DEPTH_BUFFER_BIT, GL_DepthMask(), GL_DepthTest(), GL_ONE, GL_ZERO, i, entity_render_t::model, NULL, r_refdef_scene_t::numentities, R_Mesh_ResetTextureState(), R_Mesh_SetRenderTargets(), r_refdef, R_Shadow_DrawLight(), r_shadow_prepassgeometryfbo, r_shadow_prepasslightingdiffusespecularfbo, R_Shadow_RenderMode_Begin(), R_Shadow_RenderMode_End(), r_shadow_scenelightlist, r_shadow_scenenumlights, R_TimeReport(), r_timereport_active, r_refdef_t::scene, Vector4Set, r_refdef_t::viewcache, r_refdef_scene_t::worldentity, and r_refdef_scene_t::worldmodel.

Referenced by R_RenderScene().

◆ R_Shadow_DrawShadowMaps()

void R_Shadow_DrawShadowMaps ( void )

Definition at line 4204 of file r_shadow.c.

4205{
4208
4209 // now that we have a layout of shadowmaps in the atlas, we can render the shadowmaps
4211
4212 // render model shadowmaps (r_shadows 2) if desired which will be sampled in the forward pass
4215
4217 {
4218 int lnum;
4219 for (lnum = 0; lnum < r_shadow_scenenumlights; lnum++)
4221 }
4222
4224}
qbool R_Shadow_ShadowMappingEnabled(void)
Definition r_shadow.c:378
static void R_Shadow_DrawLightShadowMaps(rtlight_t *rtlight)
Definition r_shadow.c:3700
static void R_Shadow_DrawModelShadowMaps(void)
Definition r_shadow.c:4311
int r_shadow_shadowmapatlas_modelshadows_size
Definition r_shadow.c:69
void R_Shadow_ClearShadowMapTexture(void)
Definition r_shadow.c:1480
void R_Shadow_RenderMode_ActiveLight(const rtlight_t *rtlight)
Definition r_shadow.c:1404

References NULL, R_Shadow_ClearShadowMapTexture(), R_Shadow_DrawLightShadowMaps(), R_Shadow_DrawModelShadowMaps(), R_Shadow_RenderMode_ActiveLight(), R_Shadow_RenderMode_Begin(), R_Shadow_RenderMode_End(), r_shadow_scenelightlist, r_shadow_scenenumlights, r_shadow_shadowmapatlas_modelshadows_size, and R_Shadow_ShadowMappingEnabled().

Referenced by R_RenderScene().

◆ R_Shadow_Init()

void R_Shadow_Init ( void )

Definition at line 601 of file r_shadow.c.

602{
643// Cvar_RegisterVariable(&r_shadow_shadowmapping_lod_bias);
644// Cvar_RegisterVariable(&r_shadow_shadowmapping_lod_scale);
708 maxvertexupdate = 0;
711 vertexupdatenum = 0;
712 maxshadowmark = 0;
713 numshadowmark = 0;
716 shadowmarkcount = 0;
717 maxshadowsides = 0;
718 numshadowsides = 0;
732}
void Cvar_RegisterVariable(cvar_t *variable)
registers a cvar that already has the name, string, and optionally the archive elements set.
Definition cvar.c:599
mempool_t * r_main_mempool
Definition gl_rmain.c:42
void R_RegisterModule(const char *name, void(*start)(void), void(*shutdown)(void), void(*newmap)(void), void(*devicelost)(void), void(*devicerestored)(void))
Definition r_modules.c:25
cvar_t r_shadow_glossintensity
Definition r_shadow.c:149
cvar_t r_shadow_shadowmapping_filterquality
Definition r_shadow.c:173
cvar_t r_shadow_lightradiusscale
Definition r_shadow.c:156
cvar_t r_shadow_shadowmapping_maxsize
Definition r_shadow.c:178
cvar_t r_shadow_culllights_trace
Definition r_shadow.c:190
unsigned char * r_shadow_buffer_surfacesides
Definition r_shadow.c:100
int * r_shadow_buffer_leaflist
Definition r_shadow.c:95
cvar_t r_shadow_bumpscale_bumpmap
Definition r_shadow.c:142
cvar_t r_shadow_realtime_world_compileportalculling
Definition r_shadow.c:170
cvar_t r_shadow_shadowmapping_vsdct
Definition r_shadow.c:176
cvar_t r_shadow_culllights_trace_enlarge
Definition r_shadow.c:192
cvar_t r_shadow_usenormalmap
Definition r_shadow.c:146
unsigned char * r_shadow_buffer_leafpvs
Definition r_shadow.c:94
cvar_t r_shadow_culllights_trace_expand
Definition r_shadow.c:193
cvar_t r_shadow_bouncegrid_static
Definition r_shadow.c:223
cvar_t r_shadow_bouncegrid_static_maxbounce
Definition r_shadow.c:227
cvar_t r_shadow_bouncegrid_static_lightradiusscale
Definition r_shadow.c:226
int maxshadowmark
Definition r_shadow.c:76
cvar_t r_shadow_shadowmapping_nearclip
Definition r_shadow.c:184
cvar_t r_shadow_usebihculling
Definition r_shadow.c:145
cvar_t r_shadow_realtime_dlight
Definition r_shadow.c:159
cvar_t r_shadow_bouncegrid_dynamic_hitmodels
Definition r_shadow.c:204
cvar_t r_shadow_bouncegrid_includedirectlighting
Definition r_shadow.c:215
cvar_t r_shadow_shadowmapping_bordersize
Definition r_shadow.c:183
unsigned char * r_shadow_buffer_surfacepvs
Definition r_shadow.c:98
int maxshadowsides
Definition r_shadow.c:82
unsigned char * r_shadow_buffer_visitingleafpvs
Definition r_shadow.c:93
cvar_t r_shadow_shadowmapping_minsize
Definition r_shadow.c:177
int * vertexupdate
Definition r_shadow.c:88
cvar_t r_shadow_culllights_trace_samples
Definition r_shadow.c:195
cvar_t r_shadow_realtime_world_shadows
Definition r_shadow.c:166
cvar_t r_shadow_shadowmapping_depthbits
Definition r_shadow.c:175
cvar_t r_shadow_bouncegrid_dynamic_dlightparticlemultiplier
Definition r_shadow.c:203
cvar_t r_shadow_bouncegrid_dynamic_maxbounce
Definition r_shadow.c:206
cvar_t r_shadow_sortsurfaces
Definition r_shadow.c:188
cvar_t r_shadow_realtime_world
Definition r_shadow.c:163
cvar_t r_shadow_bouncegrid_static_quality
Definition r_shadow.c:229
int maxshadowtriangles
Definition r_shadow.c:70
cvar_t r_shadow_bouncegrid_static_directionalshading
Definition r_shadow.c:225
cvar_t r_shadow_realtime_dlight_svbspculling
Definition r_shadow.c:161
cvar_t r_shadow_shadowmapping
Definition r_shadow.c:172
cvar_t r_shadow_scissor
Definition r_shadow.c:171
cvar_t r_shadow_bouncegrid_particleintensity
Definition r_shadow.c:220
cvar_t r_shadow_shadowmapping_precision
Definition r_shadow.c:180
cvar_t r_shadow_bouncegrid_lightpathsize
Definition r_shadow.c:217
cvar_t r_shadow_projectdistance
Definition r_shadow.c:157
cvar_t r_shadow_shadowmapping_useshadowsampler
Definition r_shadow.c:174
static void R_Shadow_EditLights_Init(void)
Definition r_shadow.c:5964
cvar_t r_shadow_realtime_world_importlightentitiesfrommap
Definition r_shadow.c:164
int maxshadowvertices
Definition r_shadow.c:73
int maxvertexupdate
Definition r_shadow.c:87
cvar_t r_shadow_bouncegrid_intensity
Definition r_shadow.c:216
unsigned char * r_shadow_buffer_lighttrispvs
Definition r_shadow.c:105
int * shadowmark
Definition r_shadow.c:78
cvar_t r_shadow_bouncegrid_dynamic_bounceminimumintensity
Definition r_shadow.c:200
int * r_shadow_buffer_surfacelist
Definition r_shadow.c:99
cvar_t r_shadow_bouncegrid_rng_seed
Definition r_shadow.c:221
cvar_t r_shadow_bouncegrid_static_bounceminimumintensity
Definition r_shadow.c:224
cvar_t r_shadow_culllights_trace_eyejitter
Definition r_shadow.c:191
cvar_t r_shadow_bouncegrid_dynamic_lightradiusscale
Definition r_shadow.c:205
cvar_t r_shadow_culllights_trace_pad
Definition r_shadow.c:194
cvar_t r_shadow_bouncegrid_dynamic_updateinterval
Definition r_shadow.c:210
cvar_t r_shadow_bouncegrid_static_spacing
Definition r_shadow.c:230
float * shadowvertex3f
Definition r_shadow.c:74
cvar_t r_shadow_glossexact
Definition r_shadow.c:152
int numshadowmark
Definition r_shadow.c:77
static void r_shadow_shutdown(void)
Definition r_shadow.c:503
cvar_t r_shadow_bouncegrid_subsamples
Definition r_shadow.c:231
cvar_t r_shadow_bouncegrid_particlebounceintensity
Definition r_shadow.c:219
cvar_t r_shadow_realtime_world_compile
Definition r_shadow.c:167
int r_shadow_buffer_numleafpvsbytes
Definition r_shadow.c:92
cvar_t r_shadow_gloss
Definition r_shadow.c:147
cvar_t r_shadow_realtime_world_compilesvbsp
Definition r_shadow.c:169
cvar_t r_shadow_bouncegrid_dynamic_y
Definition r_shadow.c:212
cvar_t r_shadow_bouncegrid_rng_type
Definition r_shadow.c:222
cvar_t r_shadow_culllights_pvs
Definition r_shadow.c:189
int shadowmarkcount
Definition r_shadow.c:80
cvar_t r_shadow_realtime_world_compileshadow
Definition r_shadow.c:168
cvar_t r_shadow_bouncegrid_blur
Definition r_shadow.c:199
cvar_t r_shadow_bouncegrid_dynamic_maxphotons
Definition r_shadow.c:207
int r_shadow_scenemaxlights
Definition r_shadow.c:34
cvar_t r_shadow_bouncegrid_normalizevectors
Definition r_shadow.c:218
cvar_t r_shadow_deferred
Definition r_shadow.c:144
cvar_t r_shadow_culllights_trace_delay
Definition r_shadow.c:197
unsigned char * r_shadow_buffer_shadowtrispvs
Definition r_shadow.c:103
cvar_t r_shadow_bouncegrid
Definition r_shadow.c:198
cvar_t r_shadow_realtime_dlight_portalculling
Definition r_shadow.c:162
static void r_shadow_start(void)
Definition r_shadow.c:416
cvar_t r_shadow_gloss2intensity
Definition r_shadow.c:148
int r_shadow_buffer_numsurfacepvsbytes
Definition r_shadow.c:97
int * shadowmarklist
Definition r_shadow.c:79
cvar_t r_shadow_bouncegrid_dynamic_z
Definition r_shadow.c:213
cvar_t r_shadow_realtime_dlight_shadows
Definition r_shadow.c:160
cvar_t r_shadow_bouncegrid_dynamic_spacing
Definition r_shadow.c:209
cvar_t r_shadow_bouncegrid_dynamic_culllightpaths
Definition r_shadow.c:201
cvar_t r_shadow_glossexponent
Definition r_shadow.c:150
cvar_t r_shadow_shadowmapping_bias
Definition r_shadow.c:185
cvar_t r_shadow_bouncegrid_floatcolors
Definition r_shadow.c:214
cvar_t r_shadow_gloss2exponent
Definition r_shadow.c:151
cvar_t r_shadow_bouncegrid_dynamic_quality
Definition r_shadow.c:208
static void r_shadow_newmap(void)
Definition r_shadow.c:585
cvar_t r_shadow_culllights_trace_tempsamples
Definition r_shadow.c:196
cvar_t r_shadow_bouncegrid_threaded
Definition r_shadow.c:232
cvar_t r_shadow_bouncegrid_dynamic_x
Definition r_shadow.c:211
cvar_t r_shadow_bouncegrid_dynamic_directionalshading
Definition r_shadow.c:202
cvar_t r_shadow_realtime_world_lightmaps
Definition r_shadow.c:165
int * shadowelements
Definition r_shadow.c:71
cvar_t r_shadow_bumpscale_basetexture
Definition r_shadow.c:141
cvar_t r_shadow_bouncegrid_static_maxphotons
Definition r_shadow.c:228
int vertexupdatenum
Definition r_shadow.c:90
cvar_t r_shadow_shadowmapping_texturesize
Definition r_shadow.c:179
int * vertexremap
Definition r_shadow.c:89
void Mem_ExpandableArray_NewArray(memexpandablearray_t *l, mempool_t *mempool, size_t recordsize, int numrecordsperarray)
Definition zone.c:675

◆ R_Shadow_PrepareLights()

void R_Shadow_PrepareLights ( void )

Definition at line 4031 of file r_shadow.c.

4032{
4033 int flag;
4034 int lnum;
4035 size_t lightindex;
4036 dlight_t *light;
4037 size_t range;
4038 float f;
4039
4040 int shadowmapborder = bound(1, r_shadow_shadowmapping_bordersize.integer, 16);
4041 int shadowmaptexturesize = bound(256, r_shadow_shadowmapping_texturesize.integer, (int)vid.maxtexturesize_2d);
4042 int shadowmapmaxsize = bound(shadowmapborder+2, r_shadow_shadowmapping_maxsize.integer, shadowmaptexturesize / 8);
4043
4046 r_shadow_shadowmaptexturesize != shadowmaptexturesize ||
4051 r_shadow_shadowmapborder != shadowmapborder ||
4052 r_shadow_shadowmapmaxsize != shadowmapmaxsize ||
4055
4057
4058 switch (vid.renderpath)
4059 {
4060 case RENDERPATH_GL32:
4061#ifndef USE_GLES2
4063 {
4068 break;
4069 }
4070
4072 {
4074
4082
4083 // set up the geometry pass fbo (depth + normalmap)
4086 // render depth into a renderbuffer and other important properties into the normalmap texture
4087
4088 // set up the lighting pass fbo (diffuse + specular)
4091 // render diffuse into one texture and specular into another,
4092 // with depth and normalmap bound as textures,
4093 // with depth bound as attachment as well
4094
4095 // set up the lighting pass fbo (diffuse)
4098 // render diffuse into one texture,
4099 // with depth and normalmap bound as textures,
4100 // with depth bound as attachment as well
4101 }
4102#endif
4103 break;
4104 case RENDERPATH_GLES2:
4106 break;
4107 }
4108
4110
4114 for (lightindex = 0; lightindex < range; lightindex++)
4115 {
4117 if (light && (light->flags & flag))
4118 {
4121 }
4122 }
4124 {
4125 for (lnum = 0; lnum < r_refdef.scene.numlights; lnum++)
4126 {
4129 }
4130 }
4131 else if (gl_flashblend.integer)
4132 {
4133 for (lnum = 0; lnum < r_refdef.scene.numlights; lnum++)
4134 {
4135 rtlight_t *rtlight = r_refdef.scene.lights[lnum];
4136 f = ((rtlight->style >= 0 && rtlight->style < MAX_LIGHTSTYLES) ? r_refdef.scene.lightstylevalue[rtlight->style] : 1) * r_shadow_lightintensityscale.value;
4137 VectorScale(rtlight->color, f, rtlight->currentcolor);
4138 }
4139 }
4140
4141 // when debugging a single light, we still want to run the prepare, so we only replace the light list afterward...
4143 {
4145 lightindex = r_shadow_debuglight.integer;
4147 if (light)
4148 {
4151 }
4152 }
4153
4154 // if we're doing shadowmaps we need to prepare the atlas layout now
4156 {
4157 int lod;
4158
4159 // allocate shadowmaps in the atlas now
4160 // we may have to make multiple attempts to fit the shadowmaps in the limited space of the atlas, this will appear as lod popping of all shadowmaps whenever it changes, but at least we can still cast shadows from all lights...
4161 for (lod = 0; lod < 16; lod++)
4162 {
4163 int packing_success = 0;
4164 int packing_failure = 0;
4166 // we actually have to reserve space for the R_DrawModelShadowMaps if that feature is active, it uses 0,0 so this is easy.
4169 for (lnum = 0; lnum < r_shadow_scenenumlights; lnum++)
4170 {
4171 rtlight_t *rtlight = r_shadow_scenelightlist[lnum];
4172 int size = rtlight->shadowmapsidesize >> lod;
4173 int width, height;
4174 if (!rtlight->castshadows)
4175 continue;
4177 width = size * 2;
4178 height = size * 3;
4179 // when there are noselfshadow entities in the light bounds, we have to render two separate sets of shadowmaps :(
4181 width *= 2;
4183 {
4184 rtlight->shadowmapatlassidesize = size;
4185 packing_success++;
4186 }
4187 else
4188 {
4189 // note down that we failed to pack this one, it will have to disable shadows
4190 rtlight->shadowmapatlassidesize = 0;
4191 packing_failure++;
4192 }
4193 }
4194 // generally everything fits and we stop here on the first iteration
4195 if (packing_failure == 0)
4196 break;
4197 }
4198 }
4199
4202}
vector size
int R_Mesh_CreateFramebufferObject(rtexture_t *depthtexture, rtexture_t *colortexture, rtexture_t *colortexture2, rtexture_t *colortexture3, rtexture_t *colortexture4)
Definition gl_backend.c:960
rtexture_t * R_LoadTextureRenderBuffer(rtexturepool_t *rtexturepool, const char *identifier, int width, int height, textype_t textype)
rtexture_t * R_LoadTexture2D(rtexturepool_t *rtexturepool, const char *identifier, int width, int height, const unsigned char *data, textype_t textype, int flags, int miplevel, const unsigned int *palette)
GLenum GLsizei width
Definition glquake.h:622
GLenum GLsizei GLsizei height
Definition glquake.h:622
GLint lod
Definition glquake.h:692
#define bound(min, num, max)
Definition mathlib.h:34
#define VectorScale(in, scale, out)
Definition mathlib.h:111
void Mod_AllocLightmap_Reset(mod_alloclightmap_state_t *state)
qbool Mod_AllocLightmap_Block(mod_alloclightmap_state_t *state, int blockwidth, int blockheight, int *outx, int *outy)
#define MAX_LIGHTSTYLES
max flickering light styles in level (note: affects savegame format)
Definition qdefs.h:108
void R_Shadow_DrawLightSprites(void)
Definition r_shadow.c:4762
rtexture_t * r_shadow_prepassgeometrynormalmaptexture
Definition r_shadow.c:120
rtexture_t * r_shadow_prepasslightingdiffusetexture
Definition r_shadow.c:121
GLuint r_shadow_prepasslightingdiffusefbo
Definition r_shadow.c:116
static void R_Shadow_FreeDeferred(void)
Definition r_shadow.c:3930
rtexture_t * r_shadow_prepasslightingspeculartexture
Definition r_shadow.c:122
qbool r_shadow_shadowmapshadowsampler
Definition r_shadow.c:59
static void R_Shadow_FreeShadowMaps(void)
Definition r_shadow.c:390
int r_shadow_shadowmode_shadowmapping
Definition r_shadow.c:50
qbool r_shadow_usingdeferredprepass
Definition r_shadow.c:64
mod_alloclightmap_state_t r_shadow_shadowmapatlas_state
Definition r_shadow.c:66
int r_shadow_shadowmapfilterquality
Definition r_shadow.c:53
static void R_Shadow_EnlargeLeafSurfaceTrisBuffer(int numleafs, int numsurfaces, int numshadowtriangles, int numlighttriangles)
Definition r_shadow.c:776
int r_shadow_shadowmapdepthbits
Definition r_shadow.c:54
cvar_t r_editlights
Definition r_shadow.c:237
static qbool R_Shadow_PrepareLights_AddSceneLight(rtlight_t *rtlight)
Definition r_shadow.c:4016
rtexture_t * r_shadow_prepassgeometrydepthbuffer
Definition r_shadow.c:119
int r_shadow_prepass_width
Definition r_shadow.c:117
qbool r_shadow_usingshadowmaportho
Definition r_shadow.c:38
rtexturepool_t * r_shadow_texturepool
Definition r_shadow.c:107
int r_shadow_prepass_height
Definition r_shadow.c:118
int r_shadow_shadowmapatlas_modelshadows_y
Definition r_shadow.c:68
qbool r_shadow_shadowmapdepthtexture
Definition r_shadow.c:65
int r_shadow_shadowmode_deferred
Definition r_shadow.c:51
int r_shadow_shadowmapatlas_modelshadows_x
Definition r_shadow.c:67
static void R_Shadow_PrepareLight(rtlight_t *rtlight)
Definition r_shadow.c:3397
#define TEXF_ALPHA
Definition r_textures.h:9
#define TEXF_FORCENEAREST
Definition r_textures.h:17
@ TEXTYPE_COLORBUFFER32F
Definition r_textures.h:88
@ TEXTYPE_DEPTHBUFFER24
Definition r_textures.h:92
@ TEXTYPE_COLORBUFFER16F
Definition r_textures.h:86
#define TEXF_CLAMP
Definition r_textures.h:15
#define TEXF_RENDERTARGET
Definition r_textures.h:37
float f
int flags
Definition client.h:295
surfmesh_t surfmesh
int num_surfaces
unsigned short lightstylevalue[MAX_LIGHTSTYLES]
8.8 fraction of base light value
Definition render.h:380
int shadowmapatlassidesize
size of one side of this light in the shadowmap atlas (for omnidirectional shadowmaps this is the min...
Definition client.h:190
int style
light style to monitor for brightness
Definition client.h:120
int shadowmapsidesize
the size that this light should have (assuming no scene LOD kicking in to reduce it)
Definition client.h:186
int cached_numshadowentities_noselfshadow
Definition client.h:162
qbool castshadows
set by R_Shadow_PrepareLight to indicate whether R_Shadow_DrawShadowMaps should do anything
Definition client.h:157
int shadowmapatlasposition[2]
position of this light in the shadowmap atlas
Definition client.h:188
int num_triangles
unsigned int maxtexturesize_2d
Definition vid.h:83
unsigned int maxdrawbuffers
Definition vid.h:87

References bound, model_t::brush, rtlight_t::cached_numshadowentities_noselfshadow, rtlight_t::castshadows, rtlight_t::color, rtlight_t::currentcolor, f, dlight_t::flags, gl_flashblend, height, cvar_t::integer, LIGHTFLAG_NORMALMODE, LIGHTFLAG_REALTIMEMODE, r_refdef_scene_t::lights, r_refdef_scene_t::lightstylevalue, lod, MAX_LIGHTSTYLES, viddef_t::maxdrawbuffers, viddef_t::maxtexturesize_2d, Mem_ExpandableArray_IndexRange(), Mem_ExpandableArray_RecordAtIndex(), Mod_AllocLightmap_Block(), Mod_AllocLightmap_Reset(), NULL, model_brush_t::num_leafs, model_t::num_surfaces, surfmesh_t::num_triangles, r_refdef_scene_t::numlights, r_editlights, r_fb, R_LoadTexture2D(), R_LoadTextureRenderBuffer(), R_Mesh_CreateFramebufferObject(), R_Mesh_SetRenderTargets(), r_refdef, r_shadow_debuglight, r_shadow_deferred, R_Shadow_DrawLightSprites(), R_Shadow_EnlargeLeafSurfaceTrisBuffer(), R_Shadow_FreeDeferred(), R_Shadow_FreeShadowMaps(), r_shadow_lightintensityscale, R_Shadow_PrepareLight(), R_Shadow_PrepareLights_AddSceneLight(), r_shadow_prepass_height, r_shadow_prepass_width, r_shadow_prepassgeometrydepthbuffer, r_shadow_prepassgeometryfbo, r_shadow_prepassgeometrynormalmaptexture, r_shadow_prepasslightingdiffusefbo, r_shadow_prepasslightingdiffusespecularfbo, r_shadow_prepasslightingdiffusetexture, r_shadow_prepasslightingspeculartexture, r_shadow_scenelightlist, r_shadow_scenenumlights, r_shadow_shadowmapatlas_modelshadows_size, r_shadow_shadowmapatlas_modelshadows_x, r_shadow_shadowmapatlas_modelshadows_y, r_shadow_shadowmapatlas_state, r_shadow_shadowmapborder, r_shadow_shadowmapdepthbits, r_shadow_shadowmapdepthtexture, r_shadow_shadowmapfilterquality, r_shadow_shadowmapmaxsize, r_shadow_shadowmapping, r_shadow_shadowmapping_bordersize, r_shadow_shadowmapping_depthbits, r_shadow_shadowmapping_filterquality, r_shadow_shadowmapping_maxsize, r_shadow_shadowmapping_texturesize, r_shadow_shadowmapping_useshadowsampler, r_shadow_shadowmapping_vsdct, R_Shadow_ShadowMappingEnabled(), r_shadow_shadowmapshadowsampler, r_shadow_shadowmaptexturesize, r_shadow_shadowmapvsdct, r_shadow_shadowmode_deferred, r_shadow_shadowmode_shadowmapping, r_shadow_texturepool, r_shadow_usingdeferredprepass, r_shadow_usingshadowmaportho, r_shadow_worldlightsarray, viddef_t::renderpath, RENDERPATH_GL32, RENDERPATH_GLES2, r_refdef_scene_t::rtdlight, dlight_t::rtlight, r_refdef_scene_t::rtworld, r_refdef_t::scene, r_framebufferstate_t::screentextureheight, r_framebufferstate_t::screentexturewidth, rtlight_t::shadowmapatlasposition, rtlight_t::shadowmapatlassidesize, rtlight_t::shadowmapsidesize, size, rtlight_t::style, model_t::surfmesh, TEXF_ALPHA, TEXF_CLAMP, TEXF_FORCENEAREST, TEXF_RENDERTARGET, TEXTYPE_COLORBUFFER16F, TEXTYPE_COLORBUFFER32F, TEXTYPE_DEPTHBUFFER24, r_framebufferstate_t::usedepthtextures, cvar_t::value, VectorScale, vid, width, and r_refdef_scene_t::worldmodel.

Referenced by R_RenderScene().

◆ R_Shadow_PrepareModelShadows()

void R_Shadow_PrepareModelShadows ( void )

Definition at line 4242 of file r_shadow.c.

4243{
4244 int i;
4245 float scale, size, radius, dot1, dot2;
4246 prvm_vec3_t prvmshadowdir, prvmshadowfocus;
4247 vec3_t shadowdir, shadowforward, shadowright, shadoworigin, shadowfocus, shadowmins, shadowmaxs;
4248 entity_render_t *ent;
4249
4252
4254 return;
4255
4258 radius = 0.5f * size / scale;
4259
4261 VectorCopy(prvmshadowdir, shadowdir);
4262 VectorNormalize(shadowdir);
4263 dot1 = DotProduct(r_refdef.view.forward, shadowdir);
4264 dot2 = DotProduct(r_refdef.view.up, shadowdir);
4265 if (fabs(dot1) <= fabs(dot2))
4266 VectorMA(r_refdef.view.forward, -dot1, shadowdir, shadowforward);
4267 else
4268 VectorMA(r_refdef.view.up, -dot2, shadowdir, shadowforward);
4269 VectorNormalize(shadowforward);
4270 CrossProduct(shadowdir, shadowforward, shadowright);
4271 Math_atov(r_shadows_focus.string, prvmshadowfocus);
4272 VectorCopy(prvmshadowfocus, shadowfocus);
4273 VectorM(shadowfocus[0], r_refdef.view.right, shadoworigin);
4274 VectorMA(shadoworigin, shadowfocus[1], r_refdef.view.up, shadoworigin);
4275 VectorMA(shadoworigin, -shadowfocus[2], r_refdef.view.forward, shadoworigin);
4276 VectorAdd(shadoworigin, r_refdef.view.origin, shadoworigin);
4277 if (shadowfocus[0] || shadowfocus[1] || shadowfocus[2])
4278 dot1 = 1;
4279 VectorMA(shadoworigin, (1.0f - fabs(dot1)) * radius, shadowforward, shadoworigin);
4280
4281 shadowmins[0] = shadoworigin[0] - r_shadows_throwdistance.value * fabs(shadowdir[0]) - radius * (fabs(shadowforward[0]) + fabs(shadowright[0]));
4282 shadowmins[1] = shadoworigin[1] - r_shadows_throwdistance.value * fabs(shadowdir[1]) - radius * (fabs(shadowforward[1]) + fabs(shadowright[1]));
4283 shadowmins[2] = shadoworigin[2] - r_shadows_throwdistance.value * fabs(shadowdir[2]) - radius * (fabs(shadowforward[2]) + fabs(shadowright[2]));
4284 shadowmaxs[0] = shadoworigin[0] + r_shadows_throwdistance.value * fabs(shadowdir[0]) + radius * (fabs(shadowforward[0]) + fabs(shadowright[0]));
4285 shadowmaxs[1] = shadoworigin[1] + r_shadows_throwdistance.value * fabs(shadowdir[1]) + radius * (fabs(shadowforward[1]) + fabs(shadowright[1]));
4286 shadowmaxs[2] = shadoworigin[2] + r_shadows_throwdistance.value * fabs(shadowdir[2]) + radius * (fabs(shadowforward[2]) + fabs(shadowright[2]));
4287
4288 for (i = 0; i < r_refdef.scene.numentities; i++)
4289 {
4290 ent = r_refdef.scene.entities[i];
4291 if (!BoxesOverlap(ent->mins, ent->maxs, shadowmins, shadowmaxs))
4292 continue;
4293 // cast shadows from anything of the map (submodels are optional)
4294 if (ent->model && ent->model->DrawShadowMap != NULL && (!ent->model->brush.submodel || r_shadows_castfrombmodels.integer) && (ent->flags & RENDER_SHADOW))
4295 {
4297 break;
4299 R_AnimCache_GetEntity(ent, false, false);
4300 }
4301 }
4302
4304 {
4308 }
4309}
float scale
cvar_t r_shadows_castfrombmodels
Definition gl_rmain.c:128
cvar_t r_shadows_focus
Definition gl_rmain.c:129
qbool R_AnimCache_GetEntity(entity_render_t *ent, qbool wantnormals, qbool wanttangents)
get the skeletal data or cached animated mesh data for an entity (optionally with normals and tangent...
Definition gl_rmain.c:3789
cvar_t r_shadows_throwdirection
Definition gl_rmain.c:126
cvar_t r_shadows
Definition gl_rmain.c:123
cvar_t r_shadows_shadowmapscale
Definition gl_rmain.c:130
cvar_t r_shadows_throwdistance
Definition gl_rmain.c:125
int Math_atov(const char *s, prvm_vec3_t out)
Definition mathlib.c:856
#define CrossProduct(a, b, out)
Definition mathlib.h:103
#define VectorCopy(in, out)
Definition mathlib.h:101
#define VectorAdd(a, b, out)
Definition mathlib.h:100
#define VectorMA(a, scale, b, out)
Definition mathlib.h:114
#define VectorM(scale1, b1, out)
Definition mathlib.h:115
#define RENDER_SHADOW
Definition protocol.h:365
prvm_vec_t prvm_vec3_t[3]
Definition qtypes.h:63
static entity_render_t * r_shadow_modelshadows[MAX_MODELSHADOWS]
Definition r_shadow.c:4240
static int r_shadow_nummodelshadows
Definition r_shadow.c:4239
#define MAX_MODELSHADOWS
Definition r_shadow.c:4238
const char * string
Definition cvar.h:71
vec3_t mins
Definition client.h:371
vec3_t maxs
Definition client.h:371
void(* DrawShadowMap)(int side, struct entity_render_s *ent, const vec3_t relativelightorigin, const vec3_t relativelightdirection, float lightradius, int numsurfaces, const int *surfacelist, const unsigned char *surfacesides, const vec3_t lightmins, const vec3_t lightmaxs)
float lightmapintensity
Definition render.h:387
vec3_t right
Definition render.h:270
vec3_t origin
Definition render.h:267
vec3_t forward
Definition render.h:268

References BoxesOverlap, model_t::brush, CrossProduct, DotProduct, model_t::DrawShadowMap, r_refdef_scene_t::entities, fabs(), entity_render_t::flags, r_refdef_view_t::forward, i, cvar_t::integer, r_refdef_scene_t::lightmapintensity, Math_atov(), MAX_MODELSHADOWS, entity_render_t::maxs, entity_render_t::mins, entity_render_t::model, NULL, r_refdef_scene_t::numentities, r_refdef_view_t::origin, R_AnimCache_GetEntity(), r_refdef, r_shadow_modelshadows, r_shadow_nummodelshadows, r_shadow_shadowmapatlas_modelshadows_size, r_shadow_shadowmapatlas_modelshadows_x, r_shadow_shadowmapatlas_modelshadows_y, r_shadow_shadowmapping_precision, r_shadow_shadowmaptexturesize, r_shadows, r_shadows_castfrombmodels, r_shadows_focus, r_shadows_shadowmapscale, r_shadows_throwdirection, r_shadows_throwdistance, RENDER_SHADOW, r_refdef_view_t::right, scale, r_refdef_t::scene, size, cvar_t::string, model_brush_t::submodel, r_refdef_view_t::up, cvar_t::value, VectorAdd, VectorCopy, VectorM, VectorMA, VectorNormalize, and r_refdef_t::view.

Referenced by R_RenderScene().

◆ R_Shadow_PrepareShadowMark()

void R_Shadow_PrepareShadowMark ( int numtris)

Definition at line 824 of file r_shadow.c.

825{
826 // make sure shadowmark is big enough for this volume
827 if (maxshadowmark < numtris)
828 {
829 maxshadowmark = numtris;
830 if (shadowmark)
832 if (shadowmarklist)
836 shadowmarkcount = 0;
837 }
839 // if shadowmarkcount wrapped we clear the array and adjust accordingly
840 if (shadowmarkcount == 0)
841 {
842 shadowmarkcount = 1;
843 memset(shadowmark, 0, maxshadowmark * sizeof(*shadowmark));
844 }
845 numshadowmark = 0;
846}
#define Mem_Free(mem)
Definition zone.h:96
#define Mem_Alloc(pool, size)
Definition zone.h:92

References maxshadowmark, Mem_Alloc, Mem_Free, numshadowmark, r_main_mempool, shadowmark, shadowmarkcount, and shadowmarklist.

◆ R_Shadow_PrepareShadowSides()

void R_Shadow_PrepareShadowSides ( int numtris)

Definition at line 848 of file r_shadow.c.

849{
850 if (maxshadowsides < numtris)
851 {
852 maxshadowsides = numtris;
853 if (shadowsides)
855 if (shadowsideslist)
857 shadowsides = (unsigned char *)Mem_Alloc(r_main_mempool, maxshadowsides * sizeof(*shadowsides));
859 }
860 numshadowsides = 0;
861}

References maxshadowsides, Mem_Alloc, Mem_Free, numshadowsides, r_main_mempool, shadowsides, and shadowsideslist.

Referenced by R_Mod_CompileShadowMap().

◆ R_Shadow_RenderLighting()

void R_Shadow_RenderLighting ( int texturenumsurfaces,
const struct msurface_s ** texturesurfacelist )

◆ R_Shadow_RenderMode_ActiveLight()

void R_Shadow_RenderMode_ActiveLight ( const struct rtlight_s * rtlight)

◆ R_Shadow_RenderMode_Begin()

void R_Shadow_RenderMode_Begin ( void )

Definition at line 1369 of file r_shadow.c.

1370{
1371#if 0
1372 GLint drawbuffer;
1373 GLint readbuffer;
1374#endif
1375
1379
1383 GL_DepthRange(0, 1);
1385 GL_DepthTest(true);
1386 GL_DepthMask(false);
1387 GL_Color(0, 0, 0, 1);
1389
1392
1394#if 0
1395 qglGetIntegerv(GL_DRAW_BUFFER, &drawbuffer);CHECKGLERROR
1396 qglGetIntegerv(GL_READ_BUFFER, &readbuffer);CHECKGLERROR
1397 r_shadow_drawbuffer = drawbuffer;
1398 r_shadow_readbuffer = readbuffer;
1399#endif
1402}
int GLint
Definition glquake.h:51
#define GL_READ_BUFFER
Definition glquake.h:195
#define GL_DRAW_BUFFER
Definition glquake.h:194
int r_shadow_cullface_front
Definition r_shadow.c:48
static void R_Shadow_MakeTextures(void)
Definition r_shadow.c:1232
r_shadow_rendermode_t r_shadow_lightingrendermode
Definition r_shadow.c:33
static float r_shadow_attendividebias
Definition r_shadow.c:268
@ R_SHADOW_RENDERMODE_NONE
Definition r_shadow.c:11
@ R_SHADOW_RENDERMODE_LIGHT_GLSL
Definition r_shadow.c:18
static float r_shadow_attenlinearscale
Definition r_shadow.c:269
int r_shadow_cullface_back
Definition r_shadow.c:48
float polygonoffset
Definition render.h:459
float polygonfactor
Definition render.h:458
r_viewport_t viewport
note: if r_viewscale is used, the viewport.width and viewport.height may be less than width and heigh...
Definition render.h:296
int cullface_front
Definition render.h:317

References CHECKGLERROR, r_refdef_view_t::cullface_back, r_refdef_view_t::cullface_front, GL_BlendFunc(), GL_Color(), GL_DepthMask(), GL_DepthRange(), GL_DepthTest(), GL_DRAW_BUFFER, GL_ONE, GL_PolygonOffset(), GL_READ_BUFFER, GL_Scissor(), GL_ZERO, r_viewport_t::height, r_refdef_t::polygonfactor, r_refdef_t::polygonoffset, R_Mesh_ResetTextureState(), r_refdef, r_shadow_attendividebias, r_shadow_attenlinearscale, r_shadow_cullface_back, r_shadow_cullface_front, r_shadow_lightattenuationdividebias, r_shadow_lightattenuationlinearscale, r_shadow_lightingrendermode, R_Shadow_MakeTextures(), r_shadow_rendermode, R_SHADOW_RENDERMODE_LIGHT_GLSL, R_SHADOW_RENDERMODE_NONE, cvar_t::value, r_refdef_t::view, r_refdef_view_t::viewport, r_viewport_t::width, r_viewport_t::x, and r_viewport_t::y.

Referenced by R_Q1BSP_DrawLight_TransparentCallback(), R_Shadow_DrawLights(), R_Shadow_DrawPrepass(), and R_Shadow_DrawShadowMaps().

◆ R_Shadow_RenderMode_DrawDeferredLight()

void R_Shadow_RenderMode_DrawDeferredLight ( qbool shadowmapping)

Definition at line 1642 of file r_shadow.c.

1643{
1644 int i;
1645 float vertex3f[8*3];
1647// do global setup needed for the chosen lighting mode
1654 else
1656
1657 r_shadow_usingshadowmap2d = shadowmapping;
1658
1659 // render the lighting
1661 for (i = 0;i < 8;i++)
1662 Matrix4x4_Transform(matrix, bboxpoints[i], vertex3f + i*3);
1663 GL_ColorMask(1,1,1,1);
1664 GL_DepthMask(false);
1665 GL_DepthRange(0, 1);
1666 GL_PolygonOffset(0, 0);
1667 GL_DepthTest(true);
1670 R_Mesh_PrepareVertices_Vertex3f(8, vertex3f, NULL, 0);
1671 R_Mesh_Draw(0, 8, 0, 12, NULL, NULL, 0, bboxelements, NULL, 0);
1672}
void R_Mesh_PrepareVertices_Vertex3f(int numvertices, const float *vertex3f, const r_meshbuffer_t *vertexbuffer, int bufferoffset)
void GL_DepthFunc(int state)
void R_Mesh_Draw(int firstvertex, int numvertices, int firsttriangle, int numtriangles, const int *element3i, const r_meshbuffer_t *element3i_indexbuffer, int element3i_bufferoffset, const unsigned short *element3s, const r_meshbuffer_t *element3s_indexbuffer, int element3s_bufferoffset)
void R_SetupShader_DeferredLight(const rtlight_t *rtlight)
Definition gl_rmain.c:2091
rsurfacestate_t rsurface
Definition gl_rmain.c:6919
#define GL_SRC_ALPHA
Definition glquake.h:79
#define GL_GREATER
Definition glquake.h:163
static const unsigned short bboxelements[36]
Definition r_shadow.c:1620
qbool r_shadow_usingshadowmap2d
Definition r_shadow.c:37
static const float bboxpoints[8][3]
Definition r_shadow.c:1630
const rtlight_t * rtlight
Definition render.h:748
vec_t specularscale
specular intensity to render
Definition client.h:132
matrix4x4_t matrix_lighttoworld
matrix for transforming light filter coordinates to world coordinates
Definition client.h:110

References bboxelements, bboxpoints, r_refdef_view_t::cullface_back, GL_BlendFunc(), GL_ColorMask(), GL_CullFace(), GL_DepthFunc(), GL_DepthMask(), GL_DepthRange(), GL_DepthTest(), GL_GREATER, GL_ONE, GL_PolygonOffset(), GL_SRC_ALPHA, i, identitymatrix, cvar_t::integer, Matrix4x4_Transform(), rtlight_t::matrix_lighttoworld, NULL, R_EntityMatrix(), R_Mesh_Draw(), R_Mesh_PrepareVertices_Vertex3f(), R_Mesh_SetRenderTargets(), r_refdef, R_SetupShader_DeferredLight(), r_shadow_gloss, r_shadow_lightingrendermode, r_shadow_prepasslightingdiffusefbo, r_shadow_prepasslightingdiffusespecularfbo, r_shadow_rendermode, R_Shadow_RenderMode_Reset(), r_shadow_usingshadowmap2d, rsurface, rsurfacestate_t::rtlight, rtlight_t::specularscale, and r_refdef_t::view.

Referenced by R_Shadow_DrawLight().

◆ R_Shadow_RenderMode_End()

◆ R_Shadow_RenderMode_Lighting()

void R_Shadow_RenderMode_Lighting ( qbool transparent,
qbool shadowmapping,
qbool noselfshadowpass )

Definition at line 1597 of file r_shadow.c.

1598{
1600 if (transparent)
1601 {
1606 }
1607 if (shadowmapping)
1611 if (!transparent)
1613 // do global setup needed for the chosen lighting mode
1616 r_shadow_usingshadowmap2d = shadowmapping;
1618}
#define GL_EQUAL
Definition glquake.h:161
static void R_Shadow_SetShadowmapParametersForLight(qbool noselfshadowpass)
Definition r_shadow.c:1527
int r_shadow_lightscissor[4]
Definition r_shadow.c:63

References r_refdef_view_t::colormask, GL_BlendFunc(), GL_ColorMask(), GL_DepthFunc(), GL_EQUAL, GL_ONE, GL_SRC_ALPHA, r_viewport_t::height, R_Mesh_ResetTextureState(), r_refdef, r_shadow_lightingrendermode, r_shadow_lightscissor, r_shadow_rendermode, R_SHADOW_RENDERMODE_LIGHT_GLSL, R_Shadow_RenderMode_Reset(), R_Shadow_SetShadowmapParametersForLight(), r_shadow_usingshadowmap2d, r_refdef_t::view, r_refdef_view_t::viewport, r_viewport_t::width, r_viewport_t::x, and r_viewport_t::y.

Referenced by R_Q1BSP_DrawLight_TransparentCallback(), and R_Shadow_DrawLight().

◆ R_Shadow_RenderMode_Reset()

void R_Shadow_RenderMode_Reset ( void )

Definition at line 1409 of file r_shadow.c.

References CHECKGLERROR, r_refdef_view_t::colormask, r_refdef_view_t::cullface_back, r_refdef_view_t::cullface_front, GL_BlendFunc(), GL_Color(), GL_ColorMask(), GL_CullFace(), GL_DepthFunc(), GL_DepthMask(), GL_DepthRange(), GL_DepthTest(), GL_LEQUAL, GL_ONE, GL_PolygonOffset(), GL_Scissor(), GL_ZERO, r_refdef_t::polygonfactor, r_refdef_t::polygonoffset, R_Mesh_ResetTextureState(), R_Mesh_SetRenderTargets(), r_refdef, R_SetupShader_Generic_NoTexture(), R_SetViewport(), r_shadow_cullface_back, r_shadow_cullface_front, r_shadow_lightscissor, r_shadow_usingshadowmap2d, r_shadow_viewfbo, r_refdef_t::view, and r_refdef_view_t::viewport.

Referenced by R_Shadow_ClearShadowMapTexture(), R_Shadow_RenderMode_DrawDeferredLight(), R_Shadow_RenderMode_End(), R_Shadow_RenderMode_Lighting(), R_Shadow_RenderMode_ShadowMap(), and R_Shadow_RenderMode_VisibleLighting().

◆ R_Shadow_RenderMode_VisibleLighting()

void R_Shadow_RenderMode_VisibleLighting ( qbool transparent)

◆ R_Shadow_ScissorForBBox()

qbool R_Shadow_ScissorForBBox ( const float * mins,
const float * maxs )

Definition at line 2900 of file r_shadow.c.

2901{
2903 {
2908 return false;
2909 }
2911 return true; // invisible
2917 return false;
2918}
vector mins
vector maxs
qbool R_ScissorForBBox(const float *mins, const float *maxs, int *scissor)
Definition gl_backend.c:430
cvar_t r_trippy
Definition model_brush.c:29
@ r_stat_lights_scissored
Definition r_stats.h:29

References r_viewport_t::height, cvar_t::integer, maxs, mins, r_refdef, R_ScissorForBBox(), r_shadow_lightscissor, r_shadow_scissor, r_shadow_usingdeferredprepass, r_stat_lights_scissored, r_trippy, r_refdef_t::stats, r_refdef_t::view, r_refdef_view_t::viewport, r_viewport_t::width, r_viewport_t::x, and r_viewport_t::y.

Referenced by R_Shadow_DrawLight(), and R_Shadow_DrawLightShadowMaps().

◆ R_Shadow_SetupEntityLight()

void R_Shadow_SetupEntityLight ( const struct entity_render_s * ent)

◆ R_Shadow_ShadowMapFromList()

void R_Shadow_ShadowMapFromList ( int numverts,
int numtris,
const float * vertex3f,
const int * elements,
int numsidetris,
const int * sidetotals,
const unsigned char * sides,
const int * sidetris )

Definition at line 1162 of file r_shadow.c.

1163{
1164 int i, j, outtriangles = 0;
1165 int *outelement3i[6];
1166 if (!numverts || !numsidetris || !r_shadow_compilingrtlight)
1167 return;
1168 outtriangles = sidetotals[0] + sidetotals[1] + sidetotals[2] + sidetotals[3] + sidetotals[4] + sidetotals[5];
1169 // make sure shadowelements is big enough for this mesh
1170 if (maxshadowtriangles < outtriangles)
1171 R_Shadow_ResizeShadowArrays(0, outtriangles, 0, 1);
1172
1173 // compute the offset and size of the separate index lists for each cubemap side
1174 outtriangles = 0;
1175 for (i = 0;i < 6;i++)
1176 {
1177 outelement3i[i] = shadowelements + outtriangles * 3;
1180 outtriangles += sidetotals[i];
1181 }
1182
1183 // gather up the (sparse) triangles into separate index lists for each cubemap side
1184 for (i = 0;i < numsidetris;i++)
1185 {
1186 const int *element = elements + sidetris[i] * 3;
1187 for (j = 0;j < 6;j++)
1188 {
1189 if (sides[i] & (1 << j))
1190 {
1191 outelement3i[j][0] = element[0];
1192 outelement3i[j][1] = element[1];
1193 outelement3i[j][2] = element[2];
1194 outelement3i[j] += 3;
1195 }
1196 }
1197 }
1198
1200}
void Mod_ShadowMesh_AddMesh(shadowmesh_t *mesh, const float *vertex3f, int numtris, const int *element3i)
static void R_Shadow_ResizeShadowArrays(int numvertices, int numtriangles, int vertscale, int triscale)
Definition r_shadow.c:754
rtlight_t * r_shadow_compilingrtlight
Definition r_shadow.c:272
shadowmesh_t * static_meshchain_shadow_shadowmap
optimized and culled mesh to render for world entity shadows
Definition client.h:192
int sidetotals[6]
int sideoffsets[6]

References i, maxshadowtriangles, Mod_ShadowMesh_AddMesh(), r_shadow_compilingrtlight, R_Shadow_ResizeShadowArrays(), shadowelements, shadowmesh_t::sideoffsets, shadowmesh_t::sidetotals, and rtlight_t::static_meshchain_shadow_shadowmap.

Referenced by R_Mod_CompileShadowMap().

◆ R_Shadow_ShadowMappingEnabled()

qbool R_Shadow_ShadowMappingEnabled ( void )

Definition at line 378 of file r_shadow.c.

379{
380 switch (r_shadow_shadowmode)
381 {
383 return true;
385 return false;
386 }
387 return false;
388}
@ R_SHADOW_SHADOWMODE_DISABLED
Definition r_shadow.c:27
@ R_SHADOW_SHADOWMODE_SHADOWMAP2D
Definition r_shadow.c:28
r_shadow_shadowmode_t r_shadow_shadowmode
Definition r_shadow.c:52

References r_shadow_shadowmode, R_SHADOW_SHADOWMODE_DISABLED, and R_SHADOW_SHADOWMODE_SHADOWMAP2D.

Referenced by R_RenderScene(), R_Shadow_DrawShadowMaps(), R_Shadow_PrepareLight(), and R_Shadow_PrepareLights().

◆ R_Shadow_UpdateWorldLightSelection()

void R_Shadow_UpdateWorldLightSelection ( void )

Definition at line 5289 of file r_shadow.c.

5290{
5292 {
5295 }
5296 else
5298}
static void R_Shadow_SelectLight(dlight_t *light)
Definition r_shadow.c:4700
static void R_Shadow_SetCursorLocationForView(void)
Definition r_shadow.c:5263
static void R_Shadow_SelectLightInView(void)
Definition r_shadow.c:4797

References cvar_t::integer, NULL, r_editlights, R_Shadow_SelectLight(), R_Shadow_SelectLightInView(), and R_Shadow_SetCursorLocationForView().

Referenced by R_RenderView().

Variable Documentation

◆ matrix_attenuationxyz

matrix4x4_t matrix_attenuationxyz
extern

Definition at line 734 of file r_shadow.c.

735{
736 {
737 {0.5, 0.0, 0.0, 0.5},
738 {0.0, 0.5, 0.0, 0.5},
739 {0.0, 0.0, 0.5, 0.5},
740 {0.0, 0.0, 0.0, 1.0}
741 }
742};

Referenced by R_Shadow_DrawWorldLight(), and R_Shadow_SetupEntityLight().

◆ matrix_attenuationz

matrix4x4_t matrix_attenuationz
extern

Definition at line 744 of file r_shadow.c.

745{
746 {
747 {0.0, 0.0, 0.5, 0.5},
748 {0.0, 0.0, 0.0, 0.5},
749 {0.0, 0.0, 0.0, 0.5},
750 {0.0, 0.0, 0.0, 1.0}
751 }
752};

Referenced by R_Shadow_DrawWorldLight(), and R_Shadow_SetupEntityLight().

◆ maxshadowmark

int maxshadowmark
extern

◆ maxshadowsides

int maxshadowsides
extern

◆ numshadowmark

int numshadowmark
extern

◆ numshadowsides

◆ r_shadow_bouncegrid_state

◆ r_shadow_bumpscale_basetexture

struct cvar_s r_shadow_bumpscale_basetexture
extern

Definition at line 141 of file r_shadow.c.

141{CF_CLIENT, "r_shadow_bumpscale_basetexture", "0", "generate fake bumpmaps from diffuse textures at this bumpyness, try 4 to match tenebrae, higher values increase depth, requires r_restart to take effect"};
#define CF_CLIENT
cvar/command that only the client can change/execute
Definition cmd.h:48

Referenced by R_Shadow_Init(), R_SkinFrame_GenerateTexturesFromQPixels(), R_SkinFrame_LoadExternal_SkinFrame(), R_SkinFrame_LoadInternalBGRA(), and R_SkinFrame_LoadInternalQuake().

◆ r_shadow_bumpscale_bumpmap

struct cvar_s r_shadow_bumpscale_bumpmap
extern

Definition at line 142 of file r_shadow.c.

142{CF_CLIENT, "r_shadow_bumpscale_bumpmap", "4", "what magnitude to interpret _bump.tga textures as, higher values increase depth, requires r_restart to take effect"};

Referenced by R_Shadow_Init(), and R_SkinFrame_LoadExternal_SkinFrame().

◆ r_shadow_compilingrtlight

◆ r_shadow_debuglight

struct cvar_s r_shadow_debuglight
extern

Definition at line 143 of file r_shadow.c.

143{CF_CLIENT, "r_shadow_debuglight", "-1", "renders only one light, for level design purposes or debugging"};

Referenced by R_Shadow_BounceGrid_AssignPhotons_Task(), R_Shadow_DrawCoronas(), R_Shadow_Init(), and R_Shadow_PrepareLights().

◆ r_shadow_frontsidecasting

struct cvar_s r_shadow_frontsidecasting
extern

Definition at line 158 of file r_shadow.c.

158{CF_CLIENT, "r_shadow_frontsidecasting", "1", "whether to cast shadows from illuminated triangles (front side of model) or unlit triangles (back side of model)"};

Referenced by R_Mod_GetLightInfo(), R_Shadow_ChooseSidesFromBox(), R_Shadow_Init(), and R_UpdateVariables().

◆ r_shadow_gloss

struct cvar_s r_shadow_gloss
extern

Definition at line 147 of file r_shadow.c.

147{CF_CLIENT | CF_ARCHIVE, "r_shadow_gloss", "1", "0 disables gloss (specularity) rendering, 1 uses gloss if textures are found, 2 forces a flat metallic specular effect on everything without textures (similar to tenebrae)"};
#define CF_ARCHIVE
cvar should have its set value saved to config.cfg and persist across sessions
Definition cmd.h:53

Referenced by R_Shadow_Init(), and R_Shadow_RenderMode_DrawDeferredLight().

◆ r_shadow_gloss2exponent

struct cvar_s r_shadow_gloss2exponent
extern

Definition at line 151 of file r_shadow.c.

151{CF_CLIENT, "r_shadow_gloss2exponent", "32", "same as r_shadow_glossexponent but for forced gloss (gloss 2) surfaces"};

Referenced by R_GetCurrentTexture(), R_SetupShader_DeferredLight(), and R_Shadow_Init().

◆ r_shadow_gloss2intensity

struct cvar_s r_shadow_gloss2intensity
extern

Definition at line 148 of file r_shadow.c.

148{CF_CLIENT, "r_shadow_gloss2intensity", "0.125", "how bright the forced flat gloss should look if r_shadow_gloss is 2"};

Referenced by R_GetCurrentTexture(), and R_Shadow_Init().

◆ r_shadow_glossexact

struct cvar_s r_shadow_glossexact
extern

Definition at line 152 of file r_shadow.c.

152{CF_CLIENT, "r_shadow_glossexact", "0", "use exact reflection math for gloss (slightly slower, but should look a tad better)"};

Referenced by R_CompileShader_CheckStaticParms(), R_SetupShader_DeferredLight(), R_SetupShader_Surface(), and R_Shadow_Init().

◆ r_shadow_glossexponent

struct cvar_s r_shadow_glossexponent
extern

Definition at line 150 of file r_shadow.c.

150{CF_CLIENT, "r_shadow_glossexponent", "32", "how 'sharp' the gloss should appear (specular power)"};

Referenced by R_GetCurrentTexture(), R_SetupShader_DeferredLight(), and R_Shadow_Init().

◆ r_shadow_glossintensity

struct cvar_s r_shadow_glossintensity
extern

Definition at line 149 of file r_shadow.c.

149{CF_CLIENT, "r_shadow_glossintensity", "1", "how bright textured glossmaps should look if r_shadow_gloss is 1 or 2"};

Referenced by R_GetCurrentTexture(), and R_Shadow_Init().

◆ r_shadow_lightattenuationpower

struct cvar_s r_shadow_lightattenuationpower
extern

◆ r_shadow_lightattenuationscale

struct cvar_s r_shadow_lightattenuationscale
extern

◆ r_shadow_lightintensityscale

struct cvar_s r_shadow_lightintensityscale
extern

Definition at line 155 of file r_shadow.c.

155{CF_CLIENT, "r_shadow_lightintensityscale", "1", "renders all world lights brighter or darker"};

Referenced by R_CompleteLightPoint(), R_Shadow_BounceGrid_AssignPhotons_Task(), R_Shadow_Init(), R_Shadow_PrepareLight(), and R_Shadow_PrepareLights().

◆ r_shadow_lightradiusscale

struct cvar_s r_shadow_lightradiusscale
extern

Definition at line 156 of file r_shadow.c.

156{CF_CLIENT, "r_shadow_lightradiusscale", "1", "renders all world lights larger or smaller"};

Referenced by R_RTLight_Update(), and R_Shadow_Init().

◆ r_shadow_projectdistance

struct cvar_s r_shadow_projectdistance
extern

Definition at line 157 of file r_shadow.c.

157{CF_CLIENT, "r_shadow_projectdistance", "0", "how far to cast shadows"};

Referenced by R_Shadow_Init().

◆ r_shadow_realtime_dlight

struct cvar_s r_shadow_realtime_dlight
extern

Definition at line 159 of file r_shadow.c.

159{CF_CLIENT | CF_ARCHIVE, "r_shadow_realtime_dlight", "1", "enables rendering of dynamic lights such as explosions and rocket light"};

Referenced by R_Shadow_Init().

◆ r_shadow_realtime_dlight_portalculling

struct cvar_s r_shadow_realtime_dlight_portalculling
extern

Definition at line 162 of file r_shadow.c.

162{CF_CLIENT, "r_shadow_realtime_dlight_portalculling", "0", "enables portal optimization on dynamic lights (slow!)"};

Referenced by R_Mod_GetLightInfo(), and R_Shadow_Init().

◆ r_shadow_realtime_dlight_shadows

struct cvar_s r_shadow_realtime_dlight_shadows
extern

Definition at line 160 of file r_shadow.c.

160{CF_CLIENT | CF_ARCHIVE, "r_shadow_realtime_dlight_shadows", "1", "enables rendering of shadows from dynamic lights"};

Referenced by R_Shadow_Init().

◆ r_shadow_realtime_dlight_svbspculling

struct cvar_s r_shadow_realtime_dlight_svbspculling
extern

Definition at line 161 of file r_shadow.c.

161{CF_CLIENT, "r_shadow_realtime_dlight_svbspculling", "0", "enables svbsp optimization on dynamic lights (very slow!)"};

Referenced by R_Mod_GetLightInfo(), and R_Shadow_Init().

◆ r_shadow_realtime_world

struct cvar_s r_shadow_realtime_world
extern

Definition at line 163 of file r_shadow.c.

163{CF_CLIENT | CF_ARCHIVE, "r_shadow_realtime_world", "0", "enables rendering of full world lighting (whether loaded from the map, or a .rtlights file, or a .ent file, or a .lights file produced by hlight)"};

Referenced by R_Shadow_Init().

◆ r_shadow_realtime_world_compile

struct cvar_s r_shadow_realtime_world_compile
extern

Definition at line 167 of file r_shadow.c.

167{CF_CLIENT, "r_shadow_realtime_world_compile", "1", "enables compilation of world lights for higher performance rendering"};

Referenced by R_Shadow_DrawLightShadowMaps(), R_Shadow_DrawWorldShadow_ShadowMap(), R_Shadow_Init(), and R_Shadow_PrepareLight().

◆ r_shadow_realtime_world_compileportalculling

struct cvar_s r_shadow_realtime_world_compileportalculling
extern

Definition at line 170 of file r_shadow.c.

170{CF_CLIENT, "r_shadow_realtime_world_compileportalculling", "1", "enables portal-based culling optimization during compilation (overrides compilesvbsp)"};

Referenced by R_Mod_GetLightInfo(), and R_Shadow_Init().

◆ r_shadow_realtime_world_compileshadow

struct cvar_s r_shadow_realtime_world_compileshadow
extern

Definition at line 168 of file r_shadow.c.

168{CF_CLIENT, "r_shadow_realtime_world_compileshadow", "1", "enables compilation of shadows from world lights for higher performance rendering"};

Referenced by R_Shadow_DrawLightShadowMaps(), R_Shadow_DrawWorldShadow_ShadowMap(), and R_Shadow_Init().

◆ r_shadow_realtime_world_compilesvbsp

struct cvar_s r_shadow_realtime_world_compilesvbsp
extern

Definition at line 169 of file r_shadow.c.

169{CF_CLIENT, "r_shadow_realtime_world_compilesvbsp", "1", "enables svbsp optimization during compilation (slower than compileportalculling but more exact)"};

Referenced by R_Mod_GetLightInfo(), and R_Shadow_Init().

◆ r_shadow_realtime_world_lightmaps

struct cvar_s r_shadow_realtime_world_lightmaps
extern

Definition at line 165 of file r_shadow.c.

165{CF_CLIENT | CF_ARCHIVE, "r_shadow_realtime_world_lightmaps", "0", "brightness to render lightmaps when using full world lighting, try 0.5 for a tenebrae-like appearance"};

Referenced by R_Shadow_Init().

◆ r_shadow_realtime_world_shadows

struct cvar_s r_shadow_realtime_world_shadows
extern

Definition at line 166 of file r_shadow.c.

166{CF_CLIENT | CF_ARCHIVE, "r_shadow_realtime_world_shadows", "1", "enables rendering of shadows from world lights"};

Referenced by R_Shadow_Init().

◆ r_shadow_scissor

struct cvar_s r_shadow_scissor
extern

Definition at line 171 of file r_shadow.c.

171{CF_CLIENT, "r_shadow_scissor", "1", "use scissor optimization of light rendering (restricts rendering to the portion of the screen affected by the light)"};

Referenced by R_Shadow_Init(), and R_Shadow_ScissorForBBox().

◆ shadowmark

int* shadowmark
extern

◆ shadowmarkcount

int shadowmarkcount
extern

◆ shadowmarklist

int* shadowmarklist
extern

◆ shadowsides

◆ shadowsideslist