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.37k stars 423 forks source link

Effects are visible through the water surface #698

Open Einheit-101 opened 5 years ago

Einheit-101 commented 5 years ago

Describe the bug This old rendering bug is annoying for a long time now. Effects ignore the water in front of them.

To reproduce

  1. Go to editor
  2. Go into water
  3. crun x, y, z = getElementPosition(me) createEffect("prt_bubble", x, y, z-1, 0, 0, 0, 2000)
  4. See bubbles being drawn in front of water

Expected behaviour Effects should render correctly

Screenshots image

Multi Theft Auto v1.5.6-release-15932 (Windows)

Additional context Is there maybe a shader that can be applied to effects textures that fixes this issue?

Wolfee-J commented 5 years ago

This is due to the rending order.

AlexTMjugador commented 5 years ago

If what CodyJL said is right, maybe using setWaterDrawnLast makes a difference?

Einheit-101 commented 5 years ago

No! Effects are still in front of water with setWaterDrawnLast(true)

Einheit-101 commented 5 years ago

Creating a simple shader and adding this code into the main pass does actually solve this issue: ZEnable = true; ZWriteEnable = true; ZFunc = 4;

...however since water is now writing to depth buffer, it causes zfighting with anything that is close and planar to it (including boat wake and other water effects).

image

I think the final solution would be applying another shader to these water effects (duh...) that gives them so much depth bias that they will draw on top of the water surface...

Wolfee-J commented 5 years ago

Can you check if that shader fixes the bug of not being able to see water through car windows @Einheit-101

Einheit-101 commented 5 years ago

Sure. It doesnt fix the issue. Default GTA Water with simple zWriteEnable shader:

image

Water still not visible through car window, but water surface can be illuminated by dynamic lighting

Complex water shader with zWriteEnable = same.

image

Water doesnt just refuse to render through car windows, actually it doesnt render through vehicles at all. image

Wolfee-J commented 5 years ago

Alright, reconfirms my belief that SAs rendering order is crap.

Einheit-101 commented 5 years ago

setWaterDrawnLast on top of this shader doesnt work either. It looks like the water is simply culled away. Yes, GTA render order is messed up.