Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Foam / wake vibration when approaching whirlpools #1123

Open
2 tasks done
Revmatek opened this issue Jun 19, 2023 · 20 comments
Open
2 tasks done

Foam / wake vibration when approaching whirlpools #1123

Revmatek opened this issue Jun 19, 2023 · 20 comments
Labels

Comments

@Revmatek
Copy link

Revmatek commented Jun 19, 2023

Is there an existing issue for this?

  • I have searched the existing issues.

Have you checked the documentation to resolve your problem?

  • I have read the linked documentation and could not resolve my issue.

Current Behavior

If a boat or other object approaches a whirlpool (in various configurations) as the foam or wake begins to touch the spiral / flow the rendering of the foam will beginning shake and / or vibrate from its current position as it is sucked into the flow of the whirlpool

Expected Behavior

As the boat wake approaches the whirlpool and is sucked it, the foam should appear to move smoothly with the flow of the whirlpool as it is sucked in.

Steps To Reproduce

  1. Open the "BoatWakes" dev scene
  2. Add an empty gameobject to the scene (ensure that it is in the path of the sphere wakes)
  3. Add the "Crest Whirlpool" script to the empty gameobject (increasing the radius may better display the issue)
  4. Hit the play button
  5. Move the camera to observe the foam being generated as it enters the flow of the whirlpool from various angles
  6. Observe jitter / shaking in some cases
    Note: The shakiness may not always be immediately apparent but it can be much much worse at times. Given this image below (obviously not shaking because it is a still frame) the vibration in the render occurs at the forward most edge of the foam on the right. Depending on how things are configured the entire foam cap inside the flow will vibrate
image

Unity Version

2021.3.26f1

Crest Version

4.17.3

Render Pipeline

Built-In

Editor or Standalone

Editor (Edit Mode), Editor (Play Mode), Standalone

Environment

- OS: Windows

Anything else?

I am fairly certain this used to work in an older version (4.15.2 maybe), I recently updated my version and resolved many of the other issues I had mentioned previously. I was unable to mitigate this behavior by tweaking the settings of the whirlpool other than setting the eye radius to 0 which is not really a solution.

@daleeidd
Copy link
Collaborator

Flow does cause pulsing artefacts. Is that what you are seeing? I will need a video to understand if it is not too much trouble.

@Revmatek
Copy link
Author

Flow does cause pulsing artefacts. Is that what you are seeing? I will need a video to understand if it is not too much trouble.

I will get some video.

@Revmatek
Copy link
Author

Flow does cause pulsing artefacts. Is that what you are seeing? I will need a video to understand if it is not too much trouble.

Videos are low res and broken up to support upload.

This first one is the scene more or less following the repro steps:

2023-06-24.07-53-40_2.mp4
2023-06-24.07-53-40_3.mp4

This one is with an actual physics objects / boat stuff happening.

2023-06-24.07-53-40_5.mp4

This is something new I am pretty sure, it did not used to do this.

@daleeidd
Copy link
Collaborator

Thanks. I wasn't able to reproduce it myself. Not sure what it could be.

Have you changed any of the simulation settings files (Foam or Dynamic Waves)? There is a simulation frequency setting for both that may help.

What is your frame rate?

@Revmatek
Copy link
Author

Revmatek commented Jun 29, 2023

The framerate for these in game is ~60FPS. I believe the framerate in the example scene is unbound so it was probably ~300fps. The only settings I changed in the boatwakes scene was zeroing out the spectrum for the waves to make it easier to see and adding whirlpools on empty game objects where I moved around and changed the radius.

I was able to verify this is some sort of regression, I ran the same test with the BoatWakes scene in crest version 4.15 (same unity version) and everything is nice and smooth as it gets sucked down into the whirlpools. It seems reproducible on multiple computers with 4.17.

Here is some more video comparing the 2 versions. As far as I can tell both of these have the same settings and are unaltered from the branch, with the exception of the spectrum and addition of whirlpools. The only difference I noticed is that the whirlpools do not appear until playback has started in 4.15

4.15 (smooth):

415.mp4

4.17.3 (shaky):
image

417.mp4

@Revmatek
Copy link
Author

Revmatek commented Jun 29, 2023

There is a simulation frequency setting for both that may help.

For both 4.15 and 4.17 BoatWake scenes the simulation frequency is:
image

Increasing this value in 4.17 has no effect (probably undesirable performance impacts). Decreasing the value seems to make the problem much much worse. Maybe that can help reproduce it. Decreasing this value on 4.15 does degrade visuals but the overall movement is still smooth.

The foam simulation rate is 30 on both and has similar effects as described above.

@Revmatek
Copy link
Author

Revmatek commented Jun 29, 2023

I'm looking at this more to see if I can help pinpoint the cause and provide as much info as I can.

It does not seem to be caused by changes to the following:

  • Whirlpool.cs
  • SphereWaterInteraction.cs
  • OceanRenderer.cs
  • LodDataMgrFlow

It may be related to changes to (the 2 versions are pretty incompatible so its hard to tell):

  • LodDataMgrDynWaves.cs
  • LodDataMgrPersistent.cs
  • RegisterLodDataInput

Problems do not occur if "Create Flow Sim" is off
Problems do not occur if "Create Flow" is off on Whirlpool
Problems do not occur when passing through a CrestRegisterFlowInput
Problems still occur when "Flow" is disabled on the shader (which is interesting)
Problems still occur when zoomed out (and LOD still visible)

It does not seem related to foam (just easier to see). It still happens when Foam is off on the shader: The image below is just a visual reference, shaking is hard to see even on video.
image

If I manually disable foam vs sphere interaction behavior the problems still occur if only one is enabled which tells me its definitely related to flow, not foam or sphere interactions.

I am seeing a fundamental difference in wake foam between versions as well, while not really a concern it may indicate the cause.

4.15
image
image

4.17
image
image

@daleeidd
Copy link
Collaborator

Thanks. I was able to reproduce it only intermittently. Some machines were harder than others. I was able to reproduce a more subtle jitter reliably 4.17 and 4.15. Not sure if that means 4.15 will reproduce the less subtle case or not.

Are you able to reproduce the more noticeable jitter case (like the red plane video) reliably?

I agree that it may have something to do with SWI and flow together. Since SWI queries flow I think it has to do with queries. I will see if I can get a reliably reproducible together at some point.

@Revmatek
Copy link
Author

Thanks. I was able to reproduce it only intermittently. Some machines were harder than others. I was able to reproduce a more subtle jitter reliably 4.17 and 4.15. Not sure if that means 4.15 will reproduce the less subtle case or not.

That is good news, thanks. I'm not concerned with 4.15 except as a comparison. 4.17 fixed a lot of other issues so I'm probably going to stick with it and continue updating as needed. I think there is subtle jitter in 4.15 in general, but not as extreme (that I noticed.) and it did not appear in any game builds.

Are you able to reproduce the more noticeable jitter case (like the red plane video) reliably?

Yes. Its 100% of the time in the current build with 4.17. The BoatWake scenes is about 90% of the time. I am happy to try out any available fixes / branches in the future and / or get it thoroughly tested.

I agree that it may have something to do with SWI and flow together. Since SWI queries flow I think it has to do with queries. I will see if I can get a reliably reproducible together at some point.
👍

@daleeidd
Copy link
Collaborator

daleeidd commented Jul 3, 2023

I'm not concerned with 4.15 except as a comparison

Yeah, it is more about getting a more reproducible case. I am not having much luck and starting to doubt previous findings.

For both 4.15 and 4.17 BoatWake scenes the simulation frequency is:

Is that Dynamic Waves? Foam also has a simulation frequency. Have you tried increasing it to 120 too? Everything seems related to simulation frequency so far for me. This will be especially the case at high speeds.

@Revmatek
Copy link
Author

Revmatek commented Jul 3, 2023

Is that Dynamic Waves? Foam also has a simulation frequency. Have you tried increasing it to 120 too? Everything seems related to simulation frequency so far for me. This will be especially the case at high speeds.

I attempted to adjust both of the sliders related to simulation frequency. They seemed to have little affect on the jitter. The only time the jitter ever stopped was when flow was turned off in some form.

@Revmatek
Copy link
Author

Revmatek commented Jul 3, 2023

I looked at this some more and I noticed something odd and something else useful.

What was odd was that after closing the crest project and opening it later (today), it was much harder to see any jitter. I had to play around with a bit to even see a hint of what I saw before.

I noticed when I was trying to figure out where there jitter went that by removing the camera from the wake rig, the jitter seemed less, so I used a free moving camera and placed some spheres around a new whirlpool and everything seemed mostly fine. So I checked in game and it does seem related to movement in some way. It does not occur when boats are kinematic. Could be related to velocity.

I was able to narrow this down a bit more specific. I created a sphere with a foam override that also has a CrestSimpleFloatingObject on it. I placed it in the BoatWake scene and it seems fine spinning around the flow of the whirlpool. I placed an identical object in game and it freaks out like the boat does. So now I can only assume there is something different. A settings somewhere... something that changed from 4.15 -> 4.17

I copied the entire ocean from BoatWake into the problem scene and the issue still occurs. I am going to have to start picking things apart to see when the problem stops I guess.

The more I examine this the less it seems to make sense. I added a sphere with foam override at the same time the boat was having issues and it seemed to make things smoother. Removing the sphere seemed to make it worse, seems to indicate a timing issue to me or some sort of rendering out of order. The camera in the demo scene is using Update to move the camera around, my camera is using LateUpdate. Changing camera to use Update (which is not really an option) does not make it smooth however copying the Demo camera into the scene seems to be slightly smoother for some reason. It feels like I am chasing the symptoms of a different timing issue upstream related to changes from 4.15 -> 4.17 as I cannot pinpoint any one thing causing the problem and it seems unrelated to any configuration of the Ocean given that the example one has the same issues. To confuse matters even more I am no longer able to reproduce jitter in the boat wakes scene even though I was able to this morning and previously.

@Revmatek
Copy link
Author

Revmatek commented Jul 3, 2023

If you add a sphere to the demo scene and hardcode the framerate to not be unbound it seems like it is a lot more reproducible and looks very close to what I am seeing in game. In game I have vsync on and get around 60fps so its not exactly the same.

QualitySettings.vSyncCount = 0;
Application.targetFrameRate = 50
image

Setting the framerate somewhere between 30-60 seems to display the issue. It does not always show though... which is strange. Sometimes I had to change the framerate from 30 to 50 then let it compile then hit play and it happens, other times I set it to 30 and hit play and it seems smooth, but it is definitely easier to happen. It may also help to follow the sphere with the camera as it moves. Hardcoding this behavior in 4.15 does not seem to cause this problem.

Visual reference:
image

Whirlpool settings:
image

Sphere settings:
image
image

Hope this helps!

@Revmatek
Copy link
Author

Revmatek commented Oct 5, 2023

@daleeidd Were you able to reproduce this?

@Revmatek
Copy link
Author

Revmatek commented Oct 8, 2023

Here is a repro scene modifying the BoatWakes scene. Move the camera around and follow the cube. Its a bit goofy setup, but it took a while to repro in latest.

repro.zip

@daleeidd
Copy link
Collaborator

daleeidd commented Oct 9, 2023

I don't believe I was able to reliably reproduce it before, but I could with your scene.

Just to confirm the issue, is it only related to physics objects? Applying interpolation to the rigid body to the repro seems to be a pretty good workaround.

@Revmatek
Copy link
Author

Revmatek commented Oct 9, 2023

I don't believe I was able to reliably reproduce it before, but I could with your scene.

Just to confirm the issue, is it only related to physics objects? Applying interpolation to the rigid body to the repro seems to be a pretty good workaround.

Excellent, glad you are able to see the issue now.

It does seem directly related to being tied to a physics object and flow/foam. PhysX Interpolation is not an option and does not resolve the problems at runtime or in my project. Override foam on "static" objects or transform based movement seems to have less issue.

One bizarre note about this I have been seeing off an on is that solutions can be inconsistent, for example interpolation may momentarily appear to solve the issue the same way that reducing the flow speed or changing some other setting will, but it quickly goes back to vibration foam. Similar things happen when adding new foam to the scene or removing them while attempting to troubleshoot, almost seems like it changes the timing for the better momentarily, couldn't say for sure.

I would say its some sort of timing / update issue that is revealed by FixedUpdate behavior of some sort. Something in the execution order is moving the foam/flow back to where it was or predicting its location erroneously.

@Revmatek
Copy link
Author

Revmatek commented Apr 8, 2024

Any updates on this?

@daleeidd
Copy link
Collaborator

No. I noticed Follow Horizontal Motion is disabled for the foam input. Does enabling change anything?

@Revmatek
Copy link
Author

No. I noticed Follow Horizontal Motion is disabled for the foam input. Does enabling change anything?

It does not appear to have an affect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants