Feb
12
2012

Fake Water Shader

Testing “fake” water shader & trying to make a nice looking river scene (with unity free version..)

Webplayer(s):
http://unitycoder.com/upload/demos/mFakeRiver4/ (*7mb)
http://unitycoder.com/upload/demos/mFakeRiver5/

Current “features”:

  • Terrain textures & stones are from: Advanced Terrain Shaders v2
  • Terrain modeled with heightmap, imported to Unity with mTerrain
  • Unity Terrain + normal  flat mesh plane for the river
  • Custom “water” shader: Kind of fake reflection/refraction look by using 2 textures (*image#2)
  • UV anim + Weird Waves “DepthBlur” or Refraction (?)
  • Problem: Cannot see through the water at all..

Ideas / Todo/ItWontWork:

  • Perlin noise for the waves?
  • Normal / Vertex Bump/Displacement?
  • Extra Texture layers (one more thin surface fx? more visible river bottom texture?)
  • Cubemap reflection?
  • Distance Blur?
  • Interactive object-on-water fx? (water texture color based on object distance? animated ripples coming out from the object?)
  • Sides should have slower speed +  less sky reflection + more ground color (transparency?)
  • Add particles for water splashing (but a rock on the river?)
  • Fake vignetting with unity free version? (screen sized plane, with vignette texture, drawn on top of everything?)
  • Fake Caustics with caustics map?, heres a nice Caustics Generator

Download source:

FakeWaterShader.unityPackage

(below) Image#2 : Current water shader with 2 textures (12.02.2012)

(below) Image#3: Had to redo the shader.. couldnt make it work with 1 sided planes.. Now using 2 sided box.
Starting to get some see thru effects, just need to animated it and add the surface blurring again.
Made a quick cut on the terrain..doesnt look so nice (see the edges of the terrain near river), but enough for a quick test..

(below) Image#4: Notes
– Added Foam map (currently not moving and it looks like the river has thin ice and the water is flowing under it..)
– Added Cubemap reflection (not strong enough?..have to try fix that & need to find better cubemaps..
– Problems adding vertex waves, but actually rivers dont have “sea waves”.. have to try with moving normals..(?)
– Idea: Create Foam around objects (based on distance?..but then cannot have many objects to do that inside shader?)
– Added webplayer of this version (without the foam)

(below) Image#5 : Current water shader with 4 textures (13.02.2012)

(below) Image#6

– Water is more transparent now (Transparency is based on normals)
–  Got few highlights on the water, just by doubling some color values, not sure how(?) (still would need more “fake light highlights”)
– Tried speedMask texture (middle of the river flowed faster than the sides..but that caused texture stretching problems)
– Foam map failed with speedMask texture (strecthing)
– Tried “BlinnPhong”, but that killed Cubemap..(?) so back to “Lambert”
– In the image there are few stones in the water, looks ok thru the water also
– Maybe needs extra highlight map, middle depth map (some junk flowing inside water..)
– Stone should have foam around it.. (failed to get distance to stone in shader, trying again later..)
– Added webplayer


29 Comments + Add Comment

Leave a comment

@unitycoder_com

Enter your email address to subscribe to this blog and receive notifications of new posts by email.