7 #define R_SHADOW_SHADOWMAP_NUMCUBEMAPS 8
9 extern cvar_t r_shadow_bumpscale_basetexture;
10 extern cvar_t r_shadow_bumpscale_bumpmap;
11 extern cvar_t r_shadow_debuglight;
12 extern cvar_t r_shadow_gloss;
13 extern cvar_t r_shadow_gloss2intensity;
14 extern cvar_t r_shadow_glossintensity;
15 extern cvar_t r_shadow_glossexponent;
16 extern cvar_t r_shadow_gloss2exponent;
17 extern cvar_t r_shadow_glossexact;
18 extern cvar_t r_shadow_lightattenuationpower;
19 extern cvar_t r_shadow_lightattenuationscale;
20 extern cvar_t r_shadow_lightintensityscale;
21 extern cvar_t r_shadow_lightradiusscale;
22 extern cvar_t r_shadow_projectdistance;
23 extern cvar_t r_shadow_frontsidecasting;
24 extern cvar_t r_shadow_realtime_dlight;
25 extern cvar_t r_shadow_realtime_dlight_shadows;
26 extern cvar_t r_shadow_realtime_dlight_svbspculling;
27 extern cvar_t r_shadow_realtime_dlight_portalculling;
28 extern cvar_t r_shadow_realtime_world;
29 extern cvar_t r_shadow_realtime_world_lightmaps;
30 extern cvar_t r_shadow_realtime_world_shadows;
31 extern cvar_t r_shadow_realtime_world_compile;
32 extern cvar_t r_shadow_realtime_world_compileshadow;
33 extern cvar_t r_shadow_realtime_world_compilesvbsp;
34 extern cvar_t r_shadow_realtime_world_compileportalculling;
35 extern cvar_t r_shadow_scissor;
37 // used by shader for bouncegrid feature
38 typedef struct r_shadow_bouncegrid_settings_s
41 qboolean directionalshading;
42 qboolean includedirectlighting;
44 qboolean normalizevectors;
46 float dlightparticlemultiplier;
48 float lightradiusscale;
51 float particlebounceintensity;
52 float particleintensity;
54 float energyperphoton;
58 float bounceminimumintensity2;
61 r_shadow_bouncegrid_settings_t;
63 #define PHOTON_MAX_PATHS 11
65 typedef struct r_shadow_bouncegrid_photon_path_s
71 r_shadow_bouncegrid_photon_path_t;
73 typedef struct r_shadow_bouncegrid_photon_s
75 // parameters for tracing this photon
79 float bounceminimumintensity2;
80 float startrefractiveindex;
84 r_shadow_bouncegrid_photon_path_t paths[PHOTON_MAX_PATHS];
86 r_shadow_bouncegrid_photon_t;
88 typedef struct r_shadow_bouncegrid_state_s
90 r_shadow_bouncegrid_settings_t settings;
92 qboolean allowdirectionalshading;
93 qboolean directional; // copied from settings.directionalshading after createtexture is decided
94 qboolean createtexture; // set to true to recreate the texture rather than updating it - happens when size changes or directional changes
98 double lastupdatetime;
110 // per-frame data that is very temporary
111 int highpixels_index; // which one is active - this toggles when doing blur
112 float *highpixels; // equals blurpixels[highpixels_index]
113 float *blurpixels[2];
114 unsigned char *u8pixels; // temporary processing buffer when outputting to rgba8 format
115 unsigned short *fp16pixels; // temporary processing buffer when outputting to rgba16f format
116 // describe the photons we intend to shoot for threaded dispatch
117 int numphotons; // number of photons to shoot this frame, always <= settings.maxphotons
118 r_shadow_bouncegrid_photon_t *photons; // describes the photons being shot this frame
121 taskqueue_task_t cleartex_task; // clears the highpixels array
122 taskqueue_task_t assignphotons_task; // sets the photon counts on lights, etc
123 taskqueue_task_t enqueuephotons_task; // enqueues tasks to shoot the photons
124 taskqueue_task_t *photons_tasks; // [maxphotons] taskqueue entries to perform the photon shots
125 taskqueue_task_t photons_done_task; // checks that all photon shots are completed
126 taskqueue_task_t enqueue_slices_task; // enqueues slice tasks to render the light accumulation into the texture
127 taskqueue_task_t *slices_tasks; // [resolution[1]] taskqueue entries to perform the light path accumulation into the texture
128 taskqueue_task_t slices_done_task; // checks that light accumulation in the texture is done
129 taskqueue_task_t blurpixels_task; // blurs the highpixels array
131 r_shadow_bouncegrid_state_t;
133 extern r_shadow_bouncegrid_state_t r_shadow_bouncegrid_state;
135 void R_Shadow_Init(void);
136 qboolean R_Shadow_ShadowMappingEnabled(void);
137 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);
138 int R_Shadow_CalcTriangleSideMask(const vec3_t p1, const vec3_t p2, const vec3_t p3, float bias);
139 int R_Shadow_CalcSphereSideMask(const vec3_t p1, float radius, float bias);
140 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);
141 void R_Shadow_RenderLighting(int texturenumsurfaces, const msurface_t **texturesurfacelist);
142 void R_Shadow_RenderMode_Begin(void);
143 void R_Shadow_RenderMode_ActiveLight(const rtlight_t *rtlight);
144 void R_Shadow_RenderMode_Reset(void);
145 void R_Shadow_RenderMode_Lighting(qboolean transparent, qboolean shadowmapping, qboolean noselfshadowpass);
146 void R_Shadow_RenderMode_DrawDeferredLight(qboolean shadowmapping);
147 void R_Shadow_RenderMode_VisibleLighting(qboolean transparent);
148 void R_Shadow_RenderMode_End(void);
149 void R_Shadow_ClearStencil(void);
150 void R_Shadow_SetupEntityLight(const entity_render_t *ent);
152 qboolean R_Shadow_ScissorForBBox(const float *mins, const float *maxs);
154 // these never change, they are used to create attenuation matrices
155 extern matrix4x4_t matrix_attenuationxyz;
156 extern matrix4x4_t matrix_attenuationz;
158 void R_Shadow_UpdateWorldLightSelection(void);
160 extern rtlight_t *r_shadow_compilingrtlight;
162 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);
163 void R_RTLight_Compile(rtlight_t *rtlight);
164 void R_RTLight_Uncompile(rtlight_t *rtlight);
166 void R_Shadow_PrepareLights(void);
167 void R_Shadow_ClearShadowMapTexture(void);
168 void R_Shadow_DrawPrepass(void);
169 void R_Shadow_DrawLights(void);
170 void R_Shadow_DrawCoronas(void);
172 extern int maxshadowmark;
173 extern int numshadowmark;
174 extern int *shadowmark;
175 extern int *shadowmarklist;
176 extern int shadowmarkcount;
177 void R_Shadow_PrepareShadowMark(int numtris);
179 extern int maxshadowsides;
180 extern int numshadowsides;
181 extern unsigned char *shadowsides;
182 extern int *shadowsideslist;
183 void R_Shadow_PrepareShadowSides(int numtris);
185 void R_Shadow_PrepareModelShadows(void);
187 #define LP_LIGHTMAP 1
189 #define LP_DYNLIGHT 4
190 void R_CompleteLightPoint(float *ambient, float *diffuse, float *lightdir, const vec3_t p, const int flags, float lightmapintensity, float ambientintensity);
192 void R_Shadow_DrawShadowMaps(void);