Search Unity

Realistic Water

Discussion in 'Assets and Asset Store' started by kripto289, Mar 21, 2015.

  1. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    1) It is necessary to increase in proportion to the number of polygons and texture tiling/waves scale. Usually, a large area is created by projection of the grid.
    If you make a few plane with different numbers of polygons, then you can create a lod.
    2) Now I tried to glue multiple planes. At a certain angle, the edges is not correct distorted. I'm not sure what is the reason. Perhaps a more detailed meshes this problem will not be.
    If I can find a reason not correct distortion at the edges, the next update will fix it.
     
  2. DesertRaven

    DesertRaven

    Joined:
    Jul 15, 2012
    Posts:
    137
    How hard/easy is it to apply to a custom mesh? E.g. a pool water surface that has a 2D shape? I'm also thinking would it be a good idea to create 3 different main types of water, like for rivers - lakes, pools, ponds - and ocean? Make it so the ocean water comes with a plane, the river and lake, pools and river water as a drag and drop on object kind of thing?
    I've got this one on my wishlist, trying to find a good looking, flexible and easy to use water system.
     
  3. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    My water works the same as water4. You can also easily change the mesh to any other, and set flow and water form.
     
  4. DesertRaven

    DesertRaven

    Joined:
    Jul 15, 2012
    Posts:
    137
    Is this in C# or JS?
     
  5. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    I use two scripts in C #, to create a camera of reflection and refraction (for mobile).
     
  6. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    A flow map/direction map would be especially useful for doing shores with this I think as its currently tricky to get the water behaviour down properly on things like direction - it would great to lerp between directional shore waves and more confused waves with a map
     
  7. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    @kripto289 Do you think it would be possible for you to implement some kind of displacement based on collision? I mean for example to detect the player walking in water and create a little disturbance around him?
     
  8. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    I thought about it and found several methods. I was trying to make waves as meshes, but it does not look right. I tried to draw the waves on height map, but it's too slow.
    I could not find more information, and left it for the future.
     
  9. mangax

    mangax

    Joined:
    Jul 17, 2013
    Posts:
    336
    i like this asset, the mobile version works at acceptable frame rate.. specular effects generally for both pc and mobile is underwhelming ... i hope there is some sort of specular effect on mobile, as they don't exist! even if it is a cheap effect..

    i have the following issues attached in images , desc below it>>

    issue.jpg

    am working on mobile project, in editor the Caustic PC version doesn't seem to work well with the water mobile shader??.. as you can see there are square areas indicate missing parts?

    moreover on second image below it the Caustic mobile shader as i pictured it below water surface from scene view.. it is there. but it doesn't show up at all from game default camera, and it doesn't show up as well on mobile builds as well, this is a main issue am facing..

    am using unity latest build and project build is set to android.
     
    Last edited: Apr 22, 2015
  10. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    Yes, it's a bug.
    Open shader "waterMobile" and replace

    Code (CSharp):
    1. Tags {" RenderType "=" Opaque "}
    2. Cull Off
    3. // ZWrite On

    to

    Code (CSharp):
    1. Tags {" Queue "=" Transparent "" RenderType "=" Opaque "}
    2. Cull Off
    3. ZWrite Off
    4.  
     
  11. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Hello kripto289,

    This is the most beautiful water I have seen in the asset store! Congratulation. I work with Unity3d 5 Pro version. I have a question before I buy your wonderful asset. I am working on a project for Consoles. All the action happens underwater in the ocean, and I have been looking for the best looking water around. Does your water has some sort of underwater fog? Does it works with Unity fog? I need an underwater atmosphere as you can imaging. I love the caustic effect you have going on there. But I need a fog that give me depth from underwater. Please let me know.

    Regards,
    Carlos
     
    hopeful likes this.
  12. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    I hope I understand you correctly.
    Underwater effect I have not done. But with Unity fog water works something like this.
    sdf.png
     
  13. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Hello kripto,

    I bought the asset! It is great. I have a question for you, could you tell me how could I create this as an infinite water? also is there a shader or something for good godrays passing through the surface into the water?

    Regards,
    Carlos
     
  14. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    Infinite water make using projected grid. Such as in cryengine. I still did not go into the details of how it works.
    About godrays. Have you tried using the standard godrays?
     
  15. mangax

    mangax

    Joined:
    Jul 17, 2013
    Posts:
    336
    after trying the fix, it worked well with Caustic pc, but Caustic mobile still not showing..
    also as i rotate camera around, it seems Caustic mobile works at certain angels , but not all angels.. is there some sort of culling happening?
     
  16. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    You have updated mesh for mobile caustics? I wrote this in the readme.
     
  17. Pulov

    Pulov

    Joined:
    Feb 20, 2010
    Posts:
    824
    Tested teh demo, looks great
     
  18. Dinin

    Dinin

    Joined:
    Apr 1, 2015
    Posts:
    6
    Hi!

    Your water asset looks realy cool.
    Does this asset require Unity Pro or does it work with Unity personal also ?

    regards
    Dinin
     
  19. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    Hello,
    Water work with unity4 (pro only) and unity5 (free and pro).
     
  20. Zuon94

    Zuon94

    Joined:
    Aug 4, 2011
    Posts:
    11
    I just purchased your water, and while I can see the caustics, the water itself does not show up, and none of the sliders in the demo scene change anything.


    I'm running Unity 5 on Windows 10 Technical Preview. The OS is not likely to be the problem.

    My specs are:
    Intel i3 2nd gen @ 3.3ghz
    8GB DDR3-1600
    Sapphire Radeon R7 260x 2GB OC Edition

    How do I fix this issue? Was I not supposed to allow Unity to upgrade the scripts on import?
     
    vbs likes this.
  21. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    Mobile demo scene is working correctly?
    Write to me on skype "scar289" or email "kripto289@gmail.com"?

    PS
    Problem solved. For those who will have a similar problem, check the scale of water plane fbx.
    For unity5 it may be less than 100 times.
     
    Last edited: May 5, 2015
  22. Wellsword

    Wellsword

    Joined:
    Mar 6, 2015
    Posts:
    6
    hi
    Version 1.0.0.1 mobile scene is not working correctly with Unity5 .
    Version 1.0.0.0 works correctly with Unity4.
    After I imported 1.0.0.1 in Unity5 ,I found some scripts lost in main camera , if i import 1.0.0.0 first its ok ,but the mobile sence works not correctly.
    if I import 1.0.0.0 in unity4 , then upgrade the project to unity5 , then import 1.0.0.1 in Unity5 , mobile sence works correctly, but my project is already in unity5 ,so I cant do this.
    Could you help me about this? I think the problem is about depth of field scatter script , Unity5 rewrite it with c#, but I cant find any diff about them.
    problem.jpg problem.jpg
     
  23. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    Hello,
    It's bug with rendererTexture and forward renderer in editor mode.
    Mobile scene worked correctly in editor only with deffered/legacy deffered renderer. But on mobile, scene work correctly with all settings (forward/deffered...)
    Also, water for pc do not use RendereTexture (this use GrabPass), and in editor mode he worked correctly.
     
  24. Stiffx

    Stiffx

    Joined:
    Oct 27, 2014
    Posts:
    455
    OMFG this is very beautiful, I'm truly impressed :eek:, keep it up sir
     
  25. ponx

    ponx

    Joined:
    Sep 13, 2010
    Posts:
    44
    hello Kripto, congratulations, absolutely beautiful! I have a question though: I also work on an underwater-game, and i would need the surface to realtime-reflect fishes that are close to the surface. Does that work?
     
  26. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    Yes, reflections can work under water (but then reflections above the water will not be correct).
    Enough to change the script "reflectionCamera" line
    Vector4 clipPlane = CameraSpacePlane (reflectionCamera, pos, normal, 1.0f);
    on
    Vector4 clipPlane = CameraSpacePlane (reflectionCamera, pos, norm

    asdasd.png al, -1.0f);
     
  27. Wellsword

    Wellsword

    Joined:
    Mar 6, 2015
    Posts:
    6
    thanks it works correctly with deffered in editor.
     
  28. ekow

    ekow

    Joined:
    Nov 1, 2013
    Posts:
    2
    Hello, I try to build mobile demo scene on unity 5, but the water seems black when running on device, on editor/pc everything seems fine. Thank you.

    Screenshot_2015-05-07-15-33-04 resize.jpg
     
  29. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    Hello,
    My apk demo worked correctly?
    What a mobile model?
    You use forward/deffered renderer instead of vertexlit?
     
  30. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165
  31. Dragon_AV

    Dragon_AV

    Joined:
    May 8, 2015
    Posts:
    5
    Hello,
    I noticed that in the mobile demo scenes I am missing some scripts on my camera. Could you please tell me which scripts I need to put on there?
    Thank you.
     
  32. TechiTech

    TechiTech

    Joined:
    Dec 13, 2014
    Posts:
    212
    Purchased. Very pleased!!

    Tested in Unity 5.1.0 b5

    No problems at all.
     
  33. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    I forgot to remove unnecessary references to the old scripts (I used an early version of the water).
    This can be removed.
     
  34. Recon03

    Recon03

    Joined:
    Aug 5, 2013
    Posts:
    845
    Does this work with Skyshop?? Also does this need directional lights for it to work .?
     
  35. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    Yes. Yes.
    Also, If necessary, I can make lighting control of water/caustic by setting, instead of automatically from directional light.
     
  36. Recon03

    Recon03

    Joined:
    Aug 5, 2013
    Posts:
    845
    Issue is when I use directional lighting in my scene it kills my Skyshop... so that wont work.. Still waiting to hear back from the dev why I can't use directional lights with Skyshop unless its a bug? I dunno. Only used Skyshop for a little awhile, I have another water shader and I cant use due to it needing directional lighting. Skyshop dev is helpful but a little slow on replying so I will find out hopefully soon..
     
  37. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    Sorry, my English is not very good.
    Skyshop not work with directional light? Do you want to change the the lighting of water without directional light? If so, then write me on skype, i can help you.
     
  38. Recon03

    Recon03

    Joined:
    Aug 5, 2013
    Posts:
    845
    Waiting on the dev to confirm about this... I heard some say yes, some no, but I know when I do, my scene looks bad and dark. So waiting to hear back from him.. I will let you know what s your Skype incase?
     
  39. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    Oh, I forgot to write it :)
    Skype is "scar289"
     
  40. Sprak

    Sprak

    Joined:
    May 20, 2008
    Posts:
    28
    I'm having some issues with the depth fade. Seems like geometry behind the mesh is masking the fade?
    Screen Shot 2015-05-11 at 13.49.38.jpg
    Best example is the silhouette around the fish.
    I'm on Unity 5.0.1f1, using an Nvidia GT 750M 2Gb card (Macbook Pro)
     
  41. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    I solved this bag.
    Open shader "waterPC.shader" and replace the old function half4 frag to this
    Code (CSharp):
    1. half4 frag( v2f i ) : COLOR
    2. {
    3.     half2 normal1 = UnpackNormal(tex2D(_Wave1, i.uvWave1)).rg;
    4.     half3 normal2 = UnpackNormal(tex2D(_Wave2, i.uvWave2 + normal1));
    5.     half3 normal3 = UnpackNormal(tex2D(_Wave2, i.uvWave2/2-_Time.xx * _Direction.zw + normal2.xy));
    6.     float2 foam1 = tex2D(_Foam, i.uvFoam).rg;
    7.  
    8.     float fresnel = saturate(_OffsetFresnel - dot(normal2, i.viewDir));
    9.     fresnel = pow(fresnel, _FPOW);
    10.     fresnel = _R0 + (1.0 - _R0) * fresnel;
    11.     float2 offset = normal2.xy * _Distortion * half2(0.001, 0.001);
    12.    
    13. //offset = pow(offset, 3*fadeBlend) + offset/30;
    14.     offset = offset*offset*offset + offset/30;
    15.     half4 grabDefault = tex2Dproj(_GrabTexture, UNITY_PROJ_COORD(i.uvgrab));
    16.    
    17.     i.uvgrab.xy = offset * i.uvgrab.z + i.uvgrab.xy;
    18.     half4 reflection = tex2Dproj(_ReflectionTex, UNITY_PROJ_COORD(i.uvgrab));
    19.     half4 grab = tex2Dproj(_GrabTexture, UNITY_PROJ_COORD(i.uvgrab));
    20.     float gray = grab.r * 0.3 + grab.g * 0.59 + grab.b * 0.11;
    21.     half4 col = grab;
    22.    
    23.     float sceneZ = LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.uvgrab))));
    24.     float partZ = i.projPos.z;
    25.     float deltaZ =  sceneZ-partZ;
    26.     float fadeDepth = saturate (_FadeDepth * deltaZ);
    27.     float fadeBlend = saturate (_FadeBlend * deltaZ);
    28.     float fadeBlend2 = saturate (_FadeBlend2 * deltaZ);
    29.     fadeBlend = fadeBlend/2 + 0.5;
    30.    
    31.     col = lerp(col * _Color, lerp(col * _FadeColor, _FadeColor*_LightColor0, _DepthTransperent), fadeDepth);
    32.     col += (reflection * _ReflectionColor * fresnel + reflection * _ReflectionColor/5)
    33.     * saturate(_SunIntensity - _LightColor0.w + _SunIntensity/3);
    34.  
    35.     float glare2 = lerp(normal3.r, normal3.g, normal2.x * i.fresnelGlare.x);
    36.     float4 glareCol = _LightColor0*_GlareColor * (glare2*glare2);
    37.  
    38.     float foam =  lerp(foam1.r*2, normal1.r, normal2.r)*(1-fadeBlend)*2 * gray * _LightColor0;
    39.     col = foam + col -  foam*col;
    40.     col = lerp(grabDefault, col, fadeBlend2);
    41.    
    42.     return col + glareCol;
    43. }
     
  42. Sprak

    Sprak

    Joined:
    May 20, 2008
    Posts:
    28
    Thank you! That works like a charm.
     
  43. Sprak

    Sprak

    Joined:
    May 20, 2008
    Posts:
    28
    I don't know if this is a bug or a limitation, but things that are in front of the water surface mask out the surface before the distortion, so I get these distorted edges around everything.
    For example, that sphere does not intersect at all with the water plane.
    (Pillar intersects halfway)

    Screen Shot 2015-05-11 at 20.08.57.png
     
  44. Deleted User

    Deleted User

    Guest

    This is looking fantastic. On my short list for water solutions.
     
  45. Alex3333

    Alex3333

    Joined:
    Dec 29, 2014
    Posts:
    342
    Добрый день. Будет ли интеграция с УФПС? Вода выглядит шикарно!
     
  46. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    I solved this bag.
    sfdfdsf.png
    I'll send fixes (version 1.0.0.2) for asset store review. If you need to get fixes immediately, write me to email "kripto289@gmail.com"
    Добрый день.
    Что именно вы подразумевайте под интеграцией с ufps? Волны и брызги от выстрелов? Я возможно добавлю их в будущем.
     
  47. Alex3333

    Alex3333

    Joined:
    Dec 29, 2014
    Posts:
    342
    Я имею ввиду, чтобы игрок мог держаться на поверхности воды . Брызги от шагов ,если не глубоко.Мог умереть от недостатка кислорода. и другие плюшки ))) . Так же у меня есть несколько скриптов воды на эту тему , могу скинуть ,если нужно посмотреть как это работает, только они не оnносятся к ufps.

     
    Last edited by a moderator: May 12, 2015
  48. ekow

    ekow

    Joined:
    Nov 1, 2013
    Posts:
    2
    apk demo works on unity 4, but on unity 5 sky reflection shows black only when running on mobile device
    I'm using asus fe380cg,
    I've try both forward and deffered

    edit:
    It turns out that Sunny2 skybox is the problem, after I changed it into default unity5 skybox, problem is solved.
     
    Last edited: May 12, 2015
  49. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    Sky displayed correctly without water? Reflections I do with additional camera. See setting "ReflectionCamera". It may be necessary to change renderpath?
     
    Last edited: Jun 24, 2015
  50. Goldenvale

    Goldenvale

    Joined:
    Feb 26, 2015
    Posts:
    86
    Hey I'm interested in your water asset but is there any chance that you can make the surface of the water receive shadows?