When I'm working on my current Unity3D project, Hi:Breed, a smart phone zombie shooter, I decided to add a sewer level, half flooded with murky water. So I tried a couple of standard water FX and found none of them fit the gloomy environment. I only can use the Basic Water Shader since I use Unity3D Basic Version.
The picture to the left is the standard DayLight Simple Shader, obviously not suitable since I don't want the 'water' clips all polygon under it. The middle one is using simple UV shifted transparent mesh, looks much better for me but the water is way too clean, the water should be dirty so I can only see only anything near the surface. Now, the one to the right is the, uh, right one. The submerged part near the surface is still visible, while anything deeper is harder to see.
I've read some article about this 'Murky Water Shader' and almost all of them require the render-to-texture feature, something I can't use in my Basic Version, to sample the depth buffer.
So, I've come with this stupid idea, "Hey, why don't I use this lightning fast standard image projector to fake the volumetric fog for the fake murky water"...
I know a little bit of writing fixed function pipeline shader but I'm too lazy to create the shader from scratch, so I took the standard "Shadow Material" shader and make some small modification
Here is my fake volumetric fog shader
Shader "Projector/Fog" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_ShadowTex ("Cookie", 2D) = "" { TexGen ObjectLinear }
}
Subshader {
Pass {
ZWrite off
Fog { Color (0, 0, 0) }
Color [_Color]
ColorMask RGB
Blend DstColor zero
SetTexture [_ShadowTex] {
combine texture, texture
Matrix [_Projector]
}
}
}
}
And here's the projected 'fog' texture:
And here is the result:
Still looking like a poisonous fog than water for me, something is still missing, the water surface. So, let's add the UV shifted transparent mesh on top of the fog...
And viola... Le Cheap Murky Water FX that works smoothly even on my ArmV6 powered android device
Rabu, 04 September 2013
Langganan:
Postingan (Atom)