Shader R&D Update Post 1

13 Sep

After figuring out the “too many texture interpreters” issue I was having, I have managed to wrap up the first draft of the second version of my Unity water shader.  Here are the major improvements I have added or changed since the first version:

  1. Added normal map stacking to allow for three individual normal maps to be used to create the desire water effect (deep waves, sub-surface waves, and surface turbulence)
  2. I redesigned the color system to be completely different.  It now has a main and alternate color chosen by the user that is slowly blended between using a texture map.  This slow, undulating, blend allows for more detail in the water system, while also making it appear more dynamic than before.
  3. I added the displacement mapping back into the system.  The design is based on a single broad texture map that moves back and forth, moving the verts by fairly small user-controlled increments.  This new effect makes the water seem like it is slowly swelling up and down, as opposed to the old static plane it was before.
  4. I made some level of transparency the norm, unlike the old system that was meant to be completely opaque.  In addition, I made the transparency view-angle dependent, so the water is more transparent at direct angles, and less transparent at glancing angles.
  5. I also applied the view-angle calculations to the reflection cube that already existed in the old system.  This change makes reflections more realistic by making the surface more reflective at glancing angles, and less reflective at direct angles.
  6. the texture map movement script (which is separate from the main shader, but meant to be used in conjunction) has been upgraded to give the user more control over the direction and speed of each individual texture map the moves.

All of these improvements have drastically increased the quality of the shader’s output.  There is still more work to be done however…

  1. I need to make a code cleaning pass to make sure it is organized and formatted well.
  2. I need to make sure the published properties (shader attributes) are organized and labeled well.
  3. I need to make a set of default property settings, game objects, and texture maps that, together, will be considered my “release package.” The idea is to be able to load up a scene and immediately have the shader up and running, without having to do a lot of work.
  4. Finally, my last major addition will be the development of a secondary shader that will be designed to be layered in on top of the current water shader.  This secondary shader will be used for coastal effects.  It will use the same terrain map that the main water shader uses in order to map an animated, tiled, decal onto the coastal areas of the terrain.  My current thought is to have the decal be duplicated and animated through a slight expanding of the map’s UV’s. This animation would create a cycle of growth, fading out of the now larger map, and fading in of the now back-to-normal-size second map.  The specific animation is subject to change once I see it in action, but this plan will work for now.  I will be tying in the animation controls to the existing water shader’s animation script, so as to keep things as centralized as possible.

Here is a short video capture of the new water shader in action:

Note, that the terrain I am using is untextured, and was made fairly quickly as a test bed.  I will be getting a much better terrain for official demos and documentation photos in the near future.

Leave a comment

Posted by on September 13, 2012 in Uncategorized


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: