29typedef enum : uint32_t {
55constexpr float D2R = 3.14159265f / 180.0f;
56constexpr float R2D = 180.0f / 3.14159265f;
221 static constexpr int StripsMax = 512;
224 typedef enum : uint16_t {
225 VSTRIP_FLAG_FREE = 0x0000,
226 VSTRIP_FLAG_INVISIBLE = 0x0001,
227 VSTRIP_FLAG_ALPHA = 0x0004,
228 VSTRIP_FLAG_HASCEILING = 0x0100,
229 VSTRIP_FLAG_HASFLOOR = 0x0200,
230 VSTRIP_FLAG_SEETHROUGH = 0x0400,
231 VSTRIP_FLAG_BACKCULLED = 0x0800,
232 VSTRIP_FLAG_HIGHLIGHTED = 0x1000,
261 Strip vStrips[StripsMax];
262 uint16_t vStripsMap[StripsMax];
263 float vStripsZOrders[StripsMax];
266 Strip vStripsClipped[StripsMax];
267 int vStripsClippedCount;
269 float currentCeiling;
277 std::atomic<int> pendingFrameWidth;
278 std::atomic<int> pendingFrameHeight;
279 std::atomic<int> pendingGlowmapSize;
284 uint32_t * frameLast;
285 bool framesAllocated;
299 __m128 sunAmbientArgb;
300 __m128 sunRayColorArgb;
302 float fogDistanceInv;
303 float fogDistanceOffset;
307 bool clickRegistered;
308 uint16_t clickWallID;
310 QVector2D sceneCornerBegin, sceneCornerEnd;
314 __m128 * glowmapStill;
320 void allocateObjects(
int noNodes,
int noWalls,
int noTextures,
int noLights);
321 void allocateFrames(
int width,
int height);
322 void allocateGlowmap(
int size);
323 bool allocatePixelBuffer(uint32_t *& pixels,
int width,
int height);
326 void renderChunk(Context & state,
int x1,
int x2);
327 void renderConcurrent();
332 void glowmapChunk(__m128 * gm,
bool still,
int z1,
int z2);
333 void glowmapConcurrent(__m128 * gm,
bool still);
336 void findFloorCeilings(Context & state);
337 void renderVertical(Context & state,
int depth, QList<float> stackBelow, QList<float> stackAbove,
int scanTop,
int scanBot);
338 void drawVStrips(Context & state);
340 void vstripAdd(Context & state,
const Strip & strip,
int scanTop,
int scanBot);
341 void vstripDraw(Context & state,
const Strip & strip);
342 void surfaceDraw(Context & state,
const Wall & w, uint16_t sID,
int scanTop,
int scanBot,
float height);
346 void sceneBoundsInit();
347 void sceneBoundsRegister(
float x,
float z);
348 void sceneGetCoords(
const float x,
const float z,
float & xs,
float & zs);
349 void worldGetCoords(
const float xs,
const float zs,
float & x,
float & z);
351 __m128 sampleGlowmap(
float gx,
float gy);
354 bool configLoad(
const QString & filename);
355 bool configSave(
const QString & filename);
static constexpr int DefaultFrameResoX
Definition renderer.h:62
static constexpr int DefaultGlowmapReso
Definition renderer.h:64
Node * nodes
Definition renderer.h:200
int nodesAllocated
Definition renderer.h:202
static constexpr float GlowBleedFactor
Definition renderer.h:72
float fovDistanceFar
far clip distance, in world units
Definition renderer.h:172
void clickRegister(int x, int y)
Register a frame position to pick a wall during the next render.
Definition renderer.cpp:220
void setGlowmapArea(float area)
Set the world area covered by the glowmap, in world units.
Definition renderer.cpp:96
void setFOVAngle(float angle)
Set the horizontal field of view, in degrees.
Definition renderer.cpp:110
Wall * walls
Definition renderer.h:204
void init()
Allocate the object pools, frames and tables, load the config.
Definition renderer.cpp:49
RENDERER_FLAGS getFlags() const
Definition renderer.h:140
int lightsAllocated
Definition renderer.h:214
float occlusionDarken
darkening strength (0.0 .. 1.0)
Definition renderer.h:189
int lightsCount
Definition renderer.h:213
Light * lights
Definition renderer.h:212
static constexpr float GlowSampleDistance
Definition renderer.h:71
int getFrameResoX() const
Definition renderer.h:152
static constexpr int DefaultWallsMax
Definition renderer.h:67
void setGlowmapSize(int size)
Request a glowmap resize (applied at the start of the next render).
Definition renderer.cpp:90
float fovAngle
horizontal FOV, in degrees
Definition renderer.h:170
void render(Viewpoint &vp)
Render the scene to the internal frame (see getImage).
Definition renderer.cpp:437
void setFOVDistanceNear(float distance)
Definition renderer.cpp:116
uint16_t clickGetWallID() const
Wall picked by the last registered click (see clickRegister).
Definition renderer.h:164
static constexpr uint16_t ClickNoWall
Sentinel returned by clickGetWallID when no wall was picked.
Definition renderer.h:79
void setFOVDistanceFar(float distance)
Definition renderer.cpp:121
void checkFlag(RENDERER_FLAGS flag, bool checked)
Set or clear a single renderer flag.
Definition renderer.cpp:83
float fogDistanceNear
fog start distance, in world units
Definition renderer.h:182
int texturesAllocated
Definition renderer.h:210
float getGlowmapArea() const
Definition renderer.h:148
float gammaKBlue
blue smoothstep tone gain
Definition renderer.h:197
QVector3D sunRayDirection
normalised ray direction
Definition renderer.h:177
float motionBlurFactor
previous frame blend, in percent (0 .. 100)
Definition renderer.h:192
int getFrameResoY() const
Definition renderer.h:153
float sunRayStrength
ray intensity (0.0 .. 1.0)
Definition renderer.h:179
Renderer()
Definition renderer.cpp:33
static constexpr int DefaultLightsMax
Definition renderer.h:69
void setFramesReso(int width, int height)
Request a frame resize (applied at the start of the next render).
Definition renderer.cpp:102
uint32_t fogFarColor
packed RGB fog color
Definition renderer.h:184
float fogDistanceFar
fog full-density distance, in world units
Definition renderer.h:183
static constexpr int DefaultTexturesMax
Definition renderer.h:68
static constexpr float DefaultGlowmapArea
Definition renderer.h:65
float lastFloor
Definition renderer.h:217
uint32_t sunRayColor
packed RGB direct ray color
Definition renderer.h:176
void terminate()
Release all the renderer resources.
Definition renderer.cpp:71
int nodesCount
Definition renderer.h:201
float vignetteOuterRadius
full black, in percent of half the frame height
Definition renderer.h:194
float fovDistanceNear
near clip distance, in world units
Definition renderer.h:171
int wallsAllocated
Definition renderer.h:206
static constexpr int DefaultNodesMax
Definition renderer.h:66
float vignetteInnerRadius
darkening start, in percent of half the frame height
Definition renderer.h:193
static constexpr float HeightMin
Definition renderer.h:76
void setFlags(RENDERER_FLAGS flags)
Replace the whole RENDERER_FLAGS bitmask.
Definition renderer.cpp:78
uint16_t fogFlags
combination of FOG_FLAGS
Definition renderer.h:185
float gammaKGreen
green smoothstep tone gain
Definition renderer.h:196
int wallsCount
Definition renderer.h:205
int texturesCount
Definition renderer.h:209
float sunAmbientStrength
ambient intensity (0.0 .. 1.0)
Definition renderer.h:178
static constexpr float HeightMax
Definition renderer.h:75
Texture * textures
Definition renderer.h:208
int getGlowmapSize() const
Definition renderer.h:144
float occlusionLength
corner darkening reach, in world units
Definition renderer.h:188
float lastCeiling
Definition renderer.h:218
uint32_t sunAmbient
packed RGB ambient color
Definition renderer.h:175
static constexpr int DefaultFrameResoY
Definition renderer.h:63
float gammaKRed
red smoothstep tone gain (1.0 = full curve)
Definition renderer.h:195
static constexpr float LightFallOff
Definition renderer.h:73
uint32_t flags
active RENDERER_FLAGS bitmask
Definition renderer.h:167
QImage * getImage() const
Frame rendered by the last render() call.
Definition renderer.h:133
static constexpr unsigned WorkersMax
Definition workerpool.h:28
@ WALL_SURFACES_COUNT
Definition mapobjects.h:61
Renderer renderer
Definition renderer.cpp:27
RENDERER_FLAGS
Definition renderer.h:29
@ RENDERER_FLAGS_DEFAULT
Definition renderer.h:40
@ RENDERER_FLAG_GAMMA
Definition renderer.h:37
@ RENDERER_FLAG_MOTIONBLUR
Definition renderer.h:35
@ RENDERER_FLAG_ALPHA_FEATURES
Definition renderer.h:39
@ RENDERER_FLAG_VIGNETTE
Definition renderer.h:36
@ RENDERER_FLAG_LIGHTS
Definition renderer.h:32
@ RENDERER_FLAG_AMBIENT_OCCLUSION
Definition renderer.h:33
@ RENDERER_FLAG_SURFACES
Definition renderer.h:31
@ RENDERER_FLAG_GLOWMAP_REBUILD
Definition renderer.h:34
@ RENDERER_FLAG_MULTITHREADING
Definition renderer.h:38
@ RENDERER_FLAG_WALLS
Definition renderer.h:30
constexpr float D2R
Definition renderer.h:55
constexpr float R2D
Definition renderer.h:56
Renderer-side light (compact variant, fed by Map::pass).
Definition renderer.h:112
float strength
Definition renderer.h:115
float z
Definition renderer.h:116
__m128 argb
Definition renderer.h:117
float x
Definition renderer.h:116
uint32_t color
Definition renderer.h:114
bool still
Definition renderer.h:118
uint16_t nodeID
Definition renderer.h:113
Renderer-side node (compact variant, fed by Map::pass).
Definition renderer.h:82
uint16_t flags
Definition renderer.h:84
QVector3D pos
Definition renderer.h:83
Renderer-side texture strip (column of square tiles).
Definition renderer.h:103
uint16_t count
Definition renderer.h:106
uint16_t size
Definition renderer.h:105
uint16_t mask
Definition renderer.h:107
uint32_t block
Definition renderer.h:108
uint32_t * pixels
Definition renderer.h:104
Renderer-side wall (compact variant, fed by Map::pass).
Definition renderer.h:88
uint16_t nodeID2
Definition renderer.h:90
float height
Definition renderer.h:91
uint32_t rayFront
Definition renderer.h:98
uint16_t flags
Definition renderer.h:96
uint32_t rayBack
Definition renderer.h:99
uint16_t textureID
Definition renderer.h:95
uint16_t nodeID1
Definition renderer.h:89
QVector3D offset
Definition renderer.h:93
Surface surfaces[WALL_SURFACES_COUNT]
Definition renderer.h:94
Texture mapping of one face of a map object.
Definition mapobjects.h:46
Camera position and orientation.
Definition renderer.h:47
QVector3D pos
Definition renderer.h:48
float pan
Definition renderer.h:50
float tilt
Definition renderer.h:51
QVector3D offset
Definition renderer.h:49