]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - r_shadow.h
4e1349a34071fa9fa290280dfeddf20326327f61
[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_worldtolight, 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_worldtolight, 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 // these never change, they are used to create attenuation matrices
34 extern matrix4x4_t matrix_attenuationxyz;
35 extern matrix4x4_t matrix_attenuationz;
36
37 rtexture_t *R_Shadow_Cubemap(const char *basename);
38
39 typedef struct worldlight_s
40 {
41         // saved properties
42         vec3_t origin;
43         vec3_t angles;
44         vec3_t color;
45         vec_t radius;
46         vec_t corona;
47         int drawshadows;
48         char *cubemapname;
49
50         // shadow volumes are done entirely in model space, so there are no matrices for dealing with them...
51
52         // note that the world to light matrices are inversely scaled (divided) by lightradius
53
54         // matrix for transforming world coordinates to light filter coordinates
55         //matrix4x4_t matrix_worldtolight;
56         // based on worldtolight this transforms -1 to +1 to 0 to 1 for purposes
57         // of attenuation texturing in full 3D (z result often ignored)
58         //matrix4x4_t matrix_worldtoattenuationxyz;
59         // this transforms only the Z to S, and T is always 0.5
60         //matrix4x4_t matrix_worldtoattenuationz;
61
62         // generated properties
63         vec3_t mins;
64         vec3_t maxs;
65         vec_t cullradius;
66         struct worldlight_s *next;
67         rtexture_t *cubemap;
68         int style;
69         int selected;
70
71         matrix4x4_t matrix_lighttoworld;
72         matrix4x4_t matrix_worldtolight;
73         matrix4x4_t matrix_worldtoattenuationxyz;
74         matrix4x4_t matrix_worldtoattenuationz;
75
76         // premade shadow volumes and lit surfaces to render
77         shadowmesh_t *meshchain_shadow;
78         shadowmesh_t *meshchain_light;
79         
80         // used for visibility testing
81         int numclusters;
82         int *clusterindices;
83 }
84 worldlight_t;
85
86 extern worldlight_t *r_shadow_worldlightchain;
87
88 void R_Shadow_UpdateWorldLightSelection(void);
89
90 void R_Shadow_DrawStaticWorldLight_Shadow(worldlight_t *light, matrix4x4_t *matrix);
91 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_modeltolight, const matrix4x4_t *matrix_modeltoattenuationxyz, const matrix4x4_t *matrix_modeltoattenuationz);
92
93 #endif