Académique Documents
Professionnel Documents
Culture Documents
using NVPARSE
Chris Wynn
NVIDIA Proprietary
setup
rasterizer
tex-addr
ops
texture
blending
frame-buffer
NVIDIA Proprietary
per-vertex geometry
& shading programs
tex fetch
& filter
per-pixel shading
1D Projective
2D Projective
Cube Map
Conventional (+ 3D Projective)
Special Modes
Simple Dependent
Dot Product Dependent
NVIDIA Proprietary
What is nvparse?
An easy way to use:
NV_vertex_program
NV_texture_shader
NV_register_combiners / NV_register_combiners2
What is nvparse?
NVPARSE is a library that defines two entry
points.
void nvparse( char *program_string )
used for parsing a program and setting the
corresponding OpenGL state
NVIDIA Proprietary
What is nvparse?
NVPARSE supports 3 kinds of programs:
Vertex Programs
Register Combiner Programs
Texture Shader Programs
NVIDIA Proprietary
Register Mappings:
// identity mapping
tex0
expand(tex0) // 2 * tex0 1
NVIDIA Proprietary
NVIDIA Proprietary
Syntax:
nop();
NVIDIA Proprietary
NVIDIA Proprietary
Syntax:
texture_1d();
NVIDIA Proprietary
NVIDIA Proprietary
Syntax:
texture_2d();
NVIDIA Proprietary
NVIDIA Proprietary
Syntax:
texture_rectangle();
NVIDIA Proprietary
NVIDIA Proprietary
Syntax:
texture_3d();
NVIDIA Proprietary
NVIDIA Proprietary
Syntax:
texture_cube_map();
NVIDIA Proprietary
NVIDIA Proprietary
Syntax:
cull_fragment(condEnum s, condEnum t,
condEnum r, condEnum q);
NVIDIA Proprietary
clamp(T,0,1) green
clamp(R,0,1) blue
clamp(Q,0,1) alpha
Syntax:
pass_through();
NVIDIA Proprietary
NVIDIA Proprietary
Syntax:
offset_2d( Reg prev, float m00, float m01,
float m10, float m11 );
NVIDIA Proprietary
Syntax:
offset_2d( Reg prev, float m00, float m01,
float m10, float m11,
float scale, float bias );
NVIDIA Proprietary
Syntax:
offset_rectangle( Reg prev, float m00, float m01,
float m10, float m11 );
NVIDIA Proprietary
Syntax:
offset_rectangle_scale( Reg prev,
float m00, float m01, float m10, float m11,
float scale, float bias );
NVIDIA Proprietary
Syntax:
dependent_ar( Reg prev );
NVIDIA Proprietary
Red t
Syntax:
dependent_gb( Reg prev );
NVIDIA Proprietary
Blue t
NVIDIA Proprietary
NVIDIA Proprietary
If the texcoords for unit 1 are a light vector (L) and the
texcoords for unit 2 are a halfangle vector (H), this
corresponds to doing two dot products to produce
coordinates (N L, N H) and using these (s,t) results to
lookup into a rectangle texture.
NVIDIA Proprietary
NVIDIA Proprietary
NVIDIA Proprietary
NVIDIA Proprietary
NVIDIA Proprietary
NVIDIA Proprietary
NVIDIA Proprietary
2N(NE)
E
(NN)
(Eye
(Eye
(Eye
NVIDIA Proprietary
NVIDIA Proprietary
Complete Example
// Create display list once.
glNewList(dlist,GL_COMPILE);
nvparse(
!!TS1.0\n
texture2d();\n
dot_product_2d_1of2(expand(tex0);\n
dot_product_2d_2of2(expand(tex0);\n
texture2d();\n
);
glEndList();
// Now check for errors.
for (const char** errors= nvparse_get_errors(); *errors;
errors++)
fprintf(stderr, *errors);
NVIDIA Proprietary
Complete Example
void display()
{
// Setup the texture shader state.
glCallList(dlist);
// Turn on texture shaders.
glEnable(GL_TEXTURE_SHADER_NV);
// Bind the textures.
glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, normalMap);
glActiveTextureARB(GL_TEXTURE2_ARB);
glBindTexture(GL_TEXTURE_2D, diffuseSpecularMap);
glActiveTextureARB(GL_TEXTURE3_ARB);
glBindTexture(GL_TEXTURE_2D, decalMap);
// Draw the geometry.
NVIDIA Proprietary
Questions?
Send to cwynn@nvidia.com
NVIDIA Proprietary