extend the per entity ref scaling to vehicles#5006
Open
Zephkek wants to merge 2 commits into
Open
Conversation
GTA runs the world passes with ALPHAREF 140 (CRenderer::RenderEverythingBarRoads) and 100 (CVisibilityPlugins::RenderEntity), alpha func GREATER. multitheftauto#4751 patched both to 0 for multitheftauto#425, multitheftauto#4807 made them 1 and added a D3D level dual pass that overrides the alpha test for every blended z-writing draw. between the two, every low alpha gradient pixel vanilla throws away started rendering and the LV neon lines turned into smeared bands. 1.6 has neither change, so it renders like vanilla. multitheftauto#4996 restored the RenderEntity ref and left the world pass at 1. its fallback reads materials[0].color.a at RenderOneNonRoad entry, but MTA multiplies element alpha into the materials later, inside the CObject::Render hook, and undoes it after the call. the check reads base values, never sees setElementAlpha, fires on stock models with low material alpha instead, and never restores what it writes. none of it matters for blended draws anyway, the dual pass swaps the test for GREATEREQUAL 128 / LESS 128 and the sub-ref gradient still renders in pass 2. so: - the MemPuts are gone, both refs stay stock - the dual pass only runs when the game has no meaningful alpha test of its own (ref at the DefinedState baseline of 2 or below). an active test at 100/140 already clips transparent pixels before z-write, like vanilla - objects with element alpha A < 255 get the ref scaled to ref * A / 255 around their RenderOneNonRoad call, saved and restored. setElementAlpha works at any value on both render paths and cutouts keep their vanilla shape neon renders like 1.6 again, multitheftauto#425 stays fixed.
…ir own ref cars and bikes set ALPHAREF 1 and restore it inside their own Render fns, so element alpha always worked for them. boats and trains never touch the ref, at stock 100/140 their hull drops below the test once alpha goes low enough, and that has been the case on every release so far. run them through the same scaled ref as objects. for cars and bikes it's a no-op, their own ref write lands after ours and wins during the body render.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
builds on #5005. @Dryxio asked whether setElementAlpha on a boat or train goes fully invisible. it does, and it did on 1.6 and every release before it: cars and bikes set ALPHAREF 1 inside their own Render fns, boats and trains never touch it, so at stock refs the hull drops below the test once alpha goes under ~100. run vehicles through the same scaled ref as objects. cars and bikes are unaffected, their own ref write lands after ours and wins. boats and trains get working setElementAlpha out of it.
Test plan
Checklist