First of all, hi everyone, I’m new here. Just downloaded the trial of Unity a few days ago, and I must say it blew me away!
So, without further ado, here goes my first try at doing something worthwile:
Water in Unity Indie that has depth that changes with the point of view. It’s obviously far away from water you can do with RenderToTexture functionality, but hey, not everyone can afford Unity Pro and it’s way better than simple transparent water
It’s more impressive in motion, I’ll try to attach a demo application so you can check it out.
If anyone’s interested, I’m glad to share some details and scripts, but the explanation of the technique used is a bit on the lengthy side so I won’t type it out if noone cares anyway
Mouse Scroll to zoom, keys 1 and 2 switch between standard transparent and depthmapped water.
Note that the color calculation part of the two shaders is identical (with the same crappy artifacts ), the difference is in the alpha calculation only.
That’s not very interesting to Mac users, of which there are many here…you might want to upload a web player instead (which works on Mac + Windows and is smaller).
Oops, sorry about that, I kindof forgot about the Mac. Hmm, I don’t have my own webspace, seems like it’s time to go hunt for a free one on the tubes… Any tips?
EDIT: here we go: http://approject.comxa.com/
Mouse Scroll to zoom, keys 1 and 2 switch between standard transparent and depthmapped water.
Note that the color calculation part of the two shaders is identical (with the same crappy artifacts ), the difference is in the alpha calculation only.
Actually I meant to zip the .html+.unityweb file together and upload the zip file. I tried the website link, but I guess they are suspicious of .unityweb files, and it’s not working. Of course, you could always upload a Mac build too (make it a Universal Binary). But the .unityweb file is cross-platform and takes up the least space.
Yay, that works. Cool effect…even if you’re using Pro water, that would make a better fallback than the standard water (for old machines, or if you just want more speed).
There’s two parts to the technique: a precomputation of a “depth map” done by an editor script, and a shader which utilizes the depth map to compute the depth of the water along the current viewing direction.
The precomputation script is in principle similar to lightmapping (in fact I wrote it by modifying Talzor’s awesome PixelLightMapper script - thanks Talzor!). It casts a bunch of rays in four major directions from every texel, and after some weighted averaging stores the depths in the four channels of an RGBA texture.
The shader then makes somewhat of an educated guess about the water depth along the viewing direction by weighting the depth values in the depth map with the dot product of the view direction and the major direction corresponding to that channel in the texture.
That’s the gist of it, I hope I wasn’t too confusing I’ll attach a package so you can check it out if you’d like to.
Hey, I took a look at the web preview, and thought that this looked wonderful. I downloaded the .unitypackage and installed it, everything imported just fine.
Now, I’m not sure if I’m doing this right, since I’m fairly new to Unity.
After I imported it, I got the Depthmapped water object into my scene, placed it where I wanted it, but it was invisible in the editor, and in the game. So I ran the depthmapper script from the GameObject menu, had it run on the water plane, and it gave me a depth map, though the depthmap it gave me was solid black, and the water plane is still invisible.
Any thoughts on what could be the cause? Thanks in advance.
I habe the same problem as Nilore: I attached Depthmapped Water to the plane (which pretends to be Waterplane), but I don’t see anything. I know, my question sounds n00bisch, but I’m at the beginning of my Unity-Way, so I’ll be ultra happy if somebody could just give a small hint how to append this tool (which looks awesome in the demo)
Looks like the issue is coming from something about the System.Globalization.CultureInfo. I didn’t see any mention of that in the code itself, so I’m not sure why it’s mentioned here, but there ya go. Thanks for showing as the demo though. It restored my faith in Unity Free’s water.