Skip to content

Fix objects with alpha below 141 are invisible#4751

Merged
FileEX merged 2 commits into
multitheftauto:masterfrom
FileEX:bugfix/objects_alpha
Mar 12, 2026
Merged

Fix objects with alpha below 141 are invisible#4751
FileEX merged 2 commits into
multitheftauto:masterfrom
FileEX:bugfix/objects_alpha

Conversation

@FileEX

@FileEX FileEX commented Mar 9, 2026

Copy link
Copy Markdown
Member

Summary

This PR fixes a bug where objects with alpha < 141 are not rendered.

This issue has two stages: the first is the alpha threshold (rwRENDERSTATEALPHATESTFUNCTIONREF) set to 140 in the function CRenderer::RenderEverythingBarRoads - this is the direct cause of #425. The next stage is in the function CVisibilityPlugins::RenderEntity, where the alpha threshold is set to 100, and then objects with alpha < 101 are not rendered.

Is it safe to just set this to 0?

These settings were R*’s attempts to fix the halo effect around trees and bushes, which, as can be seen in the game, did not work.

            //!PC - required to minimize alpha halo problems outside (bushes & trees mainly)
            if ((CGame::currArea==AREA_MAIN_MAP) && (!pModelInfo->GetDontWriteZBuffer()))
            {
                RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTIONREF, (void*)100);
            }
            else
            {
                RwRenderStateSet(rwRENDERSTATEALPHATESTFUNCTIONREF, (void*)0);
            }

I did not observe any new or worse rendering bugs with plants after setting these values to 0.

Alpha halo bugs "fixed" by R*:
image
image
image

Motivation

Fixes #425

Test plan

  1. crun o = createObject(1337, me.position)
  2. crun o.alpha = 140

Checklist

  • Your code should follow the coding guidelines.
  • Smaller pull requests are easier to review. If your pull request is beefy, your pull request should be reviewable commit-by-commit.

@FileEX FileEX requested a review from a team as a code owner March 9, 2026 19:01
@FileEX FileEX added the bugfix Solution to a bug of any kind label Mar 9, 2026
@Dutchman101

Copy link
Copy Markdown
Member

This would be ok, unless we get a bunch of user reports from different trees (or tree mods, or any unchecked scenario) that there's worsened visual glitches. Time will tell and we got to pay attention.

@FileEX FileEX merged commit 6bd6db5 into multitheftauto:master Mar 12, 2026
9 checks passed
@FileEX FileEX deleted the bugfix/objects_alpha branch March 12, 2026 15:04
@FileEX FileEX added this to the 1.7 (Current) milestone Mar 12, 2026
@rifleh700

Copy link
Copy Markdown

Lpsd pushed a commit to Lpsd/mtasa-blue that referenced this pull request Apr 11, 2026
This PR fixes a bug where objects with alpha < 141 are not rendered.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Solution to a bug of any kind

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Objects with alpha below 141 are invisible

3 participants