PK ‚¡-LÕ¬ãFF diff_02.patchdiff -ur --binary model3emu/Src/Graphics/New3D/Model.h model3emu-patch/Src/Graphics/New3D/Model.h --- model3emu/Src/Graphics/New3D/Model.h 2018-01-13 20:08:19.000000000 +0100 +++ model3emu-patch/Src/Graphics/New3D/Model.h 2018-01-13 18:47:32.299804600 +0100 @@ -114,7 +114,7 @@ // microtexture bool microTexture = false; int microTextureID = 0; - float microTextureScale = 0; + int microTextureScale = 0; // attributes bool doubleSided = false; @@ -132,7 +132,7 @@ bool specular = false; float shininess = 0; float specularValue = 0; - + // fog float fogIntensity = 1.0f; diff -ur --binary model3emu/Src/Graphics/New3D/New3D.cpp model3emu-patch/Src/Graphics/New3D/New3D.cpp --- model3emu/Src/Graphics/New3D/New3D.cpp 2018-01-13 20:08:19.000000000 +0100 +++ model3emu-patch/Src/Graphics/New3D/New3D.cpp 2018-01-13 18:45:40.606445300 +0100 @@ -962,31 +962,22 @@ currentMesh->fogIntensity = ph.LightModifier(); - if (currentMesh->textured) { + currentMesh->format = m_texSheet.GetTexFormat(ph.TexFormat(), ph.AlphaTest()); - currentMesh->format = m_texSheet.GetTexFormat(ph.TexFormat(), ph.AlphaTest()); - - if (currentMesh->format == 7) { - currentMesh->alphaTest = false; // alpha test is a 1 bit test, this format needs a lower threshold, since it has 16 levels of transparency - } - - currentMesh->x = ph.X(); - currentMesh->y = ph.Y(); - currentMesh->width = ph.TexWidth(); - currentMesh->height = ph.TexHeight(); - currentMesh->mirrorU = ph.TexUMirror(); - currentMesh->mirrorV = ph.TexVMirror(); - currentMesh->microTexture = ph.MicroTexture(); - currentMesh->inverted = ph.TranslatorMapOffset() == 2; - - if (currentMesh->microTexture) { - - float microTexScale[] = { 4, 8, 16, 32 }; - - currentMesh->microTextureID = ph.MicroTextureID(); - currentMesh->microTextureScale = microTexScale[ph.MicroTextureMinLOD()]; - } + if (currentMesh->format == 7) { + currentMesh->alphaTest = false; // alpha test is a 1 bit test, this format needs a lower threshold, since it has 16 levels of transparency } + + currentMesh->x = ph.X(); + currentMesh->y = ph.Y(); + currentMesh->width = ph.TexWidth(); + currentMesh->height = ph.TexHeight(); + currentMesh->mirrorU = ph.TexUMirror(); + currentMesh->mirrorV = ph.TexVMirror(); + currentMesh->microTexture = ph.MicroTexture(); + currentMesh->inverted = !ph.TranslatorMap() && ph.TranslatorMapOffset() == 2; + currentMesh->microTextureID = ph.MicroTextureID(); + currentMesh->microTextureScale = 1 << ph.MicroTextureMinLOD(); } void CNew3D::CacheModel(Model *m, const UINT32 *data) diff -ur --binary model3emu/Src/Graphics/New3D/R3DShader.cpp model3emu-patch/Src/Graphics/New3D/R3DShader.cpp --- model3emu/Src/Graphics/New3D/R3DShader.cpp 2018-01-13 20:08:19.000000000 +0100 +++ model3emu-patch/Src/Graphics/New3D/R3DShader.cpp 2018-01-13 20:06:18.474452700 +0100 @@ -9,6 +9,8 @@ // uniforms uniform float modelScale; +uniform int microTextureScale; +uniform vec2 baseTexSize; // attributes attribute vec4 inVertex; @@ -21,6 +23,7 @@ // outputs to fragment shader varying vec3 fsViewVertex; varying vec3 fsViewNormal; // per vertex normal vector +varying vec2 fsMicroTexCoord; varying vec2 fsTexCoord; varying vec4 fsColor; varying float fsDiscard; // can't have varying bool (glsl spec) @@ -44,6 +47,7 @@ fsTexCoord = inTexCoord; fsFixedShade = inFixedShade; gl_Position = gl_ModelViewProjectionMatrix * inVertex; + fsMicroTexCoord = inTexCoord * (baseTexSize / vec2(128 >> microTextureScale)); } )glsl"; @@ -57,8 +61,6 @@ // texturing uniform bool textureEnabled; uniform bool microTexture; -uniform float microTextureScale; -uniform vec2 baseTexSize; uniform bool textureInverted; uniform bool textureAlpha; uniform bool alphaTest; @@ -89,21 +91,21 @@ varying vec3 fsViewVertex; varying vec3 fsViewNormal; // per vertex normal vector varying vec4 fsColor; +varying vec2 fsMicroTexCoord; varying vec2 fsTexCoord; varying float fsDiscard; varying float fsFixedShade; vec4 GetTextureValue() { - vec4 tex1Data = texture2D( tex1, fsTexCoord.st); + vec4 tex1Data = texture2D(tex1, fsTexCoord.st); if(textureInverted) { tex1Data.rgb = vec3(1.0) - vec3(tex1Data.rgb); } if (microTexture) { - vec2 scale = baseTexSize/256.0; - vec4 tex2Data = texture2D( tex2, fsTexCoord.st * scale * microTextureScale); + vec4 tex2Data = texture2D(tex2, fsMicroTexCoord.st); tex1Data = (tex1Data+tex2Data)/2.0; } @@ -414,7 +416,7 @@ } if (m_dirtyMesh || m->microTextureScale != m_microTexScale) { - glUniform1f(m_locMicroTexScale, m->microTextureScale); + glUniform1i(m_locMicroTexScale, m->microTextureScale); m_microTexScale = m->microTextureScale; } diff -ur --binary model3emu/Src/Graphics/New3D/R3DShader.h model3emu-patch/Src/Graphics/New3D/R3DShader.h --- model3emu/Src/Graphics/New3D/R3DShader.h 2018-01-13 20:08:19.000000000 +0100 +++ model3emu-patch/Src/Graphics/New3D/R3DShader.h 2018-01-13 18:51:15.973632800 +0100 @@ -54,7 +54,7 @@ bool m_fixedShading; bool m_layered; - float m_microTexScale; + int m_microTexScale; float m_baseTexSize[2]; bool m_textureInverted; PK ‚¡-LÕ¬ãFF $ diff_02.patch …xef¢ŒÓ…xef¢ŒÓ~`ÓPK_q