]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - r_shadow.h
added gl_lightmaps cvar (for looking at the raw lightmaps in the map without textures)
[xonotic/darkplaces.git] / r_shadow.h
1
2 #ifndef R_SHADOW_H
3 #define R_SHADOW_H
4
5 extern cvar_t r_shadow_lightattenuationscale;
6 extern cvar_t r_shadow_lightintensityscale;
7 extern cvar_t r_shadow_realtime_world;
8 extern cvar_t r_shadow_realtime_world_lightmaps;
9 extern cvar_t r_shadow_realtime_dlight;
10 extern cvar_t r_shadow_visiblevolumes;
11 extern cvar_t r_shadow_gloss;
12 extern cvar_t r_shadow_debuglight;
13 extern cvar_t r_shadow_bumpscale_bumpmap;
14 extern cvar_t r_shadow_bumpscale_basetexture;
15 extern cvar_t r_shadow_worldshadows;
16 extern cvar_t r_shadow_dlightshadows;
17
18 void R_Shadow_Init(void);
19 void R_Shadow_Volume(int numverts, int numtris, const float *invertex3f, int *elements, int *neighbors, vec3_t relativelightorigin, float lightradius, float projectdistance);
20 void R_Shadow_DiffuseLighting(int numverts, int numtriangles, const int *elements, const float *vertices, const float *svectors, const float *tvectors, const float *normals, const float *texcoords, const float *relativelightorigin, float lightradius, const float *lightcolor, const matrix4x4_t *matrix_worldtofilter, const matrix4x4_t *matrix_worldtoattenuationxyz, const matrix4x4_t *matrix_worldtoattenuationz, rtexture_t *basetexture, rtexture_t *bumptexture, rtexture_t *lightcubemap);
21 void R_Shadow_SpecularLighting(int numverts, int numtriangles, const int *elements, const float *vertices, const float *svectors, const float *tvectors, const float *normals, const float *texcoords, const float *relativelightorigin, const float *relativeeyeorigin, float lightradius, const float *lightcolor, const matrix4x4_t *matrix_worldtofilter, const matrix4x4_t *matrix_worldtoattenuationxyz, const matrix4x4_t *matrix_worldtoattenuationz, rtexture_t *glosstexture, rtexture_t *bumptexture, rtexture_t *lightcubemap);
22 void R_Shadow_ClearStencil(void);
23
24 void R_Shadow_RenderShadowMeshVolume(shadowmesh_t *mesh);
25 void R_Shadow_Stage_Begin(void);
26 void R_Shadow_LoadWorldLightsIfNeeded(void);
27 void R_Shadow_Stage_ShadowVolumes(void);
28 void R_Shadow_Stage_LightWithShadows(void);
29 void R_Shadow_Stage_LightWithoutShadows(void);
30 void R_Shadow_Stage_End(void);
31 int R_Shadow_ScissorForBBox(const float *mins, const float *maxs);
32
33 typedef struct worldlight_s
34 {
35         // saved properties
36         vec3_t origin;
37         vec_t lightradius;
38         vec3_t light;
39         vec3_t angles;
40         int castshadows;
41         char *cubemapname;
42
43         // shadow volumes are done entirely in model space, so there are no matrices for dealing with them...
44
45         // note that the world to light matrices are inversely scaled (divided) by lightradius
46
47         // matrix for transforming world coordinates to light filter coordinates
48         //matrix4x4_t matrix_worldtofilter;
49         // based on worldtofilter this transforms -1 to +1 to 0 to 1 for purposes
50         // of attenuation texturing in full 3D (z result often ignored)
51         //matrix4x4_t matrix_worldtoattenuationxyz;
52         // this transforms only the Z to S, and T is always 0.5
53         //matrix4x4_t matrix_worldtoattenuationz;
54
55         // generated properties
56         vec3_t mins;
57         vec3_t maxs;
58         vec_t cullradius;
59         struct worldlight_s *next;
60         rtexture_t *cubemap;
61         int style;
62         int selected;
63
64         // premade shadow volumes and lit surfaces to render
65         shadowmesh_t *meshchain_shadow;
66         shadowmesh_t *meshchain_light;
67 }
68 worldlight_t;
69
70 extern worldlight_t *r_shadow_worldlightchain;
71
72 void R_Shadow_UpdateWorldLightSelection(void);
73
74 void R_Shadow_DrawStaticWorldLight_Shadow(worldlight_t *light, matrix4x4_t *matrix);
75 void R_Shadow_DrawStaticWorldLight_Light(worldlight_t *light, matrix4x4_t *matrix, 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);
76
77 #endif