- Home /
Is there a way to get water4 working on iOS9?
The situation is thus:
We are using unity 5.2.1, though the issue occurred on 5.2.0 as well.
We have an app using water4 (with gerstner displace disabled,) that works perfectly on iOS8 installed on an ipad Air2.
However after upgrading the device to iOS9 the water4 has visual errors, symptoms include:
Acting as if it’s out of clipping plane range when the camera is far away and the water has an object behind it. IE being invisible when it shouldn’t be.
Jagged borders where it meets the shore which become more jagged the further away you’re viewing the water from and generally look awful when a camera zooms in/out on them.
Generally these two issues combine to make water 4 radically different looking on iPad then it is on mac when viewed from a distance. (When it can even be seen at all).
I’ll be filling a unity bug for this as soon as I can put a decent demonstration project together but in the meantime I was wondering if anyone’s found a workaround.
Using OpenGL instead of metal does fix the water, however it creates several other issues in our project such as materials turning various amounts of black (depending on distance from camera) and understandably low frame rates, so I can't really use that as a solution sadly.
To clarify, these problems only occur when water4 is over the top of an object.
Answer by Foemass · Oct 14, 2015 at 10:55 AM
Here’s my workaround:
You’re going to be using your skybox as a seabed instead of any model, so make sure either your skybox bottom is a decent colour for this purpose or your water has no transparency.
Configure the culling mask of your original camera so it can only see your water layer, (which your water4 should be using.)
Duplicate your camera, change its tag then make it a child of your main camera. Configure this new camera’s culling mask so it can see everything EXCEPT your water layer. Set this camera’s depth to 0 and its clear flags to depth only.
Set up a depth mask shader + material (See http://wiki.unity3d.com/index.php?title=DepthMask for an example.)
Duplicate all your water tiles and attach them to a new parent for clarity. Remove the water tile script from them and apply your new depth mask material to them. You’ll want the mask to hide everything below the water but not the water itself.
Disable your water’s gerstner displace component if you haven't already. Not only is this necessary to avoid weird water edges, but its also needed to avoid another water4 iOS bug, (More info here: http://forum.unity3d.com/threads/water4-ios-unity-5-is-it-possible-to-get-all-these-working-together.347767.)
There are some obvious flaws with this workaround. You’ll get reflection but not refraction and won’t be able to see underwater objects through the water’s surface. Anyone scrutinising the edges of the water might also be able to see unrealistic reflections from the translucent inside of your models. The latter problem can be solved with some creative modelling but its not all that noticeable to the average user anyway I’ve found. In any case this workaround still looks vastly better then what you get from water4 on iOS9 as standard.
Your answer
Follow this Question
Related Questions
Multiple cameras not working correctly on iPad Air 0 Answers
iPad Emissive Shader 1 Answer
Unity Remote 3 and accessing multiple Input.touches? 3 Answers
How do I detect no touches on the screen? 1 Answer
Are soft shadows supported on iOS ? 2 Answers