Search Unity

Easy Water 2.0 - Mobile Compatible [RELEASED]

Discussion in 'Assets and Asset Store' started by Grespon, May 3, 2012.

  1. cyangamer

    cyangamer

    Joined:
    Feb 17, 2010
    Posts:
    234
    I know this is a long shot, but we're talking about potential features...

    I have to throw in my suggestion for sea foam - like in the old Unity demo that no longer works with Unity 4. :razz:
     
  2. Grespon

    Grespon

    Joined:
    Apr 13, 2012
    Posts:
    388
    cyangamer1,
    You mean that island demo ?
     
  3. cyangamer

    cyangamer

    Joined:
    Feb 17, 2010
    Posts:
    234
    Yeah, that one. It would make a nice effect, and that isn't something I've seen anywhere here.
     
  4. Grespon

    Grespon

    Joined:
    Apr 13, 2012
    Posts:
    388
    I made a simple tutorial.
    Not sure if it's very good though. I made in a rush.. Here's the link:

     
  5. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Very helpful, thanks! A question, when transparency is turned off in properties, then the water switches to a fully non-transparent shader with all alpha blending/testing etc. turned off in the shader code, right?

    (This is important for mobile... ;)
     
  6. Grespon

    Grespon

    Joined:
    Apr 13, 2012
    Posts:
    388
    Hi metaleap,
    Maybe you'll have performance issues, since the rest of the code for transparency is still there, but I need to see the code again at home. Just tell me which shader you are talking about, I can make a non tranparent version for the next release.
     
  7. tripknotix

    tripknotix

    Joined:
    Apr 21, 2011
    Posts:
    744
    i would also love to see a non transparent version as well.
     
  8. Xaron

    Xaron

    Joined:
    Nov 15, 2012
    Posts:
    379
    Hi there,

    I have a strange problem with the water on a Samsung S3 (Adreno GPU):

    $Screenshot_2013-09-05-12-09-38.png

    On my Sony Xperia S it looks fine!
     
  9. Grespon

    Grespon

    Joined:
    Apr 13, 2012
    Posts:
    388
    Hi Xaron,

    It seems like a resolution loss.. A user claimed about a similar issue on an Android Note two days ago and I spent some hours trying to find out why it's happening.

    It's hard for me to find the bug's reason. I only have an iPhone 4S and a Galaxy S for testing and it runs fine on both. Maybe it has something to do with the texture's import settings.

    I'll be investigating this... tips are welcome.
     
  10. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Adreno GPUs are fairly common, both my HTCs also use them. If Xaron wants I can test his test project on those, if it's a small/isolated easy-to-build project etc :cool:
     
  11. Grespon

    Grespon

    Joined:
    Apr 13, 2012
    Posts:
    388
    So you already tested on your Adreno GPU's HTC , metaleap?
     
  12. Xaron

    Xaron

    Joined:
    Nov 15, 2012
    Posts:
    379
    Thanks guys, I'll check it with the standard Easy Water setup. I just replaced the texture, scaling and tiling. Will come back to you!

    metaleap, thanks for the offer! Does the standard EasyWater module work on your HTCs?

    The Samsung S3 seems to be very picky, I had issues here and there all the time, not only for 3d stuff.

    Cheers - Xaron
     
  13. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Haven't actually gotten to the stage of actively playing with EasyWater just-yet! But as a customer I'm actively monitoring progress issues :)
     
  14. VectorNector

    VectorNector

    Joined:
    May 22, 2013
    Posts:
    62
    I guess im not crazy. So, I have a similar issue where the texture are pixelated and it runs really choppy. I've tried playing with the import settings too. I tried using most of the shaders and that didn't help. I'm going to study some more on shaders and see if I can debug it from there.
     
  15. Grespon

    Grespon

    Joined:
    Apr 13, 2012
    Posts:
    388
    Could you guys test those textures and bumpmaps with some Unity's built in shaders, please? This way we can see if the problem is with the textures or not.
     
  16. VectorNector

    VectorNector

    Joined:
    May 22, 2013
    Posts:
    62
  17. Grespon

    Grespon

    Joined:
    Apr 13, 2012
    Posts:
    388
    Thanks VectorNector,
    i'll take a look at this when I get home.
     
  18. Grespon

    Grespon

    Joined:
    Apr 13, 2012
    Posts:
    388
    If you lower the Tiles, the problem keeps on?
     
  19. VectorNector

    VectorNector

    Joined:
    May 22, 2013
    Posts:
    62
    Same blocky artifacts. :/
     
  20. Xaron

    Xaron

    Joined:
    Nov 15, 2012
    Posts:
    379
    I just did a test with the standard example which comes with EW and it looks the same on a Samsung S3:

    $Screenshot_2013-09-05-20-31-07.png

    Please note, the problem with the sky is another topic lol. Just textures which are quite too large.
     
  21. Xaron

    Xaron

    Joined:
    Nov 15, 2012
    Posts:
    379
    I think the root cause is a bug in the driver for the Adreno 225 GPU starting with Jelly Bean:

    "During the IwGL startup, glGetString(GL_VERSION) is called, among other purposes, to check for the CommonLite profile in order to switch to fixed point texture matrix arithmetic. It does it by looking for the "CL" substring in the returned string.

    The cause of the problem is that the Motorola Razr M (and probably more Adreno 225 devices) returns "OpenGL ES-CM 1.1 V@2.0 AU@ (CL@2726865)", which contains that "CL" substring but not meaning "CommonLite". Therefore, Marmalade enables fixed point texture matrices when it shouldn't.

    By enabling detailed GL trace, you can see that under this scenearios IwGx is calling the fixed-point version of the relevant function (glLoadMatrixx()) instead of the floating-point one (glLoadMatrixf()), which is the one called usually."


    https://devnet.madewithmarmalade.co...ms-rendering-on-jellybean-with-galaxy-s3.html
    http://www.shivaengine.com/developer/forum/viewtopic.php?p=60882
    https://developer.qualcomm.com/foru...ile-gaming-graphics-optimization-adreno/26785

    Looks like there are a bunch of issues... o_O
     
  22. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Xaron,

    the linked thread says: "Compiling with ES 2.0 also corrected the no textures issue for my users." --- what about your Unity project where this occurs, is that targeting GL 1.x or GL 2.x?
     
  23. Xaron

    Xaron

    Joined:
    Nov 15, 2012
    Posts:
    379
    Oh well it targets GL2.x so this won't be an issue, yes. I had big problems with GL1.1 earlier but you need at least 2.0 to make the shaders work.
     
  24. Grespon

    Grespon

    Joined:
    Apr 13, 2012
    Posts:
    388
    The shaders you're using, inside the code, did I put some line "#pragma target 3.0" ?? Try changing to "#pragma target 2.0". I don't think it's gonna work but let's try...
     
  25. Xaron

    Xaron

    Joined:
    Nov 15, 2012
    Posts:
    379
    When I change it to 2.0 I just see a violet plane, no water anymore.

    The standard water from Unity works by the way.
     
  26. Xaron

    Xaron

    Joined:
    Nov 15, 2012
    Posts:
    379
    Any news on this?
     
  27. Grespon

    Grespon

    Joined:
    Apr 13, 2012
    Posts:
    388
    Hi Xaron,
    I was waiting my wife to buy a Galaxy Note 2. She changed her mind and bought a Galaxy S4 yesterday, which I hope gives the same problem, so I can test. Now I'm having troubles building to Android..something about Android SDK setup I think..
     
  28. Xaron

    Xaron

    Joined:
    Nov 15, 2012
    Posts:
    379
    Install Java 32 bit(! yes, 32 Bit) JDK, latest Android SDK and it should work. ;)

    Regarding the S4. It has a different GPU so I don't know if it happens there. Actually there are two versions (same as with the S3)

    S3 GPU: Mali-400MP / Adreno 225
    S4 GPU: PowerVR SGX544MP3 / Adreno 320

    The Galaxy Note 2 has a Mali-400MP GPU as well so I think the Mali GPU has these issues.
     
    Last edited: Sep 18, 2013
  29. Xaron

    Xaron

    Joined:
    Nov 15, 2012
    Posts:
    379
    Maybe this helps?

    http://labs.10tons.com/2012/03/16/th...mp-and-gl_rgb/

    "You are trying to create a framebuffer object with RGB of 8-bits per channel. Mali doesn’t support this because of memory alignment issues that would impact performance."

    We had used GL_RGB in our OpenGL ES implementation and it seems that Mali-400 MP doesn’t support this at all. So, now we know that. All other devices we’ve encountered have supported it, so this was exceptional. The fix was obvious: use GL_RGBA.


    http://forums.arm.com/index.php?/topic/15343-fbo-with-gl-rgb-color-attachment-not-supported/
     
  30. mattcscz

    mattcscz

    Joined:
    Mar 7, 2010
    Posts:
    411
    Hi Grespon,

    I really love the asset and it's really helping me save time! I'm having a slight problem however, I'm trying to use a plane with easy water on, both underwater and above, however, as it's a plane, of course one side is transparent, so I try to flip the plane but I lose animation and other effects (shown below)

    $1379547879-rZMvBN.jpg

    $1379547918-7QL7EH.jpg

    Also, when trying to create under-water effects using projectors or transparent planes they act funny with my easy-water plane, resulting in weird outcomes:

    Acts differentely depending on the shader ofcourse, but I'm guesing they are multiplying. Any way around this?

    $1379548004-KAZ1iI.jpg

    Thanks in advance,

    Matt
     
  31. Grespon

    Grespon

    Joined:
    Apr 13, 2012
    Posts:
    388
    About that problem with Adreno and Mali 400 GPU's, I'm happy to say that in my wife's new S4 there's the same problem. It means I can test and fix now :)
     
  32. Grespon

    Grespon

    Joined:
    Apr 13, 2012
    Posts:
    388
    Hi Matt,
    I'm sorry. Easy Water has no underwater effects right now. I'm working on it. There was an underwater demo scene which I'm working on, but since I updated my site I still didn't upload again.

    About the projectors.. wasn't it supposed to ignore the water plane ?
     
  33. mattcscz

    mattcscz

    Joined:
    Mar 7, 2010
    Posts:
    411
    I've created my own under-water effects:

    $541388_10151653927928862_1455748687_n.jpg

    The problem is, when I flip the water up-side-down essentially (180 degrees), the waves and animations stop working (as shown, it just becomes a more, static plane).

    I've fixed the projector issue =)
     
  34. Grespon

    Grespon

    Joined:
    Apr 13, 2012
    Posts:
    388
    Hi Matt,
    Your game is looking really cool!

    Well, can't see a reason why the waves stop working for you. I've just made a quick test and it flips and keep waving..

    Have you tried using another plane as the underwater surface, hiding the above water object instead of flipping it?
     
  35. mattcscz

    mattcscz

    Joined:
    Mar 7, 2010
    Posts:
    411
    Thanks :D!

    And I've tried to duplicate and flip the water, however the same thing happens.

    Is it possible the direction of the light factors how the mapping works? Like how normals work.

    It's quite strange really, it works at differnt angels, from 0 to 90, but as soon as it's flipped it stops.
     
  36. Grespon

    Grespon

    Joined:
    Apr 13, 2012
    Posts:
    388
    Hi Matt,

    Yeah, sure.. the normals only work when it has some directional light on it (EDIT: I mean facing it). But you should still be able to see the animated textures.
    Btw, which shader are you using ?
     
    Last edited: Sep 23, 2013
  37. Xaron

    Xaron

    Joined:
    Nov 15, 2012
    Posts:
    379
    That's great! :) Looking forward to a fix!
     
  38. Grespon

    Grespon

    Joined:
    Apr 13, 2012
    Posts:
    388
    I made a fix.. It's working on a S4 Adreno GPU... but unfortunatly it didn't work with VectorNector's MALI-400MP..
     
  39. Grespon

    Grespon

    Joined:
    Apr 13, 2012
    Posts:
    388
  40. VectorNector

    VectorNector

    Joined:
    May 22, 2013
    Posts:
    62
    It's a brain teaser. I will double check Unity's water against that Samsung model thing. I didn't get the chance last night but I will certainly report back if I find anything. If it's a simple fix for the Adreno it might be a tiny fix for the Mali.
     
  41. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Hi Grespon,
    were you able to create edge foam for this? If it runs on mobile with foam it would be great. I see Water+ has it, but I don't know how it compares on perfomance with yours. They say it runs at 35 fps on an iphone 3gs

    Regards
     
  42. Grespon

    Grespon

    Joined:
    Apr 13, 2012
    Posts:
    388
    Hi creat327,
    No foam yet.
    EasyWater has about 15 different shaders with different perfomance. I never tested any of them on iPhone 3gs, but I suppose it runs fine because iPhone 3gs has low resolution and a nice GPU.
     
    Last edited: Sep 29, 2013
  43. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Wow, played a lot with EasyWater and competitors today and EasyWater has come a long way, seems like I'll be going with it for my project!

    Since I have a dynamically sky instead of a static skybox, I'll need to capture the reflection-texture periodically (every couple seconds or so) with a separate (sky-only layered) render-to-texture camera.

    So I have a question about your PDF, page 3, where it says:

    "Creating a Reflection Texture: 1 - Create a camera and move it up along the Y axis until it's far away from the ground."

    Why is that and what is "far from the ground", roughly?

    "8 - Mirror the image with some Image Editor, test it and rotate the texture file until it matches your skybox orientation."

    Care to go into any more details? In your scenario, the user captures a square screenshot. Then he rotates it? What, left or right? 45° or 180° or...?

    Would be highly interested if you have any guidance regarding generating the reflection map at run-time if possible:

    1. I know how to set up a secondary off-screen camera for render-to-texture and set its culling-mask to only render the sky...

    2. but not sure how to exactly position and rotate that temp cam so that the generated render-texture will, when applied at runtime to the EasyWater game-object, accurately reflect the sky no matter the player's position or viewing-angle

    ... thoughts? Thanks :D
     
  44. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    I should add the generated render-texture will be very lo-res, 64x64 or something (the big distortion and specularity I have going on will hide that quite nicely) so if I need to do mirroring in code via pixel processing or 2 such render passes with different cam-rotation, no prob. Would just need to know exactly what I have to produce in terms of image characteristics for a "reflection texture" to work --- how to code it will be trivial for me to figure out.

    OR --- alternatively let me know how to make the cubemap shader work. I have a copy of the EasyWater material but with "Cubemap" shader instead of c2tbdor360, set a reflection cubemap and otherwise same settings, just renders a diffuse color though. No bumps, no spec... is that shader still beta? (This is with Unity's "-force-opengl" start-up flag, project in Android mode and "Edit / Graphics Emulation" set to GL ES 2.0 --- again, the c2tbdor360 renders beautifully.)

    Other question, when using a 2Tex shader, are both textures always combined 50/50? Or is one for "far" and the other for "close", or some other logic?
     
    Last edited: Oct 4, 2013
  45. Grespon

    Grespon

    Joined:
    Apr 13, 2012
    Posts:
    388
    Hi Metaleap,
    I'm sorry I can't help you too much now. I'm on vacation, in a beach, far from home :). I come back home probably in 3-4 days.

    But let's go..
    -I never thought about doing this at realtime.

    -"Far from ground" just means "far enough to not capture the ground in the screenshot". The skybox will follow the camera so, there's not a precise y-value. You can disable all the objects too...

    -I remember having troubles to determine how much to rotate the texture after screenshotting the sky. It happens that, at least in Unity 3.5, there were different orientations if you were applying skybox via camera or render settings. In the end the degrees would be the same, but I just stopped thinking about it. I shouldn't be that lazy. My bad. If you can't find the rotation, I'll do it as soon as I get home.

    -Render-to-texture: Since I got Unity PRO, I never had the time to play with it. I'm afraid I have no idea how to help you out.

    -I wasn't aware that the cubemap shader wasn't working. I'll need to check it out.

    -When using 2 textures, they are 50/50. But it's a line of code and can be modified very easily. There's some place where you'll see finalTex = lerp(tex1, tex2, 0.5) or something. You just need to change the last parameter.

    An important detail is that EasyWater shader doesn't "know" it's own position, so if you apply a reflection texture, you can't rotate the object because the reflection will rotate together. You'll need to rotate the texture too if you need to rotate the object. It means the best way to use EasyWater is with static objects.
     
  46. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Haha, you enjoy your vacation for now and can easily get back to me when you're back, no rush!

    I already got to the stage of my reflector-camera being set up with FoV=165, cullLayer=skyOnly, rotX=270, render-to-texture is set up and connected to the water material and it looks pretty cool. Just don't know how to rotate and/or mirror the texture post-render -- right now, my reflected sun or moon is noticably offset to the left or right from the "real" one. So that's the only remaining mystery... maybe I'll stumble upon a solution myself..
     
  47. Grespon

    Grespon

    Joined:
    Apr 13, 2012
    Posts:
    388
    hum.. is your water object rotated ?
    Have you try rotating the reflector-camera a bit more/less?
    Isn't any camera option to flip the image?
     
  48. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Water isn't rotated at all, should I play with that? Reflect-Cam is only rotated on X at -90 (270). Camera flip would be cool, but Unity doesn't seem to offer this. Might have to dig somewhere deep into its projection-matrix or something...
     
  49. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Another few things -- for when you get back ;)

    1. I played with rotation -- to reflect my "sun" correctly I need to set the water's Y-rotation to -48, but to reflect my "moon" correctly I need to set it to +48! When I reset the water Y-rotation to 0 and play with the reflectorCam Y-rotation, seems like I need +45 for the moon and -45 for the sun :D So neither water rotation nor reflectorCam rotation seem sufficient to reflect "all of my sky" correctly, seems like I really need to flip the render-texture somehow?...

    2. Little bug report for Animate360 script: any value I enter at design-time for Distort Speed Y is at runtime seemingly divided by 10? For example I specify 0.015, hit Play and the property shows 0.0015. Or I specify 0.15, hit Play and the property shows 0.015..

    3. Would it be feasible to have DistortionMap/DistortionPower affect the maintex/bumpmap 1 2 (or only 1) as well? But only if this is no heavy maths-costs shader-side? ;)
     
    Last edited: Oct 6, 2013
  50. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    OK I investigated further into the reflection. I temporarily disabled my real sky and set up a simple debug skybox, like so:

    (for full-size view: right-click / open in new tab)

    View attachment 69866

    Here you can see the reflector cam preview with FoV=165 etc --- below in the Assets folder it shows a live preview of the render texture that is bound to my Water as reflection texture:

    View attachment 69867

    No matter how I rotate either the reflection-cam and/or the water itself, it always reflects respectively 2 opposites sides correctly, and the other 2 opposite sides flipped over. So the best thing would be for your pixel shader to sample the reflection texture flipped -- with a debug skybox like this (easy to set up with Paint.net or mspaint or something in 5 minutes) this should be easy to test and implement!

    Best if it works fine with water and render-cam "unrotated". In my screenshots, both cam and water have 0 y-rotation: you can see that your shader picks the "left" and "right" (yellow and red) correctly, but the "top" and "bottom" need to be flipped.

    If you cannot reproduce the glitch with such a debug skybox, then maybe it's a DX vs. GL thing --- in that case, best to have a "flip-Y" check-box in the reflective materials, or something...

    I cannot possibly flip the render-texture via script, as CPU-side texture-reads/texture-writes kill performance on mobile no matter the texture resolution -- it's the whole GPU download and GPU upload bandwidth that slows this to a crawl. Whereas flipping the texture via the shaders sampler-read should be a zero-cost operation, simply flipped texCoords.

    Incidentally, I played with the tiling/offset settings for the _Reflection texture but this didn't seem to make any difference to rendering. Not a problem, as typically one would not really change those whatsoever.