UV Flipping Technique to Avoid Repetition

Posted on April 11, 2008. Filed under: Lake water shader, shader, Uncategorized | Tags: , , |

Alex Vlachos
A common problem exists among many shaders that rely on scrolling two copies of the same
texture in slightly different directions. No matter what angle or speed the textures are scrolling,
they will eventually line up exactly and cause a visual hiccup. This scrolling technique is commonly
used to gain the effect of having random patterns, like water caustics. With caustics, the
pattern appears to stop every once in a while even though it is scrolling at a constant speed.
This was also encountered when implementing the Ocean Water and Reflective and
Refractive Water shaders when we scrolled two copies of the same bump map in opposite
directions to produce high frequency waves (see “Rendering Ocean Water” and “Rippling
Refractive and Reflective Water” later in this book). The method we used to solve this problem
is to compute the two sets of texture coordinates like you normally would. Then immediately
before using those texture coordinates to fetch from textures, choose one of the sets of texture
coordinates and swap the U and V. This will effectively flip the texture along the diagonal.
Using this method, the intermittent hiccup that appears due to the two copies being perfectly
aligned is now impossible since one of the textures is reflected about the diagonal of the

Alex Vlachos: UV Flipping Technique to Avoid Repetition [D3DShaderX]


Make a Comment

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

Liked it here?
Why not try sites on the blogroll...

%d bloggers like this: