/
rend_fakeradio.h
188 lines (165 loc) · 4.98 KB
/
rend_fakeradio.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
/** @file rend_fakeradio.h Faked Radiosity Lighting.
*
* Perhaps the most distinctive characteristic of radiosity lighting is that
* the corners of a room are slightly dimmer than the rest of the surfaces.
* (It's not the only characteristic, however.) We will fake these shadowed
* areas by generating shadow polygons for wall segments and determining which
* BSP leaf vertices will be shadowed.
*
* In other words, walls use shadow polygons (over entire lines), while planes
* use vertex lighting. As sectors are usually partitioned into a great many
* BSP leafs (and tesselated into triangles), they are better suited for vertex
* lighting. In some cases we will be forced to split a BSP leaf into smaller
* pieces than strictly necessary in order to achieve better accuracy in the
* shadow effect.
*
* @authors Copyright © 2004-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2013 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, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/
#ifndef DENG_RENDER_FAKERADIO
#define DENG_RENDER_FAKERADIO
#include "HEdge"
#include "Line"
#include "Sector"
#include "Vertex"
//#include "render/rendpoly.h"
/**
* Used to link a line to a BSP leaf for the purposes of FakeRadio shadowing.
* @ingroup render
*/
struct ShadowLink
{
ShadowLink *next;
Line *line;
byte side;
Line::Side &lineSide()
{
DENG_ASSERT(line);
return line->side(side);
}
Line::Side const &lineSide() const
{
DENG_ASSERT(line);
return line->side(side);
}
};
/**
* FakeRadio shadow data.
* @ingroup render
*/
struct shadowcorner_t
{
float corner;
Sector *proximity;
float pOffset;
float pHeight;
};
/**
* FakeRadio connected edge data.
* @ingroup render
*/
struct edgespan_t
{
float length;
float shift;
};
/**
* Stores the FakeRadio properties of a Line::Side.
* @ingroup render
*/
struct LineSideRadioData
{
/// Frame number of last update
int updateCount;
shadowcorner_t topCorners[2];
shadowcorner_t bottomCorners[2];
shadowcorner_t sideCorners[2];
/// [left, right]
edgespan_t spans[2];
};
/**
* Register the console commands, variables, etc..., of this module.
*/
void Rend_RadioRegister();
/**
* To be called after map load to perform necessary initialization within this module.
*/
void Rend_RadioInitForMap();
/**
* Returns @c true iff @a line qualifies for (edge) shadow casting.
*/
bool Rend_RadioLineCastsShadow(Line const &line);
/**
* Returns @c true iff @a plane qualifies for (wall) shadow casting.
*/
bool Rend_RadioPlaneCastsShadow(Plane const &plane);
/**
* Returns the FakeRadio data for the specified line @a side.
*/
LineSideRadioData &Rend_RadioDataForLineSide(Line::Side &side);
/**
* To be called to update the shadow properties for the specified line @a side.
*/
void Rend_RadioUpdateForLineSide(Line::Side &side);
/**
* Updates all the shadow offsets for the given vertex.
*
* @pre Lineowner rings must be set up.
*
* @param vtx Vertex to be updated.
*/
void Rend_RadioUpdateVertexShadowOffsets(Vertex &vtx);
/**
* Returns the global shadow darkness factor, derived from values in Config.
*/
float Rend_RadioCalcShadowDarkness(float lightLevel);
/**
* Arguments for Rend_RadioWallSection()
*/
struct RendRadioWallSectionParms
{
float shadowRGB[3], shadowDark;
float shadowSize;
shadowcorner_t const *botCn, *topCn, *sideCn;
edgespan_t const *spans;
coord_t segOffset;
coord_t segLength;
Line const *line;
Sector *frontSec, *backSec;
SectionEdge const *leftEdge;
SectionEdge const *rightEdge;
};
/**
* Render FakeRadio for the specified wall section. Generates and then draws all
* shadow geometry for the wall section.
*
* Note that unlike Rend_RadioBspLeafEdges() there is no guard to ensure shadow
* geometry is rendered only once per frame.
*/
void Rend_RadioWallSection(rvertex_t const *rvertices, RendRadioWallSectionParms const &parms);
/**
* Render FakeRadio for the given BSP leaf. Draws all shadow geometry linked to the
* BspLeaf, that has not already been rendered.
*/
void Rend_RadioBspLeafEdges(BspLeaf &bspLeaf);
/**
* Render the shadow poly vertices, for debug.
*/
#ifdef DENG_DEBUG
void Rend_DrawShadowOffsetVerts();
#endif
#endif // DENG_RENDER_FAKERADIO