Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Graphics Hydroform Ocean Renderer [RELEASED]

Discussion in 'Tools In Progress' started by Xix-Interactive, Feb 11, 2016.

  1. Xix-Interactive

    Xix-Interactive

    Joined:
    Aug 26, 2015
    Posts:
    442
    Thanks for the feedback Frank - can you describe the viewing angles you are talking about? Is the camera high up or close to the water? Is there any roll on the camera? Is the ocean flickering, or is it gone for seconds at a time?
     
    Last edited: Aug 4, 2017
  2. franky_li

    franky_li

    Joined:
    Aug 8, 2016
    Posts:
    163
    I would make a video to show the issue, but after I installed the update again the problem seems to be gone. At the moment I can't reproduce it anymore. I'll keep an eye on it.

    Thanks for fast responds

    Frank
     
  3. Xix-Interactive

    Xix-Interactive

    Joined:
    Aug 26, 2015
    Posts:
    442
    If you could get a video of it if/when you see it again, that would be great!
     
  4. Coalex

    Coalex

    Joined:
    Dec 7, 2016
    Posts:
    11
    Hi there,
    I seem to be having a similar issue to the one listed above but not sure if its the same thing. It seems like the culling distance of the water is changing depending on the angle of my headset(this is a VR project). I have linked in a video of the issue.

    Cheers,
    Alex

     
  5. franky_li

    franky_li

    Joined:
    Aug 8, 2016
    Posts:
    163
    Ok, the problem started again, I made a video. There is an other issue as well, sometimes the ocean gets crazy, the water level goes up and the waves are getting much higher for a few seconds.
     
  6. Xix-Interactive

    Xix-Interactive

    Joined:
    Aug 26, 2015
    Posts:
    442
    It's hard to tell what's going on in that situation, it looks like the ocean culling is fine, but it's getting shaded oddly in the distance - is that green color what is underneath the water? Or is that the water? I see some of it in the foreground on the beach to the left.
     
  7. Coalex

    Coalex

    Joined:
    Dec 7, 2016
    Posts:
    11
    The green color is what is underneath the water yes. The green shapes above the water in the foreground are a known, unrelated issue with our terrain meshes. Its just the shader clipping in the distance that we're interested in
     
    Last edited: Aug 15, 2017
  8. Xix-Interactive

    Xix-Interactive

    Joined:
    Aug 26, 2015
    Posts:
    442
    OK and this is only occurring in VR mode? Is there any chance you could eliminate any camera roll in VR mode?
     
  9. Coalex

    Coalex

    Joined:
    Dec 7, 2016
    Posts:
    11
    No It happens regardless of whether it is in VR mode or not
     
  10. Xix-Interactive

    Xix-Interactive

    Joined:
    Aug 26, 2015
    Posts:
    442
    Cool, thanks for making a video of this!

    Could you try this modification?

    in HydroformComponent.cs, look for DrawMeshes() and change the line:

    void DrawMeshes()
    {
    Camera cam = GetCamera();


    to:

    void DrawMeshes()
    {
    Camera cam = Camera.main;

    and see if that makes any difference. Thanks!
     
  11. Xix-Interactive

    Xix-Interactive

    Joined:
    Aug 26, 2015
    Posts:
    442
    Hmm, I am baffled, never seen this and don't understand how it could be happening. What is your view distance?
     
  12. Xix-Interactive

    Xix-Interactive

    Joined:
    Aug 26, 2015
    Posts:
    442
    On the water going crazy, is this happening when the camera is high up? I know about that one and have it fixed and ready for the next update.
     
  13. Coalex

    Coalex

    Joined:
    Dec 7, 2016
    Posts:
    11
    We have a very far view distance because of the scale and purpose of our project. Our view distance is currently 50,000.
     
    Xix-Interactive likes this.
  14. franky_li

    franky_li

    Joined:
    Aug 8, 2016
    Posts:
    163
    This happens even in the position from where I made the video!
     
  15. franky_li

    franky_li

    Joined:
    Aug 8, 2016
    Posts:
    163
    Seems to make no difference, it's unpredictable, sometimes in the editor and sometimes in play mode.
    But I have tons of warnings 'Mesh doesn't have normals. Please create some for GI.' for Brim Mesh
     
    Last edited: Aug 15, 2017
  16. Xix-Interactive

    Xix-Interactive

    Joined:
    Aug 26, 2015
    Posts:
    442
    Ah OK, that's probably the reason, I'll try and reproduce with that distance.
     
  17. Xix-Interactive

    Xix-Interactive

    Joined:
    Aug 26, 2015
    Posts:
    442
    OK, what version of Unity are you using? What are your settings - deferred or forward rendering, HDR? Linear shading? Realtime GI turned on? Are you seeing this behavior in the demo tropical scene?
     
  18. alejandronop

    alejandronop

    Joined:
    Jul 7, 2017
    Posts:
    11
    Hello, I have had some problems that I will list

    1) When shorefx is activated the GetHeightAtPoint function gets the height as if shorefx were off, in the image you can seen, how far from the coast the height is correct.
    upload_2017-8-30_16-10-38.png

    2) Being on the coast and looking down are stretched pixels
    upload_2017-8-30_16-9-12.png
    3) The refraction effect is showing refraction in parts that are out of the water.
    upload_2017-8-30_16-11-36.png

    I'm using Unity 2017.1.0f3, Windows 10, 64bit

    sorry for my bad English
     
  19. Xix-Interactive

    Xix-Interactive

    Joined:
    Aug 26, 2015
    Posts:
    442

    Hi alejandronop, thanks for posting.

    1) I thought I had compensated for the shore falloff on the height query, but looking through the code it looks like I haven't done that yet. I'll try and get it in the next update.

    2) I actually have some code to fix this, I left it commented out for performance reasons and most people probably won't run into this issue. Look in WaterFunc.cginc in calcPixel() under refraction.

    Uncomment this code block:
    /*
    // fade out distortion at edge of screen - commented out because more expensive, looks nice though, allows for more distortion
    float4 screenPos = UNITY_PROJ_COORD( inData.screenPos ) / inData.screenPos.w;
    screenPos.xy = screenPos.xy * 2 - 1;
    refractDir.xy = refractDir.xz; // swizzle to get distortion on y screen axis
    refractDir.xy *= float2( 1, 1 ) - abs(screenPos.xy);
    */

    3)
    That looks like it's probably screenspace reflection, not refraction. Try changing the distortion value from 0.9 to 1.0 in the code right above the code block I posted in 2).



     
  20. alejandronop

    alejandronop

    Joined:
    Jul 7, 2017
    Posts:
    11
    Thanks for the answers. Now I have found other problems

    I put a rock in front of the island and enlarge it

    With the SSR reflect, it reacts as if the mesh was cut
    upload_2017-9-4_18-55-9.png

    With the planar reflex, it is as if from the height of the ocean to the height of the wave the reflection crosses the rock and lets see the island
    upload_2017-9-4_18-54-45.png

    If necessary, I would send the project to you.

    Thank you and again, sorry for my bad English
     

    Attached Files:

  21. Xix-Interactive

    Xix-Interactive

    Joined:
    Aug 26, 2015
    Posts:
    442
    Yes, those are known artifacts and issues with both of those reflection types - which will happen with any water system. SSR in particular is meant to be a "rough" reflection that is meant to be distorted. The planar reflection could probably be adjusted to "push up" or down depending on the wave height. Look in UpdateReflection() and try adjusting the "clipPlaneOffset", or moving the camera position up or down in that function.
     
  22. Coalex

    Coalex

    Joined:
    Dec 7, 2016
    Posts:
    11
    Hi There,
    Is there any way to force an update of the water height through code? I am wanting to have a sped up tidal effect in my project, however the water seems to only update its height every second which causes it to jump up and down.
    Cheers,
    Alex
     
  23. Xix-Interactive

    Xix-Interactive

    Joined:
    Aug 26, 2015
    Posts:
    442
    Hi Alex,

    Yes, you want to move this line of code from PeriodUpdate() to LateUpdate() in HydroformComponent.cs.

    Shader.SetGlobalFloat( "_HydroWaterHeight", waveSettings.waterHeight );


    PeriodUpdate sends updates to the shader once a second rather than every frame for performance reasons. It shouldn't hurt performance to move a few things out of there though.

    -Brian
     
  24. wwg

    wwg

    Joined:
    Apr 2, 2014
    Posts:
    130
    Hi. Can anyone comment on how Hydroform fps performance compares to other water assets (specifically, Suimono and Aquas)?

    Thanks!
     
  25. Xix-Interactive

    Xix-Interactive

    Joined:
    Aug 26, 2015
    Posts:
    442
    Aquas is going to be faster than Suimono or Hydroform because it's just a flat polygon. If you want waves, there is a performance drop, but it's well worth it IMO.
     
  26. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,617
    I've just installed the latest update from the Asset Store, and am now having issues.

    The ocean is now consistently visible in the Editor except with really fast camera movement, which wasn't the case before the update. However, in Play mode it just disappears based on camera direction. Moving the Ocean GameObject around can make it re-appear again, so I'm guessing that this is a culling issue?
     
  27. Xix-Interactive

    Xix-Interactive

    Joined:
    Aug 26, 2015
    Posts:
    442
    It's either culling, or the way I'm caching the last camera is bad. Are you using one camera in your scene? One thing you could try that would help me debug this would be to put "return Camera.main;" at the top of the GetCamera() function in HydroformComponent.cs.
     
  28. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,617
    There are multiple cameras, but only one needs to show the ocean. Nonetheless, I did find when I originally set up Hydroform that I needed to put your multi-cam component on all of the cameras.
     
  29. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,617
    Coming up shortly...
     
  30. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,617
    Ok, a very quick test looks like that's working as expected in Play mode again. The Scene view now only occasionally shows the ocean.

    Personally I'd be happy with specifying the camera that needs to show the ocean, and might even modify the code accordingly. I can probably even get it to look up either my specified camera or the Editor's scene camera depending on Application.isPlaying.
     
  31. Xix-Interactive

    Xix-Interactive

    Joined:
    Aug 26, 2015
    Posts:
    442
    Right, OK, so that "fix" works? I do wish Unity's Camera.current would simply return whatever the active camera in the scene happens to be. Or offer a function that does that.

    It sounds like you have both the scene view and play view on the screen at the same time? The patch geometry is created for the 'play' camera when Application.isPlaying, and Camera.current otherwise I believe. If you want it to run on both windows at the same time, you'll have to modify that. I'm not sure it will work, but you could try.
     
  32. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,617
    I'll have to test a bit more thoroughly, but it seems to.

    When I'm developing, yeah, regularly.

    That's not really a priority for me, one at a time is fine.
     
  33. Beloudest

    Beloudest

    Joined:
    Mar 13, 2015
    Posts:
    247
    I'm giving this a run with VR, in particular the Vive and it does not seem to support it well. When I move my head around weird artefacts appear after a of short a time on the tropical island mode. Essentially the refraction's appear to move in the wrong direction and the shorelines disappear and weird artefacts appear else where. Have you any suggestions please, I assume there is some issues with positional and rotational calculations? Thanks
     
  34. Xix-Interactive

    Xix-Interactive

    Joined:
    Aug 26, 2015
    Posts:
    442
    Are you using single pass or stereo rendering? Some people have reported problems with single-pass, if you are using that, would it be possible to see if it works properly in stereo?
     
  35. Beloudest

    Beloudest

    Joined:
    Mar 13, 2015
    Posts:
    247
    It's much better in Multi, essentially the shoreline disappears very quickly after the scene loads in single pass but you do see it. Single Pass would be so awesome if you can make it work, it makes a huge difference to VR games.
     
  36. Xix-Interactive

    Xix-Interactive

    Joined:
    Aug 26, 2015
    Posts:
    442
    OK, thanks much for the info! Yes I really need to get a rig to see if I can figure out the issue. I hoping to get one in the next few months, see if the Microsoft VR drives down prices for Occulus and Vive.
     
  37. Beloudest

    Beloudest

    Joined:
    Mar 13, 2015
    Posts:
    247
    Its the Steam VR causing problems.
     
    Last edited: Oct 12, 2017
  38. Xix-Interactive

    Xix-Interactive

    Joined:
    Aug 26, 2015
    Posts:
    442
  39. Beloudest

    Beloudest

    Joined:
    Mar 13, 2015
    Posts:
    247
    Maybe using the new Mock HMD feature in unity 2017.2. In the end I fixed it, essentially the Steam VR render script does some strange positional offsets that cause issues. Everytime I tried to move my Steam VR render gameobject to the same position as the player cam it would always offset back to its original position of y = 340. Oddly I unparented the Steam VR cameras, put its position back to 0,0,0 and then parented it again and all my issues stopped.
     
  40. Beloudest

    Beloudest

    Joined:
    Mar 13, 2015
    Posts:
    247
    As a suggestion you need to put in a feature to ignore cameras. I've had to do that myself so other cameras dont conflict with the ocean script stuff so you know.

    Also I have noticed some weird graphical bugs caused by things happening in the editor and in game which make it unusable for my game which I'm sure can be fixed somehow. Maybe you can look into this one:

    When Reflection probes render they cause the ocean to disappear and flicker. This happens really badly if you capture in real time every frame but even when capturing at intervals it looks really bad.

    Here is a video example:

    https://www.dropbox.com/s/ratlhfnz2yot27w/Unity 3D 10.12.2017 - 14.29.34.06.mp4?dl=0

    It would be great to fix this asap, otherwise everything works great now. Thank you, the ocean looks nice when its stable. Here to help PM me if you like.
     

    Attached Files:

  41. Beloudest

    Beloudest

    Joined:
    Mar 13, 2015
    Posts:
    247
    I've found the problem. That issue with reflection probes is because they have a camera hidden in the gameObject and the position of it messes up frustum calculations on Ocean script. I think you either need an ignore camera list or a render cam list in the ocean script to help clarify it all. This way other cameras have no chance of breaking the ocean script. It seems much of my trouble is caused by this. Thanks, hope that helps you.
     
    Ostwind likes this.
  42. Xix-Interactive

    Xix-Interactive

    Joined:
    Aug 26, 2015
    Posts:
    442
    Thank you so much for figuring this out! I'm buried in work at the moment, but I'm looking forward to digging in and fixing these issues, especially VR.

    So it seems like the safest thing to do is have the user put a script on each camera in the scene, and then have the ocean do frustum calculations only from one of those cameras. Does that sound reasonable?
     
    hippocoder and Beloudest like this.
  43. Xix-Interactive

    Xix-Interactive

    Joined:
    Aug 26, 2015
    Posts:
    442
    A new version is out to address the ocean sometimes popping out of view and hopefully fix some issues with VR cameras. Please let me know how it works!
     
  44. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    @Xix-Interactive Hello, I'm currently trying to integrate Hydroform to Ghost of a Tale and I have to say it looks wonderful!

    I did meet a couple of issues though. Some of them have already been reported I believe:

    - There is a "striping" effect on the reflected meshes using the SSR which becomes worse depending on the steepness of the meshe's angle. Would you have any ideas as to lessen the issue?

    - The refraction setting causes a tearing artifact on the bottom (but sometimes sides) of the screen, depending on how close to the water the camera gets. Note that the artifact is clearly visible even if the camera is one or two meters above the water level. It only goes away completely if the camera is perpendicular to the water, looking down.



    - At night (I'm using a version of uSky) the overall specular/fresnel effect makes it look like the water surface is glowing. Is there a way to fix that? Or at least a way to dial it down progressively at night via code?

    - Finally my biggest issue so far: Hydroform doesn't seem to play nice with SSAO. I'm using Sonic Ether's SSAO and it looks terrible, as if the SSAO gets inverted and applied to the whole screen. Would you have a solution for that problem, please? Or could you suggest a good SSAO asset which works with Hydroform?

    FYI: I'm on Unity 5.5.3p4 (Windows), DX11, Linear, Deferred.

    Cheers!

    Update:
    I found a solution for the SSAO: I just changed to SSAOPro and that takes care of the issue. However the effect currently applies to things that are under the water surface and that looks a bit odd. I wish there was a way to not apply the SSAO effect for meshes that are under the water "plane", as if the water was considered opaque.

    Oh, and I just wanted to add that I really like this asset. It's not overly complex yet it gives me enough control to tweak the result to my liking and the tool tips are super useful. Nice job indeed!
     
    Last edited: Oct 20, 2017
  45. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    So after testing some more I got a couple of warnings and errors after doing a build (Windows standalone):





    Would you mind taking a look at those, please?

    Also I managed to largely alleviate the issue I was mentioning about the reflection/Fresnel that makes the water too bright in low-light conditions (at night) by plugin my own animation curve into the script which dampens water color, foam, etc... based on the time of day. So that's neat.

    Now another issue I noticed (linked again to the SSR effect) is there seems to be a squarish halo around the main character where nothing is reflected (you can also see the artifact I mentioned in my previous message at the bottom of the picture):



    I tried in-game to change the layer mask of the orthographic camera (inside the water prefab) but nothing changes at all. Which makes me think that you might cache this layer mask at game start and don't refer to it in real-time anymore (but I could be wrong).

    Another question for you: is there a way to reduce the distance at which the water is rendered? Just in case you'd like to use it for smaller water bodies and don't need to have the whole screen filled out.

    Final question: do you think you could add physical interaction with the water? By that I mean normal-map trails in the water (not necessarily tessellated). It would bring a lot to what is already a very sweet-looking asset.
     
  46. Xix-Interactive

    Xix-Interactive

    Joined:
    Aug 26, 2015
    Posts:
    442
    Hi Seith,

    Thanks for all the feedback!

    So for the SSR, I'm using a fast and primitive technique that is not intended to be a perfect reflection, but to be distorted. If you want a perfect reflection, switch to planar reflections.

    To fix the refraction tearing, look in WaterFunc.cginc at #ifdef HYDRO_REFRACTION around line 550. Uncomment the section of code saying "fade out the distortion at the edge of screen". Forgot to do that in the latest patch.

    Yeah there currently is not a day/night adjustment for color, but you can DIY by modifying the water colors directly in script, sounds like you figured that out.

    That error talking about too many instructions - look at getHeightFromTex() in WaterFunc.cginc and replace numOctaves in the loop with a hard-coded '4' or whatever value you are using. If it continues to persist, it's because Unity is targeting dx9 in the compile. I forget how to fix off the top of my head, google it or try playing with the #pragma targets in Water.shader (and Brim and Octave).

    That square being rendered looks like what happens when some other asset is rendering the water with an override. Are you using the latest version of Hydroform?

    There is not currently a way to draw lakes with Hydroform. That's something I'd like to do in the future after underwater rendering and VR support. Physical interaction would come after getting lakes running ;)
     
  47. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Thanks for your reply!

    So I followed your instructions for the tearing issue and that's fixed, cheers!

    Regarding planar reflections I think there might be a problem somewhere because when I activate it there's absolutely no reflections at all (same as if both reflection boxes were unchecked). Only SSR shows reflections.

    Yes, I'm indeed using the latest version of Hydroform.

    Also, how can I know how many octaves I'm currently using? What does it correspond to in the Hydroform inspector?
     
  48. Xix-Interactive

    Xix-Interactive

    Joined:
    Aug 26, 2015
    Posts:
    442
    The number of octaves corresponds to 'pix complexity' under Wave Settings. I would not recommend setting it above 4.

    That's odd that planar reflections aren't working for you. Turn them on and set a breakpoint in UpdateReflection() in HydroformComponent and see if it's returning out of the function before rendering.
     
    Seith likes this.
  49. KevinCain

    KevinCain

    Joined:
    Nov 8, 2016
    Posts:
    85
    Hoping it's useful to others, I downloaded a clean update today (Nov. 1 2017) and found the water surface invisible in both editor and game views. This is true for both clean scenes and all the demos -- e.g., in the 'boxes' demo, only the boxes are visible, though they ripple correctly for the invisible water floating them.

    Applying the explicit camera return suggested by @Xix-Interactive (see above) worked for me, e.g.:

    Camera GetCamera()
    {
    return Camera.main;

    /*
    if ( Camera.current != null && mCurCam != Camera.current )
    {
    mCurCam = Camera.current;
    }

    return mCurCam;
    */
    }
     
  50. KevinCain

    KevinCain

    Joined:
    Nov 8, 2016
    Posts:
    85
    I see the demos showcase close-up water effects; does anyone have experience with Hydroform in scenes with relatively distant shorelines of the kind shown below?

    In particular, I see that 'Shore FX' is constrained to a square that moves with the render camera, creating an obvious discontinuity when the camera lifts beyond close range (see the top image of the two below) and at loftier aerial views the illusion is entirely absent, along with any trace of motion (as in the bottom of the two images):



    The kinds of camera views I'm using are shown below. At these distances from the water surface, I can't find a combination of the exposed controls that lead to anything but a flat, repetitive look:



    I realize I could start from scratch on a shader meant to render water at a distance, but it would be silly to abandon Hydroform before the community has had a chance to make a case for it here.

    Thanks for any experiences that you think relevant...
     
    IronDuke likes this.