mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-07 00:41:26 +00:00
Split horizon lines for minimal distortion
This commit is contained in:
parent
14d6a01292
commit
f9027ccaeb
1 changed files with 48 additions and 30 deletions
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
#include "../doomstat.h"
|
#include "../doomstat.h"
|
||||||
|
|
||||||
#define HWRENDER
|
|
||||||
#ifdef HWRENDER
|
#ifdef HWRENDER
|
||||||
#include "hw_glob.h"
|
#include "hw_glob.h"
|
||||||
#include "hw_light.h"
|
#include "hw_light.h"
|
||||||
|
@ -711,6 +710,10 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
|
||||||
// Horizon lines
|
// Horizon lines
|
||||||
FOutVector horizonpts[6];
|
FOutVector horizonpts[6];
|
||||||
float dist, vx, vy;
|
float dist, vx, vy;
|
||||||
|
float x1, y1, xd, yd;
|
||||||
|
UINT8 numplanes, j;
|
||||||
|
vertex_t v; // For determining the closest distance from the line to the camera, to split render planes for minimum distortion;
|
||||||
|
|
||||||
const float renderdist = 30000.0f; // How far out to properly render the plane
|
const float renderdist = 30000.0f; // How far out to properly render the plane
|
||||||
const float farrenderdist = 32768.0f; // From here, raise plane to horizon level to fill in the line with some texture distortion
|
const float farrenderdist = 32768.0f; // From here, raise plane to horizon level to fill in the line with some texture distortion
|
||||||
|
|
||||||
|
@ -720,12 +723,26 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
|
||||||
{
|
{
|
||||||
if (!line->glseg && line->linedef->special == HORIZONSPECIAL && R_PointOnSegSide(dup_viewx, dup_viewy, line) == 0)
|
if (!line->glseg && line->linedef->special == HORIZONSPECIAL && R_PointOnSegSide(dup_viewx, dup_viewy, line) == 0)
|
||||||
{
|
{
|
||||||
//SETUP3DVERT(horizonpts[1], FIXED_TO_FLOAT(line->v1->x), FIXED_TO_FLOAT(line->v1->y));
|
P_ClosestPointOnLine(viewx, viewy, line->linedef, &v);
|
||||||
//SETUP3DVERT(horizonpts[2], FIXED_TO_FLOAT(line->v2->x), FIXED_TO_FLOAT(line->v2->y));
|
dist = FIXED_TO_FLOAT(R_PointToDist(v.x, v.y));
|
||||||
|
|
||||||
|
x1 = ((polyvertex_t *)line->pv1)->x;
|
||||||
|
y1 = ((polyvertex_t *)line->pv1)->y;
|
||||||
|
xd = ((polyvertex_t *)line->pv2)->x - x1;
|
||||||
|
yd = ((polyvertex_t *)line->pv2)->y - y1;
|
||||||
|
|
||||||
|
// Based on the seg length and the distance from the line, split horizon into multiple poly sets to reduce distortion
|
||||||
|
dist = sqrtf((xd*xd) + (yd*yd)) / dist / 16.0f;
|
||||||
|
if (dist > 100.0f)
|
||||||
|
numplanes = 100;
|
||||||
|
else
|
||||||
|
numplanes = (UINT8)dist + 1;
|
||||||
|
|
||||||
|
for (j = 0; j < numplanes; j++)
|
||||||
|
{
|
||||||
// Left side
|
// Left side
|
||||||
vx = ((polyvertex_t *)line->pv1)->x;
|
vx = x1 + xd * j / numplanes;
|
||||||
vy = ((polyvertex_t *)line->pv1)->y;
|
vy = y1 + yd * j / numplanes;
|
||||||
SETUP3DVERT((&horizonpts[1]), vx, vy);
|
SETUP3DVERT((&horizonpts[1]), vx, vy);
|
||||||
|
|
||||||
dist = sqrtf(powf(vx - gr_viewx, 2) + powf(vy - gr_viewy, 2));
|
dist = sqrtf(powf(vx - gr_viewx, 2) + powf(vy - gr_viewy, 2));
|
||||||
|
@ -734,8 +751,8 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
|
||||||
SETUP3DVERT((&horizonpts[0]), vx, vy);
|
SETUP3DVERT((&horizonpts[0]), vx, vy);
|
||||||
|
|
||||||
// Right side
|
// Right side
|
||||||
vx = ((polyvertex_t *)line->pv2)->x;
|
vx = x1 + xd * (j+1) / numplanes;
|
||||||
vy = ((polyvertex_t *)line->pv2)->y;
|
vy = y1 + yd * (j+1) / numplanes;
|
||||||
SETUP3DVERT((&horizonpts[2]), vx, vy);
|
SETUP3DVERT((&horizonpts[2]), vx, vy);
|
||||||
|
|
||||||
dist = sqrtf(powf(vx - gr_viewx, 2) + powf(vy - gr_viewy, 2));
|
dist = sqrtf(powf(vx - gr_viewx, 2) + powf(vy - gr_viewy, 2));
|
||||||
|
@ -759,6 +776,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ALAM_LIGHTING
|
#ifdef ALAM_LIGHTING
|
||||||
// add here code for dynamic lighting on planes
|
// add here code for dynamic lighting on planes
|
||||||
|
|
Loading…
Reference in a new issue