RigsOfRods / rigs-of-rods

Main development repository for Rigs of Rods soft-body physics simulator
https://www.rigsofrods.org
GNU General Public License v3.0
990 stars 175 forks source link

Waves on water is broken #3137

Open Miner34dev opened 3 months ago

Miner34dev commented 3 months ago

Hardware: AMD Ryzen 3 5300U, integrated graphics Software: Garuda Linux, latest RoR dev build, OpenGL render (of course) Settings: RoRcfg.txt

HydraX with waves on water glitches out badly (but only if you have a vehicle spawned, else it works as normal): Screenshot_20240305_132508 HydraX without waves on water somehow seems to have waves actually: Screenshot_20240305_133006 Reflection + refraction with waves on water doesn't have waves at all: Screenshot_20240305_132818

ohlidalp commented 3 months ago

Hello.

The 'waves on water' (EDIT) works by creating a grid mesh and shaping it dynamically to simulate a wavy sea, both physically and visually.

(EDIT2) I just atested that the 'waves on water' setting in 'Settings/Graphics' is always affects physics (both vehicle and character) but under HydraX it doesn't apply to graphics. HydraX waves are always visible, even if they don't affect physics.

ohlidalp commented 3 months ago

I found a crash scenario (Win10, Directx9, PSSM off, configuration=RelWithDebInfo) - OGRE crashes when rendering a frame: obrazek Steps to reproduce:

  1. In main menu, go to settings, set water=basic and Waves=on (EDIT: it seems to happen even if you start with Water=Hydrax)
  2. Load a map with water, like 'Small Island' (the one on screenshots below).
  3. Set the 'Waves height' slider in 'Top menubar/Settings' menu to middle value.
  4. Go back to main menu, set water=Hydrax and resume game (EDIT: seems to occur whether you leave 'Waves' on or turn them off)
  5. Go back to main menu again -> crash.

I'd try under Debug but there's a showstopper - the terrain calculates lightmap on background thread, and you can't return to menu until that finished. It takes ~15sec on RelWithDebInfo. On Debug it would take at least 5min. I need to code an option to force-disable lightmap calc to test.

UPDATE: with the new Settings added below, I could test right away. Apparently the culprit is incomplete initialization or cleanup of the previous water. obrazek

ohlidalp commented 3 months ago

I managed to reproduce the issue (Win10, Directx9, Visual Studio 2022, config=RelWithDebInfo, terrain=Small Island). obrazek Apparently it gets worse the more vehicles (or the more complex vehicle) is simulated. obrazek

ohlidalp commented 3 months ago

I couldn't figure anything out from the code, so I added GUI to fiddle with HydraX params... obrazek

anyway, when I figure out what causes this glitch, I'll try to replicate it as rain effect. It really looks like pouring water.

ohlidalp commented 3 months ago

Strangely, under Debug, I get this glitch even with simple water, and even if no vehicles are spawned. Probably because under Debug everything is slower by default :)

cryham commented 1 month ago

Yeah I made a video with this and other bugs some time ago. And my guess was that you have some uninited vars for water.

ohlidalp commented 2 days ago

And my guess was that you have some uninited vars for water.

You win. The glitch of Basic water was unitialized variable Water::m_waves_height. I have no progress on the Hydrax glitch though.

cryham commented 2 days ago

Cool. Well since @tritonas00 is working on the new water (btw is it on a branch?) , I also think it'd be best to finish that, and just forget Hydrax.

ohlidalp commented 2 days ago

I didn't find the issue yet, but I'm getting close ... I made a debug UI displaying min/max vertex height, so now I know the problem is in C++ code updating the water mesh. obrazek Yes, Tritonific water is super promising, but I haven't looked at it yet. I was just curious if this can be patched easily - from my experience on this project, quick and dirty solutions usually work out better that longer term projects.

EDIT: The branch is here https://github.com/tritonas00/rigs-of-rods/tree/water-2 and apparently it's GLSL-only at the moment.