]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - r_shadow.h
Fix more Mod_ValidateElements sequencing issues - always generate
[xonotic/darkplaces.git] / r_shadow.h
1
2 #ifndef R_SHADOW_H
3 #define R_SHADOW_H
4
5 #define R_SHADOW_SHADOWMAP_NUMCUBEMAPS 8
6
7 extern cvar_t r_shadow_bumpscale_basetexture;
8 extern cvar_t r_shadow_bumpscale_bumpmap;
9 extern cvar_t r_shadow_debuglight;
10 extern cvar_t r_shadow_gloss;
11 extern cvar_t r_shadow_gloss2intensity;
12 extern cvar_t r_shadow_glossintensity;
13 extern cvar_t r_shadow_glossexponent;
14 extern cvar_t r_shadow_gloss2exponent;
15 extern cvar_t r_shadow_glossexact;
16 extern cvar_t r_shadow_lightattenuationpower;
17 extern cvar_t r_shadow_lightattenuationscale;
18 extern cvar_t r_shadow_lightintensityscale;
19 extern cvar_t r_shadow_lightradiusscale;
20 extern cvar_t r_shadow_projectdistance;
21 extern cvar_t r_shadow_frontsidecasting;
22 extern cvar_t r_shadow_realtime_dlight;
23 extern cvar_t r_shadow_realtime_dlight_shadows;
24 extern cvar_t r_shadow_realtime_dlight_svbspculling;
25 extern cvar_t r_shadow_realtime_dlight_portalculling;
26 extern cvar_t r_shadow_realtime_world;
27 extern cvar_t r_shadow_realtime_world_lightmaps;
28 extern cvar_t r_shadow_realtime_world_shadows;
29 extern cvar_t r_shadow_realtime_world_compile;
30 extern cvar_t r_shadow_realtime_world_compileshadow;
31 extern cvar_t r_shadow_realtime_world_compilesvbsp;
32 extern cvar_t r_shadow_realtime_world_compileportalculling;
33 extern cvar_t r_shadow_scissor;
34 extern cvar_t r_shadow_texture3d;
35
36 // used by shader for bouncegrid feature
37 typedef struct r_shadow_bouncegrid_settings_s
38 {
39         qboolean staticmode;
40         qboolean bounceanglediffuse;
41         qboolean directionalshading;
42         qboolean includedirectlighting;
43         qboolean blur;
44         qboolean normalizevectors;
45         int floatcolors;
46         float dlightparticlemultiplier;
47         qboolean hitmodels;
48         float lightradiusscale;
49         int maxbounce;
50         float lightpathsize_initial;
51         float lightpathsize_conespread;
52         float particlebounceintensity;
53         float particleintensity;
54         int maxphotons;
55         float energyperphoton;
56         float spacing[3];
57         int rng_type;
58         int rng_seed;
59         float bounceminimumintensity2;
60 }
61 r_shadow_bouncegrid_settings_t;
62
63 typedef struct r_shadow_bouncegrid_state_s
64 {
65         r_shadow_bouncegrid_settings_t settings;
66         qboolean capable;
67         qboolean allowdirectionalshading;
68         qboolean directional; // copied from settings.directionalshading after createtexture is decided
69         qboolean createtexture; // set to true to recreate the texture rather than updating it - happens when size changes or directional changes
70         rtexture_t *texture;
71         matrix4x4_t matrix;
72         vec_t intensity;
73         double lastupdatetime;
74         int resolution[3];
75         int numpixels;
76         int pixelbands;
77         int pixelsperband;
78         int bytesperband;
79         float spacing[3];
80         float ispacing[3];
81         vec3_t mins;
82         vec3_t maxs;
83         vec3_t size;
84         int maxsplatpaths;
85
86         // per-frame data that is very temporary
87         int numsplatpaths;
88         struct r_shadow_bouncegrid_splatpath_s *splatpaths;
89         int highpixels_index; // which one is active - this toggles when doing blur
90         float *highpixels; // equals blurpixels[highpixels_index]
91         float *blurpixels[2];
92         unsigned char *u8pixels; // temporary processing buffer when outputting to rgba8 format
93         unsigned short *fp16pixels; // temporary processing buffer when outputting to rgba16f format
94 }
95 r_shadow_bouncegrid_state_t;
96
97 extern r_shadow_bouncegrid_state_t r_shadow_bouncegrid_state;
98
99 void R_Shadow_Init(void);
100 qboolean R_Shadow_ShadowMappingEnabled(void);
101 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);
102 int R_Shadow_CalcTriangleSideMask(const vec3_t p1, const vec3_t p2, const vec3_t p3, float bias);
103 int R_Shadow_CalcSphereSideMask(const vec3_t p1, float radius, float bias);
104 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);
105 void R_Shadow_RenderLighting(int texturenumsurfaces, const msurface_t **texturesurfacelist);
106 void R_Shadow_RenderMode_Begin(void);
107 void R_Shadow_RenderMode_ActiveLight(const rtlight_t *rtlight);
108 void R_Shadow_RenderMode_Reset(void);
109 void R_Shadow_RenderMode_Lighting(qboolean transparent, qboolean shadowmapping, qboolean noselfshadowpass);
110 void R_Shadow_RenderMode_DrawDeferredLight(qboolean shadowmapping);
111 void R_Shadow_RenderMode_VisibleLighting(qboolean transparent);
112 void R_Shadow_RenderMode_End(void);
113 void R_Shadow_ClearStencil(void);
114 void R_Shadow_SetupEntityLight(const entity_render_t *ent);
115
116 qboolean R_Shadow_ScissorForBBox(const float *mins, const float *maxs);
117
118 // these never change, they are used to create attenuation matrices
119 extern matrix4x4_t matrix_attenuationxyz;
120 extern matrix4x4_t matrix_attenuationz;
121
122 void R_Shadow_UpdateWorldLightSelection(void);
123
124 extern rtlight_t *r_shadow_compilingrtlight;
125
126 void R_RTLight_Update(rtlight_t *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);
127 void R_RTLight_Compile(rtlight_t *rtlight);
128 void R_RTLight_Uncompile(rtlight_t *rtlight);
129
130 void R_Shadow_PrepareLights(void);
131 void R_Shadow_ClearShadowMapTexture(void);
132 void R_Shadow_DrawPrepass(void);
133 void R_Shadow_DrawLights(void);
134 void R_Shadow_DrawCoronas(void);
135
136 extern int maxshadowmark;
137 extern int numshadowmark;
138 extern int *shadowmark;
139 extern int *shadowmarklist;
140 extern int shadowmarkcount;
141 void R_Shadow_PrepareShadowMark(int numtris);
142
143 extern int maxshadowsides;
144 extern int numshadowsides;
145 extern unsigned char *shadowsides;
146 extern int *shadowsideslist;
147 void R_Shadow_PrepareShadowSides(int numtris);
148
149 void R_Shadow_PrepareModelShadows(void);
150
151 #define LP_LIGHTMAP             1
152 #define LP_RTWORLD              2
153 #define LP_DYNLIGHT             4
154 void R_CompleteLightPoint(float *ambient, float *diffuse, float *lightdir, const vec3_t p, const int flags, float lightmapintensity, float ambientintensity);
155
156 void R_Shadow_DrawShadowMaps(void);
157
158 #endif