multitheftauto / mtasa-blue

Multi Theft Auto is a game engine that incorporates an extendable network play element into a proprietary commercial single-player game.
https://multitheftauto.com
GNU General Public License v3.0
1.32k stars 411 forks source link

dxDrawMaterialLine3D renders through buildings when heat haze is enabled and some other conditions are met #3457

Closed C0DELEVEL closed 1 week ago

C0DELEVEL commented 2 weeks ago

Describe the bug

After the postGUI to stage changes (i think) it behaves strangely for some players (about 30% of ~400 unique players) - it renders through walls and gta sa buildings (behaves like postGUI=true) depending on the angle from which you look.

The issue exists when stage parameter is set to false (legacy) or postfx

Steps to reproduce

  1. Warp to -2020.1213378906,-98.689750671387,35.1640625
  2. Start below script:
    local txt = dxCreateTexture(128,128)
    local pixels = dxGetTexturePixels (txt)
    for ii=1,128 do
        for i=1,128 do
            dxSetPixelColor(pixels,i,ii,255,255,255)
        end
    end
    dxSetTexturePixels(txt, pixels)
    addEventHandler('onClientRender',root,function()
        dxDrawMaterialLine3D(-2023.3182373047,-105.71241760254,35.290626525879,-2023.3182373047+1,-105.71241760254+1,35.290626525879,txt,1,tocolor(255,255,255),false,-2020.4468994141,-99.970504760742,35.290626525879)
    end)
  3. Look at the proper angle (pretty easy to achieve, there are only few angles that work properly)
  4. You will see the white rectangle through the wall (just like with postGUI=true, but it's false/postfx)

Version

Multi Theft Auto v1.6-release-22505

Additional context

An example showing the annoyance of the issue: click to view image

and result using the above example code: image

Relevant log output

-

Security Policy

tederis commented 2 weeks ago

Cannot reproduce the problem on 22512. Did you test it on a pure(without any custom modifications) freeroam server?

C0DELEVEL commented 2 weeks ago

As I've already said above, it was hard to debug.. But now I have more details and it's not hardware dependent, but the graphic settings dependent.

The bug is visible when you have following graphic settings set (not sure if all, but on such setup I confirmed the issue for ~5 players and myself):

Also, the weather id 4 should be set (not sure)

Wearing jetpack increases chance of issue becoming apparent

Tested on 22505 and 22512.

@tederis Please let me know if you were able to reproduce the issue, you can also dm me on dc (xskyex_), will try to help reproducing it.

neku172 commented 2 weeks ago

I can confirm that it's happening both on 22505 and 22512, however it's very hard to see this glitch without having jetpack on or having nitro toggled in a car. Seems like it's not dependent on weather (i'm using weather id 1).

image image

tederis commented 2 weeks ago

As I've already said above, it was hard to debug.. But now I have more details and it's not hardware dependent, but the graphic settings dependent.

The bug is visible when you have following graphic settings set (not sure if all, but on such setup I confirmed the issue for ~5 players and myself):

  • Fullscreen borderless
  • Very high preset
  • Anisotropic filtering off
  • AA x3
  • Heat haze enabled <-- this setting is mandatory and enabling/disabling this toggles the bug (but only with above settings setup)

Also, the weather id 4 should be set (not sure)

Wearing jetpack increases chance of issue becoming apparent

Tested on 22505 and 22512.

@tederis Please let me know if you were able to reproduce the issue, you can also dm me on dc (xskyex_), will try to help reproducing it.

I was able to reproduce the issue now. Thanks for the detailed report. I'll fix it in the next few days.

tederis commented 2 weeks ago

Okay, I've made a little research on this topic. And there's no perfect solution. We have two ways here: 1) Fix the issue by using an additional depth-stencil buffer. All will work as expected, but requires an extra VRAM. 2) Do not use an extra buffer and put a hook right after the color filter pass. No additional VRAM is used, but narrows the list of post effects that are expected to be rendered before the "postfx" stage. In other words, color correction will be before "postfx" stage, but heat haze, grain, infrared effects after the stage.

What do you think? Which way is better?

dmi7ry commented 2 weeks ago

What do you think? Which way is better?

Many projects already have problems with lack of memory, so, imho, the second option is better.

C0DELEVEL commented 2 weeks ago

What do you think? Which way is better?

I would also lean towards the second option

tederis commented 2 weeks ago

Fixed in #3478