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