# NV15 _amp; Vanta 2 GPU Update by yurtgc548

VIEWS: 1 PAGES: 21

• pg 1
```									GeForce3 Developer Workshop

• Chris Wynn (cwynn@nvidia.com)
Objectives

register combiners can work together

• Learn some of the new GeForce3 texture formats
and how they might be used

• Understand bump mapping
What we’re going to do…

• Quick review of bump mapping
• Conceptual Overview
• GeForce2 (NV1x) style bump mapping

• Introduce alternative GeForce3 style bump
•   Discussion of texture formats

• We’ll do a multi-part lab where you write the code
to achieve the effect.
Basics of Per-pixel Bump Mapping

• Basic idea:
• Provide a normal per-pixel
• Provide other lighting parameters on a per-pixel
basis (light vector, halfangle-vector, etc.)
• Compute a lighting equation using operations
performed on a per-pixel basis

•   Typically compute Phong diffuse and specular
lighting:
intensity = (N•L) + (N•H)m
Basics of Per-pixel Bump Mapping

• How this is done in real-time:
• Encode normals into a texture
• Map the “normal map” texture onto a model using
standard 2D texture mapping
• Additionally, compute L and/or H vectors on a per-
vertex basis and interpolate these across a triangle
• Compute the necessary N • H and N • L on a per-
fragment basis and use texture combining to
compute lighting equation

• Phong:   intensity = (N•L) + (N•H)m
Basics of Per-pixel Bump Mapping
• When computing dot products, L, H, and N must be
in the same coordinate space
• World, Eye, other.

• A convenient space for per-pixel lighting
operations is called “local tangent space”
• Z axis is roughly parallel to the surface normal at a vertex
• X and Y axes are perpendicular to the Z axis and can be
arbitrarily oriented around the Z axis
•   Often denoted T, B, N where T = tangent direction, B =
binormal direction, and N = T x B is the normal direction
•   A normal map is stored in this space
Basics of Per-pixel Bump Mapping

• To compute N • L or N • H on a per-pixel basis,
L and H must be provided in local tangent space
for each pixel

• This means we can rotate the L and H vectors
into tangent space at each vertex
•   (and use an appropriate form of linear interpolation
to generate texture L and H vectors per-pixel)
GeForce2 (NV1x) style Bump Mapping

• On GeForce2:
• Use a normal map to provide per-pixel N
• Compute the L vec in tangent space for each vertex
• Allow it to be interpolated across a triangle
• (Preferably using a re-normalization cubemap)
• Compute the H vect in tangent space
• Allow it to be interpolated as well…
• Use register combiners to
• compute per-pixel dot products Þ Phong
GeForce2 (NV1x) style Bump Mapping

• On GeForce2:
• This approach works great most of the time
however…

•   (N•H)m term computed in the combiners using
successive squaring
• Obscure specular exponent values can make the
mapping to combiner stages tricky
• Precision can limit the quality of term (N•H)m term
when specular exponent is large
•   Occasional “banding” artifacts.

• For GeForce3:
• Additional combiner stages simplify computing
(N•H)m term but precision can still limit quality

•   Alternative strategy that works well with fairly large
specular exponent
• Uses texture shader dot product texture 2D

• Basic Idea:
Encode the N•L and (N•H)m into a 2D LA texture
• Luminance channel = N•L
• Alpha channel = (N•H)m into

lum = (N•L)         Constant cols of luminance
Constant rows of alpha
N•H

alpha = (N•H)m

N•L

• Basic Idea:
Then use Dot Product Texture 2D to perform...

rgba = texture2D_lookup( (N’•L), (N’•H) )
rgba = ( N’•L, N’•L, N’•L, (N’•H)m )

Where
N’ is the normal fetched from the normal map
L is the interpolated tangent space light direction
H is the interpolated tangent space halfangle vector
Part 1: Vertex Program Bump
Mapping setup

• In this lab you will write a vertex program to do the
math necessary to “setup” for the Dot Product 2D

• Specifically you will:
• Pass through (s,t) texcoords for the normal map
• Compute a local tangent space L vector
• Compute a local tangent space H vector
• Pass L and H as texture coordinates for texture
units 1 and 2 respectively
• Pass through (s,t) texcoords for a decal texture map
Part 1: Vertex Program Bump
Mapping Setup
•   What you will learn:
• How to do bump-mapping setup

•   OpenGL\src\labs\texshd_bumpmap_step1
• main.cpp
• Please don’t look at main.cpp as it may spoil what you will
learn in step2!!!

•   GeForce3 Texture Formats:
The normal map can encode normal map using varying
precision AND the dot product texture shader can
use that to increase quality

External                        Internal
•    RGB / GLubyte     (8)           GL_RGB8             (8)
•    RGB / GLbyte      (8)           GL_SIGNED_RGB8      (8)
•    HILO_NV / GLbyte (8)            GL_SIGNED_HILO16_NV (16)
•    HILO_NV / GLshort (16)          GL_SIGNED_HILO16_NV (16)

•   Press the spacebar to toggle through modes
Mapping Setup

• In this lab you will write a texture shader to do the
math necessary to compute the two dot products and
lookup into the 2D texture

• Specifically you will:
• Configure the texture shaders using the nvparse
Mapping Setup
•   What you will learn:
• How to configure texture shaders

•   OpenGL\src\labs\texshd_bumpmap_step2
• main.cpp
• Please don’t look at the register combiners setup code yet as
that may spoil step 3!!!
Part 3: Register Combiners Bump
Mapping Setup

• In this lab you will write a register combiner
instructions to do the per-pixel math necessary to
compute:

rgb = decal * (N’•L) + specular _col * (N’•H)m

• Specifically you will:
• Configure the register combiners using the nvparse
Part 3: Register Combiners Bump
Mapping Setup
•   What you will learn:
• How to configure register combiners

•   OpenGL\src\labs\texshd_bumpmap_step3
• main.cpp
• Vertex_programs.h
Basics of Per-pixel Bump Mapping

• The per-vertex basis is given as T, B, N
• The matrix for rotating a vector into this space is:

• Given an L vector in world-space, can transform to
local-space using 3 dot products

```
To top