Water Rendering

Water rendering is easy to achieve in Awakening.

Shader List:


Shader File
Preview Explanation
bump_nops.sha   use a bump map to distort reflected / refractive  image.

Factor:
vec4 
water_normal -- the normalize normal vector of water surface
vec4 water_param -- x : wave speed

Usage:
local waternormal=vec4.new(0,1,0)
local wavespeed=0.2
material.setEffectVector('vecWaterNormal',waternormal
)
material.setEffectVector('vecWaterParam',vec4.new(wavespeed))

PixelShader: No


Workflow:

1. Create a surface as water

2. Create a portal on the surface

3. Add two render targets
Right-Click in the Texture Browse Window, select "
Add Render Target" from the context menu. Then select a image file in Open File Dialog. Please ensure the image width is same as height (square image). Do same for another render target.

4. Select render targets
Select the portal, in the Render To Texture rollout of portal panel, select one render target; and check '
Consistent with back buffer' style. Click the 'Actions' button, add two actions:

Message Function Object
Render Texture Begin Hide water surface
Render Texture End Show water surface

In the Render To Texture (Mirror) rollout, select another render target, and do same as above.

5. Add bump texture
Right-Click in the Texture Browse Window, select 'Add Bump Texture' from the context menu. Then select "textures\wave_height.png" in Open File Dialog.

6. Create material
In the Material panel, new a material; set 1st texture to the bump texture; set 2nd texture to the render target in RTT(Mirror); set 3rd texture to the render target in RTT; load shader file "
effects\water\bump_nops.sha".

6. Assign the material to water surface
Please ensure no texture assign to water surface. You can use UV Tool to adjust water surface's texture coordinates for changing wave size.

Tip: slightly offset portal along the normal of water surface to avoid seams near bank. (First select the portal, then select 'Edit > Move' from menu.)