help a fellow coder in need

hi. can you help with these questions?

  1. proper bump/reflection/refraction mapping: could you please point me to some sample code (don’t need an entire app) that only uses opengl 1.3 and/or arb extensions? i’ve got nvidia sdk but it relies on nv_combiners etc, i’m looking for a method that (a) is not reliant on a specific card/manufacturer, (b) allows me to vary the intensity of bumping and highlight colour/strength (preferrably dynamically and per vertex, but per triangle’s okay too)

  2. somewhat related to the above, i understand that, for max performance, you need to use vertex programs (otherwise it’s respecify entire world geometry every frame): opengl 1.4 pdf doesn’t say how you write vertex programs, is there a place where i can get language spec/syntax reference, like intel assemebly opcodes? hopefully some simple example code chunks, as i want to explore custom lighting etc.

  3. colour/convolution matrix (the imaging subset): again, glspec 1.4 pdf is too abstract for my coding brain - are there any decent code samples on potential application? specifically, i wanna know if you can use it for things like hue rotation, on-the-fly tinting/grayscaling/colour space inversion (like a smooth “flash” from negative to normal image colours).

i haven’t been able to play with these features cos there’s no opengl 1.3/1.4 sdk for win32 and i’m in the process of building my own headers/libs, and all of these features are post-1.1 version of opengl. formal gl spec is quite impenetrable in places and i prefer to learn through code, so if you could help/point me to a good resource, i’d be well grateful if it helps in any way, i’ve done around 10 years of c/c++ and about 3-4 years of opengl 1.1. thanks for reading

http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/007714.html
http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/007732.html

Here’s some snippets from a program I made:

typedef void (__stdcall *PFNGLGENPROGRAMSARB) ( int n, const unsigned int
*programs );
typedef void (__stdcall *PFNGLBINDPROGRAMARB) ( const int target, unsigned
int program );
typedef void (__stdcall *PFNGLPROGRAMSTRINGARB) ( const int target, const
int format, int len, const void *string );

PFNGLGENPROGRAMSARB glGenProgramsARB = NULL;
PFNGLBINDPROGRAMARB glBindProgramARB = NULL;
PFNGLPROGRAMSTRINGARB glProgramStringARB = NULL;

// membrane effect (as seen in nVidia effects browser)
const unsigned char myprogram = "!!ARBvp1.0
\

variable declarations


TEMP xfNorm, xfPos, r0;
\

transform vertex to clip cooridinates


DP4 result.position.x, state.matrix.mvp.row[0], vertex.position;

DP4 result.position.y, state.matrix.mvp.row[1], vertex.position;

DP4 result.position.z, state.matrix.mvp.row[2], vertex.position;

DP4 result.position.w, state.matrix.mvp.row[3], vertex.position;
\

produce point-to-eye vector


DP4 xfPos.x, state.matrix.modelview.row[0], vertex.position;

DP4 xfPos.y, state.matrix.modelview.row[1], vertex.position;

DP4 xfPos.z, state.matrix.modelview.row[2], vertex.position;

DP4 xfPos.w, state.matrix.modelview.row[3], vertex.position;
\

normalize point-to-eye vector


DP3 r0.x, xfPos, xfPos;

RSQ r0.x, r0.x;

MUL xfPos, xfPos,-r0.x;
\

transform normal to eye coordinates


DP3 xfNorm.x, state.matrix.modelview.invtrans.row[0], vertex.normal;

DP3 xfNorm.y, state.matrix.modelview.invtrans.row[1], vertex.normal;

DP3 xfNorm.z, state.matrix.modelview.invtrans.row[2], vertex.normal;
\

determine color


DP3 r0.x, xfPos, xfNorm;

ADD result.color, vertex.normal.w,-r0.x;

MOV result.texcoord[0].x, r0.x;

END";

// cloaked object effect
const unsigned char myprogram = "!!ARBvp1.0
\

variable declarations


TEMP xfNorm, xfPos, xfLit, Half, r0;
\

transform vertex to clip cooridinates


DP4 result.position.x, state.matrix.mvp.row[0], vertex.position;

DP4 result.position.y, state.matrix.mvp.row[1], vertex.position;

DP4 result.position.z, state.matrix.mvp.row[2], vertex.position;

DP4 result.position.w, state.matrix.mvp.row[3], vertex.position;
\

produce point-to-eye vector


DP4 xfPos.x, state.matrix.modelview.row[0], vertex.position;

DP4 xfPos.y, state.matrix.modelview.row[1], vertex.position;

DP4 xfPos.z, state.matrix.modelview.row[2], vertex.position;

DP4 xfPos.w, state.matrix.modelview.row[3], vertex.position;
\

normalize point-to-eye vector


DP3 r0.x, xfPos, xfPos;

RSQ r0.x, r0.x;

MUL xfPos, xfPos,-r0.x;
\

transform normal to eye coordinates


DP3 xfNorm.x, state.matrix.modelview.invtrans.row[0], vertex.normal;

DP3 xfNorm.y, state.matrix.modelview.invtrans.row[1], vertex.normal;

DP3 xfNorm.z, state.matrix.modelview.invtrans.row[2], vertex.normal;
\

produce light vector


ADD xfLit, state.light[0].position,-xfPos;
\

normalize light vector


DP3 r0.x, xfLit, xfLit;

RSQ r0.x, r0.x;

MUL xfLit, xfLit, r0.x;
\

compute half vector


ADD Half, xfLit, xfPos;
\

normalize half vector


DP3 r0.x, Half, Half;

RSQ r0.x, r0.x;

MUL Half, Half, r0.x;
\

determine color


DP3 r0.y, xfNorm, Half;

MOV r0.w, state.material.shininess;

LIT r0, r0;

DP3 r0.x, xfNorm, xfPos;

MUL r0.z, r0.z, r0.z;

ADD result.color, r0.z,-r0.x;

END";

glGenProgramsARB = (PFNGLGENPROGRAMSARB)wglGetProcAddress(
“glGenProgramsARB” );
glBindProgramARB = (PFNGLBINDPROGRAMARB)wglGetProcAddress(
“glBindProgramARB” );
glProgramStringARB = (PFNGLPROGRAMSTRINGARB)wglGetProcAddress(
“glProgramStringARB” );
if (!glGenProgramsARB | | !glBindProgramARB | | !glProgramStringARB) {
MessageBox( NULL, “Unable to retrieve vertex program procedure
addresses.”, “”, MB_OK );
return false; }
glGenProgramsARB( 1, programs );
glBindProgramARB( GL_VERTEX_PROGRAM_ARB, programs[0] );
glProgramStringARB( GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
strlen( (const char*)myprogram ), myprogram );
if (glGetError() == GL_INVALID_OPERATION) // tripped
MessageBox( NULL, “Invalid Operation”, “”, MB_OK );

// … and last, but not least, our beloved glEnable() call.
glEnable( GL_VERTEX_PROGRAM_ARB );

thanks, code chunks are always handy, but i was primarily looking for the vertex program language reference… gl 1.4 pdf has nothing to say on that, there must be a proper language spec somewhere

any takers on the other two?

The ARB_vertex_program extension spec can be found at:
http://oss.sgi.com/projects/ogl-sample/registry/ARB/vertex_program.txt

[This message has been edited by pbrown (edited 10-31-2002).]

phew. that’ll keep me busy for years thanks

what about the imaging subset? as far as i can remember right now, even my lowly gf2 supports it… sort of makes sense, cos as far as i know, according to gl spec the subset is either supported or not, and since the very common additive blending is part of it, you get the whole subset functionality?