Search Unity

Ceto (Scrawks Ocean)

Discussion in 'Assets and Asset Store' started by scrawk, May 4, 2015.

  1. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    @sadicus : There will be some helper script to make this easier in the future. Once thats done I will add some tutorials to the manual.

    @lazygunn: I had a look at a faceted shader yesterday but the idea I had didnt work. Thats the only idea I had so Im not sure how to do that effect to be honest.
     
  2. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    the faceted look is achieved by splitting verts on a mesh so there is no smoothing, i was wondering if it were possible to do this with the projected grid - it work as usual but triangles no longer share an edge, i figured itd be be better to do in script on the generation of the grid rather than in a shader
     
  3. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Thats pretty much what I tried but splitting the mesh verts will only have that effect if the ocean color is done per vertex. The current shader for the ocean does everything per fragment and because of the complexity of the ocean shader just moving stuff from the frag to vert shader doesnt work.

    Its probably possible to redesign the shader to do this but it would take a while.
     
  4. DivergenceOnline

    DivergenceOnline

    Joined:
    Apr 19, 2015
    Posts:
    244
    I appreciate the recommendation about the opaque shaders, but if I wanted a water surface that couldn't even transparency blend I wouldn't have paid $80 for this one.

    Added that script like you mentioned also to the main camera but it unfortunately had no effect at all. Is it possible there was something missing from it?
     
  5. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    The ocean will still look transparent even if the opaque materials are used. Its just the position in the render queue that changes.

    If your not happy with it I have no problem approving a refund.
     
  6. DivergenceOnline

    DivergenceOnline

    Joined:
    Apr 19, 2015
    Posts:
    244
    Then something must have went wrong because this is all i get with the opaque materials - Things beneath the water just appear black then fade to white like in the image.
    I read where you were talking to the other guy above about the colorspace - Just so you know we use legacy-deferred dx9 Linear.

    Screenshot 2015-10-29 14.31.27.png
     
  7. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Thats fair enough, i think im going to try using a very large overlay with a faceted pattern on it to modulate wave height, might do the trick (Actually could possibly get some really kooky looks with that)
     
    twobob likes this.
  8. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Can you go to the underwater component on the ocean game object and make sure you have the depth mode set to USE_OCEAN_DEPTH_PASS and the ocean depths mask is set to everything please. It has to be that mode for the opaque materials.

    I just checked my demo scene and looks like it works with legacy-deferred but if you do have USE_OCEAN_DEPTH_PASS selected and its still not working for you then it may well be some to do with legacy-deferred.

    It does look like the underwater effect in legacy-deferred is a bit darker than normal. You may have to adjust some settings to get the ocean to look more transparent.

    If so try these settings on the underwater component (presuming changing the depth mode worked).

    Set the above absorption modifier scale from 2 to 0.1.

    Set the above inscatter modifier scale from 300 to 100.

    You may aslo need to increase the refraction intensity slider.
     
    Last edited: Oct 30, 2015
  9. clickmatch

    clickmatch

    Joined:
    Dec 3, 2012
    Posts:
    58
    Don't let that stop me from spending a half hour ignoring the "Alpha from Grayscale" thing and just about tear my hair out, until I re-read your instructions. This is awesome. Thanks for spelling it out for me John.
     
    John-G likes this.
  10. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Ive had a thought really that the ocean frag shader could be completely replaced, so id be working with a faceted ocean mesh but a shader of my own, or adjusted from one of the neat npr shader things i have. Or if there are considerations regarding the overlay system, which id like to keep, i could replace things relating to the appearance of the ocean but keep things like the clipping

    If it would be possible to say how i might be able to produce the mesh in this faceted manner, assuming you had that part nailed that would be greatly appreciated. I'm not the sharpest in the book and i do have a function to take a mesh and split the verts after the mesh was generated, and i'll try that out as a recourse, but i figured you might have a more graceful approach

    Edit: should this work out ill also be looking into getting reflections via ssr as well as planar and skybox reflections if possible. All in all i could probably do what im aiming for myself but am asking about it before diving into a lot of unfamiliar code
     
    Last edited: Oct 31, 2015
  11. vampir26

    vampir26

    Joined:
    Mar 29, 2010
    Posts:
    108
    Hi

    I bought Ceto and I'm very happy with the result. I just one question:

    I could not figure out, how I can blend the edges (make it a little bit transparent to soften the hard line).

    Thanks for your advice!

     
  12. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Thanks.

    Yes, the edges are quite hard at the moment.

    There's nothing in the shader to blend them at the moment but it will be added in a future update, most likely the next one.

    You may be able to lower the above absorption modifier scale and increase the refraction intensity on the underwater component on the ocean to help get the edge color to match the terrain.

    It may help but the edge will still be a bit hard until the alpha blend is added.
     
  13. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804

    I'm sorry but this is going to be really hard with the way the projected grid works and I don't think its possible at the moment.
     
  14. kideternal

    kideternal

    Joined:
    Nov 20, 2014
    Posts:
    82
    @vampir26, my shore edges aren't nearly that hard. I can't figure out what you're doing differently. Perhaps make your shore edges less steep?

     
    Peter77 likes this.
  15. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    I think his ocean color is much darker making the edge more visible.
     
  16. Saevax

    Saevax

    Joined:
    Nov 3, 2012
    Posts:
    58
    Truesky was mentioned for solving the problem where the ocean doesn't meet the horizon at large heights, is that the only solution?

    Also fog doesn't seem to work underwater.
     
    Last edited: Nov 2, 2015
  17. vampir26

    vampir26

    Joined:
    Mar 29, 2010
    Posts:
    108
    @kideternal, smoothening the terrain take no effect. I use nearly the same values than in original values. Your ocean is very beautiful :) like to have your color...

    Have no idea why my shorelines are hard. I moved for testing every lever, value and color.
     
  18. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    If you change the refraction values right at the bottom you should be able to control the transparency of the ocean completely. Trading off changing that with the inscatter values should let you tune your ocean a bit
     
  19. kideternal

    kideternal

    Joined:
    Nov 20, 2014
    Posts:
    82
    @vampir26 I'm using linear lighting, HDR, and DX11 if that helps.
     
  20. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Another thing to make sure of/test is there being a surface underneath the ocean surface. I place a very large plane as a 'sea bed' which seems to help a lot in terms of appearances
     
  21. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    I cant remember that coming up but if your making something like a flight sim where the camera is higher above the ocean you need a sky the will have the horizon at the correct level. Not all of them do. Its not the ocean that's not at the horizon, its the sky box. I think true sky works but Im not sure.

    By fog do you mean the underwater post effect? or the normal unity lighting fog?

    The underwater post effect will render over the top of the normal fog so you wont see it under water.
     
  22. sadicus

    sadicus

    Joined:
    Jan 28, 2012
    Posts:
    272
    Ceto - How get DX11 running in Unity 5.2?
    Ceto + UFPS (visionPunk) i've been getting strange results with underwater camera and it might be linked to not having the correct DX installed.
    dxdiag says DX12
    Unity says<DX9>
    @John G Thanks for the shoreline tutorial, works great!
     
  23. vampir26

    vampir26

    Joined:
    Mar 29, 2010
    Posts:
    108
    Thank you! Now, my ocean looks much better :)
     
  24. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    I set you a email but I think the underwater issue is because your still on the previous version of Ceto (1.0.6). You need to update to 1.0.7. The scene view will still go black if you click on the camera though. Not sure whats causing that at the moment.
     
  25. Saevax

    Saevax

    Joined:
    Nov 3, 2012
    Posts:
    58
    I'm making a simulator with a free camera that can go above and below the ocean. However I need to maintain a long view distance even underwater so I'm not using the underwater effect. I am not sure how to adjust the skybox and fog to match the ocean's horizon at various y values.
     
  26. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    I had disabled the fog in the under side shader which is why its not showing up for you.

    Can you go to the OceanUnderSide_Transparent and OceanUnderSide_Opaqe shaders in the Ceto/Shaders folder and open them up.

    The tags will look like this.

    #pragma surface surf OceanBRDF nofog noforwardadd nodynlightmap nodirlightmap keepalph

    Can you remove the nofog bit.

    You can change Cetos underwater fog if you want. Its the Below inscatter modifier on the underwater script on the ocean that controls it. Just decrease the scale and maybe change the mode.

    Theres nothing I can do for the issue with the sky box. If the ocean wasnt in the scene and you just had a flat plane or a large terrain that went to the horizon you would still have the same issue. Its due to the way cube maps are sampled. The just dont match the horizon when the cameras y value is not 0.

    You need to use a sky the uses a different method like a sky dome. They should match the horizon better. It might be worth asking one of the sky assets publishers on the forums if they know a solution to this issue. They should have a better idea than me.
     
    Last edited: Nov 4, 2015
  27. sadicus

    sadicus

    Joined:
    Jan 28, 2012
    Posts:
    272
    Will anyone confirm if Ceto + UnitySky Alpha work together?
     
  28. UniqueCode

    UniqueCode

    Joined:
    Oct 20, 2015
    Posts:
    65
    Is there a way to compute the height values without any reference to unity libraries? I need an approximation of the height on the server (pure C#, because I'm a masochist).

    Thank you :)
     
  29. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Im not sure what you mean by 'without any reference to unity libraries'. Surely your server is still going to have Unity installed and running a scene with Ceto in it?

    You can get the height at any location by using Ceto's wave query like so...

    Code (CSharp):
    1.  
    2.  
    3. float h = 0.0f;
    4. if(Ceto.Ocean.Instance != null)
    5.         h = Ceto.Ocean.Instance.QueryWaves(x, z);
    6.  
    Where x and z is the world space position.

    The ocean instance will be null if Ceto is not in the scene or the ocean is disabled so its good practice to check if its null.

    If your running Ceto on a sever you need remove the ProjectedGrid, PlanarReflections and UnderWater components on the ocean as they are only needed for rendering the ocean.

    You only need the Ocean and WaveSpectrum component to generate the wave data. You can also tick disable slopes and foam on the spectrum as they wont be needed.
     
  30. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    @clickmatch are you still having issues with UFPS after the last Ceto update or is everything working fine?
     
  31. clickmatch

    clickmatch

    Joined:
    Dec 3, 2012
    Posts:
    58
    The problem was advanced shooter kit, which I don't think resolved (weapon cam vs main cam). I've since got UFPS, but have not tested it with Ceto at all. I don't really have a true active project at the moment, those things were experiments.
     
  32. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Ok, thanks. Thought it was UFPS. I think it will still have the same issue with weapon vs main cam.

    Will try and have that fixed for next update.
     
  33. InfiniteDice

    InfiniteDice

    Joined:
    Jun 30, 2015
    Posts:
    44
    Hi Scrawk,

    I'm doing the standard query for wave height, however I'm adding a wave overlay with a height texture and mask with Ignore Queries unchecked.

    My floating object seems to ignore this and continues to float at the normal wave level.

    I've had success with the shore mask... that deadens the waves and floating objects respond accordingly.

    Thanks :)
     
  34. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Hi,

    Do you have have read/write enabled on the texture used for the height and mask?

    Go to the texture, set its type to advanced to have a look.

    If check textures is ticked on the overlay script there should be a warning printed out if this is not ticked.

    If thats not the issue you may have to post a screen shot of the textures advanced setting so I can see if theres anything that sticks out.
     
    Last edited: Nov 6, 2015
  35. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Everyone, there is a bug with the normals in the under side shaders causing a variety of issues like dark marks on the underside surface when under the water looking up. It is most noticeable against the terrain and looks a blue color.

    To fix it go to the OceanUnderSide_Opaque and OceanUnderSide_Transparent shaders.

    In the frag shader there should be this line

    Code (CSharp):
    1.            
    2. half3 view = normalize(_WorldSpaceCameraPos-worldPos);
    3. float dist = length(_WorldSpaceCameraPos-worldPos);
    4.  
    add this line under it so the code now looks like this

    Code (CSharp):
    1.  
    2. half3 view = normalize(_WorldSpaceCameraPos-worldPos);
    3. float dist = length(_WorldSpaceCameraPos-worldPos);
    4.  
    5. if (dot(view, norm) < 0.0) norm = reflect(norm, view); //add me
    6.  
    This will be fixed in next update.
     
    hopeful and John-G like this.
  36. UniqueCode

    UniqueCode

    Joined:
    Oct 20, 2015
    Posts:
    65
    Hi scrawk,

    thanks for the reply. I ment without Unity at all. Looking through the code, it uses rendertextures and what not, but the math itself might be usable. At least an approximation. As a fallback, I'll use one seperate unity instance just the query the height values, but as no other instance uses Unity that would be quite ugly.
     
  37. InfiniteDice

    InfiniteDice

    Joined:
    Jun 30, 2015
    Posts:
    44


    More footage from development with Ceto!
     
  38. karmacomp

    karmacomp

    Joined:
    May 2, 2014
    Posts:
    43
    Looks really good.

    Mike
     
  39. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Im very impressed!
     
  40. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    The issues with the reflection brightness should be fixed in the next update.

    The problem was since a reflection camera renders them and then they get applied to the ocean means they basically get a double dose of lighting.

    This was causing the skybox in the reflections to be to bright and had to be scaled down with the intensity slider but doing this made the other objects in the reflections to be to dark.

    The solution was to not apply the diffuse light to the reflections on the ocean..

    I should also point out that due to they way the Fresnel works the reflection of objects close to the camera are always going to be darker.

    Here you can see how the reflections are currently. There is a mismatch between the brightness of the sky vs the terrain.

    SkyBefore.jpg

    And here you can see them with the fix. The brightness of the sky match the brightness of the terrain. The

    SkyAfter.jpg
     
    hopeful likes this.
  41. dradb

    dradb

    Joined:
    Jan 10, 2015
    Posts:
    86
  42. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
  43. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    @vampir26 A edge fade has been added and will be in the next update.

    Since it uses a alpha blend its only for the transparent materials which are used by default.

    BeforeBlend.jpg

    AfterBlend.jpg

    If anyone wants to try it now just add this function to the above transparent shader
    Code (CSharp):
    1.  
    2. /*
    3. * Returns a blend value to use as the alpha to fade ocean into shoreline.
    4. */
    5. float EdgeFade(float4 screenUV, float3 view, float3 surfacePos, float edgeStr)
    6. {
    7.  
    8.    float edgeFade = 1.0;
    9.  
    10. #ifdef CETO_UNDERWATER_ON
    11.  
    12.    //Fade based on dist between ocean surface and bottom
    13. #ifdef CETO_USE_OCEAN_DEPTHS_BUFFER
    14.    float surfaceDepth = (surfacePos.y - Ceto_OceanLevel) * -1.0;
    15.    float oceanDepth = tex2D(Ceto_OceanDepth, screenUV.xy).x * Ceto_MaxDepthDist;
    16.    float dist = oceanDepth - surfaceDepth;
    17. #else
    18.    float db = tex2D(Ceto_DepthBuffer, screenUV.xy).x;
    19.    float y = WorldPosFromDepth(screenUV.xy, db).y;
    20.    float dist = surfacePos.y - y;
    21. #endif
    22.  
    23.    dist = max(0.0, dist);
    24.    edgeFade = 1.0 - saturate(exp(-dist * edgeStr) * 2.0);
    25.  
    26.    //Restrict blending when viewing ocean from a shallow angle
    27.    //as it will cause some artifacts at horizon.
    28.    float viewMaskStr = 10.0;
    29.    float viewMask = saturate(dot(view, fixed3(0, 1, 0)) * viewMaskStr);
    30.  
    31.    edgeFade = lerp(1.0, edgeFade, viewMask);
    32.  
    33. #endif
    34.  
    35.    return edgeFade;
    36. }
    37.  
    and use the return value as the alpha

    Code (CSharp):
    1.  
    2. o.Alpha = EdgeFade(screenUV, view, worldPos, 4.0);
    3.  
    And you will need to change the first pragma in shader to this...

    #pragma surface surf OceanBRDF noforwardadd nolightmap keepalpha alpha:blend

    EDIT - fixed function to work with both depth modes
     
    Last edited: Nov 9, 2015
  44. dradb

    dradb

    Joined:
    Jan 10, 2015
    Posts:
    86
    Thanks scrawk. All the NeoOcean description says is "IOS and Android Mobile Platform Supported". Ceto (the free early version at least) just shows a blank plane on my Android mobile.
     
  45. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    @veddycent: That bug with the reflection blur in deferred/linear has been fixed and will be in next update.

    If you need a fix you can change line 336 of the PlanarReflection script to this

    Code (CSharp):
    1. if (isHdr || QualitySettings.activeColorSpace == ColorSpace.Linear)
    Enabling hdr on the camera will also fix it.
     
    veddycent likes this.
  46. InfiniteDice

    InfiniteDice

    Joined:
    Jun 30, 2015
    Posts:
    44
    Yes that seemed to fix it on a different mask texture. On the other texture still not working, but that's fine I'll make a new texture anyways...

    One last question which I think you might have answered before: How can I increase the range for the alpha value? Currently it's limited to 10, I might need from 15 - 30. I checked the script but not sure what's controlling/restricting the slider/max value.

    Thanks!
     
  47. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Also make sure the mask is in the alpha channel. I just make them as grey scale in photoshop and then tick the alpha from grey scale in unity.

    To increase the overlay height limit you need to increase the range of the slider and then increase the max allowable value. I have this a bit low as increasing it can cause issues with the projection. You may notice the mesh resolution decreasing as this value increases. 15-30 should be fine. I might increase it to this in next update.

    To increase the slider range go to the Ceto/Scripts/Ocean/Overlays/OverlayTexture.cs script and change the alpha range on line 14.

    Then go to the Ceto/Scripts/Ocean/Ocean.cs script and change the MAX_OVERLAY_WAVE_HEIGHT value on line 69.
     
    Last edited: Nov 10, 2015
  48. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    @sadicus: I looked at the UFPS with Ceto underwater post effect issue today.

    You need to have a look in the UFPS online manual about Image Effects. Because of the way the weapon cam works UFPS does not support certain images effects in deferred rendering.

    For example here is a quote about the standard global fog script which works the same as Cetos underwater effect

    So basically You need to attach the UnderwaterPostEffect script to the FPSCamera object (not the weapon cam or the player parent object) and it will only work in forward rendering which I have tested and it seems to work fine for me.

    Also on a unrelated issue if you have the underwater mode to USE_OCEAN_DEPTH_PASS then you may see the issue in the image.

    The weapon must be excluded from the 'Ocean Depths Mask' mask on the underwater script. The layer they use is hidden so you need to select nothing on the mask and then just select default.

    UFPSIssue.jpg
     
  49. InfiniteDice

    InfiniteDice

    Joined:
    Jun 30, 2015
    Posts:
    44
    Okay great, yes the projection works up to about 30 - 45m then the float altitude becomes separated from the visual water level. Is this a floating point limitation? This should work for what I'm trying to accomplish, though I can think of a few neat ideas where having a better range would increase the ease and the coolness factor even more. :)
     
  50. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Float precision is a factor but there are other issues which are a bit hard to explain. 30m will most likely be the limit that this will work. I might be able to improve it a bit but cant guarantee it.

    If you using a GPU fourier size and have disable read back ticked then let me know as this is the least optimal setting for the projection but you can manually tweak some things which might allow you to increase the limit.

    Im going to do a special section in the manual at some point that explains the projection and its limitations.

    Also, increasing the size of the overlay height buffer might help. Go to the ocean component and change the height overlay size from half to full. Probably wont help but worth a try.
     
    Last edited: Nov 10, 2015