- scale the vertex coordinates that get output to the hardware by 1024.

This is needed to get a coordinate system that is compatible with GZDoom's so that its lighting code can be reused more easily.
This commit is contained in:
Christoph Oelckers 2020-06-01 09:55:28 +02:00
parent 68c97e3c25
commit 350acd2ac3
6 changed files with 15 additions and 12 deletions

View file

@ -1645,7 +1645,9 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
int prevClamp = GLInterface.GetClamp();
GLInterface.SetClamp(0);
auto matrixindex = GLInterface.SetIdentityMatrix(Matrix_Model);
VSMatrix imat = 0;
imat.scale(1024, 1024, 1024);
auto matrixindex = GLInterface.SetMatrix(Matrix_Model, &imat);
for (surfi=0; surfi<m->head.numsurfs; surfi++)
{
@ -1700,7 +1702,8 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
//Let OpenGL (and perhaps hardware :) handle the matrix rotation
mat[3] = mat[7] = mat[11] = 0.f; mat[15] = 1.f;
GLInterface.SetMatrix(Matrix_Model, mat);
for (int i = 0; i < 15; i++) mat[i] *= 1024.f;
GLInterface.SetMatrix(Matrix_Model, mat);
// PLAG: End
bool exact = false;

View file

@ -198,8 +198,8 @@ static void resizeglcheck(void)
float m[4][4]{};
float const nearclip = 4.0f / (gxyaspect * gyxscale * 1024.f);
float const farclip = 64.f;
float const nearclip = 4.0f / (gxyaspect * gyxscale);
float const farclip = 65536.f;
m[0][0] = 1.f;
m[1][1] = fxdimen / (fydimen * ratio);
@ -474,9 +474,9 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
//update verts
vt->SetVertex(
(px[i] - ghalfx) * r * grhalfxdown10x,
(ghalfy - py[i]) * r * grhalfxdown10,
r * (1.f / 1024.f));
(px[i] - ghalfx) * r * grhalfxdown10x * 1024.f,
(ghalfy - py[i]) * r * grhalfxdown10 * 1024.f,
r);
}
GLInterface.Draw(DT_TriangleFan, data.second, npoints);

View file

@ -1122,7 +1122,9 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
//Let OpenGL (and perhaps hardware :) handle the matrix rotation
mat[3] = mat[7] = mat[11] = 0.f; mat[15] = 1.f;
int matrixindex = GLInterface.SetMatrix(Matrix_Model, mat);
for (int i = 0; i < 15; i++) mat[i] *= 1024.f;
int matrixindex = GLInterface.SetMatrix(Matrix_Model, mat);
const float ru = 1.f/((float)m->mytexx);
const float rv = 1.f/((float)m->mytexy);

View file

@ -210,7 +210,7 @@ public:
void SetVisibility(float visibility, float fviewingrange)
{
renderState.VisFactor = visibility* fviewingrange* (1.f / (64.f * 65536.f));
renderState.VisFactor = visibility* fviewingrange* (1.f / (65536.f * 65536.f));
}
void EnableBlend(bool on)

View file

@ -223,7 +223,7 @@ void main()
}
if ((u_flags & RF_MapFog) != 0) // fog hack for RRRA E2L1. Needs to be done better, this is gross, but still preferable to the broken original implementation.
{
float fogfactor = 0.55 + 0.3 * exp2 (-5.0*v_fogCoord);
float fogfactor = 0.55 + 0.3 * exp2 ((-5.0 / 1024.0)*v_distance);
color.rgb = vec3(0.6*(1.0-fogfactor)) + color.rgb * fogfactor;// mix(vec3(0.6), color.rgb, fogfactor);
}
if (color.a < u_alphaThreshold) discard; // it's only here that we have the alpha value available to be able to perform the alpha test.

View file

@ -4,7 +4,6 @@ out vec4 v_color;
out float v_distance;
out vec4 v_texCoord;
out vec4 v_detailCoord;
out float v_fogCoord;
out vec4 v_eyeCoordPosition;
uniform float u_usePalette;
@ -32,7 +31,6 @@ void main()
v_texCoord = u_textureMatrix * i_texCoord;
v_detailCoord = vec4(i_texCoord.x * u_detailParms.x, i_texCoord.y * u_detailParms.y, 0.0, 0.0);
v_fogCoord = abs(eyeCoordPosition.z);
v_color = i_color;
v_distance = eyeCoordPosition.z;