Here is an article , explaining how water can be rendered as post process effect without the needed geometry for it.
Im trying to convert the example shader into Unity without much success yet. Anyone wants to give a hand?
Here is a photo to encourage you.
There is a link to the example shader at the bottom of the article.
Slin
June 13, 2011, 6:26pm
2
Nice
I tried something like this 3 years or so ago with horde3d, but as I wasn´t ready for the math at that time, it didn´t get further than some kind of volumetric fog
Good luck
Well, if you check the sample shader provided in that article… Math is already there.
All we need is to convert it to unity compatible.
There is this function in the shader
inline float3x3 compute_tangent_frame(float3 N, float3 P, float2 UV)
{
float3 dp1 = ddx(P);
float3 dp2 = ddy(P);
float2 duv1 = ddx(UV);
float2 duv2 = ddy(UV);
float3x3 M = float3x3(dp1, dp2, cross(dp1, dp2));
float2x3 inverseM = float2x3( cross( M[1], M[2] ), cross( M[2], M[0] ) );
float3 T = mul(float2(duv1.x, duv2.x), inverseM);
float3 B = mul(float2(duv1.y, duv2.y), inverseM);
return float3x3(normalize(T), normalize(B), N);
}
And i get this error:
Shader error in ‘PPWater’: Program ‘frag’, function “ddy” not supported in this profile at line 39
ddx and ddy are not supported??
EDIT: Okay, its supported by d3d9 but not opengl.
This is a nice find and I will certainly try and take the time to look over the article for future reference.
Best Regards,
Matt.
Here is the best i could come up with after all this time. It looks awful and totally useless
White parts in the second picture represent the shoreline acording to how deep water is, just needs appropriate foam texture there.
Still, if anyone is interested in the code, just ask and ill send you.