Hi, I am trying to build a 2D Water shader and I am using Unity 4. Here is an example of what I am trying to reproduce : Limbo water shader Are there any good tutorial or whitepaper about creating such effect blur and displacement ? I am not talking about waves or something but only the depth of the water. Is it a Camera shader or an object shader ? Thanks a lot !
Not a good news. I am simulating 2D water waves on a plane and I need to apply this shader on my object.
In order to make the blur and ripples of the water, you need to grab the backgrround texture. So, you need unity pro. If you have unity pro, then check out my image effects and water shaders in the assetstore which will teach you how to get the effect you want.
could send you this shader if you want to... just the screen space reflections are bugged as im a bit confused how to statically offset the transformation matrices for those reflections... but the shader provides, alpha masks (for scrolling waves), you can color it per texture, you can add a distortion normal map.. and it's dynamic water (you can see this on those small ripples sometimes) where you just need to define in code where on the x-Axis and how strong you want to generate an impulse this script can also modify the vertex colors of the water to simulate depth (yeah reflection and refraction is only aviable in pro like aubergine said)
Yes I have Unity Pro. I saw that the best way to achieve such effect is to use Grabpass in the shader. But there are two problems with this system : - It seems that Grabpass is quite heavy for mobile as said here Using Grabpass IOS/Android devices . But as I am learning shader, I don't know any other system to create refraction. - There is an issue with foreground objects, they are refracted too. There is a solution here GPU Gems - Refractions . But is this solution available ? Another interesting link : Unite 11 - Shadowgun The fluid part is at about 30:00. @TehReason I would be happy to look at your shader even if this is not the effect I am trying to create.
if you're not to lazy.. you could just take a screenshot of everything you would like to get refracted without the object. And after the just disort the uv's for that screenshot. that you're gonna use just like the grabpass texture.. should be a good way for small areas.. or even for bigger ones just zoom out take a bigger screen and scale this one down.. that way you can even get a simple blurred refraction
Mhm maybe place a second ortogprahic camera with a render texture for those objects, and maybe only render those dynamic ones per layer to that texture that way you wont need to render the whole scene twice only the dynamic ones (I have no clue how much impact this will have to mobile hardware) I have other theories up my mind, by bulding up a trigger around your water and if a dynamic object enter that one you just switch the shader for the entering object, to a vertex modifying or just a default distorting pixel shader that has the same distortion properties as the water... (maybe you need to this in world space) Problems you'll get with that is that the rest of the scene is still statically rendered to a Texture so you need to place the distorted texture in the background of those dynamic objects
I think that RenderTextures are quite heavy on mobiles. They are good theory but I want to render everything in the shader. I really like your first idea with the "capture". I looked at some shader but they all use Grabpass but everybody says that it's heavy and there's the problem of the foreground.
Does anyone have the code for the wavy reflective water effect that is in the video above? The person who created it and offered to share the code doesn't seem to have logged on since June.
Absolutely not. We use them extensively on mobile (devices 3GS and up). You should be able to use a couple and still remain at 60fps on most devices. It's not really the rendering to a texture that's expensive, it's what you're rendering to a texture. They are also much, much faster than grabpass.
As Hippocoder says, Rendertextures are relatively cheap in terms of speed. The two things to keep in mind are: 1. Memory, which can be pretty significant for full-screen rendertextures on high resolution devices like the iPad 3+. You can usually get away with lower resolutions for at least some of your targets. 2. Performance is not due to the rendertexture itself, but the process of rendering to it. This is pretty much the same as rendering directly to the screen, so the possible culprits are overdraw, draw calls, and sometimes vertex count. GrabPass is murder on mobile and there is never a good reason to use it.
Why is GrabPass so bad? Isn't using it the same as using a rendertexture essentially? There has to be some serious overhead to it then and I wonder where it stems from.
I believe it's a result of reading from the back buffer, which is a really slow operation on most mobile GPUs.