diff --git a/source/build/src/mdsprite.cpp b/source/build/src/mdsprite.cpp index ca25be004..da515dc92 100644 --- a/source/build/src/mdsprite.cpp +++ b/source/build/src/mdsprite.cpp @@ -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; surfihead.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; diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index 7542e49ed..b7147f6aa 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -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); diff --git a/source/build/src/voxmodel.cpp b/source/build/src/voxmodel.cpp index 8932de699..262470f42 100644 --- a/source/build/src/voxmodel.cpp +++ b/source/build/src/voxmodel.cpp @@ -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); diff --git a/source/glbackend/glbackend.h b/source/glbackend/glbackend.h index cbe866fde..6cb1448f5 100644 --- a/source/glbackend/glbackend.h +++ b/source/glbackend/glbackend.h @@ -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) diff --git a/wadsrc/static/engine/shaders/glsl/polymost.fp b/wadsrc/static/engine/shaders/glsl/polymost.fp index 11ea5ad39..650e3599a 100644 --- a/wadsrc/static/engine/shaders/glsl/polymost.fp +++ b/wadsrc/static/engine/shaders/glsl/polymost.fp @@ -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. diff --git a/wadsrc/static/engine/shaders/glsl/polymost.vp b/wadsrc/static/engine/shaders/glsl/polymost.vp index b2387ad02..7be273e71 100644 --- a/wadsrc/static/engine/shaders/glsl/polymost.vp +++ b/wadsrc/static/engine/shaders/glsl/polymost.vp @@ -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;