rigs-of-rods icon indicating copy to clipboard operation
rigs-of-rods copied to clipboard

Waves on water is broken

Open Miner34dev opened this issue 11 months ago • 9 comments

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

Miner34dev avatar Mar 05 '24 12:03 Miner34dev

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 avatar Mar 24 '24 10:03 ohlidalp

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 avatar Mar 24 '24 16:03 ohlidalp

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 avatar Mar 24 '24 16:03 ohlidalp

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 avatar Mar 24 '24 20:03 ohlidalp

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 :)

ohlidalp avatar Mar 25 '24 01:03 ohlidalp

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.

cryham avatar May 07 '24 17:05 cryham

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.

ohlidalp avatar Jun 30 '24 17:06 ohlidalp

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.

cryham avatar Jun 30 '24 20:06 cryham

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.

ohlidalp avatar Jun 30 '24 20:06 ohlidalp