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.42k stars 437 forks source link

alphaTransparent and "draw_last" flag doesn't change anything! #3124

Open FileEX opened 1 year ago

FileEX commented 1 year ago

Describe the bug

Setting the "DRAW_LAST" flag for the model still doesn't change anything and transparent models still don't show vehicles and other objects behind them.

alphaTranasparent is set to true in the engineReplaceModel function.

image

I think that flags still doesn't work correctly.

Steps to reproduce

Load the model with transparent materials

Version

Multi Theft Auto v1.6-release-21890

Additional context

No response

Relevant log output

No response

Security Policy

TheNormalnij commented 1 year ago

Hi! Can you provide WTR resource, please?

FileEX commented 1 year ago

I sent the resource to you on discord

PlatinMTA commented 1 year ago

The flags do work, but they won't work for alphas that are too high in value.

diferencia alphas

Afaik this is the same bug that happens with the windshields but I'm unsure about that.

FileEX commented 1 year ago

So what should be the maximum alpha value for the flag to work properly?

The flags do work, but they won't work for alphas that are too high in value.

diferencia alphas

Afaik this is the same bug that happens with the windshields but I'm unsure about that.

PlatinMTA commented 1 year ago

So what should be the maximum alpha value for the flag to work properly?

No idea tbh. Probably 127 and lower (less than 50%).

tederis commented 1 year ago

So what should be the maximum alpha value for the flag to work properly?

No idea tbh. Probably 127 and lower (less than 50%).

Should be 100(or 140, depends on entity type). But probably better to use flag "no_zbuffer_write" for glass, in that case an alpha doesn't matter. But note that when alpha is less than beforementioned value the usage of flag "draw_last" loses its meaning because alpha testing takes the stage.

Dujin9931 commented 1 year ago

100 is better to use in this case.

tederis commented 1 year ago

And yes, this flag can produce unexpected results in some conditions. It's the specifics of GTA:SA transparent objects sorting.

FileEX commented 1 year ago

With "no_zbuffer_write" elements are visible through walls image

FileEX commented 1 year ago

This problem persists no matter what the alpha is set to. No matter if I set alpha to 140, 127, 100 it's still this bug and nothing changes. This bug appear when vehicle is so near to the glass, because when the vehicle/player is so far from the glass then everything looks fine.

image image

tederis commented 1 year ago

With "no_zbuffer_write" elements are visible through walls image

Seems like an another bug.

tederis commented 1 year ago

Please, create a test resource and attach to the issue. It would be easier to help with it.

FileEX commented 1 year ago

With "no_zbuffer_write" elements are visible through walls image

Seems like an another bug.

The "no_zbuffer_write" flag triggers when I get close to the window and the vehicle is not visible, then that vehicle is visible but is rendered later than the window with the "draw_last" flag. Look at this

Flag "draw_last" without flag "no_zbuffer_write" RESULT: So far: image So near: image

Flag "draw_last" with flag "no_zbuffer_write" RESULT: So far: image So near: image

Vehicle is rendered with no_zbuffer_write flag when dissapear without this flag

tederis commented 1 year ago

This problem persists no matter what the alpha is set to. No matter if I set alpha to 140, 127, 100 it's still this bug and nothing changes. This bug appear when vehicle is so near to the glass, because when the vehicle/player is so far from the glass then everything looks fine.

image image

This is an important comment about distance. Because it explains the where the bug comes from and how to solve it. I have a possible solution but without a test resource cannot check the correctness of it.

tederis commented 1 year ago

This problem persists no matter what the alpha is set to. No matter if I set alpha to 140, 127, 100 it's still this bug and nothing changes. This bug appear when vehicle is so near to the glass, because when the vehicle/player is so far from the glass then everything looks fine. image image

This is an important comment about distance. Because it explains the where the bug comes from and how to solve it.

Did you still need a test resource?

Yes, it would be great. I have a possible solution but without a test resource cannot check the correctness of it.

FileEX commented 1 year ago

This problem persists no matter what the alpha is set to. No matter if I set alpha to 140, 127, 100 it's still this bug and nothing changes. This bug appear when vehicle is so near to the glass, because when the vehicle/player is so far from the glass then everything looks fine. image image

This is an important comment about distance. Because it explains the where the bug comes from and how to solve it.

Did you still need a test resource?

Yes, it would be great. I have a possible solution but without a test resource cannot check the correctness of it.

I send a test resource to your discord, cuz this model is private and i can't attach this here

tederis commented 1 year ago

Okay, I just got the test resource. I have already responded in PM, but maybe it would be interested for someone else. This is not a bug actually, just a feature of GTA:SA renderer. The problem is quite common. Glass and other transparent objects must be a separate object. Without it glass isn't able to be sorted the correct way. Moreover, transparent objects must be separated so that a camera wouldn't be able to be positioned within the transparent object's bounding box.

FileEX commented 1 year ago

Okay, I just got the test resource. I have already responded in PM, but maybe it would be interested for someone else. This is not a bug actually, just a feature of GTA:SA renderer. The problem is quite common. Glass and other transparent objects must be a separate object. Without it glass isn't able to be sorted the correct way. Moreover, transparent objects must be separated so that a camera wouldn't be able to be positioned within the transparent object's bounding box.

There is still bug with glass. Even with glass as separated object with alpha 100

image image

tederis commented 1 year ago

Okay, I just got the test resource. I have already responded in PM, but maybe it would be interested for someone else. This is not a bug actually, just a feature of GTA:SA renderer. The problem is quite common. Glass and other transparent objects must be a separate object. Without it glass isn't able to be sorted the correct way. Moreover, transparent objects must be separated so that a camera wouldn't be able to be positioned within the transparent object's bounding box.

There is still bug with glass. Even with glass as separated object with alpha 100

image image

Like I said, GTA SA rendering isn't perfect and has limitations. Seems like a glass object is too large to let SA handle it correctly. You cannot create one big object contains all transparent parts of a house. There are some considerations require you to separate all windows(but depends on the windows themselves) into isolated flat(not concave or convex) objects.