-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
rend_main.h
302 lines (237 loc) · 9.25 KB
/
rend_main.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
/** @file rend_main.h Core of the rendering subsystem.
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2015 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
*/
#ifndef CLIENT_RENDER_MAIN_H
#define CLIENT_RENDER_MAIN_H
#ifndef __CLIENT__
# error "render/rend_main.h only exists in the Client"
#endif
#include "dd_types.h"
#include <de/Matrix>
#include <de/Record>
#include <de/Vector>
#include "def_main.h"
#include "MaterialVariantSpec"
#include "WallEdge"
class Lumobj;
class Sector;
class SectorCluster;
struct VectorLightData;
namespace de {
class Map;
class LightGrid;
}
// Multiplicative blending for dynamic lights?
#define IS_MUL (dynlightBlend != 1 && !fogParams.usingFog)
#define MTEX_DETAILS_ENABLED (r_detail && useMultiTexDetails && \
defs.details.size() > 0)
#define IS_MTEX_DETAILS (MTEX_DETAILS_ENABLED && numTexUnits > 1)
#define IS_MTEX_LIGHTS (!IS_MTEX_DETAILS && !fogParams.usingFog && useMultiTexLights \
&& numTexUnits > 1 && envModAdd)
#define GLOW_HEIGHT_MAX (1024.f) /// Absolute maximum
#define OMNILIGHT_SURFACE_LUMINOSITY_ATTRIBUTION_MIN (.05f)
#define SHADOW_SURFACE_LUMINOSITY_ATTRIBUTION_MIN (.05f)
DENG_EXTERN_C de::Vector3d vOrigin; // Y/Z swizzled for drawing
DENG_EXTERN_C float vang, vpitch, yfov;
DENG_EXTERN_C float viewsidex, viewsidey;
struct FogParams
{
bool usingFog;
float fogColor[4];
float fogStart;
float fogEnd;
};
extern FogParams fogParams;
DENG_EXTERN_C byte smoothTexAnim, devMobjVLights;
DENG_EXTERN_C int renderTextures; /// @c 0= no textures, @c 1= normal mode, @c 2= lighting debug
DENG_EXTERN_C int renderWireframe;
DENG_EXTERN_C int useMultiTexLights;
DENG_EXTERN_C int useMultiTexDetails;
DENG_EXTERN_C int dynlightBlend;
DENG_EXTERN_C int torchAdditive;
DENG_EXTERN_C de::Vector3f torchColor;
DENG_EXTERN_C int rAmbient;
DENG_EXTERN_C float rendLightDistanceAttenuation;
DENG_EXTERN_C int rendLightAttenuateFixedColormap;
DENG_EXTERN_C float rendLightWallAngle;
DENG_EXTERN_C byte rendLightWallAngleSmooth;
DENG_EXTERN_C float rendSkyLight; // cvar
DENG_EXTERN_C byte rendSkyLightAuto; // cvar
DENG_EXTERN_C float lightModRange[255];
DENG_EXTERN_C int extraLight;
DENG_EXTERN_C float extraLightDelta;
DENG_EXTERN_C int devRendSkyMode;
DENG_EXTERN_C int gameDrawHUD;
DENG_EXTERN_C int useBias;
DENG_EXTERN_C int useDynLights;
DENG_EXTERN_C float dynlightFactor, dynlightFogBright;
DENG_EXTERN_C int rendMaxLumobjs;
DENG_EXTERN_C int useGlowOnWalls;
DENG_EXTERN_C float glowFactor, glowHeightFactor;
DENG_EXTERN_C int glowHeightMax;
DENG_EXTERN_C int useShadows;
DENG_EXTERN_C float shadowFactor;
DENG_EXTERN_C int shadowMaxRadius;
DENG_EXTERN_C int shadowMaxDistance;
DENG_EXTERN_C byte useLightDecorations;
DENG_EXTERN_C int useShinySurfaces;
DENG_EXTERN_C float detailFactor, detailScale;
DENG_EXTERN_C int ratioLimit;
DENG_EXTERN_C int mipmapping, filterUI, texQuality, filterSprites;
DENG_EXTERN_C int texMagMode, texAniso;
DENG_EXTERN_C int useSmartFilter;
DENG_EXTERN_C int texMagMode;
DENG_EXTERN_C int glmode[6];
DENG_EXTERN_C dd_bool fillOutlines;
DENG_EXTERN_C dd_bool noHighResTex;
DENG_EXTERN_C dd_bool noHighResPatches;
DENG_EXTERN_C dd_bool highResWithPWAD;
DENG_EXTERN_C byte loadExtAlways;
DENG_EXTERN_C int devNoCulling;
DENG_EXTERN_C byte devRendSkyAlways;
DENG_EXTERN_C byte rendInfoLums;
DENG_EXTERN_C byte devDrawLums;
DENG_EXTERN_C byte freezeRLs;
void Rend_Register();
void Rend_Reset();
/// @return @c true iff multitexturing is currently enabled for lights.
bool Rend_IsMTexLights();
/// @return @c true iff multitexturing is currently enabled for detail textures.
bool Rend_IsMTexDetails();
void Rend_RenderMap(de::Map &map);
float Rend_FieldOfView();
/**
* @param inWorldSpace Apply viewer angles and head position to produce a transformation
* from world space to view space.
*/
void Rend_ModelViewMatrix(bool inWorldSpace = true);
de::Matrix4f Rend_GetModelViewMatrix(int consoleNum, bool inWorldSpace = true);
de::Vector3d Rend_EyeOrigin();
#define Rend_PointDist2D(c) (fabs((vOrigin.z-(c)[VY])*viewsidex - (vOrigin.x-(c)[VX])*viewsidey))
/**
* The DOOM lighting model applies a light level delta to everything when
* e.g. the player shoots.
*
* @return Calculated delta.
*/
float Rend_ExtraLightDelta();
void Rend_ApplyTorchLight(float *color3, float distance);
void Rend_ApplyTorchLight(de::Vector4f &color, float distance);
/**
* Apply range compression delta to @a lightValue.
* @param lightValue The light level value to apply adaptation to.
*/
void Rend_ApplyLightAdaptation(float &lightValue);
/// Same as Rend_ApplyLightAdaptation except the delta is returned.
float Rend_LightAdaptationDelta(float lightvalue);
/**
* The DOOM lighting model applies distance attenuation to sector light
* levels.
*
* @param distToViewer Distance from the viewer to this object.
* @param lightLevel Sector lightLevel at this object's origin.
* @return The specified lightLevel plus any attentuation.
*/
float Rend_AttenuateLightLevel(float distToViewer, float lightLevel);
float Rend_ShadowAttenuationFactor(coord_t distance);
/**
* Updates the lightModRange which is used to applify sector light to help
* compensate for the differences between the OpenGL lighting equation,
* the software Doom lighting model and the light grid (ambient lighting).
*
* The offsets in the lightRangeModTables are added to the sector->lightLevel
* during rendering (both positive and negative).
*/
void Rend_UpdateLightModMatrix();
/**
* Draws the lightModRange (for debug)
*/
void Rend_DrawLightModMatrix();
/**
* Draws the light grid debug visual.
*/
void Rend_LightGridVisual(de::LightGrid &lg);
/**
* Determines whether the sky light color tinting is enabled.
*/
bool Rend_SkyLightIsEnabled();
/**
* Returns the effective sky light color.
*/
de::Vector3f Rend_SkyLightColor();
/**
* Blend the given light value with the luminous object's color, applying any
* applicable global modifiers and returns the result.
*
* @param color Source light color.
* @param light Strength of the light on the illumination point.
*
* @return Calculated result.
*/
de::Vector3f Rend_LuminousColor(de::Vector3f const &color, de::dfloat light);
/**
* Given an @a intensity determine the height of the plane glow, applying any
* applicable global modifiers.
*
* @return Calculated result.
*/
coord_t Rend_PlaneGlowHeight(de::dfloat intensity);
/**
* @param point World space point to evaluate.
* @param ambientColor Ambient color of the object being lit.
* @param subspace Subspace in which @a origin resides.
* @param starkLight @c true= World light has a more pronounced affect.
*
* @todo Does not belong here.
*/
de::duint Rend_CollectAffectingLights(de::Vector3d const &point,
de::Vector3f const &ambientColor = de::Vector3f(1, 1, 1), ConvexSubspace *subspace = nullptr,
bool starkLight = false);
void Rend_DrawVectorLight(VectorLightData const &vlight, dfloat alpha);
/**
* Returns the radius of the given @a sprite, as it would visually appear to be.
*
* @note Presently considers rotation 0 only!
*/
de::ddouble Rend_VisualRadius(de::Record const &sprite);
/**
* Produce a luminous object from the given @a sprite configuration. The properties of
* any resultant lumobj are configured in "sprite-local" space. This means that it will
* be positioned relative to the center of the sprite and must be further configured
* before adding to the map (i.e., translated to the origin in map space).
*
* @return Newly generated Lumobj otherwise @c nullptr.
*/
Lumobj *Rend_MakeLumobj(de::Record const &sprite);
/**
* Selects a Material for the given map @a surface considering the current map
* renderer configuration.
*/
Material *Rend_ChooseMapSurfaceMaterial(Surface const &surface);
de::MaterialVariantSpec const &Rend_MapSurfaceMaterialSpec();
de::MaterialVariantSpec const &Rend_MapSurfaceMaterialSpec(int wrapS, int wrapT);
TextureVariantSpec const &Rend_MapSurfaceLightmapTextureSpec();
TextureVariantSpec const &Rend_MapSurfaceShinyTextureSpec();
TextureVariantSpec const &Rend_MapSurfaceShinyMaskTextureSpec();
void R_DivVerts(de::Vector3f *dst, de::Vector3f const *src,
de::WorldEdge const &leftEdge, de::WorldEdge const &rightEdge);
void R_DivTexCoords(de::Vector2f *dst, de::Vector2f const *src,
de::WorldEdge const &leftEdge, de::WorldEdge const &rightEdge);
void R_DivVertColors(de::Vector4f *dst, de::Vector4f const *src,
de::WorldEdge const &leftEdge, de::WorldEdge const &rightEdge);
#endif // CLIENT_RENDER_MAIN_H