First of all, the effect I am trying to get is a simple ripple effect on a textured plane. Ideally the ripple should distort the texture instead of just overlaying a ripple texture on top of my texture.
The good news, I found pretty much exactly what I wanted in this thread, http://forum.unity3d.com/threads/182296-GPU-Water-ripple-effect-Desktop-and-iOS-source-code-available. The bad news, I’ve been having a lot of strange bugs with this package that I will describe in detail below.
Here is a link to an imgur album with pics of the problems
Import Package Into Empty Project
- Created a new empty unity project. (Import Package 1 in imgur album)
- Imported the water ripple effect v2 package from the GPU Water ripple effect thread linked above.
- Opened the # ios scene (Import Package 2 in imgur album)
- Played the scene (Import Package 3 in imgur album)
- Closed the project without altering any code or saving the scene
- Reopened the project in unity (Import Package 4 in imgur album)
At this point the plane with the WaterMobile.shader applied to it now is only displayed behind other objects that have materials applied to them (Import Package 5 and 6 in imgur album.) The tags in WaterMobile.shader are “IgnoreProjector”=“True”, “Queue”=“Transparent”, “RenderType”=“Transparent.” I’ve tried changing them to “Queue”=“Overlay” and/or “RenderType”=“Opaque” to force the object to be displayed on top, that didn’t work. I tried manually changing the material.renderQueue of the material that uses the WaterMobile.shader to int.maxValue to force the object to be displayed on top, didn’t work. Nothing I have found seemed to affect the rendering of the plane. I did isolate the problem to only occurring after I close unity and reopen it for the first time after the package has been imported, regardless of what I do between the time of importing and the time of closing and reopening unity.
I figured maybe there was something in the package that was screwing with my code so I tried this again but instead of importing the entire package, I just imported the few assets from the package that I actually needed.
Import Assets Into Empty Project
- Created a new empty unity project (Import Assets 1 in imgur album)
- Imported only the needed assets individually (RippleEffect.cs, WaterMobile.shader, WaterRippleShader.shader, sky.png) (Import Assets 2 in imgur album)
- Created barebones scene with a plane that is set up to use the RippleEffect (Import Assets 3 in imgur album)
- Played the scene (Import Assets 4 in imgur album)
- Closed the unity project
- Reopened the unity project (Import Assets 5 in imgur album)
- Played the scene (Import Assets 6 in imgur album)
Again, I come across the problem of the water plane being displayed behind all the objects. The gif (Import Assets 7 in imgur album) shows that the box is displayed on top but is really below.
I am at a loss as to why this is happening. The only thing that is changing is the fact that I close and then open unity and it breaks. I am assuming that it is something related to the shader but I could be wrong. I am currently using Unity 4.2.2f1 Pro, I’m not sure what version the package was created for. If anyone has ANY ideas on what could be causing this or could give me some advice in how I might debug this I would be terribly grateful. I have spent all week trying to isolate this bug and fix it or find an alternative but so far this is the only effect I’ve found that handles the ripple the way I wanted.
Thanks