Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Normalization Cube Map

142 views
Skip to first unread message

Shiva

unread,
May 2, 2006, 2:14:56 AM5/2/06
to
Hi,
I am trying to implement Bump Mapping. I read the following articles

http://nehe.gamedev.net/data/articles/article.asp?article=20
http://www.paulsprojects.net/tutorials/simplebump/simplebump.html

In both article they are using norimalization cube map. I really
don't(and can't understand) know why we need normalization cube map.
Googled and found that by using normalization cube map we can easily
get normalized light vector for any vector(un-normalized). But i dont
know why we need this in bump mapping? also i read the code for
normalization cube map but not able to understand. Googled for
normalization cube map generation but found nothing usefull. Can
somebody help me?

Thanks in advance
Shiva

Dave Eberly

unread,
May 2, 2006, 10:40:06 AM5/2/06
to

"Shiva" <siva.ch...@gmail.com> wrote in message
news:1146550496.7...@j33g2000cwa.googlegroups.com...

The bump mapping relies on modulation by a dot product of
a unit-length light direction and a unit-length surface normal.
So you want your fragment program to use unit-length light
directions.

The light directions are either data specified per vertex or
generated per vertex. The typical example is having a
point light. The vertex program computes P - V as the light
direction, where P is the light position and V is the vertex
position. You can normalize to U = (P-V)/Length(P-V) in the
vertex program, but this costs you some GPU cycles. Moreover,
the rasterizer will interpolate these per-vertex unit-length
vectors, generating per-pixel directions that are usually not
unit length.

When the fragment program gets one of these light directions,
you can normalize it (assuming a powerful enough shader model)
using an inverse-sqrt operation. This is a per-pixel cost, which
is expensive. The normalization cube map is a cheap alternative
that instead uses a texture lookup to produce a unit-length light
direction. [If you have bilinear filtering enabled for the cube map,
there is an interpolation in the lookup, producing a non-unit-length
vector, but for a sufficiently large resolution cube map, this is
not really noticeable. With nearest filtering, you will get a
unit-length result.]

When using normalization cube maps, there is no need to do the
normalization of P-V in the vertex program. So overall, you avoid
the inverse-sqrt operations in both the vertex and fragment
programs.

--
Dave Eberly
http://www.geometrictools.com


0 new messages