From 864bb36b5a7c098f5bf353686887a24ef7342e31 Mon Sep 17 00:00:00 2001 From: Ian Curtis Date: Wed, 16 Jan 2019 01:07:56 +0000 Subject: [PATCH] Technically backface culling should cull polys when the dot product = 0, since when it equals 0 the polys is perpendicular to the camera and thus invisible. When you complete sega rally2 (if you can get that far lol) the champagne is invisible. The reason is because all the face normals are 0. So when multiplied by the model matrix they are still 0 and get culled. Tweaking the condition to only cull polys when greater than 0 fixes this, and allows these 'bad' polys to render as they do on the model3. --- Src/Graphics/New3D/R3DShaderQuads.h | 18 +++++++++--------- Src/Graphics/New3D/R3DShaderTriangles.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Src/Graphics/New3D/R3DShaderQuads.h b/Src/Graphics/New3D/R3DShaderQuads.h index ce4e615..bff998c 100644 --- a/Src/Graphics/New3D/R3DShaderQuads.h +++ b/Src/Graphics/New3D/R3DShaderQuads.h @@ -89,7 +89,7 @@ float area(vec2 a, vec2 b) void main(void) { - if(gs_in[0].discardPoly>=0) { + if(gs_in[0].discardPoly > 0) { return; //emulate back face culling here (all vertices in poly have same value) } @@ -439,14 +439,14 @@ vec4 GetTextureValue() if (microTexture) { vec2 scale = (baseTexSize / 128.0) * microTextureScale; - vec4 tex2Data = textureR3D( tex2, ivec2(0), vec2(128.0), fsTexCoord * scale); - - float lod = mip_map_level(fsTexCoord * scale * vec2(128.0)); - - float blendFactor = max(lod - 1.5, 0.0); // bias -1.5 - blendFactor = min(blendFactor, 1.0); // clamp to max value 1 - blendFactor = (blendFactor + 1.0) / 2.0; // 0.5 - 1 range - + vec4 tex2Data = textureR3D( tex2, ivec2(0), vec2(128.0), fsTexCoord * scale); + + float lod = mip_map_level(fsTexCoord * scale * vec2(128.0)); + + float blendFactor = max(lod - 1.5, 0.0); // bias -1.5 + blendFactor = min(blendFactor, 1.0); // clamp to max value 1 + blendFactor = (blendFactor + 1.0) / 2.0; // 0.5 - 1 range + tex1Data = mix(tex2Data, tex1Data, blendFactor); } diff --git a/Src/Graphics/New3D/R3DShaderTriangles.h b/Src/Graphics/New3D/R3DShaderTriangles.h index 9272d6c..07ec61c 100644 --- a/Src/Graphics/New3D/R3DShaderTriangles.h +++ b/Src/Graphics/New3D/R3DShaderTriangles.h @@ -280,7 +280,7 @@ void main() vec4 finalData; vec4 fogData; - if(fsDiscard>=0) { + if(fsDiscard > 0) { discard; //emulate back face culling here }